@lannguyensi/harness 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +9 -0
- package/dist/cli/adopt/derive.d.ts +15 -0
- package/dist/cli/adopt/derive.js +34 -7
- package/dist/cli/adopt/derive.js.map +1 -1
- package/dist/cli/adopt/index.d.ts +30 -0
- package/dist/cli/adopt/index.js +23 -3
- package/dist/cli/adopt/index.js.map +1 -1
- package/dist/cli/apply/generate-settings.d.ts +14 -1
- package/dist/cli/apply/generate-settings.js +7 -3
- package/dist/cli/apply/generate-settings.js.map +1 -1
- package/dist/cli/approve/stdin-report.js +2 -0
- package/dist/cli/approve/stdin-report.js.map +1 -1
- package/dist/cli/doctor/claude-mcp.d.ts +50 -0
- package/dist/cli/doctor/claude-mcp.js +170 -0
- package/dist/cli/doctor/claude-mcp.js.map +1 -0
- package/dist/cli/doctor/format.js +37 -0
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/index.d.ts +10 -0
- package/dist/cli/doctor/index.js +24 -0
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/npm-bin-path.js +42 -0
- package/dist/cli/doctor/npm-bin-path.js.map +1 -1
- package/dist/cli/doctor/types.d.ts +11 -0
- package/dist/cli/doctor/types.js.map +1 -1
- package/dist/cli/index.js +253 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/agent-tasks-auth.js +32 -0
- package/dist/cli/init/agent-tasks-auth.js.map +1 -1
- package/dist/cli/init/composer.js +3 -9
- package/dist/cli/init/composer.js.map +1 -1
- package/dist/cli/init/dependencies.js +21 -0
- package/dist/cli/init/dependencies.js.map +1 -1
- package/dist/cli/init/detect.d.ts +20 -3
- package/dist/cli/init/detect.js +34 -36
- package/dist/cli/init/detect.js.map +1 -1
- package/dist/cli/init/interactive.d.ts +33 -0
- package/dist/cli/init/interactive.js +399 -5
- package/dist/cli/init/interactive.js.map +1 -1
- package/dist/cli/init/profiles.d.ts +1 -1
- package/dist/cli/init/profiles.js +1 -1
- package/dist/cli/init/templates.d.ts +1 -1
- package/dist/cli/init/templates.js +64 -5
- package/dist/cli/init/templates.js.map +1 -1
- package/dist/cli/main.js +10 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/pack/hook-post-merge-gate-record.d.ts +30 -0
- package/dist/cli/pack/hook-post-merge-gate-record.js +153 -0
- package/dist/cli/pack/hook-post-merge-gate-record.js.map +1 -0
- package/dist/cli/pack/hook-post-merge-gate.d.ts +28 -0
- package/dist/cli/pack/hook-post-merge-gate.js +244 -0
- package/dist/cli/pack/hook-post-merge-gate.js.map +1 -0
- package/dist/cli/pack/hook-solution-acceptance-writeguard.js +148 -2
- package/dist/cli/pack/hook-solution-acceptance-writeguard.js.map +1 -1
- package/dist/cli/pack/understanding-report-schema-hint.js +1 -1
- package/dist/cli/pack/understanding-report-schema-hint.js.map +1 -1
- package/dist/cli/record/index.d.ts +64 -0
- package/dist/cli/record/index.js +211 -0
- package/dist/cli/record/index.js.map +1 -0
- package/dist/cli/session-start/index.d.ts +7 -0
- package/dist/cli/session-start/index.js +133 -38
- package/dist/cli/session-start/index.js.map +1 -1
- package/dist/cli/session-start/toolchain-parity.d.ts +149 -0
- package/dist/cli/session-start/toolchain-parity.js +618 -0
- package/dist/cli/session-start/toolchain-parity.js.map +1 -0
- package/dist/cli/uninstall/index.d.ts +73 -1
- package/dist/cli/uninstall/index.js +134 -2
- package/dist/cli/uninstall/index.js.map +1 -1
- package/dist/io/claude-mcp.d.ts +258 -0
- package/dist/io/claude-mcp.js +544 -0
- package/dist/io/claude-mcp.js.map +1 -0
- package/dist/policies/ledger-client.d.ts +34 -1
- package/dist/policies/ledger-client.js +21 -16
- package/dist/policies/ledger-client.js.map +1 -1
- package/dist/policy-packs/builtin/post-merge-gate-runtime.d.ts +195 -0
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js +290 -0
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js.map +1 -0
- package/dist/policy-packs/builtin/post-merge-gate.d.ts +56 -0
- package/dist/policy-packs/builtin/post-merge-gate.js +291 -0
- package/dist/policy-packs/builtin/post-merge-gate.js.map +1 -0
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js +28 -13
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js.map +1 -1
- package/dist/policy-packs/registry.d.ts +1 -1
- package/dist/policy-packs/registry.js +12 -0
- package/dist/policy-packs/registry.js.map +1 -1
- package/dist/runtime/git-context.d.ts +50 -0
- package/dist/runtime/git-context.js +108 -1
- package/dist/runtime/git-context.js.map +1 -1
- package/dist/runtime/hermetic-spawn-guard.d.ts +25 -0
- package/dist/runtime/hermetic-spawn-guard.js +136 -0
- package/dist/runtime/hermetic-spawn-guard.js.map +1 -0
- package/dist/runtime/ledger-writer.d.ts +27 -0
- package/dist/runtime/ledger-writer.js +46 -0
- package/dist/runtime/ledger-writer.js.map +1 -0
- package/dist/runtime/read-only-bash.js +118 -0
- package/dist/runtime/read-only-bash.js.map +1 -1
- package/dist/schema/index.d.ts +41 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/toolchain-parity.d.ts +18 -0
- package/dist/schema/toolchain-parity.js +35 -0
- package/dist/schema/toolchain-parity.js.map +1 -0
- package/package.json +4 -2
|
@@ -299,20 +299,35 @@ export function bashReferencesVerdictDir(command, dir) {
|
|
|
299
299
|
(leaf.length >= 6 && command.includes(leaf))) {
|
|
300
300
|
return true;
|
|
301
301
|
}
|
|
302
|
-
// Glob-obscured references. bash expands `*?[` against EXISTING
|
|
303
|
-
// runtime, so a glob like `solution-ver*/<id>.json` reaches the
|
|
304
|
-
// without the literal leaf ever appearing in the command text, and a
|
|
302
|
+
// Glob- and brace-obscured references. bash expands `*?[` against EXISTING
|
|
303
|
+
// paths at runtime, so a glob like `solution-ver*/<id>.json` reaches the
|
|
304
|
+
// dir without the literal leaf ever appearing in the command text, and a
|
|
305
305
|
// matching glob can OVERWRITE an existing marker (flipping ready:false ->
|
|
306
|
-
// true).
|
|
307
|
-
//
|
|
308
|
-
//
|
|
309
|
-
//
|
|
310
|
-
//
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
315
|
-
|
|
306
|
+
// true). `{...,...}` brace expansion is unconditional (no filesystem
|
|
307
|
+
// lookup needed) and can split the leaf the same way: `solution-verdict{s,}`
|
|
308
|
+
// expands to `solution-verdicts` / `solution-verdict`, neither of which
|
|
309
|
+
// contains the literal leaf as a contiguous substring, so the direct check
|
|
310
|
+
// above misses it. We cannot safely expand either (that is the shell-eval
|
|
311
|
+
// surface read-only-bash refuses), so when a glob OR brace metacharacter is
|
|
312
|
+
// present we match the leaf's distinctive sub-words: a single glob or
|
|
313
|
+
// brace can split the hyphenated leaf but not erase every >=6-char word of
|
|
314
|
+
// it (`solution-ver*` and `solution-verdict{s,}` both keep "solution";
|
|
315
|
+
// `solu*verdicts` keeps "verdicts"). The leaf words, not the parent
|
|
316
|
+
// segment, are used on purpose: the parent here is `agent-grounding`,
|
|
317
|
+
// which is also a repo name and would over-block legitimate work. A
|
|
318
|
+
// command that globs/braces EVERY path segment is the residual the
|
|
319
|
+
// marker-signing follow-up closes.
|
|
320
|
+
//
|
|
321
|
+
// ACCEPTED COST of including `{` here: any brace now enters this
|
|
322
|
+
// leaf-word fallback, so a command carrying a brace AND one of the
|
|
323
|
+
// generic words above trips it even when it never reaches the dir.
|
|
324
|
+
// Measured examples that block today and did not before: `cd
|
|
325
|
+
// /repo/{solution,notes}`, `cd /repo/{a,b}/solution-docs`, and any
|
|
326
|
+
// non-read-only command containing a brace plus "solution"/"verdicts".
|
|
327
|
+
// "solution" is a common word, so this is not rare. It is deliberate:
|
|
328
|
+
// it fails safe, and the tighter alternative (dropping `{`) reopens
|
|
329
|
+
// the `solution-verdict{s,}` split-leaf hole, which fails open.
|
|
330
|
+
if (/[*?[{]/.test(command)) {
|
|
316
331
|
const leafWords = leaf.split(/[^A-Za-z0-9]+/).filter((w) => w.length >= 6);
|
|
317
332
|
if (leafWords.some((w) => command.includes(w)))
|
|
318
333
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solution-acceptance-runtime.js","sourceRoot":"","sources":["../../../src/policy-packs/builtin/solution-acceptance-runtime.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAC9E,4EAA4E;AAC5E,sEAAsE;AACtE,wEAAwE;AACxE,4EAA4E;AAC5E,6CAA6C;AAC7C,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,2DAA2D;AAC3D,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,oCAAoC;AACpC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,sEAAsE;AACtE,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,gBAAgB;AAEhB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAGhF,MAAM,CAAC,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,qBAAqB;CACb,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,CAAC,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AM,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,yEAAyE;IACzE,
|
|
1
|
+
{"version":3,"file":"solution-acceptance-runtime.js","sourceRoot":"","sources":["../../../src/policy-packs/builtin/solution-acceptance-runtime.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAC9E,4EAA4E;AAC5E,sEAAsE;AACtE,wEAAwE;AACxE,4EAA4E;AAC5E,6CAA6C;AAC7C,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,2DAA2D;AAC3D,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,oCAAoC;AACpC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,sEAAsE;AACtE,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,gBAAgB;AAEhB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAGhF,MAAM,CAAC,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,qBAAqB;CACb,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,CAAC,MAA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IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,2EAA2E;IAC3E,yEAAyE;IACzE,yEAAyE;IACzE,0EAA0E;IAC1E,qEAAqE;IACrE,6EAA6E;IAC7E,wEAAwE;IACxE,2EAA2E;IAC3E,0EAA0E;IAC1E,4EAA4E;IAC5E,sEAAsE;IACtE,2EAA2E;IAC3E,uEAAuE;IACvE,oEAAoE;IACpE,sEAAsE;IACtE,oEAAoE;IACpE,mEAAmE;IACnE,mCAAmC;IACnC,EAAE;IACF,iEAAiE;IACjE,mEAAmE;IACnE,mEAAmE;IACnE,6DAA6D;IAC7D,mEAAmE;IACnE,uEAAuE;IACvE,sEAAsE;IACtE,oEAAoE;IACpE,gEAAgE;IAChE,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;QAC3E,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -3,7 +3,7 @@ import type { PolicyPack, PolicyUx, Producer } from "../schema/index.js";
|
|
|
3
3
|
import { type ResolvePackOptions } from "./builtin/understanding-before-execution.js";
|
|
4
4
|
import { type Runtime } from "./runtime.js";
|
|
5
5
|
import type { PackContribution } from "./types.js";
|
|
6
|
-
export declare const KNOWN_BUILTIN_PACKS: readonly ["understanding-before-execution", "branch-protection", "solution-acceptance"];
|
|
6
|
+
export declare const KNOWN_BUILTIN_PACKS: readonly ["understanding-before-execution", "branch-protection", "solution-acceptance", "post-merge-gate"];
|
|
7
7
|
export type BuiltinPackName = (typeof KNOWN_BUILTIN_PACKS)[number];
|
|
8
8
|
export declare function isBuiltinPackName(name: string): name is BuiltinPackName;
|
|
9
9
|
export interface ResolveBuiltinResult {
|
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
import { configSchema as branchProtectionConfigSchema, defaultUx as branchProtectionDefaultUx, PACK_NAME as BRANCH_PROTECTION, resolve as resolveBranchProtection, } from "./builtin/branch-protection.js";
|
|
8
8
|
import { configSchema as understandingBeforeExecutionConfigSchema, defaultProducers as understandingBeforeExecutionDefaultProducers, defaultUx as understandingBeforeExecutionDefaultUx, PACK_NAME as UNDERSTANDING_BEFORE_EXECUTION, resolve as resolveUnderstandingBeforeExecution, resolveMode as resolveUnderstandingBeforeExecutionMode, VERSION_COMMAND as UNDERSTANDING_BEFORE_EXECUTION_VERSION_COMMAND, } from "./builtin/understanding-before-execution.js";
|
|
9
9
|
import { configSchema as solutionAcceptanceConfigSchema, PACK_NAME as SOLUTION_ACCEPTANCE, resolve as resolveSolutionAcceptance, } from "./builtin/solution-acceptance.js";
|
|
10
|
+
import { configSchema as postMergeGateConfigSchema, defaultUx as postMergeGateDefaultUx, PACK_NAME as POST_MERGE_GATE, resolve as resolvePostMergeGate, } from "./builtin/post-merge-gate.js";
|
|
10
11
|
import { DEFAULT_RUNTIME } from "./runtime.js";
|
|
11
12
|
export const KNOWN_BUILTIN_PACKS = [
|
|
12
13
|
UNDERSTANDING_BEFORE_EXECUTION,
|
|
13
14
|
BRANCH_PROTECTION,
|
|
14
15
|
SOLUTION_ACCEPTANCE,
|
|
16
|
+
POST_MERGE_GATE,
|
|
15
17
|
];
|
|
16
18
|
export function isBuiltinPackName(name) {
|
|
17
19
|
return KNOWN_BUILTIN_PACKS.includes(name);
|
|
@@ -26,6 +28,8 @@ export function resolveBuiltin(pack, runtime = DEFAULT_RUNTIME, opts = {}) {
|
|
|
26
28
|
return resolveBranchProtection(pack, runtime);
|
|
27
29
|
case SOLUTION_ACCEPTANCE:
|
|
28
30
|
return resolveSolutionAcceptance(pack, runtime, opts);
|
|
31
|
+
case POST_MERGE_GATE:
|
|
32
|
+
return resolvePostMergeGate(pack, runtime);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
@@ -45,6 +49,8 @@ export function resolveBuiltinConfigSchema(packName) {
|
|
|
45
49
|
return branchProtectionConfigSchema;
|
|
46
50
|
case SOLUTION_ACCEPTANCE:
|
|
47
51
|
return solutionAcceptanceConfigSchema;
|
|
52
|
+
case POST_MERGE_GATE:
|
|
53
|
+
return postMergeGateConfigSchema;
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
@@ -69,6 +75,10 @@ export function resolveBuiltinVersionCommand(packName) {
|
|
|
69
75
|
// Blocker is harness itself; the producer (grounding-mcp) is probed
|
|
70
76
|
// via its tools.mcp min_version, not a pack-side bin.
|
|
71
77
|
return null;
|
|
78
|
+
case POST_MERGE_GATE:
|
|
79
|
+
// Both the producer and the blocker are harness itself; no
|
|
80
|
+
// separate package-side bin to probe.
|
|
81
|
+
return null;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
export function resolveBuiltinDefaultConfig(pack) {
|
|
@@ -86,6 +96,8 @@ export function resolveBuiltinDefaultConfig(pack) {
|
|
|
86
96
|
return { ux: branchProtectionDefaultUx() };
|
|
87
97
|
case SOLUTION_ACCEPTANCE:
|
|
88
98
|
return null;
|
|
99
|
+
case POST_MERGE_GATE:
|
|
100
|
+
return { ux: postMergeGateDefaultUx() };
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/policy-packs/registry.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,sEAAsE;AACtE,oEAAoE;AACpE,mEAAmE;AAIn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
17
|
*/
|
|
18
18
|
sha: string;
|
|
19
19
|
}
|
|
20
|
+
export interface GitEntry {
|
|
21
|
+
/** Directory that contains the `.git` entry (the work-tree root). */
|
|
22
|
+
worktreeRoot: string;
|
|
23
|
+
/** Resolved git directory — for a `.git` file, its `gitdir:` target. */
|
|
24
|
+
gitDir: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Walk up from `startDir` looking for a `.git` entry. Handles both the
|
|
28
|
+
* common `.git` directory and the `.git` *file* form used by linked
|
|
29
|
+
* worktrees and submodules. The walk is bounded so a pathologically
|
|
30
|
+
* deep cwd cannot spin.
|
|
31
|
+
*
|
|
32
|
+
* Exported (task T-001, record-verbs) so `cli/record/index.ts` can
|
|
33
|
+
* locate the same `.git` directory this module resolves `repo`/
|
|
34
|
+
* `branch`/`sha` from, without re-walking the tree with duplicate
|
|
35
|
+
* logic — its base-branch resolution needs the raw git directory (to
|
|
36
|
+
* read `refs/remotes/origin/HEAD` / `packed-refs`), which
|
|
37
|
+
* `resolveGitContext`'s return shape does not expose. Behavior is
|
|
38
|
+
* unchanged; this is a visibility-only change.
|
|
39
|
+
*/
|
|
40
|
+
export declare function findGitEntry(startDir: string): GitEntry | null;
|
|
20
41
|
/**
|
|
21
42
|
* Resolve `{ repo, branch, sha }` for a working directory. Returns empty
|
|
22
43
|
* strings (never throws) when `cwd` is not inside a git work tree, or
|
|
@@ -24,3 +45,32 @@ export interface GitRepoContext {
|
|
|
24
45
|
* fall through to their own behaviour.
|
|
25
46
|
*/
|
|
26
47
|
export declare function resolveGitContext(cwd: string): GitRepoContext;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the remote's default branch name from `<gitDir>/refs/remotes/
|
|
50
|
+
* origin/HEAD`. Loose symbolic ref first (the normal shape: `ref: refs/
|
|
51
|
+
* remotes/origin/<name>`, written by `git clone` / `git remote set-head
|
|
52
|
+
* origin -a`). When that loose file is absent, falls back to
|
|
53
|
+
* `packed-refs`: some git versions / tooling pack `refs/remotes/origin/
|
|
54
|
+
* HEAD` as a plain `<sha> <ref>` entry instead of a symref, which loses
|
|
55
|
+
* the branch NAME directly — recovered here by matching that sha
|
|
56
|
+
* against another packed `refs/remotes/origin/<name>` entry that shares
|
|
57
|
+
* it (mirrors the loose-then-packed shape `resolveBranchSha` uses
|
|
58
|
+
* above, adapted since packed-refs has no symref concept). Returns null
|
|
59
|
+
* when neither source resolves a name.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveOriginHeadBase(gitDir: string): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Resolve the actual shared git directory for `gitDir`, following the
|
|
64
|
+
* `commondir` file linked worktrees write. `git worktree add` gives each
|
|
65
|
+
* worktree its own private `.git` FILE pointing at `<main>/.git/
|
|
66
|
+
* worktrees/<name>/` (what `findGitEntry` returns as `gitDir`), but
|
|
67
|
+
* `refs/remotes/origin/HEAD` and `packed-refs` are NOT duplicated there
|
|
68
|
+
* — they live only in the shared common dir, reachable via that
|
|
69
|
+
* per-worktree directory's own `commondir` file (a path, normally
|
|
70
|
+
* `../..`, relative to the per-worktree directory itself; see
|
|
71
|
+
* `git-worktree(1)`). Without this indirection, `resolveOriginHeadBase`
|
|
72
|
+
* would look for those refs in the empty per-worktree directory and
|
|
73
|
+
* always miss. Returns `gitDir` unchanged when no `commondir` file
|
|
74
|
+
* exists (the normal, non-worktree case).
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveCommonDir(gitDir: string): string;
|
|
@@ -35,8 +35,16 @@ const SHA_RE = /^[0-9a-f]{40}$/;
|
|
|
35
35
|
* common `.git` directory and the `.git` *file* form used by linked
|
|
36
36
|
* worktrees and submodules. The walk is bounded so a pathologically
|
|
37
37
|
* deep cwd cannot spin.
|
|
38
|
+
*
|
|
39
|
+
* Exported (task T-001, record-verbs) so `cli/record/index.ts` can
|
|
40
|
+
* locate the same `.git` directory this module resolves `repo`/
|
|
41
|
+
* `branch`/`sha` from, without re-walking the tree with duplicate
|
|
42
|
+
* logic — its base-branch resolution needs the raw git directory (to
|
|
43
|
+
* read `refs/remotes/origin/HEAD` / `packed-refs`), which
|
|
44
|
+
* `resolveGitContext`'s return shape does not expose. Behavior is
|
|
45
|
+
* unchanged; this is a visibility-only change.
|
|
38
46
|
*/
|
|
39
|
-
function findGitEntry(startDir) {
|
|
47
|
+
export function findGitEntry(startDir) {
|
|
40
48
|
let dir = path.resolve(startDir);
|
|
41
49
|
for (let depth = 0; depth < 128; depth++) {
|
|
42
50
|
const dotGit = path.join(dir, ".git");
|
|
@@ -143,4 +151,103 @@ export function resolveGitContext(cwd) {
|
|
|
143
151
|
}
|
|
144
152
|
return { repo, branch, sha };
|
|
145
153
|
}
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// Default-branch resolution (offline, no `gh`/`git` subprocess).
|
|
156
|
+
//
|
|
157
|
+
// Originally written for `harness record review`'s `--base` fallback
|
|
158
|
+
// (task T-001, record-verbs) and lived only in `cli/record/index.ts`.
|
|
159
|
+
// Exported here (task post-merge-gate, T-001) so
|
|
160
|
+
// `policy-packs/builtin/post-merge-gate-runtime.ts` can resolve the same
|
|
161
|
+
// "what's the default branch to switch back to" answer for its deny
|
|
162
|
+
// message without a policy-pack module reaching into `cli/`. Behavior is
|
|
163
|
+
// unchanged; this is a visibility/location move, not a rewrite — see
|
|
164
|
+
// `findGitEntry`'s doc comment above for the identical precedent
|
|
165
|
+
// (record/index.ts reusing this module's git-dir walk instead of
|
|
166
|
+
// duplicating it).
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
// `.git/refs/remotes/origin/HEAD` on a normal clone: a symbolic ref
|
|
169
|
+
// pointing at the remote's default branch.
|
|
170
|
+
const ORIGIN_HEAD_REF_RE = /^ref:\s*refs\/remotes\/origin\/(.+)$/;
|
|
171
|
+
const ORIGIN_HEAD_REF_PATH = "refs/remotes/origin/HEAD";
|
|
172
|
+
const ORIGIN_REMOTE_PREFIX = "refs/remotes/origin/";
|
|
173
|
+
/**
|
|
174
|
+
* Resolve the remote's default branch name from `<gitDir>/refs/remotes/
|
|
175
|
+
* origin/HEAD`. Loose symbolic ref first (the normal shape: `ref: refs/
|
|
176
|
+
* remotes/origin/<name>`, written by `git clone` / `git remote set-head
|
|
177
|
+
* origin -a`). When that loose file is absent, falls back to
|
|
178
|
+
* `packed-refs`: some git versions / tooling pack `refs/remotes/origin/
|
|
179
|
+
* HEAD` as a plain `<sha> <ref>` entry instead of a symref, which loses
|
|
180
|
+
* the branch NAME directly — recovered here by matching that sha
|
|
181
|
+
* against another packed `refs/remotes/origin/<name>` entry that shares
|
|
182
|
+
* it (mirrors the loose-then-packed shape `resolveBranchSha` uses
|
|
183
|
+
* above, adapted since packed-refs has no symref concept). Returns null
|
|
184
|
+
* when neither source resolves a name.
|
|
185
|
+
*/
|
|
186
|
+
export function resolveOriginHeadBase(gitDir) {
|
|
187
|
+
try {
|
|
188
|
+
const raw = fs
|
|
189
|
+
.readFileSync(path.join(gitDir, "refs", "remotes", "origin", "HEAD"), "utf8")
|
|
190
|
+
.trim();
|
|
191
|
+
const match = ORIGIN_HEAD_REF_RE.exec(raw);
|
|
192
|
+
if (match)
|
|
193
|
+
return match[1].trim();
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
/* loose symref missing — try packed-refs */
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const packed = fs.readFileSync(path.join(gitDir, "packed-refs"), "utf8");
|
|
200
|
+
let headSha = null;
|
|
201
|
+
const entries = [];
|
|
202
|
+
for (const rawLine of packed.split("\n")) {
|
|
203
|
+
const line = rawLine.trim();
|
|
204
|
+
if (line === "" || line.startsWith("#") || line.startsWith("^"))
|
|
205
|
+
continue;
|
|
206
|
+
const parts = line.split(/\s+/);
|
|
207
|
+
const sha = parts[0];
|
|
208
|
+
const ref = parts[1];
|
|
209
|
+
if (!sha || !ref || !SHA_RE.test(sha))
|
|
210
|
+
continue;
|
|
211
|
+
if (ref === ORIGIN_HEAD_REF_PATH)
|
|
212
|
+
headSha = sha;
|
|
213
|
+
else
|
|
214
|
+
entries.push({ sha, ref });
|
|
215
|
+
}
|
|
216
|
+
if (headSha) {
|
|
217
|
+
const match = entries.find((e) => e.sha === headSha && e.ref.startsWith(ORIGIN_REMOTE_PREFIX));
|
|
218
|
+
if (match)
|
|
219
|
+
return match.ref.slice(ORIGIN_REMOTE_PREFIX.length);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
/* packed-refs missing too — caller treats null as "unresolvable" */
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Resolve the actual shared git directory for `gitDir`, following the
|
|
229
|
+
* `commondir` file linked worktrees write. `git worktree add` gives each
|
|
230
|
+
* worktree its own private `.git` FILE pointing at `<main>/.git/
|
|
231
|
+
* worktrees/<name>/` (what `findGitEntry` returns as `gitDir`), but
|
|
232
|
+
* `refs/remotes/origin/HEAD` and `packed-refs` are NOT duplicated there
|
|
233
|
+
* — they live only in the shared common dir, reachable via that
|
|
234
|
+
* per-worktree directory's own `commondir` file (a path, normally
|
|
235
|
+
* `../..`, relative to the per-worktree directory itself; see
|
|
236
|
+
* `git-worktree(1)`). Without this indirection, `resolveOriginHeadBase`
|
|
237
|
+
* would look for those refs in the empty per-worktree directory and
|
|
238
|
+
* always miss. Returns `gitDir` unchanged when no `commondir` file
|
|
239
|
+
* exists (the normal, non-worktree case).
|
|
240
|
+
*/
|
|
241
|
+
export function resolveCommonDir(gitDir) {
|
|
242
|
+
try {
|
|
243
|
+
const raw = fs.readFileSync(path.join(gitDir, "commondir"), "utf8").trim();
|
|
244
|
+
if (raw.length > 0) {
|
|
245
|
+
return path.isAbsolute(raw) ? raw : path.resolve(gitDir, raw);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
/* no commondir file — gitDir already IS the common dir */
|
|
250
|
+
}
|
|
251
|
+
return gitDir;
|
|
252
|
+
}
|
|
146
253
|
//# sourceMappingURL=git-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-context.js","sourceRoot":"","sources":["../../src/runtime/git-context.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,aAAa;AACb,EAAE;AACF,uEAAuE;AACvE,gEAAgE;AAChE,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,gEAAgE;AAChE,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,sEAAsE;AACtE,gEAAgE;AAChE,sCAAsC;AACtC,EAAE;AACF,oEAAoE;AACpE,qEAAqE;AACrE,mEAAmE;AACnE,gEAAgE;AAChE,mDAAmD;AAEnD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAsBlC,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AAEhE,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACrC,uEAAuE;AACvE,oDAAoD;AACpD,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACjD,sEAAsE;AACtE,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAShC
|
|
1
|
+
{"version":3,"file":"git-context.js","sourceRoot":"","sources":["../../src/runtime/git-context.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,aAAa;AACb,EAAE;AACF,uEAAuE;AACvE,gEAAgE;AAChE,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,gEAAgE;AAChE,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,sEAAsE;AACtE,gEAAgE;AAChE,sCAAsC;AACtC,EAAE;AACF,oEAAoE;AACpE,qEAAqE;AACrE,mEAAmE;AACnE,gEAAgE;AAChE,mDAAmD;AAEnD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAA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AAM,CAAC;QACP,oEAAoE;IACtE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3E,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;IAC5D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by {@link assertNoRealSpawnInTests} when a real-spawn code path
|
|
3
|
+
* runs under vitest without a test-injected fake. Callers whose
|
|
4
|
+
* surrounding try/catch degrades ordinary runner failures to a warning
|
|
5
|
+
* MUST re-throw instances of this class past that catch — never let it
|
|
6
|
+
* be treated as an ordinary (optional, warn-and-continue) failure.
|
|
7
|
+
*/
|
|
8
|
+
export declare class HermeticSpawnViolationError extends Error {
|
|
9
|
+
constructor(binaryLabel: string, hint: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Guard for a "real spawn" implementation: throws
|
|
13
|
+
* {@link HermeticSpawnViolationError} when called under vitest, so an
|
|
14
|
+
* accidental real spawn in a test fails hard instead of silently
|
|
15
|
+
* running. No-op outside of vitest (production behavior is unchanged),
|
|
16
|
+
* and no-op when `HARNESS_ALLOW_REAL_SPAWN=1` is set (see module doc) —
|
|
17
|
+
* the first such no-op under vitest prints a one-time stderr warning so
|
|
18
|
+
* the disabled guard is visible rather than silent.
|
|
19
|
+
*
|
|
20
|
+
* @param binaryLabel human-readable name of what would be spawned (e.g.
|
|
21
|
+
* `"npx orchestrator-workflow init"`), used in the error message.
|
|
22
|
+
* @param hint one line telling the test author what to do instead (e.g.
|
|
23
|
+
* "inject a fake `owInitSpawn` runner").
|
|
24
|
+
*/
|
|
25
|
+
export declare function assertNoRealSpawnInTests(binaryLabel: string, hint: string): void;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Hermetic-spawn guard (task 54739002). Small, reusable primitive for
|
|
2
|
+
// "real spawn" implementations that back a test-injectable runner (e.g.
|
|
3
|
+
// `owInitSpawn` in src/cli/init/interactive.ts, and the sibling
|
|
4
|
+
// `realClaudeMcpExec` guard planned in task 0d80e969 for
|
|
5
|
+
// src/io/claude-mcp.ts).
|
|
6
|
+
//
|
|
7
|
+
// Incident this guards against: PR #359 found a confirm-queue in
|
|
8
|
+
// tests/cli/init-interactive.test.ts that fell through the trailing
|
|
9
|
+
// orchestrator-workflow co-install prompt (no queued answer + no
|
|
10
|
+
// injected `owInitSpawn`), which let a test silently run a REAL `npx
|
|
11
|
+
// orchestrator-workflow init` against the checkout. The bug itself is
|
|
12
|
+
// already fixed (the mock confirm queue now auto-declines on an
|
|
13
|
+
// exhausted queue); this guard is defense-in-depth so any FUTURE gap of
|
|
14
|
+
// the same shape (a new call site, a reordered prompt, a queue typo)
|
|
15
|
+
// fails the test loudly instead of quietly spawning a real process. A
|
|
16
|
+
// follow-up review (same task) found the same "injectable runner + real
|
|
17
|
+
// default" shape unguarded at three more call sites; a sixth
|
|
18
|
+
// (`realNpmExec` in src/cli/doctor/npm-bin-path.ts) was guarded later,
|
|
19
|
+
// under task 325ace29. As of that task, the guarded `real*Spawn`/
|
|
20
|
+
// `real*Exec` functions are:
|
|
21
|
+
// - `realClaudeMcpExec` (src/io/claude-mcp.ts)
|
|
22
|
+
// - `realSpawn` (src/cli/init/dependencies.ts)
|
|
23
|
+
// - `realProbeSpawn` (src/cli/init/agent-tasks-auth.ts)
|
|
24
|
+
// - `realLoginSpawn` (src/cli/init/agent-tasks-auth.ts)
|
|
25
|
+
// - `realOwInitSpawn` (src/cli/init/interactive.ts)
|
|
26
|
+
// - `realNpmExec` (src/cli/doctor/npm-bin-path.ts)
|
|
27
|
+
// Two more were added under the toolchain-parity task (PATH-Shim-Vorfall
|
|
28
|
+
// 2026-07-22 follow-up), both in src/cli/session-start/toolchain-parity.ts:
|
|
29
|
+
// - `realNodeVersionSpawn` (spawns `node --version` via PATH — the
|
|
30
|
+
// whole point is capturing the shell's PATH-resolved node, not
|
|
31
|
+
// `process.version`, so this one is especially load-bearing to keep
|
|
32
|
+
// hermetic)
|
|
33
|
+
// - `realNpmGlobalsSpawn` (spawns `npm ls -g --depth=0 --json`)
|
|
34
|
+
// Naming them here (instead of just a count) is deliberate (review
|
|
35
|
+
// finding F5, task T-007): a bare count silently drifts every time a new
|
|
36
|
+
// call site is added and nobody remembers to bump it. See the guard call
|
|
37
|
+
// site listed at each function above (each links back to this doc) for
|
|
38
|
+
// the up-to-date detail on that specific call chain.
|
|
39
|
+
//
|
|
40
|
+
// Env signal: `process.env.VITEST`, checked for a truthy, non-"false"/
|
|
41
|
+
// "0" value (vitest itself only ever sets it to the string "true", but
|
|
42
|
+
// we don't want an errant `VITEST=false` or `VITEST=0` in some outer
|
|
43
|
+
// environment to misfire the guard). Vitest sets this on every worker
|
|
44
|
+
// it runs (documented at https://vitest.dev/config/ under the `env`/
|
|
45
|
+
// `VITEST_*` variables it exposes to test code) and nothing else in
|
|
46
|
+
// this repo's runtime or CI sets it deliberately. That makes it safe to
|
|
47
|
+
// gate on for THIS repo's own `harness init`/`harness doctor` runs: a
|
|
48
|
+
// real, standalone invocation will never have VITEST set.
|
|
49
|
+
//
|
|
50
|
+
// Caveat (precision, not a promise): `process.env` is inherited by
|
|
51
|
+
// child processes, so this guard only detects "a vitest process is
|
|
52
|
+
// somewhere in the current process's inheritance chain" — e.g. if some
|
|
53
|
+
// OTHER project's vitest run were to shell out to `harness init` as a
|
|
54
|
+
// subprocess, that subprocess would inherit VITEST=true and this guard
|
|
55
|
+
// would (correctly, for ITS OWN purpose) fire there too. That is a
|
|
56
|
+
// deliberately conservative false-positive, not a gap: it never
|
|
57
|
+
// misfires in the other direction (a real, non-test-nested `harness
|
|
58
|
+
// init` run never sees VITEST set), which is the property that matters
|
|
59
|
+
// — the guard must never break a genuine production run.
|
|
60
|
+
//
|
|
61
|
+
// Deliberately NOT `NODE_ENV === "test"`: that var is set broadly by
|
|
62
|
+
// other tooling (bundlers, some CI steps) for reasons unrelated to "am I
|
|
63
|
+
// inside vitest right now", so it would risk misfiring outside of tests
|
|
64
|
+
// and breaking real `harness init` runs — the one thing this guard must
|
|
65
|
+
// never do.
|
|
66
|
+
//
|
|
67
|
+
// Escape hatch: `HARNESS_ALLOW_REAL_SPAWN=1` disables the guard even
|
|
68
|
+
// under vitest. This exists for a test that deliberately wants to
|
|
69
|
+
// exercise the REAL spawn path end-to-end (e.g. a manual, opt-in
|
|
70
|
+
// integration check) — it must not be set in normal test runs, CI, or
|
|
71
|
+
// production, and no test in this repo sets it today. Because this is a
|
|
72
|
+
// SILENT global kill-switch for every guarded call site listed above,
|
|
73
|
+
// activating it under vitest prints a one-time stderr warning (module-local flag,
|
|
74
|
+
// not per-call) so an accidentally-set env var is visible in test output
|
|
75
|
+
// instead of quietly disabling every tripwire in this file.
|
|
76
|
+
//
|
|
77
|
+
// Call this at the very top of a "real spawn" function (the one a
|
|
78
|
+
// caller falls back to via `opts.someSpawn ?? realSomeSpawn`), BEFORE
|
|
79
|
+
// touching `child_process`. It throws instead of returning so a caller
|
|
80
|
+
// whose surrounding try/catch degrades ordinary spawn failures to a
|
|
81
|
+
// warning (e.g. "OW is optional, warn and continue") does not
|
|
82
|
+
// accidentally swallow a hermetic violation too — callers must
|
|
83
|
+
// re-throw `HermeticSpawnViolationError` past any such catch (see
|
|
84
|
+
// offerOrchestratorWorkflow in src/cli/init/interactive.ts for the
|
|
85
|
+
// pattern).
|
|
86
|
+
/**
|
|
87
|
+
* Thrown by {@link assertNoRealSpawnInTests} when a real-spawn code path
|
|
88
|
+
* runs under vitest without a test-injected fake. Callers whose
|
|
89
|
+
* surrounding try/catch degrades ordinary runner failures to a warning
|
|
90
|
+
* MUST re-throw instances of this class past that catch — never let it
|
|
91
|
+
* be treated as an ordinary (optional, warn-and-continue) failure.
|
|
92
|
+
*/
|
|
93
|
+
export class HermeticSpawnViolationError extends Error {
|
|
94
|
+
constructor(binaryLabel, hint) {
|
|
95
|
+
super(`Refusing to spawn a REAL "${binaryLabel}" process while running under vitest ` +
|
|
96
|
+
`(process.env.VITEST is set). ${hint}`);
|
|
97
|
+
this.name = "HermeticSpawnViolationError";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** True when `process.env.VITEST` is set to a truthy, non-"false"/"0" value. */
|
|
101
|
+
function vitestEnvIsActive() {
|
|
102
|
+
const v = process.env.VITEST;
|
|
103
|
+
return !!v && v !== "false" && v !== "0";
|
|
104
|
+
}
|
|
105
|
+
// Module-local, one-shot: printed at most once per process, the first
|
|
106
|
+
// time the escape hatch is observed active under vitest. Not reset
|
|
107
|
+
// between calls — "one-time" means one time for the life of the
|
|
108
|
+
// process, not once per call site.
|
|
109
|
+
let printedAllowRealSpawnWarning = false;
|
|
110
|
+
/**
|
|
111
|
+
* Guard for a "real spawn" implementation: throws
|
|
112
|
+
* {@link HermeticSpawnViolationError} when called under vitest, so an
|
|
113
|
+
* accidental real spawn in a test fails hard instead of silently
|
|
114
|
+
* running. No-op outside of vitest (production behavior is unchanged),
|
|
115
|
+
* and no-op when `HARNESS_ALLOW_REAL_SPAWN=1` is set (see module doc) —
|
|
116
|
+
* the first such no-op under vitest prints a one-time stderr warning so
|
|
117
|
+
* the disabled guard is visible rather than silent.
|
|
118
|
+
*
|
|
119
|
+
* @param binaryLabel human-readable name of what would be spawned (e.g.
|
|
120
|
+
* `"npx orchestrator-workflow init"`), used in the error message.
|
|
121
|
+
* @param hint one line telling the test author what to do instead (e.g.
|
|
122
|
+
* "inject a fake `owInitSpawn` runner").
|
|
123
|
+
*/
|
|
124
|
+
export function assertNoRealSpawnInTests(binaryLabel, hint) {
|
|
125
|
+
if (process.env.HARNESS_ALLOW_REAL_SPAWN === "1") {
|
|
126
|
+
if (vitestEnvIsActive() && !printedAllowRealSpawnWarning) {
|
|
127
|
+
printedAllowRealSpawnWarning = true;
|
|
128
|
+
process.stderr.write("⚠ hermetic spawn guard DISABLED via HARNESS_ALLOW_REAL_SPAWN=1 — real spawns are allowed under vitest.\n");
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (vitestEnvIsActive()) {
|
|
133
|
+
throw new HermeticSpawnViolationError(binaryLabel, hint);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=hermetic-spawn-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hermetic-spawn-guard.js","sourceRoot":"","sources":["../../src/runtime/hermetic-spawn-guard.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,wEAAwE;AACxE,gEAAgE;AAChE,yDAAyD;AACzD,yBAAyB;AACzB,EAAE;AACF,iEAAiE;AACjE,oEAAoE;AACpE,iEAAiE;AACjE,qEAAqE;AACrE,sEAAsE;AACtE,gEAAgE;AAChE,wEAAwE;AACxE,qEAAqE;AACrE,sEAAsE;AACtE,wEAAwE;AACxE,6DAA6D;AAC7D,uEAAuE;AACvE,kEAAkE;AAClE,6BAA6B;AAC7B,iDAAiD;AACjD,iDAAiD;AACjD,0DAA0D;AAC1D,0DAA0D;AAC1D,sDAAsD;AACtD,qDAAqD;AACrD,yEAAyE;AACzE,4EAA4E;AAC5E,qEAAqE;AACrE,mEAAmE;AACnE,wEAAwE;AACxE,gBAAgB;AAChB,kEAAkE;AAClE,mEAAmE;AACnE,yEAAyE;AACzE,yEAAyE;AACzE,uEA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AAM,UAAU,wBAAwB,CAAC,WAAmB,EAAE,IAAY;IACxE,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,EAAE,CAAC;QACjD,IAAI,iBAAiB,EAAE,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACzD,4BAA4B,GAAG,IAAI,CAAC;YACpC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,0GAA0G,CAC3G,CAAC;QACJ,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,iBAAiB,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,2BAA2B,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type AddLedgerFactResult } from "./ledger-add.js";
|
|
2
|
+
import type { Manifest, McpServer } from "../schema/index.js";
|
|
3
|
+
export interface LedgerWriteArgs {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
content: string;
|
|
6
|
+
source: string;
|
|
7
|
+
}
|
|
8
|
+
export type LedgerWriteFn = (args: LedgerWriteArgs) => Promise<AddLedgerFactResult>;
|
|
9
|
+
export declare function findGroundingMcp(manifest: Manifest): McpServer | null;
|
|
10
|
+
export declare function mcpCommandList(server: McpServer): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a `LedgerWriteFn` bound to the manifest's declared
|
|
13
|
+
* `grounding-mcp` server, or `{ ok: false, reason }` when no such
|
|
14
|
+
* server is declared. Callers that want a verb-specific tail on the
|
|
15
|
+
* reason (e.g. "; cannot record preflight tag") append it themselves —
|
|
16
|
+
* this function's message stays generic so it is reusable verbatim
|
|
17
|
+
* across every producer.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveManifestLedgerWriter(manifest: Manifest, opts?: {
|
|
20
|
+
ledgerTimeoutMs?: number;
|
|
21
|
+
}): {
|
|
22
|
+
ok: true;
|
|
23
|
+
write: LedgerWriteFn;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
reason: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Shared manifest -> grounding-mcp ledger-writer wiring (task T-001,
|
|
2
|
+
// record-verbs).
|
|
3
|
+
//
|
|
4
|
+
// `harness session-start preflight` originally inlined this lookup
|
|
5
|
+
// (find the `grounding-mcp` MCP server entry in the manifest, split its
|
|
6
|
+
// `command` into an argv array, resolve a per-call timeout, and close
|
|
7
|
+
// over `addLedgerFact`). `harness record {review,review-subagent,
|
|
8
|
+
// dogfood}` needs the exact same wiring, so it is lifted here verbatim
|
|
9
|
+
// — behavior unchanged, just made reusable. `session-start/index.ts`
|
|
10
|
+
// now imports this instead of defining its own copies.
|
|
11
|
+
import { addLedgerFact } from "./ledger-add.js";
|
|
12
|
+
export function findGroundingMcp(manifest) {
|
|
13
|
+
return manifest.tools.mcp.find((m) => m.name === "grounding-mcp") ?? null;
|
|
14
|
+
}
|
|
15
|
+
export function mcpCommandList(server) {
|
|
16
|
+
return Array.isArray(server.command)
|
|
17
|
+
? server.command
|
|
18
|
+
: server.command.trim().split(/\s+/);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve a `LedgerWriteFn` bound to the manifest's declared
|
|
22
|
+
* `grounding-mcp` server, or `{ ok: false, reason }` when no such
|
|
23
|
+
* server is declared. Callers that want a verb-specific tail on the
|
|
24
|
+
* reason (e.g. "; cannot record preflight tag") append it themselves —
|
|
25
|
+
* this function's message stays generic so it is reusable verbatim
|
|
26
|
+
* across every producer.
|
|
27
|
+
*/
|
|
28
|
+
export function resolveManifestLedgerWriter(manifest, opts = {}) {
|
|
29
|
+
const server = findGroundingMcp(manifest);
|
|
30
|
+
if (!server) {
|
|
31
|
+
return { ok: false, reason: "grounding-mcp not declared in manifest" };
|
|
32
|
+
}
|
|
33
|
+
const command = mcpCommandList(server);
|
|
34
|
+
const env = server.env ?? undefined;
|
|
35
|
+
const timeoutMs = opts.ledgerTimeoutMs ?? server.health?.timeout_ms ?? 5_000;
|
|
36
|
+
return {
|
|
37
|
+
ok: true,
|
|
38
|
+
write: (args) => addLedgerFact({
|
|
39
|
+
mcpCommand: command,
|
|
40
|
+
...(env && { mcpEnv: env }),
|
|
41
|
+
timeoutMs,
|
|
42
|
+
...args,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=ledger-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-writer.js","sourceRoot":"","sources":["../../src/runtime/ledger-writer.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,iBAAiB;AACjB,EAAE;AACF,mEAAmE;AACnE,wEAAwE;AACxE,sEAAsE;AACtE,kEAAkE;AAClE,uEAAuE;AACvE,qEAAqE;AACrE,uDAAuD;AAEvD,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAW1E,MAAM,UAAU,gBAAgB,CAAC,QAAkB;IACjD,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,IAAI,IAAI,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAiB;IAC9C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAClC,CAAC,CAAC,MAAM,CAAC,OAAO;QAChB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAkB,EAClB,OAAqC,EAAE;IAEvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,wC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