@lannguyensi/harness 0.59.2 → 0.60.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/dist/cli/apply/apply.d.ts +20 -0
  4. package/dist/cli/apply/apply.js +13 -7
  5. package/dist/cli/apply/apply.js.map +1 -1
  6. package/dist/cli/apply/install-codex-config.d.ts +11 -3
  7. package/dist/cli/apply/install-codex-config.js +130 -52
  8. package/dist/cli/apply/install-codex-config.js.map +1 -1
  9. package/dist/cli/approve/understanding.js +34 -28
  10. package/dist/cli/approve/understanding.js.map +1 -1
  11. package/dist/cli/doctor/format.js +22 -0
  12. package/dist/cli/doctor/format.js.map +1 -1
  13. package/dist/cli/doctor/index.js +60 -31
  14. package/dist/cli/doctor/index.js.map +1 -1
  15. package/dist/cli/doctor/types.d.ts +17 -0
  16. package/dist/cli/dry-run.js +7 -0
  17. package/dist/cli/dry-run.js.map +1 -1
  18. package/dist/cli/index.js +46 -144
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/cli/pack/auto-approve-path.js +25 -11
  21. package/dist/cli/pack/auto-approve-path.js.map +1 -1
  22. package/dist/cli/pack/hook-codex-post-tool-use.js +2 -2
  23. package/dist/cli/pack/hook-codex-post-tool-use.js.map +1 -1
  24. package/dist/cli/pack/hook-codex-pre-tool-use.js +32 -5
  25. package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
  26. package/dist/cli/pack/hook-post-merge-gate-record.d.ts +7 -0
  27. package/dist/cli/pack/hook-post-merge-gate-record.js +39 -2
  28. package/dist/cli/pack/hook-post-merge-gate-record.js.map +1 -1
  29. package/dist/cli/pack/hook-post-tool-use.js +2 -2
  30. package/dist/cli/pack/hook-post-tool-use.js.map +1 -1
  31. package/dist/cli/pack/hook-pre-tool-use.js +60 -15
  32. package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
  33. package/dist/cli/policy/intercept.js +5 -1
  34. package/dist/cli/policy/intercept.js.map +1 -1
  35. package/dist/cli/record/index.d.ts +11 -2
  36. package/dist/cli/record/index.js +18 -5
  37. package/dist/cli/record/index.js.map +1 -1
  38. package/dist/cli/session-start/branch-check.d.ts +3 -29
  39. package/dist/cli/session-start/branch-check.js +7 -37
  40. package/dist/cli/session-start/branch-check.js.map +1 -1
  41. package/dist/cli/session-start/index.d.ts +16 -30
  42. package/dist/cli/session-start/index.js +72 -26
  43. package/dist/cli/session-start/index.js.map +1 -1
  44. package/dist/cli/session-start/shared-options.d.ts +92 -0
  45. package/dist/cli/session-start/shared-options.js +109 -0
  46. package/dist/cli/session-start/shared-options.js.map +1 -0
  47. package/dist/cli/session-start/stale-base-check.d.ts +3 -28
  48. package/dist/cli/session-start/stale-base-check.js +7 -37
  49. package/dist/cli/session-start/stale-base-check.js.map +1 -1
  50. package/dist/cli/session-start/toolchain-parity.d.ts +5 -21
  51. package/dist/cli/session-start/toolchain-parity.js +6 -38
  52. package/dist/cli/session-start/toolchain-parity.js.map +1 -1
  53. package/dist/cli/smoke/index.d.ts +1 -1
  54. package/dist/cli/smoke/index.js +8 -11
  55. package/dist/cli/smoke/index.js.map +1 -1
  56. package/dist/policy-packs/builtin/post-merge-gate-runtime.d.ts +11 -0
  57. package/dist/policy-packs/builtin/post-merge-gate-runtime.js +11 -0
  58. package/dist/policy-packs/builtin/post-merge-gate-runtime.js.map +1 -1
  59. package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.d.ts +36 -0
  60. package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.js +73 -0
  61. package/dist/policy-packs/builtin/understanding-before-execution/expiry-reason.js.map +1 -0
  62. package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +3 -2
  63. package/dist/policy-packs/builtin/understanding-before-execution/index.js +5 -2
  64. package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
  65. package/dist/policy-packs/builtin/understanding-before-execution/markers.js +1 -0
  66. package/dist/policy-packs/builtin/understanding-before-execution/markers.js.map +1 -1
  67. package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +205 -1
  68. package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +360 -3
  69. package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +1 -1
  70. package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.d.ts +1 -1
  71. package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js +2 -2
  72. package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js.map +1 -1
  73. package/dist/policy-packs/builtin/understanding-before-execution/task-markers.d.ts +36 -0
  74. package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js +50 -0
  75. package/dist/policy-packs/builtin/understanding-before-execution/task-markers.js.map +1 -1
  76. package/dist/runtime/bash-prefix-parse.js +319 -126
  77. package/dist/runtime/bash-prefix-parse.js.map +1 -1
  78. package/dist/runtime/intercept.d.ts +38 -0
  79. package/dist/runtime/intercept.js +224 -5
  80. package/dist/runtime/intercept.js.map +1 -1
  81. package/dist/runtime/read-only-bash.js +11 -1
  82. package/dist/runtime/read-only-bash.js.map +1 -1
  83. package/dist/runtime/shell-word.d.ts +16 -1
  84. package/dist/runtime/shell-word.js +82 -1
  85. package/dist/runtime/shell-word.js.map +1 -1
  86. package/package.json +1 -1
@@ -17,11 +17,18 @@
17
17
  // `environments.resolvers[]` runs. Three POSIX forms are supported in v1
18
18
  // (kept narrow on purpose, see follow-up scope in the originating tasks):
19
19
  //
20
- // 1. Inline env: leading `\w+=value` tokens. Values may be unquoted,
21
- // single-quoted (literal), or double-quoted (literal, no $
22
- // interpolation in v1).
23
- // 2. cd prefix: a single leading `cd <path> [&&|;] ...`. Quoted paths
24
- // supported. No `pushd`, no subshell `(cd X && ...)`, no `bash -c`.
20
+ // 1. Inline env: leading `\w+=value` tokens. A value is read as one
21
+ // shell word (see `readWord`): unquoted text, backslash escapes,
22
+ // single-quoted parts (literal) and double-quoted parts (literal, no
23
+ // $ interpolation in v1) glued together up to unescaped whitespace,
24
+ // so `VAR="say \"hi\""` is `say "hi"` and `VAR='it'\''s'` is `it's`
25
+ // (task b093911d). NOT covered, pinned by tests: ANSI-C `$'...'`
26
+ // (kept as the raw text, not decoded), `$VAR` / `$(...)` (kept as
27
+ // literal text), and `;` / `&` inside an UNQUOTED value (they do not
28
+ // end it).
29
+ // 2. cd prefix: a single leading `cd <path> [&&|;] ...`. The path is
30
+ // read as the same kind of shell word, ended at an unquoted `;` or
31
+ // `&`. No `pushd`, no subshell `(cd X && ...)`, no `bash -c`.
25
32
  // 3. git branch switch: a single leading `git [-C <path>]
26
33
  // (switch|checkout) <branch> [&&|;] ...` (task 341e024b). The
27
34
  // `<branch>` must be a plain, literal token, unquoted OR quoted
@@ -34,10 +41,16 @@
34
41
  // `--`, `-b`, ...; this is how `git checkout -- <path>`'s
35
42
  // file-restore form is excluded) or an unquoted `$VAR`/`${VAR}`
36
43
  // shell variable is left unresolved (`branchTarget: null`) rather
37
- // than guessed; a DOUBLE-quoted token whose content contains a `$`
38
- // is treated the same way (not guessed) since double quotes DO
39
- // interpolate in real bash and this parser does not evaluate the
40
- // shell environment — a single-quoted token is always taken
44
+ // than guessed; a token that STARTS with a quote and carries an
45
+ // unescaped `$` in a double-quoted part (`"release/$V"`) is treated
46
+ // the same way (not guessed) since double quotes DO interpolate in
47
+ // real bash and this parser does not evaluate the shell
48
+ // environment. A token that does NOT start with a quote but carries
49
+ // such a `$` mid-word (`release/"$V"`) is read raw, quotes included,
50
+ // exactly as before the escape-aware reader: bash expands it, so the
51
+ // branch is unknown, but the raw word still matches a glob like
52
+ // `release/*` and the clauses behind it (a later `cd`, the kubectl
53
+ // remainder) stay reachable. A single-quoted token is always taken
41
54
  // literally, since single quotes never interpolate. The optional
42
55
  // `-C <path>` is recognized so it does not block the match, but its
43
56
  // value is discarded: the ONLY thing this idiom feeds the resolver
@@ -67,6 +80,67 @@
67
80
  // resolver-side fallback to process env / hook cwd holds. There are no
68
81
  // thrown errors from this module.
69
82
  //
83
+ // ESCAPES VS FALL-THROUGH (task b093911d): for a gate that SEARCHES for
84
+ // production indicators, falling through is not the safe direction, a
85
+ // dropped `cd` target or env value hides the very signal being looked
86
+ // for. So a quoted word is decoded the way bash reads it instead of
87
+ // being abandoned when it contains a backslash. Two places keep the OLD
88
+ // reading on purpose: a word whose quote only an escaped quote could
89
+ // close (`VAR="abc\" cd /x && y`, an unterminated string for bash), where
90
+ // the first matching quote ends the word, and a branch word that does not
91
+ // start with a quote but has a `$` in a double-quoted part (form 3).
92
+ //
93
+ // ACCEPTANCE RULE (task b093911d): a reader that changes word boundaries
94
+ // cannot promise "nothing extracted before is lost", so this change is
95
+ // held to a signal-level rule instead, measured against the pre-change
96
+ // parser: (i) no production signal (env value, branch, cd target,
97
+ // kubectl remainder) that the old parser saw and this one does not, on a
98
+ // named high-risk shape set (plain, quoted and escaped env values and cd
99
+ // paths, literal, quoted and `release/"$V"` branches followed by a cd or
100
+ // kubectl, `__proto__=`, the `'\''` idiom, `\"` in double quotes) and on
101
+ // a replay of real agent commands; (ii) fewer missed signals than the old
102
+ // parser on fixed-seed generated corpora with bash as referee, for env,
103
+ // branch and cd from a non-prod cwd; (iii) every remaining new miss
104
+ // belongs to a named residual class whose plain twin the old parser
105
+ // already misses; (iv) the cd downgrades from a prod cwd are reported with
106
+ // numbers. What was measured against that rule is in the CHANGELOG entry
107
+ // and the pull request; the cd-target arms of
108
+ // `scripts/measure-bash-prefix-parse.mjs` show no lost honest target
109
+ // against master and the shipped release (11 of 17 arms prove nothing).
110
+ // Known residuals, not covered. The old parser already gets the plain
111
+ // twin of each of the first four wrong, so they are follow-up work for
112
+ // the prefix walk; the last two are shapes outside the high-risk set,
113
+ // pinned by tests:
114
+ // - OPERATOR SWALLOWED BY AN ENV WORD: an inline env word that does not
115
+ // start with a quote swallows unquoted `;`, `&`, `|` and `||` (the
116
+ // plain `A=x|| cd /t && y` always has; an escape-led or mid-quote word
117
+ // now does too, kept so `V=\"; W=/tmp cmd` still yields `W` and so a
118
+ // clause bash runs after a short circuit is still reached). So a `cd`
119
+ // or assignment behind the operator is read as a leading one: a
120
+ // phantom `cd` bash never runs (`A=a\ b|| cd /t && y`), or a later
121
+ // backgrounded assignment that overrides the value bash keeps
122
+ // (`D=a"b c"; D=dev&T` reads `dev&T`, plain twin `D=x; D=dev&T`);
123
+ // - PLAIN PATH ACROSS `|`: a plain `cd` path ends at whitespace, `;` or
124
+ // `&` only, so `cd /srv/p|rod; T` reads `/srv/p|rod` where bash runs
125
+ // `cd /srv/p` in a pipeline;
126
+ // - FIRST CD ONLY, AND-LIST BACKGROUNDED: only the first leading `cd` is
127
+ // read (a later `cd` wins in bash), and a `cd` in an and-list that a
128
+ // later `&` backgrounds is read although bash runs it in a subshell;
129
+ // - WORD FOLLOWED BY MORE WORDS: a cd or branch word with no `&&` / `;`
130
+ // right behind it yields no clause, which now also covers an escaped
131
+ // `;` inside the word (`git switch release/1.2\; cd dev && T` passes
132
+ // `release/1.2;`, `cd`, `dev` to git), plain twin
133
+ // `git switch release/1 checkout main && T`;
134
+ // - a `cd` path or branch word that carries a quote or an escape and is
135
+ // ended at an unquoted `|`, `<`, `>`, `(` or `)` (`cd /srv/p|ro"d"`)
136
+ // rejects its clause and stops the prefix walk;
137
+ // - ANSI-C `$'...'` and `$VAR` / `$(...)` are kept as raw text, so a
138
+ // value glued to an unset variable (`D='o'$d`) reads `o$d`.
139
+ // Because this reader now reads more quoted and escaped `cd` paths, the
140
+ // first three classes also produce more cd DOWNGRADES from a prod cwd
141
+ // than the old parser did (a non-prod `cd` that bash does not end in);
142
+ // that trade is measured and accepted in the pull request.
143
+ //
70
144
  // MEASUREMENT RULE (task 47297478): any claim about this parser's
71
145
  // CD-TARGET extraction versus another build (lost or gained `cdTarget`
72
146
  // values) must come from scripts/measure-bash-prefix-parse.mjs, the
@@ -83,9 +157,9 @@
83
157
  */
84
158
  export function parseBashPrefix(command) {
85
159
  if (typeof command !== "string" || command.length === 0) {
86
- return { inlineEnv: {}, cdTarget: null, branchTarget: null, remainderStart: 0 };
160
+ return { inlineEnv: newEnvMap(), cdTarget: null, branchTarget: null, remainderStart: 0 };
87
161
  }
88
- const inlineEnv = {};
162
+ const inlineEnv = newEnvMap();
89
163
  let cdTarget = null;
90
164
  let branchTarget = null;
91
165
  let cursor = 0;
@@ -120,6 +194,173 @@ export function parseBashPrefix(command) {
120
194
  const WS = /\s/;
121
195
  const VAR_START = /[A-Za-z_]/;
122
196
  const VAR_CONT = /[A-Za-z0-9_]/;
197
+ /**
198
+ * The `inlineEnv` map. A null-prototype object, so an assignment to a
199
+ * name that exists on `Object.prototype` is kept instead of lost:
200
+ * `into["__proto__"] = value` on a plain `{}` runs the prototype
201
+ * setter, which ignores a string, so `__proto__=/prod cd /x && ...`
202
+ * used to drop the assignment without a trace. The same shape also
203
+ * means a lookup of a name that was never assigned (`constructor`,
204
+ * `toString`) reads as `undefined` instead of an inherited function.
205
+ * Spreading it into a plain object (what the resolver does) creates
206
+ * own data properties, `__proto__` included.
207
+ */
208
+ function newEnvMap() {
209
+ return Object.create(null);
210
+ }
211
+ /** Unquoted, unescaped characters that end a word (see `readWord` for where the old reading is kept instead). */
212
+ const WORD_STOPS = ";&|<>()";
213
+ /** Extra word terminators of a plain inline env value (none) and of a plain `cd` path / branch token. */
214
+ const ENV_PLAIN_STOPS = "";
215
+ const PATH_PLAIN_STOPS = ";&";
216
+ /**
217
+ * Read one shell word starting at `start`, the way bash does: a run of
218
+ * unquoted text, backslash escapes, single-quoted parts and double-quoted
219
+ * parts, glued together until the first unquoted, unescaped whitespace
220
+ * (task b093911d). `'it'\''s fine'` is therefore ONE word (`it's fine`),
221
+ * and so is `"say \"hi\""`.
222
+ *
223
+ * - Outside quotes `\x` is the literal `x`; a backslash-newline pair
224
+ * vanishes (line continuation); a backslash that ends the string is a
225
+ * literal backslash (bash does the same for `bash -c 'VAR=a\'`).
226
+ * - In single quotes nothing is special, a backslash included.
227
+ * - In double quotes a backslash escapes only `"`, `\`, `$`, `` ` `` and
228
+ * a newline; before any other character it stays a literal backslash.
229
+ * `$VAR` / `$(...)` are NOT evaluated: they stay literal text (v1).
230
+ * - An unquoted `$'...'` (ANSI-C quoting) is NOT decoded: the raw text
231
+ * including its `$'` and `'` is kept, so the value is no worse than
232
+ * before (explicitly not covered).
233
+ *
234
+ * Pre-existing behaviour that is kept to limit what the new reader can
235
+ * lose (bash itself ends a word at every unquoted shell metacharacter;
236
+ * this is not a no-loss guarantee, see the module doc's residuals):
237
+ * - a word with no quote and no backslash in it is read exactly as
238
+ * before (`readWordLegacy`): an inline env value ends at whitespace
239
+ * only, so it swallows an unquoted `;`, `&`, `|`, ...; a `cd` path or
240
+ * branch token (`plainStops` = `;&`) ends at whitespace or `;` / `&`;
241
+ * - an inline env word that carries an escape or a mid-word quote but
242
+ * does not START with a quote (`swallowOps`) keeps swallowing the
243
+ * same operators, because the old reading did and a later assignment
244
+ * behind them (`V=\"& W=/tmp cmd`) was extracted through it. That
245
+ * includes `|` and `||`, so `A=a\ b|| cd /x && y` reads the `cd` like
246
+ * the plain `A=x|| cd /x && y` always has (a known phantom, not
247
+ * covered); ending the word at `||` was tried and lost honest clauses
248
+ * that bash runs after the short circuit;
249
+ * - a word that STARTS with a quote, and every `cd` / branch word, ends
250
+ * at an unquoted, unescaped `;`, `&`, `|`, `<`, `>`, `(` or `)`, so
251
+ * `A='a b'|| cd /x && y` ends the value at `||` and never reads the
252
+ * `cd` behind a short-circuit or a pipe as a leading one (the old
253
+ * reading also stopped right after the closing quote).
254
+ *
255
+ * Returns null when a quote has no closing quote. Never throws.
256
+ */
257
+ function readWord(s, start, plainStops, swallowOps) {
258
+ let end = start;
259
+ while (end < s.length && !WS.test(s[end]) && !plainStops.includes(s[end]))
260
+ end++;
261
+ if (!/['"\\]/.test(s.slice(start, end)))
262
+ return readWordLegacy(s, start, plainStops);
263
+ const swallow = swallowOps && s[start] !== "'" && s[start] !== '"';
264
+ const stops = swallow ? "" : WORD_STOPS;
265
+ let i = start;
266
+ let value = "";
267
+ let interpolates = false;
268
+ while (i < s.length) {
269
+ const c = s[i];
270
+ if (WS.test(c) || stops.includes(c))
271
+ break;
272
+ if (c === "'") {
273
+ const end = s.indexOf("'", i + 1);
274
+ if (end < 0)
275
+ return null;
276
+ value += s.slice(i + 1, end);
277
+ i = end + 1;
278
+ }
279
+ else if (c === '"') {
280
+ i++;
281
+ let closed = false;
282
+ while (i < s.length) {
283
+ const d = s[i];
284
+ if (d === '"') {
285
+ closed = true;
286
+ i++;
287
+ break;
288
+ }
289
+ if (d === "\\" && i + 1 < s.length) {
290
+ const e = s[i + 1];
291
+ if (e === '"' || e === "\\" || e === "$" || e === "`") {
292
+ value += e;
293
+ i += 2;
294
+ continue;
295
+ }
296
+ if (e === "\n") {
297
+ i += 2;
298
+ continue;
299
+ }
300
+ }
301
+ else if (d === "$") {
302
+ interpolates = true;
303
+ }
304
+ value += d;
305
+ i++;
306
+ }
307
+ if (!closed)
308
+ return null;
309
+ }
310
+ else if (c === "\\") {
311
+ if (i + 1 < s.length) {
312
+ if (s[i + 1] !== "\n")
313
+ value += s[i + 1];
314
+ i += 2;
315
+ }
316
+ else {
317
+ value += c;
318
+ i++;
319
+ }
320
+ }
321
+ else if (c === "$" && s[i + 1] === "'") {
322
+ let j = i + 2;
323
+ while (j < s.length && s[j] !== "'")
324
+ j += s[j] === "\\" ? 2 : 1;
325
+ if (j >= s.length)
326
+ return null;
327
+ value += s.slice(i, j + 1);
328
+ i = j + 1;
329
+ }
330
+ else {
331
+ value += c;
332
+ i++;
333
+ }
334
+ }
335
+ return { value, next: i, interpolates };
336
+ }
337
+ /**
338
+ * The reading this module used before it knew about escapes: a word that
339
+ * opens with a quote ends at the FIRST matching quote character, any
340
+ * other word ends at whitespace (and at any character of `plainStops`).
341
+ * Kept as the fall-back for a word `readWord` cannot terminate, so that
342
+ * word still yields what the old reading yielded (`VAR="abc\" cd /x && y`
343
+ * is an unterminated string for bash, but the old reading still yields
344
+ * `VAR` and the `cd`). Null only for a quote with no closing quote at all.
345
+ */
346
+ function readWordLegacy(s, start, plainStops) {
347
+ const first = s[start];
348
+ if (first === "'" || first === '"') {
349
+ const end = s.indexOf(first, start + 1);
350
+ if (end < 0)
351
+ return null;
352
+ const value = s.slice(start + 1, end);
353
+ return { value, next: end + 1, interpolates: first === '"' && value.includes("$") };
354
+ }
355
+ let i = start;
356
+ while (i < s.length && !WS.test(s[i]) && !plainStops.includes(s[i]))
357
+ i++;
358
+ return { value: s.slice(start, i), next: i, interpolates: false };
359
+ }
360
+ /** `readWord`, else `readWordLegacy`; null only when no reading closes the quote. */
361
+ function readWordOrLegacy(s, start, plainStops, swallowOps) {
362
+ return readWord(s, start, plainStops, swallowOps) ?? readWordLegacy(s, start, plainStops);
363
+ }
123
364
  function skipWs(s, i) {
124
365
  while (i < s.length && WS.test(s[i]))
125
366
  i++;
@@ -136,17 +377,16 @@ function skipWs(s, i) {
136
377
  * start of that token, preserving the rest of the command for fallback.
137
378
  *
138
379
  * QUOTE-MODEL DIVERGENCE, recorded so the next change here starts from
139
- * the known state instead of rediscovering it (task 13e55484, review
140
- * round 1): `command-normalize.ts`'s `consumeAssignment` is a SECOND
141
- * quote model for the same leading-`VAR=value` construction, with
142
- * different deliberate coverage — it handles backslash escapes (outside
143
- * single quotes) and chained quote runs (`'a b'"c d"`), which this
144
- * function does not, while this function extracts the VALUE (which the
145
- * normaliser never needs). Neither model handles ANSI-C `$'...'`
146
- * escapes; the normaliser side carries a one-directional guard so that
147
- * divergence can only fall back to its pre-continuation behaviour,
148
- * never swallow a gated head token. This function's own escape gaps are
149
- * task `b093911d`.
380
+ * the known state instead of rediscovering it (task 13e55484; updated
381
+ * by task b093911d): `command-normalize.ts`'s
382
+ * `consumeAssignment` is a SECOND quote model for the same leading
383
+ * `VAR=value` construction. Both now handle backslash escapes (outside
384
+ * single quotes) and chained quote runs (`'a b'"c d"`), but they stay
385
+ * two separate implementations (not unified), and this function
386
+ * extracts the VALUE (which the normaliser never needs). Neither model
387
+ * handles ANSI-C `$'...'` escapes; the normaliser side carries a
388
+ * one-directional guard so that divergence can only fall back to its
389
+ * pre-continuation behaviour, never swallow a gated head token.
150
390
  */
151
391
  function consumeInlineEnv(s, start, into) {
152
392
  let i = skipWs(s, start);
@@ -162,28 +402,13 @@ function consumeInlineEnv(s, start, into) {
162
402
  break;
163
403
  const name = s.slice(nameStart, i);
164
404
  i++;
165
- // Read value: quoted (single/double, literal) or unquoted (to ws).
166
- let value;
167
- if (s[i] === "'") {
168
- const end = s.indexOf("'", i + 1);
169
- if (end < 0)
170
- return lastGood;
171
- value = s.slice(i + 1, end);
172
- i = end + 1;
173
- }
174
- else if (s[i] === '"') {
175
- const end = s.indexOf('"', i + 1);
176
- if (end < 0)
177
- return lastGood;
178
- value = s.slice(i + 1, end);
179
- i = end + 1;
180
- }
181
- else {
182
- const vStart = i;
183
- while (i < s.length && !WS.test(s[i]))
184
- i++;
185
- value = s.slice(vStart, i);
186
- }
405
+ // Read the value as one shell word: unquoted text, backslash escapes
406
+ // and quoted parts glued together up to unescaped whitespace.
407
+ const word = readWordOrLegacy(s, i, ENV_PLAIN_STOPS, true);
408
+ if (word === null)
409
+ return lastGood;
410
+ const value = word.value;
411
+ i = word.next;
187
412
  into[name] = value;
188
413
  i = skipWs(s, i);
189
414
  lastGood = i;
@@ -206,28 +431,12 @@ function consumeLeadingCd(s, start) {
206
431
  if (i + 2 >= s.length || !WS.test(s[i + 2]))
207
432
  return null;
208
433
  i = skipWs(s, i + 2);
209
- // Path: quoted or unquoted.
210
- let path;
211
- if (s[i] === "'") {
212
- const end = s.indexOf("'", i + 1);
213
- if (end < 0)
214
- return null;
215
- path = s.slice(i + 1, end);
216
- i = end + 1;
217
- }
218
- else if (s[i] === '"') {
219
- const end = s.indexOf('"', i + 1);
220
- if (end < 0)
221
- return null;
222
- path = s.slice(i + 1, end);
223
- i = end + 1;
224
- }
225
- else {
226
- const pStart = i;
227
- while (i < s.length && !WS.test(s[i]) && s[i] !== ";" && s[i] !== "&")
228
- i++;
229
- path = s.slice(pStart, i);
230
- }
434
+ // Path: one shell word (quotes, escapes and quote runs as in an env value).
435
+ const word = readWordOrLegacy(s, i, PATH_PLAIN_STOPS, false);
436
+ if (word === null)
437
+ return null;
438
+ const path = word.value;
439
+ i = word.next;
231
440
  if (path.length === 0)
232
441
  return null;
233
442
  i = skipWs(s, i);
@@ -257,26 +466,13 @@ function matchKeyword(s, i, word) {
257
466
  /**
258
467
  * Skip a single path token (quoted or unquoted) starting at `i`.
259
468
  * Returns the cursor just past it, or null on an unterminated quote or
260
- * an empty token. Deliberately a separate copy of `consumeLeadingCd`'s
261
- * path-reading rules rather than a shared helper: this function's only
262
- * caller (`consumeLeadingGitSwitch`'s `-C <path>` skip) discards the
263
- * value, `consumeLeadingCd`'s does not, and factoring them together was
264
- * judged not worth the risk to `consumeLeadingCd`'s existing,
265
- * separately-measured behavior for a value nothing here uses.
469
+ * an empty token. Reads the token with the same `readWordOrLegacy` rules
470
+ * `consumeLeadingCd` uses for its path; this function's only caller
471
+ * (`consumeLeadingGitSwitch`'s `-C <path>` skip) discards the value.
266
472
  */
267
473
  function skipPathToken(s, i) {
268
- if (s[i] === "'") {
269
- const end = s.indexOf("'", i + 1);
270
- return end < 0 ? null : end + 1;
271
- }
272
- if (s[i] === '"') {
273
- const end = s.indexOf('"', i + 1);
274
- return end < 0 ? null : end + 1;
275
- }
276
- const start = i;
277
- while (i < s.length && !WS.test(s[i]) && s[i] !== ";" && s[i] !== "&")
278
- i++;
279
- return i > start ? i : null;
474
+ const word = readWordOrLegacy(s, i, PATH_PLAIN_STOPS, false);
475
+ return word !== null && word.next > i ? word.next : null;
280
476
  }
281
477
  /**
282
478
  * Consume a single leading `git [-C <path>] (switch|checkout) <branch>
@@ -292,26 +488,26 @@ function skipPathToken(s, i) {
292
488
  * - An unquoted `$VAR` / `${VAR}` first argument: a shell variable,
293
489
  * not a literal branch name. Resolving it would require evaluating
294
490
  * the shell environment, which this parser does not do (see module
295
- * doc). A DOUBLE-quoted token whose content contains a `$` is
296
- * excluded the same way (double quotes interpolate in real bash); a
297
- * single-quoted token is never excluded on this basis (single
298
- * quotes never interpolate, so its content is always the literal
299
- * branch name).
491
+ * doc). A token that STARTS with a quote and carries an unescaped `$`
492
+ * in a double-quoted part is excluded the same way (double quotes
493
+ * interpolate in real bash); a single-quoted token is never excluded
494
+ * on this basis (single quotes never interpolate, so its content is
495
+ * always the literal branch name). A token that does not start with a
496
+ * quote but has such a `$` mid-word (`release/"$V"`) is NOT excluded:
497
+ * it is read raw (quotes kept) as before, so a glob like `release/*`
498
+ * and the clauses behind it still resolve.
300
499
  * - A missing trailing `&&` / `;` separator, mirroring
301
500
  * `consumeLeadingCd`'s identical rule: `git switch main` alone, with
302
501
  * nothing following, has no "rest of command" for the branch
303
502
  * candidate to apply to.
304
503
  *
305
- * The branch token itself is read as a single word up to the next
306
- * whitespace/`;`/`&` (unquoted — this covers slashed names like
307
- * `task/foo`, `release/1.2`, since branch names cannot contain
308
- * whitespace), OR, when the token opens with `'` or `"`, as a quoted
309
- * literal with the surrounding quotes stripped (task 341e024b fix round
310
- * 1) — mirroring `consumeLeadingCd`'s / `skipPathToken`'s quoted-token
311
- * handling, since a whitespace-free branch name can still be quoted by
312
- * the operator (`git switch "main"`), and an unstripped quote character
313
- * left inside the extracted token would never match a plain
314
- * `branch_patterns` entry.
504
+ * The branch token is read as ONE shell word, with the same rules as a
505
+ * `cd` path (`readWordOrLegacy`, ended at whitespace / `;` / `&`): an
506
+ * unquoted slashed name like `task/foo` or `release/1.2`, a quoted
507
+ * literal with its quotes stripped (task 341e024b: a quote character
508
+ * left inside the token would never match a plain `branch_patterns`
509
+ * entry), and, since task b093911d, backslash escapes
510
+ * and chained quote runs (`'it'\''s'`, `"ma\"in"`, `feat\ x`).
315
511
  *
316
512
  * The optional leading `-C <path>` is recognized so it does not block
317
513
  * the match, but its value is discarded — see the module doc's form 3
@@ -343,34 +539,31 @@ function consumeLeadingGitSwitch(s, start) {
343
539
  // plain branch name — do not guess (see doc comment above).
344
540
  if (s[i] === "-" || s[i] === "$")
345
541
  return null;
346
- let branch;
347
- if (s[i] === "'" || s[i] === '"') {
348
- // Quoted branch literal (task 341e024b fix round 1): strip the
349
- // surrounding quotes, mirroring `consumeLeadingCd`'s path handling.
350
- // A DOUBLE-quoted token containing `$` is left unresolved (real
351
- // bash interpolates inside double quotes; this parser does not
352
- // evaluate the shell environment) — a SINGLE-quoted token is always
353
- // literal, since single quotes never interpolate.
354
- const quote = s[i];
355
- const end = s.indexOf(quote, i + 1);
356
- if (end < 0)
357
- return null;
358
- const content = s.slice(i + 1, end);
359
- if (quote === '"' && content.includes("$"))
360
- return null;
361
- if (content.length === 0)
362
- return null;
363
- branch = content;
364
- i = end + 1;
365
- }
366
- else {
367
- const branchStart = i;
368
- while (i < s.length && !WS.test(s[i]) && s[i] !== ";" && s[i] !== "&")
369
- i++;
370
- branch = s.slice(branchStart, i);
371
- if (branch.length === 0)
372
- return null;
542
+ // One shell word, quotes and escapes decoded like a `cd` path (task
543
+ // 341e024b for the quote stripping, task b093911d for the escapes). A word with an UNESCAPED `$` inside double quotes is left
544
+ // unresolved (real bash interpolates there; this parser does not
545
+ // evaluate the shell environment); a single-quoted `$` and an escaped
546
+ // `\$` are literal and kept.
547
+ let word = readWordOrLegacy(s, i, PATH_PLAIN_STOPS, false);
548
+ // A word that does NOT start with a quote but carries a `$` in a
549
+ // double-quoted part (`release/"$V"`): bash expands it, so the branch
550
+ // is unknown, but the pre-change reading kept the raw word (quotes
551
+ // included, which still matches a glob such as `release/*`) and went on
552
+ // to the clauses behind it (a later `cd`, the kubectl remainder). Fall
553
+ // back to that reading instead of dropping them. A word that starts
554
+ // with a double quote stays unresolved: the pre-change reading did the
555
+ // same. One that starts with a single quote cannot be saved either: the
556
+ // old reading ends it at the first closing quote, and a `$` part glued
557
+ // behind it means the next character is neither whitespace nor `;` / `&`.
558
+ if (word !== null && word.interpolates && s[i] !== '"') {
559
+ word = readWordLegacy(s, i, PATH_PLAIN_STOPS);
373
560
  }
561
+ if (word === null || word.interpolates)
562
+ return null;
563
+ const branch = word.value;
564
+ if (branch.length === 0)
565
+ return null;
566
+ i = word.next;
374
567
  i = skipWs(s, i);
375
568
  if (s[i] === "&" && s[i + 1] === "&") {
376
569
  return { branch, next: i + 2 };
@@ -1 +1 @@
1
- {"version":3,"file":"bash-prefix-parse.js","sourceRoot":"","sources":["../../src/runtime/bash-prefix-parse.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,sDAAsD;AACtD,EAAE;AACF,kEAAkE;AAClE,uEAAuE;AACvE,kEAAkE;AAClE,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,oDAAoD;AACpD,EAAE;AACF,wEAAwE;AACxE,2DAA2D;AAC3D,yEAAyE;AACzE,0EAA0E;AAC1E,EAAE;AACF,uEAAuE;AACvE,gEAAgE;AAChE,6BAA6B;AAC7B,wEAAwE;AACxE,yEAAyE;AACzE,4DAA4D;AAC5D,mEAAmE;AACnE,qEAAqE;AACrE,qEAAqE;AACrE,yEAAyE;AACzE,uEAAuE;AACvE,mEAAmE;AACnE,wEAAwE;AACxE,wEAAwE;AACxE,+DAA+D;AAC/D,qEAAqE;AACrE,uEAAuE;AACvE,wEAAwE;AACxE,oEAAoE;AACpE,sEAAsE;AACtE,iEAAiE;AACjE,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,iDAAiD;AACjD,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,oBAAoB;AACpB,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,sEAAsE;AACtE,oEAAoE;AACpE,gEAAgE;AAChE,mEAAmE;AACnE,sEAAsE;AACtE,wEAAwE;AACxE,8CAA8C;AAC9C,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,4DAA4D;AAC5D,EAAE;AAC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AAC;IACjC,CAAC;IACD,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"bash-prefix-parse.js","sourceRoot":"","sources":["../../src/runtime/bash-prefix-parse.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,sDAAsD;AACtD,EAAE;AACF,kEAAkE;AAClE,uEAAuE;AACvE,kEAAkE;AAClE,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,oDAAoD;AACpD,EAAE;AACF,wEAAwE;AACxE,2DAA2D;AAC3D,yEAAyE;AACzE,0EAA0E;AAC1E,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,sEAAsE;AACtE,uEAAuE;AACvE,0EAA0E;AAC1E,gBAAgB;AAChB,uEAAuE;AACvE,wEAAwE;AACxE,mEAAmE;AACnE,4DAA4D;AAC5D,mEAAmE;AACnE,qEAAqE;AACrE,qEAAqE;AACrE,yEAAyE;AACzE,uEAAuE;AACvE,mEAAmE;AACnE,wEAAwE;AACxE,wEAAwE;AACxE,+DAA+D;AAC/D,qEAAqE;AACrE,uEAAuE;AACvE,qEAAqE;AACrE,yEAAyE;AACzE,wEAAwE;AACxE,6DAA6D;AAC7D,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,qEAAqE;AACrE,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,iDAAiD;AACjD,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,oBAAoB;AACpB,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,sEAAsE;AACtE,oEAAoE;AACpE,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,IAAI,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAC;IAC3D,iEAAiE;IACjE,sEAAsE;IACtE,mEAAmE;IACnE,wEAAwE;IACxE,uEAAuE;IACvE,oEAAoE;IACpE,uEAAuE;IACvE,wEAAwE;IACxE,uEAAuE;IACvE,0EAA0E;IAC1E,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACvD,IAAI,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IACd,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -56,6 +56,17 @@ export interface PolicyDecision {
56
56
  * match from a fail-closed unclassified command at a glance.
57
57
  */
58
58
  whenUnclassifiedFallback?: boolean;
59
+ /**
60
+ * Set when the policy's `ledger_tag` references `${REPO}` / `${BRANCH}`
61
+ * and the value resolved for this context was empty (cwd outside every
62
+ * git repository, detached HEAD, or an empty override), so the engine
63
+ * decided per enforcement WITHOUT rendering or querying a ledger tag.
64
+ * In-memory only: it is not part of the serialised audit row (the
65
+ * `reason` and the placeholder `ledgerTag` already carry the cause).
66
+ * The agent envelope renders `reason` with precedence over the policy's
67
+ * `ux:` / `producers:` text when this is set.
68
+ */
69
+ emptyIdentifier?: EmptyIdentifier;
59
70
  evaluatedAt: string;
60
71
  }
61
72
  /**
@@ -393,6 +404,33 @@ export declare function isBlockingDecision(d: PolicyDecision): boolean;
393
404
  * one-line stderr surface.
394
405
  */
395
406
  export declare function sanitizeEnvelopeReason(reason: string): string;
407
+ /** Which per-repo builtin resolved to an empty value; see {@link emptyIdentifierGuard}. */
408
+ export type EmptyIdentifier = "REPO" | "BRANCH";
409
+ export interface EmptyIdentifierGuard {
410
+ identifier: EmptyIdentifier;
411
+ /** Agent-facing text naming a state the agent can establish itself. */
412
+ message: string;
413
+ }
414
+ /**
415
+ * Does `ledgerTagTemplate` reference `${REPO}` / `${BRANCH}` while the
416
+ * value resolved for this context is empty? An empty identifier must
417
+ * never be rendered into a ledger tag: `preflight:` is a substring of
418
+ * EVERY preflight fact, so a blank tag lets any unrelated fact satisfy
419
+ * the gate (and `preflight-before-push` would render "You cannot push
420
+ * branch yet."). The caller decides per enforcement with
421
+ * `message` instead of querying the ledger.
422
+ *
423
+ * `REPO` wins over `BRANCH`, and a branch-only template evaluated where
424
+ * REPO is empty too (no repository at all) gets the no-repository text,
425
+ * since "HEAD is detached" would be false there. The messages name a
426
+ * state the agent can establish (`cd` / `git -C` / `git switch`), never
427
+ * a tag to produce, so there is no producer trap, and never an opt-out
428
+ * (a block that names its own disable path is not a gate).
429
+ *
430
+ * Exported so `harness dry-run` shows the same hint instead of a blank
431
+ * tag (`src/cli/dry-run.ts`).
432
+ */
433
+ export declare function emptyIdentifierGuard(ledgerTagTemplate: string, values: Record<string, string>): EmptyIdentifierGuard | null;
396
434
  /**
397
435
  * Which of a policy's own trigger-satisfying segments name a target — the
398
436
  * attribution sibling of `policyMatchesEvent` (task `98ad072f`, T-003).