fix(invariants): join package checks at startup

This commit is contained in:
Tianyi Cui
2026-07-20 01:53:09 +08:00
parent 684fcf3357
commit e80fc3e61b
31 changed files with 596 additions and 314 deletions

View File

@@ -13,17 +13,14 @@ export const name = 'home-invariant'
export const inject = ['invariants']
/** Assert the canonical environment key and configured-path precedence. */
const install: InvariantInstaller = (ctx, fail) => {
ctx.effect(async () => {
const { DSH_HOME_ENV, resolveDshHome } = await import('./index.ts')
const environmentKey: string = DSH_HOME_ENV
assertInvariant(fail, environmentKey === ['DSH', 'HOME'].join('_'),
'the canonical Harness home environment key must remain DSH_HOME')
const configured = 'relative-invariant-home'
assertInvariant(fail, resolveDshHome(configured) === resolve(configured),
'an explicitly configured Harness home must normalize to an absolute path')
return () => {}
}, 'home: validate canonical DSH home resolution')
const install: InvariantInstaller = async (_ctx, fail) => {
const { DSH_HOME_ENV, resolveDshHome } = await import('./index.ts')
const environmentKey: string = DSH_HOME_ENV
assertInvariant(fail, environmentKey === ['DSH', 'HOME'].join('_'),
'the canonical Harness home environment key must remain DSH_HOME')
const configured = 'relative-invariant-home'
assertInvariant(fail, resolveDshHome(configured) === resolve(configured),
'an explicitly configured Harness home must normalize to an absolute path')
}
/**