@lannguyensi/harness 0.43.0 → 0.44.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 +35 -0
- package/dist/cli/dry-run.js +18 -12
- package/dist/cli/dry-run.js.map +1 -1
- package/dist/cli/index.js +4 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/templates.d.ts +1 -1
- package/dist/cli/init/templates.js +6 -4
- package/dist/cli/init/templates.js.map +1 -1
- package/dist/cli/pack/hook-post-merge-gate.js +43 -25
- package/dist/cli/pack/hook-post-merge-gate.js.map +1 -1
- package/dist/cli/policy/intercept.js +168 -40
- package/dist/cli/policy/intercept.js.map +1 -1
- package/dist/policy-packs/builtin/post-merge-gate-runtime.d.ts +90 -10
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js +112 -16
- package/dist/policy-packs/builtin/post-merge-gate-runtime.js.map +1 -1
- package/dist/policy-packs/builtin/post-merge-gate.js +39 -22
- package/dist/policy-packs/builtin/post-merge-gate.js.map +1 -1
- package/dist/policy-packs/builtin/solution-acceptance-runtime.d.ts +13 -0
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js +14 -1
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js.map +1 -1
- package/dist/runtime/command-normalize.d.ts +317 -4
- package/dist/runtime/command-normalize.js +741 -35
- package/dist/runtime/command-normalize.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/intercept.d.ts +171 -3
- package/dist/runtime/intercept.js +422 -42
- package/dist/runtime/intercept.js.map +1 -1
- package/dist/runtime/read-only-bash.js +58 -7
- package/dist/runtime/read-only-bash.js.map +1 -1
- package/dist/runtime/shell-word.d.ts +21 -0
- package/dist/runtime/shell-word.js +242 -0
- package/dist/runtime/shell-word.js.map +1 -0
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-merge-gate-runtime.js","sourceRoot":"","sources":["../../../src/policy-packs/builtin/post-merge-gate-runtime.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,sEAAsE;AACtE,yEAAyE;AACzE,iDAAiD;AACjD,EAAE;AACF,6CAA6C;AAC7C,iEAAiE;AACjE,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AACxE,0EAA0E;AAC1E,oEAAoE;AACpE,yEAAyE;AACzE,kEAAkE;AAClE,qEAAqE;AACrE,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,0DAA0D;AAC1D,sEAAsE;AACtE,kEAAkE;AAClE,yCAAyC;AACzC,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"post-merge-gate-runtime.js","sourceRoot":"","sources":["../../../src/policy-packs/builtin/post-merge-gate-runtime.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,sEAAsE;AACtE,yEAAyE;AACzE,iDAAiD;AACjD,EAAE;AACF,6CAA6C;AAC7C,iEAAiE;AACjE,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AACxE,0EAA0E;AAC1E,oEAAoE;AACpE,yEAAyE;AACzE,kEAAkE;AAClE,qEAAqE;AACrE,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,0DAA0D;AAC1D,sEAAsE;AACtE,kEAAkE;AAClE,yCAAyC;AACzC,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,2DAA2D;AAC3D,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,2EAA2E;AAC3E,yEAAyE;AACzE,kEAAkE;AAClE,0EAA0E;AAC1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,MAAM,EAAE,0CAA0C;SACnD,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,MAAM;YAChB,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,4BAA4B,QAAQ,gEAAgE;SAC7G,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;IACxD,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO;YACL,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,iBAAiB;YAC3B,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,EAAE;YAC5C,MAAM,EAAE,0EAA0E;SACnF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,MAAM;QAChB,EAAE,EAAE,IAAI;QACR,MAAM,EACJ,sHAAsH;KACzH,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACzC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,qBAAqB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -38,11 +38,14 @@
|
|
|
38
38
|
// when the CURRENT branch tip still equals a recorded merged tip
|
|
39
39
|
// for this repo+branch — an exact sha match, not ancestry, so a new
|
|
40
40
|
// commit (moving the tip) or a recycled branch name (a different
|
|
41
|
-
// tip) both fall silently outside the gate.
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// be starved by an unrelated failure
|
|
41
|
+
// tip) both fall silently outside the gate. GATE-ELIGIBILITY is
|
|
42
|
+
// classified FIRST, before any manifest load or ledger query, so
|
|
43
|
+
// the recovery vocabulary (git switch/checkout/pull/fetch, git
|
|
44
|
+
// branch -d/-D, git stash list/show, any `harness ...` command) can
|
|
45
|
+
// never be starved by an unrelated failure — none of those verbs is
|
|
46
|
+
// a curated mutation. Task 19356be7: DENY WINS when one command
|
|
47
|
+
// chains recovery vocabulary with a curated mutation; the escape
|
|
48
|
+
// list no longer short-circuits the whole command string.
|
|
46
49
|
//
|
|
47
50
|
// Fails OPEN when the ledger is unreachable (unlike branch-protection's
|
|
48
51
|
// fail-closed posture): without the ledger, "merged" and "not merged"
|
|
@@ -127,7 +130,7 @@ function buildHooks() {
|
|
|
127
130
|
command: BLOCKER_COMMAND,
|
|
128
131
|
blocking: "hard",
|
|
129
132
|
budget_ms: 5000,
|
|
130
|
-
description: "Blocker: deny curated history-mutating Bash commands (git commit/add/push/merge/rebase/cherry-pick/revert/reset/stash pop|apply, gh pr create/merge) when the current branch tip matches a recorded merged tip.
|
|
133
|
+
description: "Blocker: deny curated history-mutating Bash commands (git commit/add/push/merge/rebase/cherry-pick/revert/reset/stash pop|apply, gh pr create/merge) when the current branch tip matches a recorded merged tip. The recovery vocabulary (git switch/checkout/pull/fetch, git branch -d/-D, git stash list/show, any `harness ...` command) always passes as its own command, classified before any manifest or ledger access; chaining one of those with a curated mutation does NOT exempt the mutation. Fails open when the ledger is unreachable.",
|
|
131
134
|
},
|
|
132
135
|
];
|
|
133
136
|
}
|
|
@@ -185,12 +188,17 @@ ${runtime}${runtime === "codex" ? " (UNSUPPORTED — see \"Known gaps\" below; b
|
|
|
185
188
|
|
|
186
189
|
2. \`PreToolUse\` blocker (\`${BLOCKER_COMMAND}\`, blocking: hard) on
|
|
187
190
|
\`Bash\`: checked in this order —
|
|
188
|
-
a. **
|
|
189
|
-
load or ledger query):
|
|
190
|
-
\`${
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
a. **Gate-eligibility classification first, unconditionally** (before
|
|
192
|
+
any manifest load or ledger query): the curated mutation matcher
|
|
193
|
+
\`${CURATED_MUTATION_BASH_RE.source}\`. Commands it
|
|
194
|
+
does not match pass through untouched — that unconditionally covers the whole recovery
|
|
195
|
+
vocabulary (\`${ESCAPE_GIT_BASH_RE.source}\` and
|
|
196
|
+
\`${ESCAPE_HARNESS_BASH_RE.source}\`), since none of those verbs are
|
|
197
|
+
curated mutations. **Deny wins over the recovery vocabulary** when
|
|
198
|
+
one command chains both (task 19356be7): \`harness preflight &&
|
|
199
|
+
git push\` is judged by its push half, not exempted by its
|
|
200
|
+
preflight half.
|
|
201
|
+
b. **Ledger check**: denies only when the current branch tip exactly
|
|
194
202
|
equals a recorded \`${MERGED_TAG_PREFIX}:<repo>:<branch>:<sha>\` fact
|
|
195
203
|
for this repo+branch. A new commit moves the tip (gate falls
|
|
196
204
|
silent — that's legitimate continued work); a recycled branch name
|
|
@@ -204,9 +212,12 @@ ${runtime}${runtime === "codex" ? " (UNSUPPORTED — see \"Known gaps\" below; b
|
|
|
204
212
|
\`git branch -d <branch>\` to clean up the merged local branch.
|
|
205
213
|
- **Read-only / inspection commands** (\`git switch\`/\`checkout\`,
|
|
206
214
|
\`pull\`/\`fetch\`, \`branch -d\`/\`-D\`, \`stash list\`/\`show\`, and any
|
|
207
|
-
\`harness ...\` invocation) always pass
|
|
208
|
-
reachability — the gate can never itself become
|
|
209
|
-
recovery path is unavailable.
|
|
215
|
+
\`harness ...\` invocation) always pass **as their own commands**,
|
|
216
|
+
independent of ledger reachability — the gate can never itself become
|
|
217
|
+
the reason the recovery path is unavailable. Chaining one of them with
|
|
218
|
+
a curated mutation does NOT exempt the mutation (the pre-19356be7
|
|
219
|
+
escape-first ordering did, which let the documented
|
|
220
|
+
preflight-then-push workflow skip the gate entirely).
|
|
210
221
|
|
|
211
222
|
## Known gaps (documented, not attempted in v1)
|
|
212
223
|
|
|
@@ -225,13 +236,19 @@ ${runtime}${runtime === "codex" ? " (UNSUPPORTED — see \"Known gaps\" below; b
|
|
|
225
236
|
commands on a just-merged branch (e.g. hand-editing files outside
|
|
226
237
|
git's own history primitives) are out of v1 scope, mirroring
|
|
227
238
|
branch-protection's documented scope-cut.
|
|
228
|
-
- **Chained-escape bypass
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
239
|
+
- **Chained-escape bypass — CLOSED (task 19356be7)**: the original
|
|
240
|
+
escape-first ordering matched the escape list against the WHOLE
|
|
241
|
+
command string, so a curated mutation chained with an escape verb
|
|
242
|
+
(\`harness preflight && git push\`, \`git commit -am x && git switch
|
|
243
|
+
main\`) skipped the gate entirely. The blocker now classifies by the
|
|
244
|
+
curated mutation match alone (deny wins; measured 0-divergent from
|
|
245
|
+
per-clause evaluation thanks to the escape/deny verb disjointness —
|
|
246
|
+
escape-at-start-only was measured and rejected, it still exempts three
|
|
247
|
+
of the four lines this closed).
|
|
248
|
+
Residual, measured and accepted: a deny verb as quoted TEXT in a
|
|
249
|
+
chain (\`git pull && echo 'a && git push'\`) is gate-eligible even
|
|
250
|
+
though bash never runs it — the existing accepted false-positive
|
|
251
|
+
class, no longer rescued by a chained escape verb.
|
|
235
252
|
- **Inverted trust-boundary residual**: a merged fact written by any
|
|
236
253
|
means OTHER than the producer (e.g. directly via
|
|
237
254
|
\`mcp__grounding-mcp__ledger_add\`) that happens to exactly match the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-merge-gate.js","sourceRoot":"","sources":["../../../src/policy-packs/builtin/post-merge-gate.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,mEAAmE;AACnE,gEAAgE;AAChE,uEAAuE;AACvE,wEAAwE;AACxE,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,iCAAiC;AACjC,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,0DAA0D;AAC1D,oEAAoE;AACpE,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AACxE,qEAAqE;AACrE,2EAA2E;AAC3E,oEAAoE;AACpE,yEAAyE;AACzE,2EAA2E;AAC3E,qEAAqE;AACrE,2EAA2E;AAC3E,uEAAuE;AACvE,2DAA2D;AAC3D,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,gBAAgB;AAChB,EAAE;AACF,yEAAyE;AACzE,sDAAsD;AACtD,sEAAsE;AACtE,sEAAsE;AACtE,yEAAyE;AACzE,sEAAsE;AACtE,qEAAqE;AACrE,oEAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"post-merge-gate.js","sourceRoot":"","sources":["../../../src/policy-packs/builtin/post-merge-gate.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,mEAAmE;AACnE,gEAAgE;AAChE,uEAAuE;AACvE,wEAAwE;AACxE,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,iCAAiC;AACjC,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,0DAA0D;AAC1D,oEAAoE;AACpE,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AACxE,qEAAqE;AACrE,2EAA2E;AAC3E,oEAAoE;AACpE,yEAAyE;AACzE,2EAA2E;AAC3E,qEAAqE;AACrE,2EAA2E;AAC3E,uEAAuE;AACvE,2DAA2D;AAC3D,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,gBAAgB;AAChB,EAAE;AACF,yEAAyE;AACzE,sDAAsD;AACtD,sEAAsE;AACtE,sEAAsE;AACtE,yEAAyE;AACzE,sEAAsE;AACtE,qEAAqE;AACrE,sEAAsE;AACtE,oEAAoE;AACpE,yEAAyE;AACzE,yEAAyE;AACzE,qEAAqE;AACrE,sEAAsE;AACtE,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,sEAAsE;AACtE,uEAAuE;AACvE,yEAAyE;AACzE,+DAA+D;AAC/D,kFAAkF;AAClF,kEAAkE;AAClE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AAO,EAAE,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;SAC1C;KACF,CAAC;IACF,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,QAAQ,CAAC,IAAI,CACX,gBAAgB,IAAI,CAAC,IAAI,8JAA8J,CACxL,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -14,6 +14,19 @@ export declare const DEFAULT_PROTECTED_COMPLETION_TOOLS: readonly ["task_finish"
|
|
|
14
14
|
* load-bearing choke points; hardening this is follow-up `7207d8f9`.
|
|
15
15
|
* Tolerates a leading `cd … &&`, inline `VAR=val` assignments, and `git -C
|
|
16
16
|
* <path> push`.
|
|
17
|
+
*
|
|
18
|
+
* Task 76671e5a: bare `&` added to the boundary alternation (`&&` kept to
|
|
19
|
+
* its left only to mirror `src/runtime/command-normalize.ts`'s alternation
|
|
20
|
+
* order for readability — NOT because order is load-bearing here, unlike
|
|
21
|
+
* that module). Same fix as `d834a065` applied to every policy trigger —
|
|
22
|
+
* bash starts a new command after a single `&`, so `A=x&git push` used to
|
|
23
|
+
* slip past this DENY matcher entirely. Broadening is the stricter direction
|
|
24
|
+
* here (this gates completion actions, it is not an allow-list). Measured:
|
|
25
|
+
* swapping to `&|&&` produces a byte-identical match set for this matcher
|
|
26
|
+
* (a `RegExp.test` existential check over every start offset, not a
|
|
27
|
+
* segmenter — the reasoning that makes order matter in
|
|
28
|
+
* `command-normalize.ts`'s `BOUNDARY_RE`/`AMP_BOUNDARY_RE` does not transfer
|
|
29
|
+
* to a plain `.test()` matcher like this one).
|
|
17
30
|
*/
|
|
18
31
|
export declare const DEFAULT_PUSH_BASH_RE: RegExp;
|
|
19
32
|
/**
|
|
@@ -65,8 +65,21 @@ export const DEFAULT_PROTECTED_COMPLETION_TOOLS = [
|
|
|
65
65
|
* load-bearing choke points; hardening this is follow-up `7207d8f9`.
|
|
66
66
|
* Tolerates a leading `cd … &&`, inline `VAR=val` assignments, and `git -C
|
|
67
67
|
* <path> push`.
|
|
68
|
+
*
|
|
69
|
+
* Task 76671e5a: bare `&` added to the boundary alternation (`&&` kept to
|
|
70
|
+
* its left only to mirror `src/runtime/command-normalize.ts`'s alternation
|
|
71
|
+
* order for readability — NOT because order is load-bearing here, unlike
|
|
72
|
+
* that module). Same fix as `d834a065` applied to every policy trigger —
|
|
73
|
+
* bash starts a new command after a single `&`, so `A=x&git push` used to
|
|
74
|
+
* slip past this DENY matcher entirely. Broadening is the stricter direction
|
|
75
|
+
* here (this gates completion actions, it is not an allow-list). Measured:
|
|
76
|
+
* swapping to `&|&&` produces a byte-identical match set for this matcher
|
|
77
|
+
* (a `RegExp.test` existential check over every start offset, not a
|
|
78
|
+
* segmenter — the reasoning that makes order matter in
|
|
79
|
+
* `command-normalize.ts`'s `BOUNDARY_RE`/`AMP_BOUNDARY_RE` does not transfer
|
|
80
|
+
* to a plain `.test()` matcher like this one).
|
|
68
81
|
*/
|
|
69
|
-
export const DEFAULT_PUSH_BASH_RE = /(?:^|\n
|
|
82
|
+
export const DEFAULT_PUSH_BASH_RE = /(?:^|\n|;|\||&&|&|\()\s*(?:\w+=\S+\s+)*(?:git(?:\s+-C\s+\S+)?\s+push|gh\s+pr\s+merge)\b/;
|
|
70
83
|
/**
|
|
71
84
|
* Resolve the completion verbs the gate fires on: the pack's
|
|
72
85
|
* `config.protected_completion_tools` override, else the default set.
|
|
@@ -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
|
|
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,gEAAg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,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"}
|
|
@@ -13,10 +13,13 @@ export interface NormalizedCommand {
|
|
|
13
13
|
* that disagree, or the only named value is `~`-prefixed (see the
|
|
14
14
|
* module header's target-directory-extraction rules).
|
|
15
15
|
*
|
|
16
|
-
* NOT WIRED TO ANY GATE (see the module header's STATUS
|
|
17
|
-
* extracted and fully tested,
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
16
|
+
* STILL NOT WIRED TO ANY GATE (see the module header's STATUS
|
|
17
|
+
* paragraph): extracted and fully tested, but task `98ad072f`'s
|
|
18
|
+
* per-policy redesign (T-003) attributes a target from the per-segment
|
|
19
|
+
* `segmentViewOf` view below instead of this whole-command aggregate —
|
|
20
|
+
* a single per-event `targetDir` cannot express "this invocation
|
|
21
|
+
* targets repo B, but the gated verb after it runs in the caller's
|
|
22
|
+
* cwd," which is exactly the property the redesign needs.
|
|
20
23
|
*/
|
|
21
24
|
targetDir: string | null;
|
|
22
25
|
/**
|
|
@@ -42,6 +45,177 @@ export interface NormalizedCommand {
|
|
|
42
45
|
*/
|
|
43
46
|
truncated: boolean;
|
|
44
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* One boundary-delimited segment's canonicalised text plus its own and
|
|
50
|
+
* "effective" target directory (task `98ad072f`, T-002 of run
|
|
51
|
+
* `2026-08-02-per-repo-gate-scoping-redesign`) — attributes a target to
|
|
52
|
+
* the SPECIFIC segment satisfying a policy's own `bash_match` trigger,
|
|
53
|
+
* instead of the single, whole-command `targetDir` / `targetBase` on
|
|
54
|
+
* `NormalizedCommand` above. Produced by `segmentViewOf`. WIRED as of
|
|
55
|
+
* T-003, this run: `src/runtime/intercept.ts`'s `attributeTriggerSegments`
|
|
56
|
+
* / `resolveAttributedContexts` are the consumer (see the module header's
|
|
57
|
+
* STATUS/UPDATE note for the exact contract).
|
|
58
|
+
*/
|
|
59
|
+
export interface CommandSegment {
|
|
60
|
+
/**
|
|
61
|
+
* This segment's canonicalised text — the same rewrite
|
|
62
|
+
* `NormalizedCommand.normalized` applies to the corresponding span,
|
|
63
|
+
* boundary tokens EXCLUDED (they sit between segments, never inside
|
|
64
|
+
* one). Every shipped `bash_match` pattern's boundary alternation
|
|
65
|
+
* includes a `^` branch, so testing such a pattern against THIS string
|
|
66
|
+
* alone (no leading boundary character) is well-defined — see
|
|
67
|
+
* `01-plan.md`'s Proposed Approach item 2 for how a future consumer
|
|
68
|
+
* uses this.
|
|
69
|
+
*/
|
|
70
|
+
text: string;
|
|
71
|
+
/**
|
|
72
|
+
* D-021 (UNIVERSAL-ADDITIVE, run 2026-08-02-per-repo-gate-scoping-
|
|
73
|
+
* redesign): the only remaining consumer of this field is
|
|
74
|
+
* `computeSegmentTarget`'s own internal `effectiveTarget` derivation
|
|
75
|
+
* (below) — `src/runtime/intercept.ts`'s `resolveAttributedContexts`
|
|
76
|
+
* (the gate) reads `effectiveTarget` only and no longer consults
|
|
77
|
+
* `ownTarget` at all. Kept as a public, separately-populated field
|
|
78
|
+
* (part of the T-002 API) rather than folded away, since a future
|
|
79
|
+
* consumer distinguishing "this segment's OWN explicit target" from
|
|
80
|
+
* "the directory it composes to once an incoming `cd` basis is
|
|
81
|
+
* accounted for" is exactly what the two-field split exists for.
|
|
82
|
+
*
|
|
83
|
+
* This segment's OWN explicit target, named by ITS OWN invocation
|
|
84
|
+
* only — a git invocation's REPO-RELOCATING global option ONLY: `-C` /
|
|
85
|
+
* `--git-dir` (or the SAME invocation's wrapping `env -C`, git-own-
|
|
86
|
+
* target-prioritised the same way `NormalizedCommand.targetDir` already
|
|
87
|
+
* is) — or, for a recognised bare `cd <path>` segment, the parsed path.
|
|
88
|
+
* Deliberately EXCLUDES `--work-tree` (D-017, fix round 2, run
|
|
89
|
+
* `2026-08-02-per-repo-gate-scoping-redesign`): `--work-tree` sets a
|
|
90
|
+
* git invocation's working tree but does NOT relocate its `--git-dir`
|
|
91
|
+
* search, so `git --work-tree=<B> push`/`log`/`status` still operate on
|
|
92
|
+
* whatever repo the invocation's ACTUAL directory names, never `<B>`
|
|
93
|
+
* alone — folding it into this field as though it were repo-identity-
|
|
94
|
+
* bearing (the pre-fix behaviour) let `resolveAttributedContexts`
|
|
95
|
+
* (`src/runtime/intercept.ts`, D-011) REPLACE the cwd demand with `<B>`'s
|
|
96
|
+
* on the strength of a flag that never moved the invocation there,
|
|
97
|
+
* measured as a live cross-repo fail-open. `null` when this segment
|
|
98
|
+
* names no repo-relocating target of its own (not a git invocation, not
|
|
99
|
+
* a `cd` segment, a bare git invocation, or a git invocation whose ONLY
|
|
100
|
+
* target-bearing flag is `--work-tree`) OR the named value is one of
|
|
101
|
+
* this view's unattributable forms: `~`-prefixed, carrying a stray quote
|
|
102
|
+
* character (the tokeniser is not quote-aware — a quoted value is
|
|
103
|
+
* captured WITH its quote character(s) still attached, not a real
|
|
104
|
+
* path), containing a command-substitution marker (`$(` or a backtick),
|
|
105
|
+
* or — for `cd` specifically — a bare `cd` with no argument or a `cd`
|
|
106
|
+
* with a flag (`cd -P /x`, three tokens instead of two). ALSO `null`
|
|
107
|
+
* when the SAME invocation names a git target via BOTH a relative own
|
|
108
|
+
* `-C` / `--git-dir` AND a wrapping `env -C` / `--chdir` base (`env -C
|
|
109
|
+
* /tmp/base git -C sub status`) — a mixed, internally ambiguous
|
|
110
|
+
* composition, unattributable for the same reason a relative own target
|
|
111
|
+
* after a preceding `cd` is (see `effectiveTarget` below); this is the
|
|
112
|
+
* ONE case where `ownTarget` itself, not just `effectiveTarget`, is
|
|
113
|
+
* nulled by a composition rule rather than by the raw value being
|
|
114
|
+
* unrecognisable on its own. A relative value (including `-C .`) and an
|
|
115
|
+
* absolute value are both otherwise preserved here verbatim, unresolved
|
|
116
|
+
* against any cwd — that resolution is a future consumer's job, not
|
|
117
|
+
* this module's. `git --git-dir=<A>/.git --work-tree=<B> ...`: this
|
|
118
|
+
* field is `<A>` (the `.git` parent) — `--git-dir` wins regardless of
|
|
119
|
+
* which flag appears first in the invocation, because `--work-tree`
|
|
120
|
+
* never contributes to this field at all, not because of any ordering
|
|
121
|
+
* rule between the two.
|
|
122
|
+
*
|
|
123
|
+
* ALSO `null` (D-018, fix round 3, pass-3 CRITICAL) when the invocation
|
|
124
|
+
* carries MORE THAN ONE recognised, resolved repo-relocating option:
|
|
125
|
+
* two-or-more `-C`, `-C` combined with `--git-dir`, `--git-dir` twice,
|
|
126
|
+
* or a same-invocation `env -C`/`--chdir` wrap whose target diverges
|
|
127
|
+
* from git's own ABSOLUTE `-C`/`--git-dir` target. Real git composes
|
|
128
|
+
* every one of these cumulatively (a later absolute value wins); this
|
|
129
|
+
* module does not encode that composition (same "not this module's
|
|
130
|
+
* job" reasoning as the relative-mix case above) and instead falls back
|
|
131
|
+
* to unattributable rather than trust the first flag it saw — `git -C
|
|
132
|
+
* <forge> -C <realA> push` actually runs in `<realA>`, but a first-
|
|
133
|
+
* flag-wins reading named `<forge>`, letting an agent redirect a gate's
|
|
134
|
+
* demanded evidence away from the repo the verb truly targets (measured
|
|
135
|
+
* against real git 2.34.1). An EXACT repeat of the same already-
|
|
136
|
+
* recorded value (`-C X -C X`, `env -C X git -C X`) is not new
|
|
137
|
+
* information and does not trigger this — see `peelGitGlobalOptions`'s
|
|
138
|
+
* `noteRelocatingOption` for the precise counting rule.
|
|
139
|
+
*
|
|
140
|
+
* D-021 (UNIVERSAL-ADDITIVE, operator decision, run 2026-08-02-per-
|
|
141
|
+
* repo-gate-scoping-redesign): the D-017/D-018 exclusions above (only a
|
|
142
|
+
* SINGLE recognised repo-relocating flag sets this field; `--work-tree`
|
|
143
|
+
* never does) are PRECISION, not the safety mechanism, since
|
|
144
|
+
* `src/runtime/intercept.ts`'s `resolveAttributedContexts` no longer
|
|
145
|
+
* REPLACES the cwd demand with this field's value — it ADDS to it, and
|
|
146
|
+
* the cwd demand is never dropped regardless of what this field
|
|
147
|
+
* resolves to. What these exclusions still prevent is a SPURIOUS extra
|
|
148
|
+
* demand (over-attributing a target the invocation does not actually,
|
|
149
|
+
* unambiguously name), not a dropped one — see that function's own doc
|
|
150
|
+
* comment for the full D-021 rationale.
|
|
151
|
+
*/
|
|
152
|
+
ownTarget: string | null;
|
|
153
|
+
/**
|
|
154
|
+
* The directory this segment's own invocation actually runs in, once
|
|
155
|
+
* composed with the LAST PRECEDING recognised `cd <path>` segment in the
|
|
156
|
+
* same command (not necessarily the immediately preceding segment — any
|
|
157
|
+
* non-`cd` segment in between leaves the running cd-basis unchanged, the
|
|
158
|
+
* same way a non-`cd` shell command never itself changes the directory).
|
|
159
|
+
* Composition rules (`01-plan.md`, Proposed Approach item 1, verbatim):
|
|
160
|
+
* - `ownTarget === null` → inherits the incoming cd-basis as-is
|
|
161
|
+
* (including `null` when nothing preceding named one either).
|
|
162
|
+
* - `ownTarget` absolute → itself, unconditionally — an absolute
|
|
163
|
+
* value is never "relative to" anything a preceding `cd` named.
|
|
164
|
+
* - `ownTarget` relative AND a preceding `cd` basis is known
|
|
165
|
+
* (non-`null`) → `null`. This is the K1 divergence case
|
|
166
|
+
* (`docs/okf/quote-model-divergence.md`): `cd T && git -C sub
|
|
167
|
+
* status` does NOT become `T/sub` here — that would need real
|
|
168
|
+
* filesystem-shaped path joining this module deliberately does not
|
|
169
|
+
* perform — so it is UNATTRIBUTABLE rather than guessed at.
|
|
170
|
+
* - `ownTarget` relative AND no preceding `cd` basis is known → the
|
|
171
|
+
* raw relative value itself (deferred to a future consumer to
|
|
172
|
+
* resolve against the real cwd).
|
|
173
|
+
* A same-invocation mixed `env -C <base>` + relative own `-C`/
|
|
174
|
+
* `--git-dir` composition (see `ownTarget` above — `--work-tree` is
|
|
175
|
+
* EXCLUDED from this mix entirely, D-017: it never sets `ownTarget`, so
|
|
176
|
+
* it can never trigger this ambiguity either) is `null` here TOO —
|
|
177
|
+
* checked BEFORE the cd-basis rules above and
|
|
178
|
+
* independently of them: `env -C /tmp/base git -C sub status` never
|
|
179
|
+
* becomes `/tmp/base/sub` (real path joining, deliberately not this
|
|
180
|
+
* module's job — same reasoning as the cd-basis K1 case) NOR does it
|
|
181
|
+
* fall through to the "relative, no cd basis, stays raw" branch above
|
|
182
|
+
* (that would hand a future consumer resolving relatives against ITS
|
|
183
|
+
* OWN cwd a CONFIDENTLY WRONG repository whenever the caller's cwd
|
|
184
|
+
* differs from `/tmp/base` — the "relative and `~` target dirs resolve
|
|
185
|
+
* to a confidently wrong repo" class named in the 07-27 review). A bare
|
|
186
|
+
* `env -C <base> git status` (no relative own target) is UNAFFECTED —
|
|
187
|
+
* `ownTarget` is `<base>` as usual, composed the ordinary way below.
|
|
188
|
+
* A recognised `cd <path>` segment whose OWN value is one of the
|
|
189
|
+
* unattributable forms above (e.g. `cd ~`) still RESETS the running
|
|
190
|
+
* cd-basis to `null` for every LATER segment — a later segment must not
|
|
191
|
+
* silently keep inheriting whatever basis existed BEFORE that `cd`,
|
|
192
|
+
* since the shell genuinely changed directory to somewhere this module
|
|
193
|
+
* cannot name.
|
|
194
|
+
*
|
|
195
|
+
* FULL reset-trigger list (D-014, fix round, run 2026-08-02-per-repo-
|
|
196
|
+
* gate-scoping-redesign — corrects this comment, which previously named
|
|
197
|
+
* only the unattributable-`cd`-value case above): the running basis
|
|
198
|
+
* resets to `null` — rather than the pre-fix behaviour of silently
|
|
199
|
+
* carrying an earlier basis forward unchanged — for ALL of: a bare `cd`
|
|
200
|
+
* with no argument, `cd -`, any other flagged `cd` (`cd -P /tmp/x`),
|
|
201
|
+
* `pushd`, `popd` (see `classifyCdSegment`), and the unattributable-
|
|
202
|
+
* `cd`-value case documented above. TWO of the reset triggers are NOT
|
|
203
|
+
* decided by this per-segment composition at all — they depend on the
|
|
204
|
+
* BOUNDARY a segment sits behind, which only the caller
|
|
205
|
+
* (`segmentAndCanonicalize`'s own walk) can see: the basis never
|
|
206
|
+
* crosses a bare `|` (each side of a pipe is bash's own subshell), and
|
|
207
|
+
* it resets after any segment whose text contains a `)` (a subshell
|
|
208
|
+
* close — `BOUNDARY_RE` has no `)` boundary of its own, so this is a
|
|
209
|
+
* substring check on the segment that happens to end there, not paren-
|
|
210
|
+
* depth tracking). See `segmentAndCanonicalize`'s own comment at its
|
|
211
|
+
* `computeSegmentTarget` call site for those two. NOT covered by any of
|
|
212
|
+
* this (same ceiling as before this fix round, unchanged): a `cd`
|
|
213
|
+
* inside a NESTED subshell that never closes within the command
|
|
214
|
+
* string's visible boundaries, and any construct outside this module's
|
|
215
|
+
* documented NOT-SUPPORTED list in the module header.
|
|
216
|
+
*/
|
|
217
|
+
effectiveTarget: string | null;
|
|
218
|
+
}
|
|
45
219
|
/**
|
|
46
220
|
* The `git` token itself, matched by BASENAME so a path-qualified
|
|
47
221
|
* invocation (`/usr/bin/git`, `./git`) is recognised too (F4 fix).
|
|
@@ -81,6 +255,60 @@ export declare const NON_GIT_HEAD_TOKENS: ReadonlySet<string>;
|
|
|
81
255
|
* hand-copying it into a diagnostic message.
|
|
82
256
|
*/
|
|
83
257
|
export declare const MAX_NORMALIZE_LENGTH = 100000;
|
|
258
|
+
/**
|
|
259
|
+
* Second boundary alphabet (task aabbad63): identical to `BOUNDARY_RE`
|
|
260
|
+
* plus a bare `&` — bash's OWN "start a new command here" token, which
|
|
261
|
+
* every shipped `bash_match` trigger regex has treated as one of its own
|
|
262
|
+
* anchor characters since task `d834a065`, but which `BOUNDARY_RE` above
|
|
263
|
+
* has never recognised as a NORMALISATION-time boundary (see its comment
|
|
264
|
+
* for the reverted, measured-140/140-regression attempt to add it there
|
|
265
|
+
* directly).
|
|
266
|
+
*
|
|
267
|
+
* ALTERNATION ORDER IS LOAD-BEARING: `&&` MUST be listed to the LEFT of
|
|
268
|
+
* the bare `&` alternative. JS regex alternation is leftmost-FIRST, not
|
|
269
|
+
* leftmost-longest — with `&` tried before `&&`, every `&&` in a command
|
|
270
|
+
* would tokenise as TWO consecutive one-character `&` boundary MATCHES
|
|
271
|
+
* instead of a single two-character `&&` boundary match.
|
|
272
|
+
*
|
|
273
|
+
* MEASURED, NOT ASSUMED (do not "simplify" the pin below to an
|
|
274
|
+
* end-to-end `.normalized` string assertion): for THIS module's segment-
|
|
275
|
+
* and-rejoin architecture specifically, that reordering is, perhaps
|
|
276
|
+
* counter-intuitively, INVISIBLE in `normalizeCommandAmpAware`'s own
|
|
277
|
+
* output string. Two adjacent single-`&` matches sandwich a genuinely
|
|
278
|
+
* zero-length segment between them (the two `&` characters of a real
|
|
279
|
+
* `&&` are, by definition, adjacent), `canonicalizeSegment("")` is a
|
|
280
|
+
* verbatim no-op, and `parts.join("")` reassembles the exact same bytes
|
|
281
|
+
* either way — verified directly (not merely reasoned about) by
|
|
282
|
+
* temporarily swapping this alternation's order, rebuilding, and
|
|
283
|
+
* diffing `normalizeCommandAmpAware(...).normalized` across several
|
|
284
|
+
* `&&`-bearing commands (including this comment's own `git -C
|
|
285
|
+
* /tmp/repoB status && git -C /tmp/repoB log` example): byte-identical
|
|
286
|
+
* output both ways. So a test asserting on the OUTPUT STRING alone
|
|
287
|
+
* cannot distinguish the two orderings for this architecture — the pin
|
|
288
|
+
* in `tests/runtime/command-normalize.test.ts` therefore execs this
|
|
289
|
+
* regex object DIRECTLY against a `&&`-bearing string and asserts the
|
|
290
|
+
* match text is `"&&"`, not `"&"`, which DOES fail under a swap. The
|
|
291
|
+
* order is still specified exactly as documented above (leftmost-first
|
|
292
|
+
* is real JS semantics, and the internal `segmentAndCanonicalize`
|
|
293
|
+
* bookkeeping this alphabet ALSO drives — `hasAmbiguousNonGitSegment`,
|
|
294
|
+
* discarded by `normalizeCommandAmpAware` but not by a hypothetical
|
|
295
|
+
* future consumer of `segmentAndCanonicalize` under this alphabet —
|
|
296
|
+
* would still see a spurious extra "non-git segment" under the wrong
|
|
297
|
+
* order), it just cannot be pinned through this module's ONE exposed
|
|
298
|
+
* string alone.
|
|
299
|
+
*
|
|
300
|
+
* Used ONLY by `normalizeCommandAmpAware` below, which is consulted ONLY
|
|
301
|
+
* as `policyMatchesEvent`'s third, additional matching arm — see that
|
|
302
|
+
* function's own comment for why its result never carries a `targetDir`/
|
|
303
|
+
* `targetBase`, and `src/runtime/intercept.ts` for the memoised-thunk
|
|
304
|
+
* threading that keeps this off the common (raw-or-normalised-already-
|
|
305
|
+
* matched) path. Exported (mirrors `GIT_TOKEN_RE` / `NON_GIT_HEAD_TOKENS`
|
|
306
|
+
* / `MAX_NORMALIZE_LENGTH` above) solely so the ordering pin test can
|
|
307
|
+
* exec it directly instead of re-declaring an equivalent regex literal
|
|
308
|
+
* that would test JS semantics in general, not THIS source's actual
|
|
309
|
+
* alternation.
|
|
310
|
+
*/
|
|
311
|
+
export declare const AMP_BOUNDARY_RE: RegExp;
|
|
84
312
|
/**
|
|
85
313
|
* Given a Bash command string, return its normalised form and the target
|
|
86
314
|
* directory (and base, if relative) of its git invocation. Never throws:
|
|
@@ -90,3 +318,88 @@ export declare const MAX_NORMALIZE_LENGTH = 100000;
|
|
|
90
318
|
* to the input unchanged.
|
|
91
319
|
*/
|
|
92
320
|
export declare function normalizeCommand(command: string): NormalizedCommand;
|
|
321
|
+
/**
|
|
322
|
+
* Given a Bash command string, return its per-segment view (task
|
|
323
|
+
* `98ad072f` groundwork, T-002) — see `CommandSegment`'s own doc comment
|
|
324
|
+
* for the field-level composition rules. `null` when the input exceeded
|
|
325
|
+
* `MAX_NORMALIZE_LENGTH` (mirrors `NormalizedCommand.truncated`, but as
|
|
326
|
+
* the ABSENCE of a view rather than a boolean flag alongside one, since
|
|
327
|
+
* there is no meaningful per-segment view to return for an input whose
|
|
328
|
+
* normalisation itself was skipped). `[]` for an empty or non-string
|
|
329
|
+
* command, and as the never-throws fallback (mirrors `normalizeCommand`'s
|
|
330
|
+
* own defensive backstop — see its doc comment above).
|
|
331
|
+
*
|
|
332
|
+
* THIS function's OWN call into `segmentAndCanonicalize` (`collectSegments:
|
|
333
|
+
* true`) is one walk, O(length) — the "no additional pass" claim is scoped
|
|
334
|
+
* to that ONE call, not to a caller's total work. CORRECTED (D-015, fix
|
|
335
|
+
* round, run 2026-08-02-per-repo-gate-scoping-redesign) — the prior wording
|
|
336
|
+
* here read "no additional pass over the command string" without that
|
|
337
|
+
* scoping, which a reader could take as "calling this costs nothing beyond
|
|
338
|
+
* `normalizeCommand`'s own walk." Measured false: `normalizeCommand(cmd)`
|
|
339
|
+
* and `segmentViewOf(cmd)` are two SEPARATE top-level calls, each running
|
|
340
|
+
* its own full `segmentAndCanonicalize` pass over the SAME string — a
|
|
341
|
+
* caller needing both (as `src/cli/policy/intercept.ts` does, for
|
|
342
|
+
* `normalized`/`truncated` and the segment view respectively) pays TWO
|
|
343
|
+
* walks, not one; measured +206% at the `MAX_NORMALIZE_LENGTH` bound
|
|
344
|
+
* (2.73 → 8.36 ms), harmless against the 1000 ms hook budget but not free.
|
|
345
|
+
* As of the same fix round, the one production caller only pays this
|
|
346
|
+
* second walk lazily, when some matching policy actually needs it (see
|
|
347
|
+
* `InterceptOptions.commandSegmentsThunk` in `src/runtime/intercept.ts`) —
|
|
348
|
+
* but that laziness lives in the CALLER, not in this function, which still
|
|
349
|
+
* does exactly one walk every time it runs. The ampersand-aware second pass
|
|
350
|
+
* (`normalizeCommandAmpAware`) NEVER collects a segment view (always calls
|
|
351
|
+
* `segmentAndCanonicalize` with `collectSegments: false`) — see that
|
|
352
|
+
* function's own comment for why a directory extracted under the
|
|
353
|
+
* ampersand-aware alphabet would be unreliable in the first place; the
|
|
354
|
+
* same reasoning applies here, so this module offers no amp-aware variant
|
|
355
|
+
* of this function at all.
|
|
356
|
+
*/
|
|
357
|
+
export declare function segmentViewOf(command: string): CommandSegment[] | null;
|
|
358
|
+
/**
|
|
359
|
+
* Return type of `normalizeCommandAmpAware` — deliberately NOT
|
|
360
|
+
* `NormalizedCommand` (task aabbad63, hard constraint). It carries only
|
|
361
|
+
* `normalized`/`truncated`; there is no `targetDir`/`targetBase` field at
|
|
362
|
+
* all, so a future caller cannot wire one up to a gate by mistake — see
|
|
363
|
+
* `normalizeCommandAmpAware`'s own comment for why a directory extracted
|
|
364
|
+
* under the ampersand-aware alphabet would be unreliable in the first
|
|
365
|
+
* place, not merely "unwired today".
|
|
366
|
+
*/
|
|
367
|
+
export interface AmpAwareNormalizedCommand {
|
|
368
|
+
/** Same contract as `NormalizedCommand.normalized`, under `AMP_BOUNDARY_RE`. */
|
|
369
|
+
normalized: string;
|
|
370
|
+
/** Same contract as `NormalizedCommand.truncated`. */
|
|
371
|
+
truncated: boolean;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Ampersand-aware SECOND normalisation pass (task aabbad63). Segments the
|
|
375
|
+
* command under `AMP_BOUNDARY_RE` (`BOUNDARY_RE` plus a bare `&`) instead
|
|
376
|
+
* of `BOUNDARY_RE`, then canonicalises exactly like the primary pass
|
|
377
|
+
* (same `canonicalizeSegment`, same wrapper-peeling rules, same
|
|
378
|
+
* `MAX_NORMALIZE_LENGTH` bound). Closes the gap `BOUNDARY_RE`'s own
|
|
379
|
+
* comment names: `A=x&env -C /tmp git status` and `echo hi & nice git
|
|
380
|
+
* status` were ungated because a wrapper can only be peeled after a
|
|
381
|
+
* recognised boundary, and a bare `&` was not one.
|
|
382
|
+
*
|
|
383
|
+
* Return type deliberately has NO `targetDir`/`targetBase` — not merely
|
|
384
|
+
* "always null under this alphabet", genuinely ABSENT from the type, so
|
|
385
|
+
* no consumer can read one by mistake. Reason: a bare `&` is ALSO how
|
|
386
|
+
* bash spells a background job (`git -C /x push &`) and how a redirect
|
|
387
|
+
* merges streams (`git -C /x log 2>&1`, `... &> out`). Under THIS
|
|
388
|
+
* alphabet each of those splits into a spurious extra "segment", which
|
|
389
|
+
* `segmentAndCanonicalize`'s own non-git-segment ambiguity rule (a
|
|
390
|
+
* segment that starts a new command and is not itself a git invocation
|
|
391
|
+
* forces `targetDir` to `null` — see its G1 comment) would turn into a
|
|
392
|
+
* wrong-shaped loss for a case the PRIMARY pass still resolves correctly
|
|
393
|
+
* today. Pinned in `tests/runtime/command-normalize.test.ts`'s "aabbad63
|
|
394
|
+
* groundwork" describe block, which exercises ONLY `normalizeCommand`
|
|
395
|
+
* (the primary pass), never this function — `targetDir`/`targetBase`
|
|
396
|
+
* stay the primary pass's property alone.
|
|
397
|
+
*
|
|
398
|
+
* Only consulted by `policyMatchesEvent`'s third arm
|
|
399
|
+
* (`src/runtime/intercept.ts`), and only when a policy's `bash_match`
|
|
400
|
+
* regex has already missed BOTH the raw command and the primary
|
|
401
|
+
* normalised form — see that module and `src/cli/policy/intercept.ts`
|
|
402
|
+
* for the memoised-thunk threading that keeps this computation off the
|
|
403
|
+
* common (already-matched) path.
|
|
404
|
+
*/
|
|
405
|
+
export declare function normalizeCommandAmpAware(command: string): AmpAwareNormalizedCommand;
|