@lannguyensi/harness 0.43.0 → 0.45.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 +1248 -0
- package/dist/cli/adopt/derive.d.ts +16 -7
- package/dist/cli/adopt/derive.js +19 -2
- package/dist/cli/adopt/derive.js.map +1 -1
- package/dist/cli/adopt/index.js +18 -3
- package/dist/cli/adopt/index.js.map +1 -1
- package/dist/cli/apply/apply.d.ts +1 -0
- package/dist/cli/apply/apply.js +62 -6
- package/dist/cli/apply/apply.js.map +1 -1
- package/dist/cli/apply/generate-codex-config.js +5 -6
- package/dist/cli/apply/generate-codex-config.js.map +1 -1
- package/dist/cli/apply/generate-opencode-config.d.ts +58 -0
- package/dist/cli/apply/generate-opencode-config.js +210 -0
- package/dist/cli/apply/generate-opencode-config.js.map +1 -0
- package/dist/cli/apply/generate-settings.d.ts +90 -32
- package/dist/cli/apply/generate-settings.js +133 -10
- package/dist/cli/apply/generate-settings.js.map +1 -1
- package/dist/cli/apply/index.d.ts +2 -1
- package/dist/cli/apply/index.js +2 -1
- package/dist/cli/apply/index.js.map +1 -1
- package/dist/cli/approve/stdin-report.d.ts +15 -0
- package/dist/cli/approve/stdin-report.js +1 -1
- package/dist/cli/approve/stdin-report.js.map +1 -1
- package/dist/cli/approve/understanding.d.ts +75 -0
- package/dist/cli/approve/understanding.js +150 -2
- package/dist/cli/approve/understanding.js.map +1 -1
- package/dist/cli/audit.d.ts +1 -1
- package/dist/cli/audit.js +3 -2
- package/dist/cli/audit.js.map +1 -1
- package/dist/cli/doctor/claude-mcp.d.ts +19 -1
- package/dist/cli/doctor/claude-mcp.js +36 -10
- package/dist/cli/doctor/claude-mcp.js.map +1 -1
- package/dist/cli/doctor/codex.d.ts +3 -1
- package/dist/cli/doctor/codex.js +6 -9
- package/dist/cli/doctor/codex.js.map +1 -1
- package/dist/cli/doctor/format.js +94 -8
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/index.d.ts +23 -0
- package/dist/cli/doctor/index.js +106 -2
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/opencode.d.ts +24 -0
- package/dist/cli/doctor/opencode.js +107 -0
- package/dist/cli/doctor/opencode.js.map +1 -0
- package/dist/cli/doctor/target-checks.d.ts +11 -0
- package/dist/cli/doctor/target-checks.js +25 -0
- package/dist/cli/doctor/target-checks.js.map +1 -0
- package/dist/cli/doctor/toolchain-parity.d.ts +63 -0
- package/dist/cli/doctor/toolchain-parity.js +154 -0
- package/dist/cli/doctor/toolchain-parity.js.map +1 -0
- package/dist/cli/doctor/types.d.ts +85 -1
- package/dist/cli/doctor/types.js +1 -1
- package/dist/cli/doctor/types.js.map +1 -1
- package/dist/cli/doctor/understanding-mode-env.d.ts +39 -0
- package/dist/cli/doctor/understanding-mode-env.js +83 -0
- package/dist/cli/doctor/understanding-mode-env.js.map +1 -0
- package/dist/cli/dry-run.js +34 -13
- package/dist/cli/dry-run.js.map +1 -1
- package/dist/cli/explain.d.ts +1 -1
- package/dist/cli/explain.js +1 -1
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/index.js +62 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/composer.js +36 -13
- package/dist/cli/init/composer.js.map +1 -1
- package/dist/cli/init/interactive.d.ts +7 -4
- package/dist/cli/init/interactive.js +79 -27
- package/dist/cli/init/interactive.js.map +1 -1
- package/dist/cli/init/profiles.d.ts +2 -2
- package/dist/cli/init/profiles.js +32 -1
- package/dist/cli/init/profiles.js.map +1 -1
- package/dist/cli/init/templates.d.ts +2 -1
- package/dist/cli/init/templates.js +136 -24
- package/dist/cli/init/templates.js.map +1 -1
- package/dist/cli/pack/approve-escape.js +69 -8
- package/dist/cli/pack/approve-escape.js.map +1 -1
- package/dist/cli/pack/hook-branch-protection.js +1 -1
- package/dist/cli/pack/hook-branch-protection.js.map +1 -1
- package/dist/cli/pack/hook-codex-pre-tool-use.js +27 -1
- package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-post-merge-gate.js +44 -26
- package/dist/cli/pack/hook-post-merge-gate.js.map +1 -1
- package/dist/cli/pack/hook-pre-tool-use.js +91 -4
- package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-solution-acceptance.js +19 -2
- package/dist/cli/pack/hook-solution-acceptance.js.map +1 -1
- package/dist/cli/pack/understanding-report-schema-hint.d.ts +13 -0
- package/dist/cli/pack/understanding-report-schema-hint.js +52 -3
- package/dist/cli/pack/understanding-report-schema-hint.js.map +1 -1
- package/dist/cli/pause/index.js +1 -1
- package/dist/cli/pause/index.js.map +1 -1
- package/dist/cli/policy/intercept.d.ts +148 -0
- package/dist/cli/policy/intercept.js +538 -79
- package/dist/cli/policy/intercept.js.map +1 -1
- package/dist/cli/session-start/index.d.ts +12 -3
- package/dist/cli/session-start/index.js +67 -11
- package/dist/cli/session-start/index.js.map +1 -1
- package/dist/cli/session-start/stale-base-check.d.ts +71 -0
- package/dist/cli/session-start/stale-base-check.js +379 -0
- package/dist/cli/session-start/stale-base-check.js.map +1 -0
- package/dist/cli/session-start/toolchain-parity.d.ts +142 -8
- package/dist/cli/session-start/toolchain-parity.js +244 -36
- package/dist/cli/session-start/toolchain-parity.js.map +1 -1
- package/dist/cli/smoke/assertions.d.ts +9 -2
- package/dist/cli/smoke/assertions.js +9 -2
- package/dist/cli/smoke/assertions.js.map +1 -1
- package/dist/cli/uninstall/index.js +18 -2
- package/dist/cli/uninstall/index.js.map +1 -1
- package/dist/cli/validate/checks.d.ts +3 -1
- package/dist/cli/validate/checks.js +298 -3
- package/dist/cli/validate/checks.js.map +1 -1
- package/dist/io/claude-mcp.d.ts +122 -1
- package/dist/io/claude-mcp.js +214 -12
- package/dist/io/claude-mcp.js.map +1 -1
- package/dist/io/duration.js.map +1 -0
- package/dist/io/expand-home.js.map +1 -0
- package/dist/io/extract.js.map +1 -0
- package/dist/io/harness-lock.js +1 -1
- package/dist/io/harness-lock.js.map +1 -1
- package/dist/{runtime → io}/ledger-record.d.ts +1 -1
- package/dist/io/ledger-record.js.map +1 -0
- package/dist/policies/index.d.ts +2 -2
- package/dist/policies/index.js +2 -2
- package/dist/policies/index.js.map +1 -1
- package/dist/policies/ledger-client.js +10 -6
- package/dist/policies/ledger-client.js.map +1 -1
- package/dist/policies/producers.js +1 -1
- package/dist/policies/producers.js.map +1 -1
- package/dist/policies/requires.js +2 -2
- package/dist/policies/requires.js.map +1 -1
- package/dist/policy-packs/builtin/branch-protection.js +28 -3
- package/dist/policy-packs/builtin/branch-protection.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 +84 -31
- package/dist/policy-packs/builtin/post-merge-gate.js.map +1 -1
- package/dist/policy-packs/builtin/solution-acceptance-runtime.d.ts +152 -8
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js +260 -13
- package/dist/policy-packs/builtin/solution-acceptance-runtime.js.map +1 -1
- package/dist/policy-packs/builtin/solution-acceptance.js +17 -3
- package/dist/policy-packs/builtin/solution-acceptance.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/active-claim.d.ts +25 -0
- package/dist/policy-packs/builtin/understanding-before-execution/active-claim.js +89 -0
- package/dist/policy-packs/builtin/understanding-before-execution/active-claim.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +13 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.js +39 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/ledger.d.ts +25 -0
- package/dist/policy-packs/builtin/understanding-before-execution/ledger.js +56 -0
- package/dist/policy-packs/builtin/understanding-before-execution/ledger.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/lifecycle.d.ts +20 -0
- package/dist/policy-packs/builtin/understanding-before-execution/lifecycle.js +79 -0
- package/dist/policy-packs/builtin/understanding-before-execution/lifecycle.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/markers.d.ts +103 -0
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js +203 -0
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +177 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +309 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.d.ts +106 -0
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js +209 -0
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.d.ts +78 -0
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js +185 -0
- package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution-runtime.d.ts +1 -536
- package/dist/policy-packs/builtin/understanding-before-execution-runtime.js +9 -1095
- package/dist/policy-packs/builtin/understanding-before-execution-runtime.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution.d.ts +109 -1
- package/dist/policy-packs/builtin/understanding-before-execution.js +183 -15
- package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
- package/dist/policy-packs/registry.d.ts +11 -0
- package/dist/policy-packs/registry.js +1 -1
- package/dist/policy-packs/registry.js.map +1 -1
- package/dist/policy-packs/runtime.d.ts +1 -1
- package/dist/policy-packs/runtime.js +10 -1
- package/dist/policy-packs/runtime.js.map +1 -1
- package/dist/runtime/agent-facing.js +1 -1
- package/dist/runtime/agent-facing.js.map +1 -1
- package/dist/runtime/bash-match-facts.d.ts +9 -7
- package/dist/runtime/bash-match-facts.js +9 -7
- package/dist/runtime/bash-match-facts.js.map +1 -1
- package/dist/runtime/bash-match-registry.d.ts +75 -38
- package/dist/runtime/bash-match-registry.js +279 -232
- package/dist/runtime/bash-match-registry.js.map +1 -1
- package/dist/runtime/bash-prefix-parse.d.ts +7 -0
- package/dist/runtime/bash-prefix-parse.js +205 -17
- package/dist/runtime/bash-prefix-parse.js.map +1 -1
- package/dist/runtime/command-normalize.d.ts +429 -4
- package/dist/runtime/command-normalize.js +1146 -67
- package/dist/runtime/command-normalize.js.map +1 -1
- package/dist/runtime/hermetic-spawn-guard.js +6 -0
- package/dist/runtime/hermetic-spawn-guard.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/intercept.d.ts +247 -4
- package/dist/runtime/intercept.js +553 -61
- package/dist/runtime/intercept.js.map +1 -1
- package/dist/runtime/ledger-add.js +1 -1
- package/dist/runtime/ledger-add.js.map +1 -1
- package/dist/runtime/read-only-bash.js +356 -26
- 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/dist/schema/doctor.d.ts +25 -0
- package/dist/schema/doctor.js +23 -0
- package/dist/schema/doctor.js.map +1 -0
- package/dist/schema/extract.js +1 -1
- package/dist/schema/extract.js.map +1 -1
- package/dist/schema/index.d.ts +76 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/requires.js +2 -2
- package/dist/schema/requires.js.map +1 -1
- package/dist/schema/risk.d.ts +7 -0
- package/dist/schema/risk.js +23 -0
- package/dist/schema/risk.js.map +1 -1
- package/dist/schema/stale-base-check.d.ts +18 -0
- package/dist/schema/stale-base-check.js +37 -0
- package/dist/schema/stale-base-check.js.map +1 -0
- package/dist/schema/toolchain-parity.d.ts +3 -0
- package/dist/schema/toolchain-parity.js +13 -0
- package/dist/schema/toolchain-parity.js.map +1 -1
- package/package.json +5 -2
- package/dist/policies/duration.js.map +0 -1
- package/dist/policies/extract.js.map +0 -1
- package/dist/runtime/expand-home.js.map +0 -1
- package/dist/runtime/ledger-record.js.map +0 -1
- /package/dist/{policies → io}/duration.d.ts +0 -0
- /package/dist/{policies → io}/duration.js +0 -0
- /package/dist/{runtime → io}/expand-home.d.ts +0 -0
- /package/dist/{runtime → io}/expand-home.js +0 -0
- /package/dist/{policies → io}/extract.d.ts +0 -0
- /package/dist/{policies → io}/extract.js +0 -0
- /package/dist/{runtime → io}/ledger-record.js +0 -0
|
@@ -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,200 @@ 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;
|
|
406
|
+
/**
|
|
407
|
+
* Return type of `normalizeCommandQuoteAware` — same shape and same
|
|
408
|
+
* reasoning as `AmpAwareNormalizedCommand` above: no `targetDir`/
|
|
409
|
+
* `targetBase`, so no consumer can read one extracted under quote-aware
|
|
410
|
+
* segmentation by mistake. Unlike the amp-aware pass, THIS alphabet is
|
|
411
|
+
* exactly `BOUNDARY_RE`'s own (no new boundary characters, only new
|
|
412
|
+
* quote-tracking around the existing ones), so the reason for omitting
|
|
413
|
+
* these fields is different: `computeSegmentTarget` / `classifyCdSegment`
|
|
414
|
+
* / `canonicalizeSegment` all assume `tokenizeWithOffsets`'s whitespace
|
|
415
|
+
* tokenisation lines up with the segment boundaries `findNextBoundary`
|
|
416
|
+
* produces, which is still true for the boundary ALPHABET itself but is
|
|
417
|
+
* now also entangled with `consumeAssignment`'s OWN, separate quote
|
|
418
|
+
* tracking (per-token, inside one segment) once segments can be wider and
|
|
419
|
+
* carry an unbalanced quote at their edges in new ways this task's own
|
|
420
|
+
* corpus does not exhaustively characterise for `targetDir` purposes —
|
|
421
|
+
* left unexplored rather than guessed at, mirroring the amp-aware pass's
|
|
422
|
+
* own "not this task's job" scoping.
|
|
423
|
+
*/
|
|
424
|
+
export interface QuoteAwareNormalizedCommand {
|
|
425
|
+
/** Same contract as `NormalizedCommand.normalized`, under quote-aware segmentation. */
|
|
426
|
+
normalized: string;
|
|
427
|
+
/** Same contract as `NormalizedCommand.truncated`. */
|
|
428
|
+
truncated: boolean;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Quote-aware THIRD normalisation pass (task cf3dff51). Segments the
|
|
432
|
+
* command under `BOUNDARY_RE`'s own alphabet — same characters as the
|
|
433
|
+
* primary pass, no widening — but tracks single/double-quote state while
|
|
434
|
+
* scanning (`findNextBoundaryQuoteAware` below) so a boundary character
|
|
435
|
+
* sitting INSIDE a quoted assignment value is no longer treated as a real
|
|
436
|
+
* segment split. Closes the gap the module header's "DELIBERATELY NOT
|
|
437
|
+
* SUPPORTED" list and `BOUNDARY_RE`'s own comment both name: `VAR='a; b'
|
|
438
|
+
* git push` (task 13e55484's pinned residual) — `BOUNDARY_RE` used to cut
|
|
439
|
+
* the segment at the `;`, landing squarely between the two halves of one
|
|
440
|
+
* quoted value, so neither resulting piece carried a recognisable
|
|
441
|
+
* invocation and `consumeAssignment`'s own multi-token quote continuation
|
|
442
|
+
* (built for exactly this shape) never got the chance to run: it operates
|
|
443
|
+
* AFTER segmentation, on tokens WITHIN one segment, and the quoted value
|
|
444
|
+
* was never in one segment to begin with. Once quote-aware segmentation
|
|
445
|
+
* keeps the value whole, `consumeAssignment` needs no changes at all — it
|
|
446
|
+
* already reconstructs a multi-token quoted value correctly; this pass
|
|
447
|
+
* only fixes what gets handed to it as ONE segment in the first place.
|
|
448
|
+
*
|
|
449
|
+
* BUILT AS A NEW, INDEPENDENT PASS RATHER THAN AN IN-PLACE EDIT OF
|
|
450
|
+
* `BOUNDARY_RE` / `segmentAndCanonicalize` — this is the module header's
|
|
451
|
+
* HALT CRITERION, restated here at the point it governs: quote-aware
|
|
452
|
+
* segmentation can MERGE a segment the primary pass currently splits, and
|
|
453
|
+
* that merge cuts in BOTH directions — it can turn a previously-missed
|
|
454
|
+
* bypass into a match (the fix), but it can just as easily turn a
|
|
455
|
+
* previously-accepted, ALREADY-WIRED over-block into a miss (a
|
|
456
|
+
* regression). Measured, not hypothetical: `tests/runtime/command-
|
|
457
|
+
* normalize.test.ts`'s "accepted over-block: a quoted assignment inside
|
|
458
|
+
* TEXT after a boundary char now matches" pin — `echo "a; VAR='x y' git
|
|
459
|
+
* push"` — matches via `normalizeCommand` TODAY only because `BOUNDARY_RE`
|
|
460
|
+
* splits it at the `;`, landing `VAR='x y' git push` at a segment start
|
|
461
|
+
* where the assignment continuation turns it into a match. An in-place
|
|
462
|
+
* quote-aware edit of THAT pass would un-split it back into the outer
|
|
463
|
+
* `echo "..."` segment — not itself a recognised invocation — and flip
|
|
464
|
+
* that pin to a lost match, in violation of the raw-OR-normalised-OR-amp-
|
|
465
|
+
* aware-OR-(this) never-lose-a-match discipline every other pass in this
|
|
466
|
+
* module already honours. Building this as a SEPARATE pass instead means
|
|
467
|
+
* `normalizeCommand`'s own segmentation, and every test resting on it —
|
|
468
|
+
* including that exact one — is untouched by this task; see this file's
|
|
469
|
+
* own test suite for the differential proof (every case the first three
|
|
470
|
+
* arms already matched still matches, by construction, because none of
|
|
471
|
+
* those three arms' code changed at all).
|
|
472
|
+
*
|
|
473
|
+
* WIRED to `policyMatchesEvent` (`src/runtime/intercept.ts`) as its
|
|
474
|
+
* FOURTH arm — same shape as `normalizeCommandAmpAware`'s own third-arm
|
|
475
|
+
* wiring (task aabbad63): consulted only after the raw command,
|
|
476
|
+
* `normalizedCommand`, and the amp-aware pass have all missed, via a
|
|
477
|
+
* memoised thunk (`InterceptOptions.quoteNormalizedCommandThunk`,
|
|
478
|
+
* `src/cli/policy/intercept.ts`'s `quoteNormalizedCommandThunk`) so the
|
|
479
|
+
* segmentation cost is paid at most once per event, on the common
|
|
480
|
+
* (already-matched) path it costs nothing at all. Wiring landed in a
|
|
481
|
+
* SECOND round of this task, after the orchestrator extended the first
|
|
482
|
+
* round's file scope specifically for this one wiring point — the first
|
|
483
|
+
* round shipped this function fully built and tested but genuinely
|
|
484
|
+
* unwired (an inert security fix, called out explicitly as the wrong
|
|
485
|
+
* shipped state in that round's own report) — `src/cli/dry-run.ts`'s own,
|
|
486
|
+
* independently-copied matcher was deliberately NOT extended in the same
|
|
487
|
+
* round (out of the extended scope too) and stayed a named residual until
|
|
488
|
+
* task f561e44c closed it by adding the same fourth OR-arm there too — see
|
|
489
|
+
* that file's own comment.
|
|
490
|
+
*
|
|
491
|
+
* THIS PASS'S OWN OVER-BLOCK SURFACE is measured and named in the test
|
|
492
|
+
* file rather than assumed — and the measurement CORRECTS an earlier,
|
|
493
|
+
* pre-measurement guess that used to sit in this comment: it does NOT
|
|
494
|
+
* reproduce the `echo "a; VAR='x y' git push"` accepted over-block named
|
|
495
|
+
* above. Quote-aware merging keeps that whole `echo "..."` segment
|
|
496
|
+
* together, starting with the unrecognised head token `echo`, so this
|
|
497
|
+
* function's output for it is byte-identical to the raw input
|
|
498
|
+
* (`normalizeCommand`'s OWN, separate, unchanged-by-this-task match for
|
|
499
|
+
* that same string is unaffected either way). Measured against a broader
|
|
500
|
+
* adversarial probe, both at this function's own level and again at
|
|
501
|
+
* `policyMatchesEvent`'s wired level (a bash-shim-verified corpus of
|
|
502
|
+
* chained/prefixed/subshell-wrapped genuine invocations plus candidate
|
|
503
|
+
* over-block shapes — entirely quoted `echo`/`printf` arguments that only
|
|
504
|
+
* PRINT the spelling): every additional match this pass adds beyond raw /
|
|
505
|
+
* `normalizeCommand` / `normalizeCommandAmpAware` is a TRUE positive (a
|
|
506
|
+
* real invocation bash would actually execute); no NEW over-block class
|
|
507
|
+
* distinct from `consumeAssignment`'s own, already-reviewed precision
|
|
508
|
+
* limits was found. This function shares `canonicalizeSegment` /
|
|
509
|
+
* `consumeAssignment` completely unchanged with the other passes — only
|
|
510
|
+
* the segmentation boundary decision differs — which is also the
|
|
511
|
+
* structural reason a longer (merged) segment can only REVEAL a match
|
|
512
|
+
* those functions would already accept from a shorter view, never
|
|
513
|
+
* fabricate a new kind of one; see the module header's cf3dff51 UPDATE
|
|
514
|
+
* paragraph for the fuller statement of this reasoning and its
|
|
515
|
+
* "not a formal proof" caveat.
|
|
516
|
+
*/
|
|
517
|
+
export declare function normalizeCommandQuoteAware(command: string): QuoteAwareNormalizedCommand;
|