@deftai/directive-core 0.108.0 → 0.109.1

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 (157) 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 +8 -1
  27. package/dist/design-critique/completed-arc-record.js +98 -14
  28. package/dist/hooks/classify/host-session-identity.d.ts +25 -12
  29. package/dist/hooks/classify/host-session-identity.js +64 -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 +22 -2
  38. package/dist/hooks/dispatcher.js +338 -66
  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 +3 -0
  44. package/dist/hooks/index.js +3 -0
  45. package/dist/hooks/owner-liveness.d.ts +92 -0
  46. package/dist/hooks/owner-liveness.js +103 -0
  47. package/dist/hooks/shell-write-targets.d.ts +10 -0
  48. package/dist/hooks/shell-write-targets.js +274 -0
  49. package/dist/hooks/tools.d.ts +49 -2
  50. package/dist/hooks/tools.js +96 -1
  51. package/dist/init-deposit/agent-hooks.d.ts +10 -0
  52. package/dist/init-deposit/agent-hooks.js +39 -0
  53. package/dist/init-deposit/gitignore.d.ts +7 -0
  54. package/dist/init-deposit/gitignore.js +24 -0
  55. package/dist/init-deposit/host-tool-coverage.d.ts +53 -0
  56. package/dist/init-deposit/host-tool-coverage.js +150 -0
  57. package/dist/init-deposit/index.d.ts +1 -0
  58. package/dist/init-deposit/index.js +1 -0
  59. package/dist/init-deposit/init-deposit.js +3 -0
  60. package/dist/init-deposit/refresh.js +7 -0
  61. package/dist/init-deposit/runtime-writers.d.ts +14 -0
  62. package/dist/init-deposit/runtime-writers.js +33 -0
  63. package/dist/intake/issue-ingest.d.ts +6 -1
  64. package/dist/intake/issue-ingest.js +21 -2
  65. package/dist/intake/reconcile-issues.js +13 -13
  66. package/dist/lifecycle/brief-envelope.d.ts +25 -0
  67. package/dist/lifecycle/brief-envelope.js +42 -0
  68. package/dist/lifecycle/index.d.ts +1 -0
  69. package/dist/lifecycle/index.js +1 -0
  70. package/dist/literal-acceptance/evaluate.js +14 -5
  71. package/dist/literal-acceptance/index.d.ts +1 -1
  72. package/dist/literal-acceptance/index.js +1 -1
  73. package/dist/literal-acceptance/run.d.ts +2 -0
  74. package/dist/literal-acceptance/run.js +19 -1
  75. package/dist/orchestration/subagent-monitor.d.ts +6 -0
  76. package/dist/orchestration/subagent-monitor.js +23 -1
  77. package/dist/orphan-active/candidate-scope.d.ts +53 -0
  78. package/dist/orphan-active/candidate-scope.js +157 -0
  79. package/dist/orphan-active/evaluate.d.ts +27 -0
  80. package/dist/orphan-active/evaluate.js +63 -6
  81. package/dist/orphan-active/index.d.ts +1 -0
  82. package/dist/orphan-active/index.js +1 -0
  83. package/dist/policy/merge-approval-head.js +7 -6
  84. package/dist/pr-closing-keywords/gh.js +32 -9
  85. package/dist/pr-closing-keywords/main.d.ts +1 -0
  86. package/dist/pr-closing-keywords/main.js +68 -3
  87. package/dist/pr-closing-keywords/types.d.ts +2 -0
  88. package/dist/pr-merge-readiness/gh.js +32 -9
  89. package/dist/pr-protected-issues/gh.js +36 -9
  90. package/dist/pr-wait-mergeable/wrappers.js +3 -3
  91. package/dist/product-first-done-gate/evaluate.js +6 -2
  92. package/dist/product-first-done-gate/types.js +2 -0
  93. package/dist/release/consumer-hard-stops.d.ts +48 -0
  94. package/dist/release/consumer-hard-stops.js +140 -0
  95. package/dist/release/consumer-readiness-disclosure.d.ts +18 -0
  96. package/dist/release/consumer-readiness-disclosure.js +51 -0
  97. package/dist/release/index.d.ts +2 -0
  98. package/dist/release/index.js +2 -0
  99. package/dist/release/pipeline.js +55 -0
  100. package/dist/release/run-consumer-readiness.d.ts +15 -0
  101. package/dist/release/run-consumer-readiness.js +24 -0
  102. package/dist/release/types.d.ts +6 -0
  103. package/dist/review-monitor/github-lease.js +4 -3
  104. package/dist/run-summary/types.d.ts +2 -2
  105. package/dist/scm/build-command.d.ts +2 -2
  106. package/dist/scm/build-command.js +2 -2
  107. package/dist/scm/call-shape.d.ts +25 -0
  108. package/dist/scm/call-shape.js +59 -0
  109. package/dist/scm/call.d.ts +7 -4
  110. package/dist/scm/call.js +41 -11
  111. package/dist/scm/gh-rest.d.ts +25 -12
  112. package/dist/scm/gh-rest.js +65 -15
  113. package/dist/scm/index.d.ts +2 -0
  114. package/dist/scm/index.js +2 -0
  115. package/dist/scm/spawn-status.d.ts +33 -0
  116. package/dist/scm/spawn-status.js +53 -0
  117. package/dist/scope/acceptance-evidence.d.ts +1 -1
  118. package/dist/scope/transition.js +4 -14
  119. package/dist/session/ac-pass-banking.d.ts +2 -2
  120. package/dist/session/ac-pass-banking.js +2 -2
  121. package/dist/session/child-occupancy.d.ts +72 -0
  122. package/dist/session/child-occupancy.js +209 -0
  123. package/dist/session/host-session-owner.d.ts +93 -0
  124. package/dist/session/host-session-owner.js +148 -0
  125. package/dist/session/index.d.ts +2 -0
  126. package/dist/session/index.js +2 -0
  127. package/dist/session/occupancy.d.ts +107 -2
  128. package/dist/session/occupancy.js +272 -34
  129. package/dist/session/verify-ac-session-cache.d.ts +2 -2
  130. package/dist/session/verify-ac-session-cache.js +2 -2
  131. package/dist/swarm/complete-cohort.js +2 -0
  132. package/dist/swarm/pre-dispatch.js +2 -0
  133. package/dist/swarm/subagent-status-dir.d.ts +2 -1
  134. package/dist/swarm/subagent-status-dir.js +11 -2
  135. package/dist/swarm/worktrees.js +2 -0
  136. package/dist/triage/evaluate/worktrees.js +153 -6
  137. package/dist/umbrella-current-shape/index.d.ts +51 -3
  138. package/dist/umbrella-current-shape/index.js +106 -18
  139. package/dist/validate-content/deposit-required.d.ts +39 -0
  140. package/dist/validate-content/deposit-required.js +147 -0
  141. package/dist/validate-content/index.d.ts +1 -0
  142. package/dist/validate-content/index.js +1 -0
  143. package/dist/validate-content/validate-links.d.ts +2 -3
  144. package/dist/validate-content/validate-links.js +29 -2
  145. package/dist/vbrief-activate/activate.d.ts +7 -2
  146. package/dist/vbrief-activate/activate.js +26 -13
  147. package/dist/verify-ac/evaluate.d.ts +9 -0
  148. package/dist/verify-ac/evaluate.js +32 -9
  149. package/dist/verify-env/agent-hooks.d.ts +6 -1
  150. package/dist/verify-env/agent-hooks.js +28 -2
  151. package/dist/verify-source/deposit-closure.d.ts +23 -0
  152. package/dist/verify-source/deposit-closure.js +162 -0
  153. package/dist/verify-source/index.d.ts +2 -0
  154. package/dist/verify-source/index.js +2 -0
  155. package/dist/verify-source/semantic-single-source.d.ts +36 -0
  156. package/dist/verify-source/semantic-single-source.js +349 -0
  157. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { join, relative, resolve, sep } from "node:path";
3
+ import { evaluateLiveProcedureTargets, formatLiveProcedureFailure, } from "../deposit/live-procedure-targets.js";
3
4
  import { NON_PRODUCT_DIRS } from "../fs/non-product-dirs.js";
4
5
  import { extractLinkTargets, shouldSkipLinkTarget } from "./link-parser.js";
5
6
  /**
@@ -43,7 +44,8 @@ function collectMarkdownFiles(root) {
43
44
  walk(root, []);
44
45
  return out.sort();
45
46
  }
46
- function findBrokenLinks(cwd) {
47
+ /** Collect broken internal markdown links under cwd. Used by packed-fixture tests (#3937). */
48
+ export function collectBrokenLinks(cwd) {
47
49
  const broken = [];
48
50
  const root = resolve(cwd);
49
51
  for (const md of collectMarkdownFiles(root)) {
@@ -82,13 +84,38 @@ function findBrokenLinks(cwd) {
82
84
  /**
83
85
  * Validate internal markdown links. Faithful to `scripts/validate-links.py`.
84
86
  */
87
+ function contentRootForC3(cwd) {
88
+ const underContent = join(cwd, "content");
89
+ return existsSync(underContent) ? underContent : cwd;
90
+ }
91
+ function extraMarkdownForC3(cwd) {
92
+ const extras = [];
93
+ for (const name of ["main.md", "SKILL.md"]) {
94
+ const absolutePath = join(cwd, name);
95
+ if (existsSync(absolutePath)) {
96
+ extras.push({ relativePath: name, absolutePath });
97
+ }
98
+ }
99
+ return extras;
100
+ }
85
101
  export function evaluate(options = {}) {
86
102
  const cwd = resolve(options.cwd ?? ".");
87
103
  const strict = options.strict === true ||
88
104
  options.linkCheckStrict === true ||
89
105
  (options.argv ?? []).includes("--strict") ||
90
106
  process.env.LINK_CHECK_STRICT === "1";
91
- const broken = findBrokenLinks(cwd);
107
+ const c3 = evaluateLiveProcedureTargets({
108
+ stagedRoot: contentRootForC3(cwd),
109
+ extraFiles: extraMarkdownForC3(cwd),
110
+ });
111
+ if (c3.uniqueTargets.length > 0) {
112
+ return {
113
+ code: 1,
114
+ message: formatLiveProcedureFailure(c3),
115
+ stream: "stdout",
116
+ };
117
+ }
118
+ const broken = collectBrokenLinks(cwd);
92
119
  if (broken.length === 0) {
93
120
  return {
94
121
  code: 0,
@@ -6,8 +6,13 @@ export interface ActivateOptions {
6
6
  readonly now?: Date;
7
7
  }
8
8
  /**
9
- * Pure activator returns ``{ exitCode, message }``. Faithful to
10
- * ``scripts/vbrief_activate.py::activate``.
9
+ * Pure activator -- returns ``{ exitCode, message }``. Ported from
10
+ * ``scripts/vbrief_activate.py::activate`` under the #1782 byte-identical
11
+ * parity contract, with one deliberate divergence: the Python oracle created a
12
+ * ``vBRIEFInfo`` when the artifact carried no envelope, and that behaviour is
13
+ * NOT preserved (#3933). Envelope handling now follows the shared lifecycle
14
+ * policy -- stamp whichever envelope exists, refuse an envelope-less artifact
15
+ * by name.
11
16
  */
12
17
  export declare function activate(vbriefPath: string, options?: ActivateOptions): ActivateResult;
13
18
  //# sourceMappingURL=activate.d.ts.map
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, unli
2
2
  import { basename, dirname, resolve } from "node:path";
3
3
  import { containedWrite } from "../fs/contained-write.js";
4
4
  import { assertProjectionContained, ProjectionContainmentError, } from "../fs/projection-containment.js";
5
+ import { BRIEF_ENVELOPE_KEYS, missingEnvelopeMessage, stampExistingEnvelopes, } from "../lifecycle/brief-envelope.js";
5
6
  import { evaluateEffortActivateGate } from "../scope/effort-activate-gate.js";
6
7
  import { utcNowIso } from "../scope/vbrief-json.js";
7
8
  import { pythonJsonPretty } from "../vbrief-build/json.js";
@@ -57,8 +58,13 @@ function loadVbrief(vbriefPath) {
57
58
  return { payload: payload, error: null };
58
59
  }
59
60
  /**
60
- * Pure activator returns ``{ exitCode, message }``. Faithful to
61
- * ``scripts/vbrief_activate.py::activate``.
61
+ * Pure activator -- returns ``{ exitCode, message }``. Ported from
62
+ * ``scripts/vbrief_activate.py::activate`` under the #1782 byte-identical
63
+ * parity contract, with one deliberate divergence: the Python oracle created a
64
+ * ``vBRIEFInfo`` when the artifact carried no envelope, and that behaviour is
65
+ * NOT preserved (#3933). Envelope handling now follows the shared lifecycle
66
+ * policy -- stamp whichever envelope exists, refuse an envelope-less artifact
67
+ * by name.
62
68
  */
63
69
  export function activate(vbriefPath, options = {}) {
64
70
  const now = options.now ?? new Date();
@@ -143,19 +149,26 @@ export function activate(vbriefPath, options = {}) {
143
149
  }
144
150
  throw err;
145
151
  }
146
- planObj.status = TARGET_STATUS;
147
- let info = payload.vBRIEFInfo;
148
- if (info === undefined) {
149
- info = {};
150
- payload.vBRIEFInfo = info;
152
+ for (const key of BRIEF_ENVELOPE_KEYS) {
153
+ if (!(key in payload)) {
154
+ continue;
155
+ }
156
+ const env = payload[key];
157
+ if (env === null || typeof env !== "object" || Array.isArray(env)) {
158
+ return {
159
+ exitCode: 1,
160
+ message: `vBRIEF at ${vbriefPath} has a non-object \`${key}\` -- malformed.`,
161
+ };
162
+ }
151
163
  }
152
- if (info === null || typeof info !== "object" || Array.isArray(info)) {
153
- return {
154
- exitCode: 1,
155
- message: `vBRIEF at ${vbriefPath} has a non-object \`vBRIEFInfo\` -- malformed.`,
156
- };
164
+ // #3933: stamp the envelope the brief already carries; never create one. A
165
+ // manufactured version-less `vBRIEFInfo` wins schema resolution over a valid
166
+ // `xBRIEFInfo`, so the brief this verb just moved would fail validation.
167
+ const stampedEnvelopes = stampExistingEnvelopes(payload, utcNowIso(now));
168
+ if (stampedEnvelopes.length === 0) {
169
+ return { exitCode: 1, message: missingEnvelopeMessage(`vBRIEF at ${vbriefPath}`) };
157
170
  }
158
- info.updated = utcNowIso(now);
171
+ planObj.status = TARGET_STATUS;
159
172
  try {
160
173
  mkdirSync(activeDir, { recursive: true });
161
174
  }
@@ -44,6 +44,15 @@ export declare const VERIFY_AC_CHECK_ID_PREFIX = "verify:ac";
44
44
  export declare function verifyAcCheckId(scopeKey?: string | null): string;
45
45
  /** Test seam: isolate stdout-dest buffer across cases. */
46
46
  export declare function resetInProcessVerificationBuffer(): void;
47
+ /**
48
+ * Product-oracle outcome for one acceptance walk (#3615).
49
+ *
50
+ * A safety refusal is not a measurement. All-refused walks emit nothing.
51
+ * Mixed refused + executed-pass walks emit nothing (filtering refusals then
52
+ * classifying the remainder would be a false green). Any executed fail still
53
+ * emits fail. flag.ts is unchanged.
54
+ */
55
+ export declare function productOracleOutcomeForWalk(runs: readonly LiteralAcceptanceRunResult[]): "pass" | "fail" | null;
47
56
  /**
48
57
  * Record one walk-level verification event for the executed command set (#3322 / #3397).
49
58
  * Fail and pass use the same method_fingerprint shape (command list + cwd hash).
@@ -10,6 +10,7 @@
10
10
  import { createHash } from "node:crypto";
11
11
  import { existsSync, readFileSync } from "node:fs";
12
12
  import { resolve } from "node:path";
13
+ import { isSafetyRefusalRun } from "../literal-acceptance/run.js";
13
14
  import { parseRunSummaryJsonl, RunSummaryEmitter, resolveRunSummaryDestination, } from "../run-summary/index.js";
14
15
  import { flagPassAfterFailWithMethodChange, readVerificationAttempts, unresolvedMethodChangePasses, } from "./flag.js";
15
16
  function formatUnresolved(flag) {
@@ -57,6 +58,25 @@ function inProcessVerificationText() {
57
58
  }
58
59
  return inProcessVerificationLines.join("\n");
59
60
  }
61
+ /**
62
+ * Product-oracle outcome for one acceptance walk (#3615).
63
+ *
64
+ * A safety refusal is not a measurement. All-refused walks emit nothing.
65
+ * Mixed refused + executed-pass walks emit nothing (filtering refusals then
66
+ * classifying the remainder would be a false green). Any executed fail still
67
+ * emits fail. flag.ts is unchanged.
68
+ */
69
+ export function productOracleOutcomeForWalk(runs) {
70
+ const refused = runs.filter(isSafetyRefusalRun);
71
+ const executed = runs.filter((run) => !isSafetyRefusalRun(run));
72
+ if (executed.length === 0) {
73
+ return null;
74
+ }
75
+ if (refused.length > 0 && executed.every((run) => run.ok)) {
76
+ return null;
77
+ }
78
+ return executed.every((run) => run.ok) ? "pass" : "fail";
79
+ }
60
80
  /**
61
81
  * Record one walk-level verification event for the executed command set (#3322 / #3397).
62
82
  * Fail and pass use the same method_fingerprint shape (command list + cwd hash).
@@ -69,6 +89,10 @@ export function emitVerifyAcAttempts(options) {
69
89
  if (options.runs.length === 0) {
70
90
  return;
71
91
  }
92
+ const outcome = productOracleOutcomeForWalk(options.runs);
93
+ if (outcome === null) {
94
+ return;
95
+ }
72
96
  try {
73
97
  const env = options.env ?? process.env;
74
98
  const projectRoot = resolve(options.projectRoot);
@@ -85,16 +109,15 @@ export function emitVerifyAcAttempts(options) {
85
109
  component: "verify-ac",
86
110
  writeStdout: options.writeStdout,
87
111
  });
88
- // One walk-level event: the method is the command set, not each command.
89
- // Per-command emit was blind to a shrinking list that kept the first command (#3397).
90
- const commands = options.runs.map((run) => run.command);
91
- const firstCwd = options.runs[0]?.cwd ?? "";
92
- // Hash the cwd key (joined only when cwds differ) so cwd paths never enter
93
- // the fingerprint; commandCountFromFingerprint can still count commands.
94
- const cwdKey = options.runs.every((run) => run.cwd === firstCwd)
112
+ // Method identity is the executed command set. Refused rows are not
113
+ // measurements; including them would make a later same-command product
114
+ // fix look like a method change (#3615 Greptile P1).
115
+ const executed = options.runs.filter((run) => !isSafetyRefusalRun(run));
116
+ const commands = executed.map((run) => run.command);
117
+ const firstCwd = executed[0]?.cwd ?? "";
118
+ const cwdKey = executed.every((run) => run.cwd === firstCwd)
95
119
  ? firstCwd
96
- : options.runs.map((run) => run.cwd).join("\0");
97
- const outcome = options.runs.every((run) => run.ok) ? "pass" : "fail";
120
+ : executed.map((run) => run.cwd).join("\0");
98
121
  const emitted = emitter.emitVerification({
99
122
  check_id: checkId,
100
123
  method_fingerprint: methodFingerprintForWalk(commands, cwdKey),
@@ -1,4 +1,5 @@
1
1
  import { type AgentHookInspection } from "../init-deposit/agent-hooks.js";
2
+ import { type HostToolCoverageFinding, inspectHostToolCoverage } from "../init-deposit/host-tool-coverage.js";
2
3
  import type { HostHooksPolicy } from "../policy/host-hooks.js";
3
4
  import type { OutputStream } from "./verify-hooks-installed.js";
4
5
  export interface AgentHookHealthResult {
@@ -6,7 +7,11 @@ export interface AgentHookHealthResult {
6
7
  readonly message: string;
7
8
  readonly stream: OutputStream;
8
9
  readonly registrations: readonly AgentHookInspection[];
10
+ /** Host tool-surface coverage gaps found alongside registration health (#3987). */
11
+ readonly coverage: readonly HostToolCoverageFinding[];
9
12
  }
10
13
  /** Read-only P0 agent-host registration health, independent of git hooks. */
11
- export declare function evaluateAgentHooks(projectRoot: string, hostHooksPolicy?: HostHooksPolicy): AgentHookHealthResult;
14
+ export declare function evaluateAgentHooks(projectRoot: string, hostHooksPolicy?: HostHooksPolicy,
15
+ /** Test seam for the #3987 tool-surface coverage probe. */
16
+ inspectCoverage?: typeof inspectHostToolCoverage): AgentHookHealthResult;
12
17
  //# sourceMappingURL=agent-hooks.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { statSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
3
  import { inspectAgentHookDeposit } from "../init-deposit/agent-hooks.js";
4
+ import { HOST_TOOL_COVERAGE_RECOVERY, inspectHostToolCoverage, } from "../init-deposit/host-tool-coverage.js";
4
5
  import { loadHostHooksPolicyFromProject, UNUSED_HOST_HOOKS_RECOVERY, } from "../policy/host-hooks.js";
5
6
  function isDirectory(path) {
6
7
  try {
@@ -11,7 +12,9 @@ function isDirectory(path) {
11
12
  }
12
13
  }
13
14
  /** Read-only P0 agent-host registration health, independent of git hooks. */
14
- export function evaluateAgentHooks(projectRoot, hostHooksPolicy = loadHostHooksPolicyFromProject(projectRoot)) {
15
+ export function evaluateAgentHooks(projectRoot, hostHooksPolicy = loadHostHooksPolicyFromProject(projectRoot),
16
+ /** Test seam for the #3987 tool-surface coverage probe. */
17
+ inspectCoverage = inspectHostToolCoverage) {
15
18
  const root = resolve(projectRoot);
16
19
  if (!isDirectory(root)) {
17
20
  return {
@@ -19,9 +22,11 @@ export function evaluateAgentHooks(projectRoot, hostHooksPolicy = loadHostHooksP
19
22
  message: `❌ deft agent hooks: project root ${root} does not exist (config error).`,
20
23
  stream: "stderr",
21
24
  registrations: [],
25
+ coverage: [],
22
26
  };
23
27
  }
24
28
  const registrations = inspectAgentHookDeposit(root, hostHooksPolicy);
29
+ const coverage = inspectCoverage(root, hostHooksPolicy);
25
30
  const unhealthy = registrations.filter((entry) => entry.status === "missing" || entry.status === "drifted");
26
31
  if (unhealthy.length > 0) {
27
32
  return {
@@ -34,6 +39,25 @@ export function evaluateAgentHooks(projectRoot, hostHooksPolicy = loadHostHooksP
34
39
  UNUSED_HOST_HOOKS_RECOVERY,
35
40
  stream: "stderr",
36
41
  registrations,
42
+ coverage,
43
+ };
44
+ }
45
+ // #3987: a structurally current registration can still leave a host tool
46
+ // uncovered, which is the failure this issue is about — a deposit the host
47
+ // never matches is enforcement that never runs.
48
+ if (coverage.length > 0) {
49
+ return {
50
+ code: 1,
51
+ message: "❌ deft agent hook tool-surface coverage INCOMPLETE:\n" +
52
+ coverage
53
+ .map((finding) => ` - ${finding.host}: ${finding.kind}` +
54
+ `${finding.toolName === null ? "" : ` \`${finding.toolName}\``} ` +
55
+ `at ${finding.path} — ${finding.detail}`)
56
+ .join("\n") +
57
+ `\n ${HOST_TOOL_COVERAGE_RECOVERY}`,
58
+ stream: "stderr",
59
+ registrations,
60
+ coverage,
37
61
  };
38
62
  }
39
63
  const disabledHosts = registrations
@@ -48,9 +72,11 @@ export function evaluateAgentHooks(projectRoot, hostHooksPolicy = loadHostHooksP
48
72
  "DEFT_HOOK_READ_ONLY=1 and explore subagent_type. Codex runtime trust is user-controlled and must be reviewed with `/hooks`; shell/MCP policy is deferred." +
49
73
  (disabledHosts.length > 0
50
74
  ? ` Intentional hostHooks disabled: ${disabledHosts.join(", ")}.`
51
- : ""),
75
+ : "") +
76
+ " Per-host mutation tool names verified against the deposited matchers (#3987).",
52
77
  stream: "stdout",
53
78
  registrations,
79
+ coverage,
54
80
  };
55
81
  }
56
82
  //# sourceMappingURL=agent-hooks.js.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Check 1 -- staged-pack deposit closure (#3900 / #3601 C1).
3
+ *
4
+ * Resolves the C1 declaration against a staged pack root. Does not infer
5
+ * required paths from AGENTS.md prose. Reuses evaluateDepositClosure.
6
+ *
7
+ * Three-state: 0 clean / 1 missing declared paths / 2 config.
8
+ */
9
+ import { type DepositClosureResult, type DepositRequiredDeclaration } from "../validate-content/deposit-required.js";
10
+ export interface StagedDepositClosureResult {
11
+ readonly code: 0 | 1 | 2;
12
+ readonly message: string;
13
+ readonly stream: "stdout" | "stderr";
14
+ readonly missing: readonly string[];
15
+ readonly checked: number;
16
+ }
17
+ /** Copy declared C1 paths into dest using the content-package mapping. */
18
+ export declare function stageDeclaredPack(repoRoot: string, destPackRoot: string): DepositRequiredDeclaration;
19
+ export declare function formatStagedDepositClosureLine(result: DepositClosureResult): string;
20
+ export declare function evaluateStagedDepositClosure(packRoot: string, paths: readonly string[]): StagedDepositClosureResult;
21
+ export declare function evaluateDepositClosureFromRepo(repoRoot: string): StagedDepositClosureResult;
22
+ export declare function evaluateDepositClosureAtRoot(root: string, packRootExplicit: boolean): StagedDepositClosureResult;
23
+ //# sourceMappingURL=deposit-closure.d.ts.map
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Check 1 -- staged-pack deposit closure (#3900 / #3601 C1).
3
+ *
4
+ * Resolves the C1 declaration against a staged pack root. Does not infer
5
+ * required paths from AGENTS.md prose. Reuses evaluateDepositClosure.
6
+ *
7
+ * Three-state: 0 clean / 1 missing declared paths / 2 config.
8
+ */
9
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, rmSync, statSync } from "node:fs";
10
+ import { tmpdir } from "node:os";
11
+ import { dirname, join, resolve } from "node:path";
12
+ import { evaluateDepositClosure, loadDepositRequiredDeclaration, packRelativeFromDepositPath, resolveDeclarationFile, sourcePathForPackRelative, } from "../validate-content/deposit-required.js";
13
+ const EXIT_OK = 0;
14
+ const EXIT_MISSING = 1;
15
+ const EXIT_CONFIG = 2;
16
+ const REMEDIATION = "Recovery: restore the declared files in content/ (or root harness files) so they survive content-package prepack. Do not infer paths from AGENTS.md prose (#3601 C1 / #3900).";
17
+ function keepPackFile(src) {
18
+ const posix = src.replace(/\\/g, "/");
19
+ if (posix.includes("__pycache__"))
20
+ return false;
21
+ if (posix.endsWith(".pyc") || posix.endsWith(".py"))
22
+ return false;
23
+ return true;
24
+ }
25
+ /** Copy declared C1 paths into dest using the content-package mapping. */
26
+ export function stageDeclaredPack(repoRoot, destPackRoot) {
27
+ const declarationPath = resolveDeclarationFile(repoRoot);
28
+ if (declarationPath === null) {
29
+ throw new Error("deposit-closure: C1 declaration missing (contracts/deposit-required-paths.json).");
30
+ }
31
+ const declaration = loadDepositRequiredDeclaration(declarationPath);
32
+ mkdirSync(destPackRoot, { recursive: true });
33
+ for (const declared of declaration.paths) {
34
+ const rel = packRelativeFromDepositPath(declared);
35
+ const from = sourcePathForPackRelative(repoRoot, rel);
36
+ if (!existsSync(from)) {
37
+ continue;
38
+ }
39
+ if (!keepPackFile(from)) {
40
+ continue;
41
+ }
42
+ const to = join(destPackRoot, ...rel.split("/"));
43
+ mkdirSync(dirname(to), { recursive: true });
44
+ cpSync(from, to);
45
+ }
46
+ return declaration;
47
+ }
48
+ export function formatStagedDepositClosureLine(result) {
49
+ if (result.ok) {
50
+ return ("Deposit required-paths: ok -- " +
51
+ String(result.checked) +
52
+ " declared C1 path(s) exist in the staged pack.");
53
+ }
54
+ const sample = result.missing.slice(0, 5).join(", ");
55
+ const extra = result.missing.length > 5 ? " (+" + String(result.missing.length - 5) + " more)" : "";
56
+ return ("Deposit required-paths: fail -- " +
57
+ String(result.missing.length) +
58
+ " declared path(s) missing from staged pack. Examples: " +
59
+ sample +
60
+ extra +
61
+ ". " +
62
+ REMEDIATION);
63
+ }
64
+ export function evaluateStagedDepositClosure(packRoot, paths) {
65
+ const root = resolve(packRoot);
66
+ let isDir = false;
67
+ try {
68
+ isDir = statSync(root).isDirectory();
69
+ }
70
+ catch {
71
+ isDir = false;
72
+ }
73
+ if (!isDir) {
74
+ return {
75
+ code: EXIT_CONFIG,
76
+ message: "verify_deposit_closure: --pack-root is not a directory: " +
77
+ root +
78
+ "\n Recovery: pass a staged pack root or framework checkout.",
79
+ stream: "stderr",
80
+ missing: [],
81
+ checked: 0,
82
+ };
83
+ }
84
+ const result = evaluateDepositClosure({ packRoot: root, paths });
85
+ if (result.ok) {
86
+ return {
87
+ code: EXIT_OK,
88
+ message: formatStagedDepositClosureLine(result),
89
+ stream: "stdout",
90
+ missing: result.missing,
91
+ checked: result.checked,
92
+ };
93
+ }
94
+ return {
95
+ code: EXIT_MISSING,
96
+ message: formatStagedDepositClosureLine(result),
97
+ stream: "stderr",
98
+ missing: result.missing,
99
+ checked: result.checked,
100
+ };
101
+ }
102
+ export function evaluateDepositClosureFromRepo(repoRoot) {
103
+ const root = resolve(repoRoot);
104
+ const declarationPath = resolveDeclarationFile(root);
105
+ if (declarationPath === null) {
106
+ return {
107
+ code: EXIT_CONFIG,
108
+ message: "verify_deposit_closure: C1 declaration missing.\n Recovery: add content/contracts/deposit-required-paths.json (#3601 C1).",
109
+ stream: "stderr",
110
+ missing: [],
111
+ checked: 0,
112
+ };
113
+ }
114
+ const tmp = mkdtempSync(join(tmpdir(), "deft-3900-pack-"));
115
+ try {
116
+ const declaration = stageDeclaredPack(root, tmp);
117
+ return evaluateStagedDepositClosure(tmp, declaration.paths);
118
+ }
119
+ catch (err) {
120
+ const reason = err instanceof Error ? err.message : String(err);
121
+ return {
122
+ code: EXIT_CONFIG,
123
+ message: "verify_deposit_closure: " + reason + "\n " + REMEDIATION,
124
+ stream: "stderr",
125
+ missing: [],
126
+ checked: 0,
127
+ };
128
+ }
129
+ finally {
130
+ rmSync(tmp, { recursive: true, force: true });
131
+ }
132
+ }
133
+ export function evaluateDepositClosureAtRoot(root, packRootExplicit) {
134
+ if (packRootExplicit) {
135
+ const declarationPath = resolveDeclarationFile(root);
136
+ if (declarationPath === null) {
137
+ return {
138
+ code: EXIT_CONFIG,
139
+ message: "verify_deposit_closure: C1 declaration missing under the given pack root.\n Recovery: stage contracts/deposit-required-paths.json with the pack (#3601 C1).",
140
+ stream: "stderr",
141
+ missing: [],
142
+ checked: 0,
143
+ };
144
+ }
145
+ try {
146
+ const declaration = loadDepositRequiredDeclaration(declarationPath);
147
+ return evaluateStagedDepositClosure(root, declaration.paths);
148
+ }
149
+ catch (err) {
150
+ const reason = err instanceof Error ? err.message : String(err);
151
+ return {
152
+ code: EXIT_CONFIG,
153
+ message: "verify_deposit_closure: " + reason + "\n " + REMEDIATION,
154
+ stream: "stderr",
155
+ missing: [],
156
+ checked: 0,
157
+ };
158
+ }
159
+ }
160
+ return evaluateDepositClosureFromRepo(root);
161
+ }
162
+ //# sourceMappingURL=deposit-closure.js.map
@@ -5,10 +5,12 @@ export * from "./contained-writes.js";
5
5
  export * from "./content-manifest.js";
6
6
  export { CANONICAL_SCHEMA_REL, type ContractDriftOptions, type ContractDriftResult, evaluateContractDrift, PUBLISHED_SCHEMA_REL, } from "./contract-drift.js";
7
7
  export * from "./cursor-tier1.js";
8
+ export * from "./deposit-closure.js";
8
9
  export * from "./openclaw-tier1.js";
9
10
  export * from "./python-call-scan.js";
10
11
  export * from "./rule-ownership-lint.js";
11
12
  export * from "./scm-boundary.js";
13
+ export * from "./semantic-single-source.js";
12
14
  export * from "./skill-external-fetch-gate.js";
13
15
  export * from "./verify-stubs.js";
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -5,10 +5,12 @@ export * from "./contained-writes.js";
5
5
  export * from "./content-manifest.js";
6
6
  export { CANONICAL_SCHEMA_REL, evaluateContractDrift, PUBLISHED_SCHEMA_REL, } from "./contract-drift.js";
7
7
  export * from "./cursor-tier1.js";
8
+ export * from "./deposit-closure.js";
8
9
  export * from "./openclaw-tier1.js";
9
10
  export * from "./python-call-scan.js";
10
11
  export * from "./rule-ownership-lint.js";
11
12
  export * from "./scm-boundary.js";
13
+ export * from "./semantic-single-source.js";
12
14
  export * from "./skill-external-fetch-gate.js";
13
15
  export * from "./verify-stubs.js";
14
16
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * C2 — semantic single-source conformance (#3600 / #3899).
3
+ *
4
+ * Shipped guidance must name one value where the framework has one value.
5
+ * The 0.6-versus-0.8 defect lives inside a file that resolves perfectly, so
6
+ * pointer existence (C1) cannot see it. This oracle is not a link checker.
7
+ *
8
+ * Evaluates a staged pack root (flattened consumer deposit) or a source
9
+ * checkout (content/ prefix + root main.md). Three-state: 0 clean / 1 drift / 2 config.
10
+ */
11
+ /** Closed, typed current-authoring surfaces (#3600 AC / #3899 C2). */
12
+ export declare const C2_AUTHORING_SURFACES: readonly ["main.md", "skills/deft-directive-setup/SKILL.md", "skills/deft-directive-build/SKILL.md", "skills/deft-directive-interview/SKILL.md", "skills/deft-directive-refinement/SKILL.md", "skills/deft-directive-sync/SKILL.md", "templates/project.md.template", "templates/make-spec.md", "conventions/references.md", "commands.md"];
13
+ export type C2AuthoringSurface = (typeof C2_AUTHORING_SURFACES)[number];
14
+ export interface SemanticSingleSourceViolation {
15
+ readonly path: string;
16
+ readonly line: number;
17
+ readonly version: string;
18
+ readonly excerpt: string;
19
+ }
20
+ export interface SemanticSingleSourceResult {
21
+ readonly code: 0 | 1 | 2;
22
+ readonly message: string;
23
+ readonly stream: "stdout" | "stderr";
24
+ readonly setupWriteVersion: string | null;
25
+ readonly violations: readonly SemanticSingleSourceViolation[];
26
+ readonly currentWriteVersions: readonly string[];
27
+ }
28
+ /**
29
+ * Resolve a closed-list surface against a flattened pack root or a source
30
+ * checkout (content/ prefix for everything except root harness main.md).
31
+ */
32
+ export declare function resolveAuthoringSurface(packRoot: string, rel: string): string | null;
33
+ export declare function extractQuotedVersions(line: string): string[];
34
+ export declare function extractSetupWriteVersion(setupText: string): string | null;
35
+ export declare function evaluateSemanticSingleSource(packRoot: string): SemanticSingleSourceResult;
36
+ //# sourceMappingURL=semantic-single-source.d.ts.map