@deftai/directive-core 0.108.0 → 0.109.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 (138) hide show
  1. package/dist/cache/operations.js +1 -1
  2. package/dist/check/gate-lists.d.ts +14 -0
  3. package/dist/check/gate-lists.js +26 -3
  4. package/dist/check/session-completed-ac.d.ts +1 -1
  5. package/dist/check/session-completed-ac.js +1 -1
  6. package/dist/consumer-check-contract/evaluate.d.ts +47 -0
  7. package/dist/consumer-check-contract/evaluate.js +181 -15
  8. package/dist/delivery-attempt/evaluate.d.ts +9 -1
  9. package/dist/delivery-attempt/evaluate.js +69 -0
  10. package/dist/delivery-attempt/index.d.ts +1 -1
  11. package/dist/delivery-attempt/index.js +1 -1
  12. package/dist/deposit/live-procedure-exclusions.d.ts +18 -0
  13. package/dist/deposit/live-procedure-exclusions.js +110 -0
  14. package/dist/deposit/live-procedure-targets.d.ts +45 -0
  15. package/dist/deposit/live-procedure-targets.js +274 -0
  16. package/dist/deposit/python-free.d.ts +6 -0
  17. package/dist/deposit/python-free.js +15 -0
  18. package/dist/deposit/rewrite-deposit-links.d.ts +42 -0
  19. package/dist/deposit/rewrite-deposit-links.js +148 -0
  20. package/dist/deposit/run-stage-content-pack.d.ts +2 -0
  21. package/dist/deposit/run-stage-content-pack.js +3 -0
  22. package/dist/deposit/stage-content-pack.d.ts +17 -0
  23. package/dist/deposit/stage-content-pack.js +91 -0
  24. package/dist/design-critique/citation-grammar.d.ts +7 -0
  25. package/dist/design-critique/citation-grammar.js +1 -1
  26. package/dist/design-critique/completed-arc-record.d.ts +1 -1
  27. package/dist/design-critique/completed-arc-record.js +59 -14
  28. package/dist/hooks/classify/host-session-identity.d.ts +24 -11
  29. package/dist/hooks/classify/host-session-identity.js +46 -49
  30. package/dist/hooks/classify/index.d.ts +2 -2
  31. package/dist/hooks/classify/index.js +2 -2
  32. package/dist/hooks/classify/paths.d.ts +2 -0
  33. package/dist/hooks/classify/paths.js +8 -4
  34. package/dist/hooks/classify/stdin.js +69 -3
  35. package/dist/hooks/dest-form.d.ts +20 -1
  36. package/dist/hooks/dest-form.js +158 -21
  37. package/dist/hooks/dispatcher.d.ts +6 -2
  38. package/dist/hooks/dispatcher.js +258 -62
  39. package/dist/hooks/fixtures/cases.d.ts +6 -0
  40. package/dist/hooks/fixtures/cases.js +53 -0
  41. package/dist/hooks/git-destructive-log.d.ts +32 -0
  42. package/dist/hooks/git-destructive-log.js +46 -0
  43. package/dist/hooks/index.d.ts +2 -0
  44. package/dist/hooks/index.js +2 -0
  45. package/dist/hooks/shell-write-targets.d.ts +10 -0
  46. package/dist/hooks/shell-write-targets.js +274 -0
  47. package/dist/hooks/tools.d.ts +20 -2
  48. package/dist/hooks/tools.js +30 -1
  49. package/dist/init-deposit/gitignore.d.ts +7 -0
  50. package/dist/init-deposit/gitignore.js +24 -0
  51. package/dist/init-deposit/init-deposit.js +3 -0
  52. package/dist/init-deposit/refresh.js +7 -0
  53. package/dist/init-deposit/runtime-writers.d.ts +14 -0
  54. package/dist/init-deposit/runtime-writers.js +33 -0
  55. package/dist/intake/issue-ingest.d.ts +6 -1
  56. package/dist/intake/issue-ingest.js +21 -2
  57. package/dist/intake/reconcile-issues.js +13 -13
  58. package/dist/lifecycle/brief-envelope.d.ts +25 -0
  59. package/dist/lifecycle/brief-envelope.js +42 -0
  60. package/dist/lifecycle/index.d.ts +1 -0
  61. package/dist/lifecycle/index.js +1 -0
  62. package/dist/literal-acceptance/evaluate.js +14 -5
  63. package/dist/literal-acceptance/index.d.ts +1 -1
  64. package/dist/literal-acceptance/index.js +1 -1
  65. package/dist/literal-acceptance/run.d.ts +2 -0
  66. package/dist/literal-acceptance/run.js +19 -1
  67. package/dist/orphan-active/candidate-scope.d.ts +53 -0
  68. package/dist/orphan-active/candidate-scope.js +157 -0
  69. package/dist/orphan-active/evaluate.d.ts +27 -0
  70. package/dist/orphan-active/evaluate.js +63 -6
  71. package/dist/orphan-active/index.d.ts +1 -0
  72. package/dist/orphan-active/index.js +1 -0
  73. package/dist/policy/merge-approval-head.js +7 -6
  74. package/dist/pr-closing-keywords/gh.js +32 -9
  75. package/dist/pr-closing-keywords/main.d.ts +1 -0
  76. package/dist/pr-closing-keywords/main.js +68 -3
  77. package/dist/pr-closing-keywords/types.d.ts +2 -0
  78. package/dist/pr-merge-readiness/gh.js +32 -9
  79. package/dist/pr-protected-issues/gh.js +36 -9
  80. package/dist/pr-wait-mergeable/wrappers.js +3 -3
  81. package/dist/product-first-done-gate/evaluate.js +6 -2
  82. package/dist/product-first-done-gate/types.js +2 -0
  83. package/dist/release/consumer-hard-stops.d.ts +48 -0
  84. package/dist/release/consumer-hard-stops.js +140 -0
  85. package/dist/release/consumer-readiness-disclosure.d.ts +18 -0
  86. package/dist/release/consumer-readiness-disclosure.js +51 -0
  87. package/dist/release/index.d.ts +2 -0
  88. package/dist/release/index.js +2 -0
  89. package/dist/release/pipeline.js +55 -0
  90. package/dist/release/run-consumer-readiness.d.ts +15 -0
  91. package/dist/release/run-consumer-readiness.js +24 -0
  92. package/dist/release/types.d.ts +6 -0
  93. package/dist/review-monitor/github-lease.js +4 -3
  94. package/dist/run-summary/types.d.ts +2 -2
  95. package/dist/scm/build-command.d.ts +2 -2
  96. package/dist/scm/build-command.js +2 -2
  97. package/dist/scm/call-shape.d.ts +25 -0
  98. package/dist/scm/call-shape.js +59 -0
  99. package/dist/scm/call.d.ts +7 -4
  100. package/dist/scm/call.js +41 -11
  101. package/dist/scm/gh-rest.d.ts +25 -12
  102. package/dist/scm/gh-rest.js +65 -15
  103. package/dist/scm/index.d.ts +2 -0
  104. package/dist/scm/index.js +2 -0
  105. package/dist/scm/spawn-status.d.ts +33 -0
  106. package/dist/scm/spawn-status.js +53 -0
  107. package/dist/scope/acceptance-evidence.d.ts +1 -1
  108. package/dist/scope/transition.js +4 -14
  109. package/dist/session/ac-pass-banking.d.ts +2 -2
  110. package/dist/session/ac-pass-banking.js +2 -2
  111. package/dist/session/host-session-owner.d.ts +53 -0
  112. package/dist/session/host-session-owner.js +89 -0
  113. package/dist/session/index.d.ts +1 -0
  114. package/dist/session/index.js +1 -0
  115. package/dist/session/occupancy.d.ts +21 -1
  116. package/dist/session/occupancy.js +70 -12
  117. package/dist/session/verify-ac-session-cache.d.ts +2 -2
  118. package/dist/session/verify-ac-session-cache.js +2 -2
  119. package/dist/triage/evaluate/worktrees.js +153 -6
  120. package/dist/umbrella-current-shape/index.d.ts +51 -3
  121. package/dist/umbrella-current-shape/index.js +106 -18
  122. package/dist/validate-content/deposit-required.d.ts +39 -0
  123. package/dist/validate-content/deposit-required.js +147 -0
  124. package/dist/validate-content/index.d.ts +1 -0
  125. package/dist/validate-content/index.js +1 -0
  126. package/dist/validate-content/validate-links.d.ts +2 -3
  127. package/dist/validate-content/validate-links.js +29 -2
  128. package/dist/vbrief-activate/activate.d.ts +7 -2
  129. package/dist/vbrief-activate/activate.js +26 -13
  130. package/dist/verify-ac/evaluate.d.ts +9 -0
  131. package/dist/verify-ac/evaluate.js +32 -9
  132. package/dist/verify-source/deposit-closure.d.ts +23 -0
  133. package/dist/verify-source/deposit-closure.js +162 -0
  134. package/dist/verify-source/index.d.ts +2 -0
  135. package/dist/verify-source/index.js +2 -0
  136. package/dist/verify-source/semantic-single-source.d.ts +36 -0
  137. package/dist/verify-source/semantic-single-source.js +349 -0
  138. package/package.json +3 -3
@@ -12,7 +12,10 @@
12
12
  * *forms* instead, and see `content/contracts/path-write-fence.md`.
13
13
  *
14
14
  * Residual known-open (recognition, not resolution): `python -c`,
15
- * `cmd /c copy`, obfuscated `bash -c`.
15
+ * `cmd /c copy`, obfuscated `bash -c`. Tree-wide destructive git
16
+ * (`reset --hard`, `clean -f`, `checkout -f`/`switch -f`, `stash drop`/`clear`)
17
+ * is classified separately by {@link classifyGitDestructive} and is always
18
+ * fail-closed at the dispatcher, independent of `shellDestForms`.
16
19
  *
17
20
  * Commit-time active-scope is out of this slice (#3438), and ⊗ do not weaken
18
21
  * Edit to match Shell. Keep this sentence on ONE line: acceptance clause 4 is
@@ -113,13 +116,14 @@ export function classifyProductDestForms(command) {
113
116
  // bypass.
114
117
  //
115
118
  // ⊗ Recognition is NOT total either, and this is not a security boundary.
116
- // Only four verbs are recognized, and a non-literal verb (`\rm`, `rm${IFS}x`)
117
- // defeats the tokenizer, so the fail-closed branch below only fires when the
118
- // verb is still legible. Unrecognized mutators (`git reset --hard`,
119
- // `git clean`, `git checkout` without `--`, `mv`, `sed -i`, `>` redirection)
120
- // and interpreters (`bash -c`, `python -c`) are fail-OPEN. See the threat
121
- // model in content/contracts/path-write-fence.md: this is a guardrail for
122
- // careless agents, not a boundary against adversarial ones.
119
+ // Only four dest-form verbs are recognized, and a non-literal verb (`\rm`,
120
+ // `rm${IFS}x`) defeats the tokenizer, so the fail-closed branch below only
121
+ // fires when the verb is still legible. Tree-wide destructive git is handled
122
+ // by classifyGitDestructive (always-on). Remaining fail-OPEN mutators:
123
+ // `git checkout` without `--` or `-f`, `mv`, `sed -i`, `>` redirection, and
124
+ // interpreters (`bash -c`, `python -c`). See the threat model in
125
+ // content/contracts/path-write-fence.md: this is a guardrail for careless
126
+ // agents, not a boundary against adversarial ones.
123
127
  if (segments.length === 1 && !hasUnsupportedSyntax(cmd)) {
124
128
  return classifySimpleDestForms(segments[0] ?? "");
125
129
  }
@@ -136,6 +140,29 @@ export function classifyProductDestForms(command) {
136
140
  expansion: true,
137
141
  }));
138
142
  }
143
+ /**
144
+ * Tree-wide destructive git — always-on at the dispatcher, not behind
145
+ * `shellDestForms`. Empty when the command is not one of those forms.
146
+ */
147
+ export function classifyGitDestructive(command) {
148
+ const cmd = command.trim();
149
+ if (cmd.length === 0)
150
+ return [];
151
+ const segments = splitCommandSegments(cmd);
152
+ const compound = segments.length > 1 || hasUnsupportedSyntax(cmd);
153
+ const found = [];
154
+ const seen = new Set();
155
+ for (const seg of segments) {
156
+ const form = classifyGitDestructiveSegment(seg);
157
+ if (form === null)
158
+ continue;
159
+ if (seen.has(form.kind))
160
+ continue;
161
+ seen.add(form.kind);
162
+ found.push(compound ? { ...form, unprovable: true } : form);
163
+ }
164
+ return found;
165
+ }
139
166
  /** Classify one command with no operators, no grouping, and no substitution. */
140
167
  function classifySimpleDestForms(segment) {
141
168
  const found = [];
@@ -334,9 +361,33 @@ function isGitWorkTreeAssign(token) {
334
361
  // A config FILE override can set core.worktree out of sight.
335
362
  return key === "GIT_CONFIG" || key === "GIT_CONFIG_GLOBAL" || key === "GIT_CONFIG_SYSTEM";
336
363
  }
364
+ function gitDirOrWorkTreeValue(token) {
365
+ const eq = token.indexOf("=");
366
+ if (eq <= 0)
367
+ return null;
368
+ const key = token.slice(0, eq);
369
+ const value = token.slice(eq + 1);
370
+ if ((key === "GIT_WORK_TREE" || key === "GIT_DIR") && value.length > 0)
371
+ return value;
372
+ return null;
373
+ }
337
374
  function skipPrefix(tokens) {
338
375
  let i = 0;
339
376
  let gitContext = false;
377
+ let opaqueContext = false;
378
+ const relocators = [];
379
+ const noteAssign = (tok) => {
380
+ const reloc = gitDirOrWorkTreeValue(tok);
381
+ if (reloc !== null) {
382
+ gitContext = true;
383
+ relocators.push(reloc);
384
+ return;
385
+ }
386
+ if (isGitWorkTreeAssign(tok)) {
387
+ gitContext = true;
388
+ opaqueContext = true;
389
+ }
390
+ };
340
391
  const consumeAssigns = () => {
341
392
  while (i < tokens.length) {
342
393
  const tok = tokens[i];
@@ -351,8 +402,7 @@ function skipPrefix(tokens) {
351
402
  }
352
403
  if (!isEnvAssign(tok))
353
404
  break;
354
- if (isGitWorkTreeAssign(tok))
355
- gitContext = true;
405
+ noteAssign(tok);
356
406
  i++;
357
407
  }
358
408
  };
@@ -380,15 +430,14 @@ function skipPrefix(tokens) {
380
430
  continue;
381
431
  }
382
432
  if (isEnvAssign(tok)) {
383
- if (isGitWorkTreeAssign(tok))
384
- gitContext = true;
433
+ noteAssign(tok);
385
434
  i++;
386
435
  continue;
387
436
  }
388
437
  break;
389
438
  }
390
439
  }
391
- return { i, gitContext };
440
+ return { i, gitContext, relocators, opaqueContext };
392
441
  }
393
442
  /**
394
443
  * Skip git's global options, reporting whether any of them RELOCATES the work
@@ -400,31 +449,51 @@ function skipPrefix(tokens) {
400
449
  function skipGitGlobals(tokens, start) {
401
450
  let i = start;
402
451
  let gitContext = false;
452
+ let opaqueContext = false;
453
+ const relocators = [];
403
454
  while (i < tokens.length) {
404
455
  const t = tokens[i];
405
456
  if (t === undefined || !t.startsWith("-"))
406
- return { i, gitContext };
457
+ return { i, gitContext, relocators, opaqueContext };
407
458
  if (t === "-c" || t === "--config-env") {
408
- if (isCoreWorkTreeConfig(tokens[i + 1]))
459
+ if (isCoreWorkTreeConfig(tokens[i + 1])) {
409
460
  gitContext = true;
461
+ opaqueContext = true;
462
+ }
410
463
  i += 2;
411
464
  continue;
412
465
  }
413
466
  if (t.startsWith("--config-env=")) {
414
- if (isCoreWorkTreeConfig(t.slice("--config-env=".length)))
467
+ if (isCoreWorkTreeConfig(t.slice("--config-env=".length))) {
415
468
  gitContext = true;
469
+ opaqueContext = true;
470
+ }
416
471
  i++;
417
472
  continue;
418
473
  }
419
474
  if (t === "-C" || t === "--work-tree" || t === "--git-dir") {
420
475
  gitContext = true;
476
+ const val = tokens[i + 1];
477
+ if (val !== undefined)
478
+ relocators.push(val);
421
479
  i += 2;
422
480
  continue;
423
481
  }
424
- if (t.startsWith("--work-tree=") ||
425
- t.startsWith("--git-dir=") ||
426
- (t.startsWith("-C") && t.length > 2)) {
482
+ if (t.startsWith("--work-tree=")) {
483
+ gitContext = true;
484
+ relocators.push(t.slice("--work-tree=".length));
485
+ i++;
486
+ continue;
487
+ }
488
+ if (t.startsWith("--git-dir=")) {
427
489
  gitContext = true;
490
+ relocators.push(t.slice("--git-dir=".length));
491
+ i++;
492
+ continue;
493
+ }
494
+ if (t.startsWith("-C") && t.length > 2) {
495
+ gitContext = true;
496
+ relocators.push(t.slice(2));
428
497
  i++;
429
498
  continue;
430
499
  }
@@ -437,14 +506,16 @@ function skipGitGlobals(tokens, start) {
437
506
  continue;
438
507
  }
439
508
  if (t.startsWith("-c")) {
440
- if (isCoreWorkTreeConfig(t.slice(2)))
509
+ if (isCoreWorkTreeConfig(t.slice(2))) {
441
510
  gitContext = true;
511
+ opaqueContext = true;
512
+ }
442
513
  i++;
443
514
  continue;
444
515
  }
445
516
  i++;
446
517
  }
447
- return { i, gitContext };
518
+ return { i, gitContext, relocators, opaqueContext };
448
519
  }
449
520
  function pathsAfterDashDash(tokens, start) {
450
521
  const dash = tokens.indexOf("--", start);
@@ -469,6 +540,72 @@ function dests(kind, paths, unsafe = false) {
469
540
  .filter((path) => path.length > 0)
470
541
  .map((path) => (unsafe ? { kind, path, expansion: true } : { kind, path }));
471
542
  }
543
+ function tokensHaveFlag(tokens, start, names) {
544
+ for (let i = start; i < tokens.length; i++) {
545
+ const t = tokens[i];
546
+ if (t === undefined)
547
+ break;
548
+ if (names.has(t))
549
+ return true;
550
+ for (const name of names) {
551
+ if (name.startsWith("--") && t.startsWith(`${name}=`))
552
+ return true;
553
+ }
554
+ }
555
+ return false;
556
+ }
557
+ function tokensHaveShortForce(tokens, start) {
558
+ for (let i = start; i < tokens.length; i++) {
559
+ const t = tokens[i];
560
+ if (t === undefined || t === "--")
561
+ break;
562
+ if (t === "-f" || t === "-B")
563
+ return true;
564
+ if (t.startsWith("-") && !t.startsWith("--") && t.includes("f"))
565
+ return true;
566
+ }
567
+ return false;
568
+ }
569
+ function classifyGitDestructiveSegment(segment) {
570
+ const tokens = tokenizeSegment(segment.trim());
571
+ const prefixSkip = skipPrefix(tokens);
572
+ let i = prefixSkip.i;
573
+ const binRaw = tokens[i];
574
+ if (binRaw === undefined)
575
+ return null;
576
+ const bin = binRaw.replace(/^[({!]+/, "").toLowerCase();
577
+ if (bin !== "git" && bin !== "git.exe")
578
+ return null;
579
+ const skipped = skipGitGlobals(tokens, i + 1);
580
+ i = skipped.i;
581
+ const sub = tokens[i]?.toLowerCase();
582
+ if (sub === undefined)
583
+ return null;
584
+ let kind = null;
585
+ if (sub === "reset" && tokensHaveFlag(tokens, i + 1, new Set(["--hard"]))) {
586
+ kind = "git-reset-hard";
587
+ }
588
+ else if (sub === "clean" &&
589
+ (tokensHaveFlag(tokens, i + 1, new Set(["--force", "-f"])) ||
590
+ tokensHaveShortForce(tokens, i + 1))) {
591
+ kind = "git-clean";
592
+ }
593
+ else if ((sub === "checkout" || sub === "switch") &&
594
+ (tokensHaveFlag(tokens, i + 1, new Set(["--force", "-f", "-B"])) ||
595
+ tokensHaveShortForce(tokens, i + 1))) {
596
+ kind = "git-checkout-force";
597
+ }
598
+ else if (sub === "stash") {
599
+ const action = tokens[i + 1]?.toLowerCase();
600
+ if (action === "drop" || action === "clear")
601
+ kind = "git-stash-drop";
602
+ }
603
+ if (kind === null)
604
+ return null;
605
+ const relocators = [...prefixSkip.relocators, ...skipped.relocators];
606
+ const opaque = prefixSkip.opaqueContext || skipped.opaqueContext;
607
+ return { kind, relocators, unprovable: opaque };
608
+ }
472
609
  /**
473
610
  * `-c core.workTree=...` / `--config-env` relocates the work tree through git
474
611
  * config. Resolution depends on the git dir, which this classifier does not
@@ -7,7 +7,7 @@ import { type DetectWorkSelection, type RitualRunner, type VerifyResult } from "
7
7
  import { type HookPayloadContext } from "./classify/index.js";
8
8
  import { type ActiveScopeInspection } from "./scope.js";
9
9
  export { ASSIST_SESSION_POSTURE_ENV, hookReadOnlyFromPayload, isAssistPosture, isEphemeralSpawn, isExploreSpawn, isReadOnlyHookContext, } from "./readonly.js";
10
- export { DIRECT_WRITE_HOOK_MATCHER, DIRECT_WRITE_TOOL_NAMES, isDirectWriteTool, isMcpTool, isShellTool, isSpawnTool, MCP_HOOK_MATCHER, MCP_PUSH_MERGE_BARE_NAMES, READ_ONLY_HOOK_ENV, SHELL_HOOK_MATCHER, SHELL_TOOL_NAMES, SPAWN_HOOK_MATCHER, SPAWN_TOOL_NAMES, } from "./tools.js";
10
+ export { DIRECT_WRITE_HOOK_MATCHER, DIRECT_WRITE_TOOL_NAMES, GROK_MUTATION_TOOL_CATALOG, GROK_NON_MUTATION_TOOLS, isDirectWriteTool, isMcpTool, isShellTool, isSpawnTool, MCP_HOOK_MATCHER, MCP_PUSH_MERGE_BARE_NAMES, matcherHasLiteralToken, READ_ONLY_HOOK_ENV, SHELL_HOOK_MATCHER, SHELL_TOOL_NAMES, SPAWN_HOOK_MATCHER, SPAWN_TOOL_NAMES, } from "./tools.js";
11
11
  export declare const HOOK_HOSTS: readonly ["claude", "grok", "cursor", "codex"];
12
12
  export type HookHost = (typeof HOOK_HOSTS)[number];
13
13
  export declare const HOOK_EVENTS: readonly ["session.start", "session.compact", "tool.before"];
@@ -44,7 +44,11 @@ export type HookDecisionCode = "session-start" | "session-start-disabled" | "ses
44
44
  /** UAT lease / human-origin grant denial (#2944). */
45
45
  | "authz-uat-deny" | "authz-grant-missing" | "authz-grant-origin-reject" | "authz-grant-scope-deny" | "authz-grant-expired" | "authz-grant-revoked" | "authz-grant-single-use-spent"
46
46
  /** Slash-command intent ceiling denial (#1193). */
47
- | "intent-ceiling-deny";
47
+ | "intent-ceiling-deny"
48
+ /** Tree-wide destructive git aimed at this checkout (#3917). */
49
+ | "git-destructive-deny"
50
+ /** Tree-wide destructive git aimed at an absolute out-of-root fixture (#3917). */
51
+ | "git-destructive-fixture";
48
52
  export interface HookDecision {
49
53
  readonly verdict: HookVerdict;
50
54
  readonly code: HookDecisionCode;