@holmes-lab/holmes-kit 0.35.25 → 0.36.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 (127) hide show
  1. package/CHANGELOG.md +346 -0
  2. package/README.md +3 -2
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/cli/approve-status.js +4 -1
  5. package/dist/holmes/cli/approve-watch.js +3 -1
  6. package/dist/holmes/cli/approve.d.ts +10 -0
  7. package/dist/holmes/cli/approve.js +31 -1
  8. package/dist/holmes/cli/claude-switches.d.ts +7 -1
  9. package/dist/holmes/cli/claude-switches.js +11 -7
  10. package/dist/holmes/cli/codex-toml.d.ts +3 -0
  11. package/dist/holmes/cli/codex-toml.js +2 -1
  12. package/dist/holmes/cli/doctor.d.ts +25 -1
  13. package/dist/holmes/cli/doctor.js +153 -7
  14. package/dist/holmes/cli/index.js +99 -4
  15. package/dist/holmes/cli/init.js +4 -3
  16. package/dist/holmes/cli/os-notify.d.ts +3 -1
  17. package/dist/holmes/cli/os-notify.js +10 -4
  18. package/dist/holmes/cli/review.d.ts +25 -0
  19. package/dist/holmes/cli/review.js +111 -0
  20. package/dist/holmes/cli/roles-readme.d.ts +11 -0
  21. package/dist/holmes/cli/roles-readme.js +38 -16
  22. package/dist/holmes/cli/roles.d.ts +12 -0
  23. package/dist/holmes/cli/roles.js +86 -0
  24. package/dist/holmes/cli/run.d.ts +65 -0
  25. package/dist/holmes/cli/run.js +308 -0
  26. package/dist/holmes/cli/runtime-binding.d.ts +30 -0
  27. package/dist/holmes/cli/runtime-binding.js +96 -7
  28. package/dist/holmes/cli/test-platform.d.ts +16 -0
  29. package/dist/holmes/cli/test-platform.js +31 -1
  30. package/dist/holmes/config/config.d.ts +49 -0
  31. package/dist/holmes/config/config.js +146 -3
  32. package/dist/holmes/config/project-caps.d.ts +21 -0
  33. package/dist/holmes/config/project-caps.js +114 -0
  34. package/dist/holmes/governance/approval-queue.d.ts +17 -3
  35. package/dist/holmes/governance/approval-queue.js +48 -6
  36. package/dist/holmes/governance/autonomy.d.ts +6 -0
  37. package/dist/holmes/governance/autonomy.js +21 -0
  38. package/dist/holmes/governance/push-gate-runner.d.ts +8 -0
  39. package/dist/holmes/governance/push-gate-runner.js +49 -1
  40. package/dist/holmes/governance/replica-id.d.ts +9 -0
  41. package/dist/holmes/governance/replica-id.js +44 -7
  42. package/dist/holmes/governance/role-policy.d.ts +41 -1
  43. package/dist/holmes/governance/role-policy.js +137 -20
  44. package/dist/holmes/governance/run-mode.d.ts +14 -0
  45. package/dist/holmes/governance/run-mode.js +120 -0
  46. package/dist/holmes/governance/tool-actions.d.ts +30 -0
  47. package/dist/holmes/governance/tool-actions.js +121 -0
  48. package/dist/holmes/guardrail/agent-launch-policy.d.ts +15 -0
  49. package/dist/holmes/guardrail/agent-launch-policy.js +177 -0
  50. package/dist/holmes/guardrail/classification-mode.d.ts +17 -0
  51. package/dist/holmes/guardrail/classification-mode.js +135 -0
  52. package/dist/holmes/guardrail/dynamic-write.d.ts +43 -0
  53. package/dist/holmes/guardrail/dynamic-write.js +304 -0
  54. package/dist/holmes/guardrail/phase.d.ts +2 -1
  55. package/dist/holmes/guardrail/phase.js +22 -8
  56. package/dist/holmes/guardrail/powershell-shell.d.ts +21 -0
  57. package/dist/holmes/guardrail/powershell-shell.js +801 -0
  58. package/dist/holmes/guardrail/refusal-codes.d.ts +24 -0
  59. package/dist/holmes/guardrail/refusal-codes.js +141 -0
  60. package/dist/holmes/guardrail/risk-classifier.d.ts +17 -0
  61. package/dist/holmes/guardrail/risk-classifier.js +242 -26
  62. package/dist/holmes/guardrail/risk-types.d.ts +15 -0
  63. package/dist/holmes/guardrail/run-plan-scope.d.ts +23 -0
  64. package/dist/holmes/guardrail/run-plan-scope.js +155 -0
  65. package/dist/holmes/guardrail/run-refusals.d.ts +116 -0
  66. package/dist/holmes/guardrail/run-refusals.js +348 -0
  67. package/dist/holmes/guardrail/run-stages.d.ts +67 -0
  68. package/dist/holmes/guardrail/run-stages.js +188 -0
  69. package/dist/holmes/guardrail/scope-judgment.d.ts +5 -1
  70. package/dist/holmes/guardrail/scope-judgment.js +8 -10
  71. package/dist/holmes/guardrail/scope-refusal-memory.d.ts +3 -0
  72. package/dist/holmes/guardrail/scope-refusal-memory.js +85 -0
  73. package/dist/holmes/guardrail/shell-words.js +7 -7
  74. package/dist/holmes/guardrail/write-target.d.ts +31 -2
  75. package/dist/holmes/guardrail/write-target.js +118 -16
  76. package/dist/holmes/hooks/adapters/antigravity.d.ts +1 -1
  77. package/dist/holmes/hooks/adapters/antigravity.js +6 -2
  78. package/dist/holmes/hooks/pre-tool-use.d.ts +55 -2
  79. package/dist/holmes/hooks/pre-tool-use.js +749 -89
  80. package/dist/holmes/hooks/session-start.js +5 -3
  81. package/dist/holmes/hooks/stop.d.ts +32 -0
  82. package/dist/holmes/hooks/stop.js +129 -4
  83. package/dist/holmes/mcp/handlers/graph-operations.js +5 -5
  84. package/dist/holmes/mcp/handlers/maintenance-analysis.js +2 -2
  85. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +2 -1
  86. package/dist/holmes/mcp/handlers/operator-inspection.js +3 -1
  87. package/dist/holmes/mcp/handlers/phase-queries.js +16 -1
  88. package/dist/holmes/mcp/handlers/requirement-triage.js +2 -2
  89. package/dist/holmes/mcp/handlers/spec-approval.d.ts +3 -3
  90. package/dist/holmes/mcp/handlers/spec-approval.js +54 -8
  91. package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +1 -0
  92. package/dist/holmes/mcp/handlers/spec-lifecycle.js +3 -3
  93. package/dist/holmes/mcp/handlers/spec-queries.d.ts +7 -0
  94. package/dist/holmes/mcp/handlers/spec-queries.js +5 -0
  95. package/dist/holmes/mcp/handlers/workspace-queries.js +2 -2
  96. package/dist/holmes/mcp/handlers.d.ts +2 -3
  97. package/dist/holmes/mcp/handlers.js +22 -2
  98. package/dist/holmes/mcp/harness-attestation.d.ts +2 -0
  99. package/dist/holmes/mcp/harness-attestation.js +3 -1
  100. package/dist/holmes/mcp/operator-recovery.d.ts +2 -0
  101. package/dist/holmes/mcp/operator-recovery.js +4 -3
  102. package/dist/holmes/mcp/server.js +9 -0
  103. package/dist/holmes/mcp/tool-schemas.js +6 -3
  104. package/dist/holmes/project/root.js +6 -1
  105. package/dist/holmes/project/run-records.d.ts +17 -0
  106. package/dist/holmes/project/run-records.js +126 -0
  107. package/dist/holmes/review/mrp.d.ts +35 -0
  108. package/dist/holmes/review/mrp.js +119 -0
  109. package/dist/holmes/review/verdicts.d.ts +117 -0
  110. package/dist/holmes/review/verdicts.js +345 -0
  111. package/dist/holmes/semantic/cloud-usage.d.ts +20 -0
  112. package/dist/holmes/semantic/cloud-usage.js +106 -0
  113. package/dist/holmes/semantic/embedder.d.ts +15 -6
  114. package/dist/holmes/semantic/embedder.js +84 -3
  115. package/dist/holmes/semantic/local-model.d.ts +21 -2
  116. package/dist/holmes/semantic/local-model.js +14 -3
  117. package/dist/holmes/semantic/tier.d.ts +25 -0
  118. package/dist/holmes/semantic/tier.js +86 -1
  119. package/dist/holmes/semantic/vector-cache.d.ts +1 -0
  120. package/dist/holmes/semantic/vector-cache.js +4 -1
  121. package/dist/holmes/spec/approval-blockers.d.ts +11 -1
  122. package/dist/holmes/spec/approval-blockers.js +70 -2
  123. package/dist/holmes/spec/renumber.d.ts +1 -1
  124. package/dist/holmes/spec/renumber.js +5 -2
  125. package/dist/holmes/spec/transition-policy.d.ts +5 -7
  126. package/dist/holmes/spec/transition-policy.js +17 -2
  127. package/package.json +1 -1
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.detectInstallMode = detectInstallMode;
37
37
  exports.buildSessionStartOutput = buildSessionStartOutput;
38
38
  exports.driftNudge = driftNudge;
39
- // @implements A-SPEC-531.2, A-SPEC-734
39
+ // @implements A-SPEC-531.2, A-SPEC-734, A-SPEC-476.1
40
40
  // The SessionStart banner hook. It emits the intro (+ optional update notice) as additionalContext,
41
41
  // which Claude Code delivers to BOTH the human transcript and the agent context — the "human and
42
42
  // agent" delivery REQ-531 asks for. The update refresh is a DETACHED, fire-and-forget child so the
@@ -205,10 +205,12 @@ if (require.main === module) {
205
205
  // again — a recurring advertisement for an opt-in feature is the noise class this project
206
206
  // removed the same day. Fail-open, exactly like the autonomy banner above it.
207
207
  try {
208
- const { resolveSemanticTier } = require('../semantic/tier');
208
+ const { resolveProjectSemanticTier } = require('../semantic/tier');
209
209
  const { tierAdviceLines, shouldInvite, markInvited } = require('../semantic/tier-advice');
210
+ const { resolveProjectRoot } = require('../project/root');
210
211
  const cwd = process.cwd();
211
- const tier = resolveSemanticTier();
212
+ // @implements A-SPEC-476.1 — the project's capped tier, read at its `.ax` root.
213
+ const tier = resolveProjectSemanticTier(resolveProjectRoot(cwd).root);
212
214
  if (shouldInvite(tier, cwd, (p) => fs.existsSync(p))) {
213
215
  const lines = tierAdviceLines(tier);
214
216
  if (lines.length > 0) {
@@ -114,6 +114,19 @@ export interface StopEvidence {
114
114
  * changed source files and still catches a file with no anchor at all.
115
115
  */
116
116
  unanchoredChangedSources?: string[];
117
+ /** @implements A-SPEC-166.3 — changed-source anchors naming a draft or missing spec; `undefined` is no signal. */
118
+ unapprovedChangedAnchors?: {
119
+ file: string;
120
+ id: string;
121
+ }[];
122
+ /** @implements A-SPEC-166.3 — a run or `classification.strict`: the findings above block (ART-1); else tracked. */
123
+ anchorStrict?: boolean;
124
+ /** @implements A-SPEC-102.3 — in a run, the run's range whose review gate fails; absent is no signal. */
125
+ reviewGate?: {
126
+ base: string;
127
+ head: string;
128
+ reasons: string[];
129
+ };
117
130
  /**
118
131
  * @implements A-SPEC-453
119
132
  * Spec ids approved in the working tree with NO `spec-approved` record in the ledger — ART-5's
@@ -183,6 +196,25 @@ export declare function changedAnchoredAspecs(root: string): string[] | undefine
183
196
  * which produces no violation. Failing closed here would block every ungoverned scratch directory.
184
197
  */
185
198
  export declare function unanchoredChangedSources(root: string): string[] | undefined;
199
+ /**
200
+ * @implements A-SPEC-166.3
201
+ * M3 at the turn boundary: the write gate judged the disk before the harness wrote, and other paths never met the gate.
202
+ * Every anchor on a changed source must name an approved spec; one naming a draft or a missing spec is a finding.
203
+ * `undefined` is no signal (as for ART-1); a file that cannot be read drops out rather than becoming a finding.
204
+ */
205
+ /**
206
+ * @implements A-SPEC-102.3 — the I/O half: in a run whose record carries `base`, the review gate over base..HEAD of the
207
+ * run's worktree. Nothing outside a run, without a base, at an unmoved HEAD, on a passing gate, or on any error.
208
+ */
209
+ export declare function runReviewGate(root: string, env: NodeJS.ProcessEnv, cwd?: string, sessionId?: string): {
210
+ base: string;
211
+ head: string;
212
+ reasons: string[];
213
+ } | undefined;
214
+ export declare function unapprovedChangedAnchors(root: string, specs: Spec[]): {
215
+ file: string;
216
+ id: string;
217
+ }[] | undefined;
186
218
  export interface DependencyReappraisal {
187
219
  file: string;
188
220
  aspecs: string[];
@@ -41,6 +41,8 @@ exports.collectDistFreshness = collectDistFreshness;
41
41
  exports.collectCiVerdicts = collectCiVerdicts;
42
42
  exports.changedAnchoredAspecs = changedAnchoredAspecs;
43
43
  exports.unanchoredChangedSources = unanchoredChangedSources;
44
+ exports.runReviewGate = runReviewGate;
45
+ exports.unapprovedChangedAnchors = unapprovedChangedAnchors;
44
46
  exports.dependencyReappraisals = dependencyReappraisals;
45
47
  exports.reappraisalWarningLine = reappraisalWarningLine;
46
48
  exports.escalateReappraisals = escalateReappraisals;
@@ -63,7 +65,7 @@ exports.collectForbiddenEdgeJudgement = collectForbiddenEdgeJudgement;
63
65
  exports.stopSharedScan = stopSharedScan;
64
66
  exports.scanCodeCycles = scanCodeCycles;
65
67
  exports.writeGuardCount = writeGuardCount;
66
- // @implements A-SPEC-734, A-SPEC-772.1, A-SPEC-770.3, A-SPEC-770.7
68
+ // @implements A-SPEC-734, A-SPEC-772.1, A-SPEC-770.3, A-SPEC-770.7, A-SPEC-774.21, A-SPEC-778.1, A-SPEC-476.1
67
69
  // @implements A-SPEC-769.9, A-SPEC-769.10, A-SPEC-769.11
68
70
  const fs = __importStar(require("node:fs"));
69
71
  // @implements A-SPEC-549.3 — evaluateStop's messages are English here; the Hangul-absence guard
@@ -273,8 +275,8 @@ function collectSemanticCoverage(root, tier) {
273
275
  // shipped default — zero egress, never opted in — was told "not run" on EVERY turn about a
274
276
  // layer it never asked for. Found by a consumer-shape probe before release, not by the suite,
275
277
  // because the not-adopted case was exercised through a verdict object the consumer never has.
276
- const { resolveSemanticTier } = require('../semantic/tier');
277
- const t = tier ?? resolveSemanticTier();
278
+ const { resolveProjectSemanticTier } = require('../semantic/tier');
279
+ const t = tier ?? resolveProjectSemanticTier(root); // @implements A-SPEC-476.1
278
280
  if (t.tier === 'none')
279
281
  return '';
280
282
  const { readCoverageState, coverageStopLine } = require('../semantic/vector-coverage');
@@ -428,6 +430,76 @@ function unanchoredChangedSources(root) {
428
430
  }
429
431
  return out;
430
432
  }
433
+ /**
434
+ * @implements A-SPEC-166.3
435
+ * M3 at the turn boundary: the write gate judged the disk before the harness wrote, and other paths never met the gate.
436
+ * Every anchor on a changed source must name an approved spec; one naming a draft or a missing spec is a finding.
437
+ * `undefined` is no signal (as for ART-1); a file that cannot be read drops out rather than becoming a finding.
438
+ */
439
+ /**
440
+ * @implements A-SPEC-102.3 — the I/O half: in a run whose record carries `base`, the review gate over base..HEAD of the
441
+ * run's worktree. Nothing outside a run, without a base, at an unmoved HEAD, on a passing gate, or on any error.
442
+ */
443
+ function runReviewGate(root, env, cwd, sessionId) {
444
+ let mode;
445
+ try {
446
+ const { runMode } = require('../governance/run-mode');
447
+ mode = runMode(env, root, cwd, sessionId);
448
+ }
449
+ catch {
450
+ return undefined;
451
+ } // whether this is a run cannot be read: as an interactive session
452
+ if (!mode.run)
453
+ return undefined;
454
+ // @implements A-SPEC-774.21 — in a run, a gate that cannot judge blocks, naming what it could not read.
455
+ const cannot = (what, base = '?', head = '?') => ({ base, head, reasons: [`the review gate could not judge this run: ${what}`] });
456
+ try {
457
+ if (!mode.id)
458
+ return cannot('the run has no id');
459
+ const { listRuns, mainCheckoutOf } = require('../project/run-records');
460
+ const rec = listRuns(mainCheckoutOf(root)).find((r) => r.run_id === mode.id);
461
+ if (!rec)
462
+ return cannot(`no run record for ${mode.id}`);
463
+ if (typeof rec.base !== 'string' || rec.base === '')
464
+ return cannot('run record carries no base');
465
+ const { gateRange, resolveRange } = require('../review/verdicts');
466
+ const range = resolveRange(rec.worktree, rec.base, 'HEAD');
467
+ if ('error' in range)
468
+ return cannot(`the range ${rec.base}..HEAD does not resolve (${range.error})`, rec.base);
469
+ if (range.head === range.base)
470
+ return undefined;
471
+ const g = gateRange(rec.worktree, range.base, range.head, {});
472
+ return g.ok ? undefined : { base: range.base, head: range.head, reasons: g.reasons };
473
+ }
474
+ catch (e) {
475
+ return cannot(e instanceof Error ? e.message : String(e));
476
+ }
477
+ }
478
+ function unapprovedChangedAnchors(root, specs) {
479
+ const SOURCE = /\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs|py|go|rs|java|kt|cs|rb|php|swift)$/;
480
+ const VENDORED = /^(?:reference|node_modules|dist|build|vendor|third_party)\//;
481
+ const paths = workTreePaths(root);
482
+ if (paths === null)
483
+ return undefined;
484
+ const { anchorSpecIds, stripStringLiterals } = require('../rtm/anchor-ids');
485
+ const approved = new Set(specs.filter((s) => s.status === 'approved').map((s) => s.id));
486
+ const out = [];
487
+ for (const rel of [...paths].sort()) {
488
+ if (!SOURCE.test(rel) || VENDORED.test(rel))
489
+ continue;
490
+ let text;
491
+ try {
492
+ text = readRegularText(path.join(root, rel));
493
+ }
494
+ catch {
495
+ continue;
496
+ }
497
+ for (const id of new Set(anchorSpecIds(stripStringLiterals(text))))
498
+ if (!approved.has(id))
499
+ out.push({ file: rel, id });
500
+ }
501
+ return out;
502
+ }
431
503
  const REAPPRAISAL_VENDORED = /^(?:reference|node_modules|dist|build|vendor|third_party)\//;
432
504
  function depLangOf(rel) {
433
505
  if (/\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/.test(rel))
@@ -848,6 +920,26 @@ function evaluateStop(specs, evidence) {
848
920
  problems.push(`[ART-1] ${detail}`);
849
921
  structured.push({ article: 'ART-1', detail });
850
922
  }
923
+ // @implements A-SPEC-166.3 — the turn-boundary re-check of changed anchors: blocking in a run or under strict,
924
+ // a tracked line otherwise (the owner principle: interactive use keeps its 0.35.25 verdicts).
925
+ const unapprovedAnchorDetails = (evidence?.unapprovedChangedAnchors ?? []).map((f) => `${f.file}: its anchor names ${f.id}, which is not approved — approve it, or re-anchor through the write gate`);
926
+ if (evidence?.anchorStrict) {
927
+ for (const detail of unapprovedAnchorDetails) {
928
+ problems.push(`[ART-1] ${detail}`);
929
+ structured.push({ article: 'ART-1', detail });
930
+ }
931
+ }
932
+ else if (unapprovedAnchorDetails.length > 0) {
933
+ tracked = [...(tracked ?? []), ...unapprovedAnchorDetails.map((detail) => ({ article: 'ART-1', detail }))];
934
+ }
935
+ // @implements A-SPEC-102.3 — a run's work is done only with an independent passing review of its range.
936
+ if (evidence?.reviewGate) {
937
+ const g = evidence.reviewGate;
938
+ const detail = `the run's commits ${g.base}..${g.head} are not reviewed (${g.reasons.join('; ')}) — an independent reviewer records a verdict with `
939
+ + `holmes-kit review record --base ${g.base} --head ${g.head} --verdict pass`;
940
+ problems.push(`[ART-7] ${detail}`);
941
+ structured.push({ article: 'ART-7', detail });
942
+ }
851
943
  // @implements A-SPEC-453 — ART-5's second enforcement point. The seal is forgeable; the record
852
944
  // of the approving act is not.
853
945
  for (const id of evidence?.unrecordedApprovals ?? []) {
@@ -868,6 +960,8 @@ function evaluateStop(specs, evidence) {
868
960
  .concat(evidence?.provenance && !evidence.provenance.ok ? ['ART-2'] : [])
869
961
  .concat(evidence?.findingsUnreadable ? ['ART-7'] : [])
870
962
  .concat((evidence?.unanchoredChangedSources ?? []).length > 0 ? ['ART-1'] : [])
963
+ .concat(evidence?.anchorStrict && (evidence?.unapprovedChangedAnchors ?? []).length > 0 ? ['ART-1'] : [])
964
+ .concat(evidence?.reviewGate ? ['ART-7'] : [])
871
965
  .concat((evidence?.unrecordedApprovals ?? []).length > 0 ? ['ART-5'] : [])
872
966
  .concat((evidence?.rolledBackLedgers ?? []).length > 0 ? ['ART-2'] : []))];
873
967
  return {
@@ -1561,6 +1655,21 @@ if (require.main === module) {
1561
1655
  } // @implements A-SPEC-191 (§4a) — list() absorbs ENOENT; a throw means the ledger EXISTS and cannot be read, which must block, not launder
1562
1656
  // @implements A-SPEC-452 — collected here (I/O half) so evaluateStop stays pure.
1563
1657
  const unanchored = unanchoredChangedSources(stopProjectRoot());
1658
+ // @implements A-SPEC-166.3 — the same changed sources, asked whether their anchors name approved specs. The mode is
1659
+ // read here (I/O half): a run, or the owner's classification.strict. Any error leaves the signal absent.
1660
+ let unapprovedAnchors;
1661
+ let anchorStrict = false;
1662
+ try {
1663
+ unapprovedAnchors = unapprovedChangedAnchors(stopProjectRoot(), specs);
1664
+ const { runMode } = require('../governance/run-mode');
1665
+ anchorStrict = runMode(process.env, stopProjectRoot(), typeof input.cwd === 'string' ? input.cwd : undefined, typeof input.session_id === 'string' ? input.session_id : undefined).run
1666
+ || (0, config_1.loadConfig)(stopProjectRoot()).classification.strict;
1667
+ }
1668
+ catch {
1669
+ unapprovedAnchors = undefined;
1670
+ }
1671
+ // @implements A-SPEC-102.3 — in a run, the review gate over the run's range.
1672
+ const reviewGate = runReviewGate(stopProjectRoot(), process.env, typeof input.cwd === 'string' ? input.cwd : undefined, typeof input.session_id === 'string' ? input.session_id : undefined);
1564
1673
  // @implements A-SPEC-453
1565
1674
  const unrecorded = unrecordedApprovals(stopProjectRoot());
1566
1675
  // @implements A-SPEC-455
@@ -1678,7 +1787,7 @@ if (require.main === module) {
1678
1787
  pendingRequests = require('../governance/approval-queue').readQueue(stopProjectRoot()).pending;
1679
1788
  }
1680
1789
  catch { /* text only */ }
1681
- let out = evaluateStop(specs, { pendingRequests, testCasesByAspec, provenance, executedByAspec, findings, findingsUnreadable, unanchoredChangedSources: unanchored, unrecordedApprovals: unrecorded, rolledBackLedgers: rolledBack, redFirstMode, changedAspecs, outcomesByAspec, ...(knownDefects ? { knownDefects } : {}), ...(ci ? { ci } : {}), ...(dist ? { dist } : {}), ...(analysis ? { analysis } : {}), ...(semantic ? { semantic } : {}), ...(forbiddenEdges ? { forbiddenEdges } : {}), ...(cycles ? { cycles } : {}) });
1790
+ let out = evaluateStop(specs, { pendingRequests, testCasesByAspec, provenance, executedByAspec, findings, findingsUnreadable, unanchoredChangedSources: unanchored, ...(unapprovedAnchors ? { unapprovedChangedAnchors: unapprovedAnchors, anchorStrict } : {}), ...(reviewGate ? { reviewGate } : {}), unrecordedApprovals: unrecorded, rolledBackLedgers: rolledBack, redFirstMode, changedAspecs, outcomesByAspec, ...(knownDefects ? { knownDefects } : {}), ...(ci ? { ci } : {}), ...(dist ? { dist } : {}), ...(analysis ? { analysis } : {}), ...(semantic ? { semantic } : {}), ...(forbiddenEdges ? { forbiddenEdges } : {}), ...(cycles ? { cycles } : {}) });
1682
1791
  // @implements A-SPEC-534.4 — track mode records ART-8 findings without blocking: surface them so
1683
1792
  // the operator observes RED-first gaps before an owner promotes the posture to strict.
1684
1793
  // @implements A-SPEC-559.2 — spec-evolution trigger (observe-first, NEVER blocks): a dirty
@@ -1719,6 +1828,18 @@ if (require.main === module) {
1719
1828
  }
1720
1829
  const guard = decideStopGuard(out.block, guardCountOrZero(sessionId));
1721
1830
  const persisted = writeGuardCount(sessionId, guard.nextCount);
1831
+ // @implements A-SPEC-778.1 — in a run, each blocked Stop goes on the run's log, and the cap yield stalls the run
1832
+ // there, so the orchestrator reads a stalled run instead of a turn that merely ended. Never touches the verdict.
1833
+ let stallLine = null;
1834
+ if (out.block) {
1835
+ try {
1836
+ const { recordRunStopBlock } = require('../guardrail/run-refusals');
1837
+ stallLine = recordRunStopBlock({ projectRoot: stopProjectRoot(), env: process.env, cwd: typeof input.cwd === 'string' ? input.cwd : undefined, sessionId }, out.articles ?? [], guard.capped || (guard.block && !persisted && input.stop_hook_active === true));
1838
+ }
1839
+ catch {
1840
+ stallLine = null;
1841
+ }
1842
+ }
1722
1843
  // @implements A-SPEC-769.2 — the stage line, only when the stages used at least half of the hook budget; a
1723
1844
  // clock fault is swallowed, because an observation never touches the verdict.
1724
1845
  clock.mark('evaluate');
@@ -1743,6 +1864,8 @@ if (require.main === module) {
1743
1864
  // State cannot persist -> the counter can never advance. Degrade to the stateless one-shot
1744
1865
  // guard instead of blocking forever: stop_hook_active means we already blocked once.
1745
1866
  process.stderr.write(`[Holmes-Kit] governance gate yielding (guard state unwritable, one-shot fallback) — issues remain UNRESOLVED:\n${out.reason ?? ''}\n`);
1867
+ if (stallLine)
1868
+ process.stderr.write(`${stallLine}\n`);
1746
1869
  process.exitCode = 0;
1747
1870
  return;
1748
1871
  }
@@ -1757,6 +1880,8 @@ if (require.main === module) {
1757
1880
  }
1758
1881
  else if (guard.capped) {
1759
1882
  process.stderr.write(`[Holmes-Kit] governance gate YIELDING after ${exports.MAX_CONSECUTIVE_BLOCKS} consecutive blocks — issues remain UNRESOLVED:\n${out.reason ?? ''}\n`);
1883
+ if (stallLine)
1884
+ process.stderr.write(`${stallLine}\n`);
1760
1885
  }
1761
1886
  // exitCode, NOT process.exit(): exit() tears the process down before large async stdout
1762
1887
  // writes flush — a >64KB block decision reached the hook runner as TRUNCATED (invalid) JSON
@@ -39,7 +39,7 @@ exports.warmRequirementSemanticCache = warmRequirementSemanticCache;
39
39
  exports.headOf = headOf;
40
40
  exports.refreshSemanticVectors = refreshSemanticVectors;
41
41
  exports.createGraphOperationsHandlers = createGraphOperationsHandlers;
42
- // @implements A-SPEC-719, A-SPEC-734, A-SPEC-741.1, A-SPEC-758.1, A-SPEC-688.1, A-SPEC-719.5, A-SPEC-719.8
42
+ // @implements A-SPEC-476.1, A-SPEC-719, A-SPEC-734, A-SPEC-741.1, A-SPEC-758.1, A-SPEC-688.1, A-SPEC-719.5, A-SPEC-719.8
43
43
  // @implements A-SPEC-614, A-SPEC-613, A-SPEC-100.2, A-SPEC-121.2, A-SPEC-128, A-SPEC-139, A-SPEC-189, A-SPEC-280, A-SPEC-282, A-SPEC-283, A-SPEC-419, A-SPEC-433, A-SPEC-469, A-SPEC-478, A-SPEC-568.1, A-SPEC-568.2, A-SPEC-569.1, A-SPEC-569.2, A-SPEC-569.3, A-SPEC-589
44
44
  // @implements A-SPEC-632
45
45
  const fs = __importStar(require("node:fs"));
@@ -52,7 +52,7 @@ const graph_store_1 = require("../../rtm/graph-store");
52
52
  const assoc_arm_1 = require("../../assoc/assoc-arm");
53
53
  const trace_gaps_1 = require("../../rtm/trace-gaps");
54
54
  // @implements A-SPEC-478 — the semantic tier runtime stays at the async reindex edge.
55
- const tier_1 = require("../../semantic/tier");
55
+ const tier_1 = require("../../semantic/tier"); // A-SPEC-476.1: the project-capped tier
56
56
  const vector_cache_1 = require("../../semantic/vector-cache");
57
57
  const embedder_1 = require("../../semantic/embedder");
58
58
  const unreadable_paths_1 = require("../../semantic/unreadable-paths");
@@ -100,7 +100,7 @@ function publishCurrentGraph(root, specs, scanned) {
100
100
  * could not embed — a discharge must not record the last one as done.
101
101
  */
102
102
  async function warmSemanticCache(root, scanned) {
103
- const tier = (0, tier_1.resolveSemanticTier)();
103
+ const tier = (0, tier_1.resolveProjectSemanticTier)(root);
104
104
  if (tier.tier === 'none')
105
105
  return { status: 'not-applicable', tier: 'none' };
106
106
  const configured = tier.model ? `${tier.tier}:${tier.model}` : tier.tier;
@@ -125,7 +125,7 @@ async function warmSemanticCache(root, scanned) {
125
125
  }
126
126
  /** Requirement prose is warmed only by the explicit reindex operation. */
127
127
  async function warmRequirementSemanticCache(root, specs) {
128
- const tier = (0, tier_1.resolveSemanticTier)();
128
+ const tier = (0, tier_1.resolveProjectSemanticTier)(root);
129
129
  if (tier.tier === 'none')
130
130
  return { status: 'not-applicable', tier: 'none' };
131
131
  const configured = tier.model ? `${tier.tier}:${tier.model}` : tier.tier;
@@ -165,7 +165,7 @@ function headOf(root) {
165
165
  * records SUPPRESSED rather than a failure, so an owner who turned it off is never shown a fault.
166
166
  */
167
167
  async function refreshSemanticVectors(root, env = process.env, warm = warmSemanticCache, scan) {
168
- const tier = (0, tier_1.resolveSemanticTier)();
168
+ const tier = (0, tier_1.resolveProjectSemanticTier)(root);
169
169
  if (tier.tier === 'none')
170
170
  return { lane: 'not-adopted' }; // never opted in: nothing transferred
171
171
  const at = new Date().toISOString();
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createMaintenanceAnalysisHandlers = createMaintenanceAnalysisHandlers;
37
- // @implements A-SPEC-745, A-SPEC-469.1, A-SPEC-469.2, A-SPEC-741, A-SPEC-741.1, A-SPEC-612, A-SPEC-100.2, A-SPEC-128, A-SPEC-189, A-SPEC-267, A-SPEC-268, A-SPEC-269, A-SPEC-277, A-SPEC-283, A-SPEC-290, A-SPEC-292, A-SPEC-293, A-SPEC-378, A-SPEC-388, A-SPEC-418, A-SPEC-478, A-SPEC-571.2, A-SPEC-573.4, A-SPEC-578.5, A-SPEC-734, A-SPEC-278.3
37
+ // @implements A-SPEC-476.1, A-SPEC-745, A-SPEC-469.1,A-SPEC-469.2, A-SPEC-741, A-SPEC-741.1, A-SPEC-612, A-SPEC-100.2, A-SPEC-128, A-SPEC-189, A-SPEC-267, A-SPEC-268, A-SPEC-269, A-SPEC-277, A-SPEC-283, A-SPEC-290, A-SPEC-292, A-SPEC-293, A-SPEC-378, A-SPEC-388, A-SPEC-418, A-SPEC-478, A-SPEC-571.2, A-SPEC-573.4, A-SPEC-578.5, A-SPEC-734, A-SPEC-278.3
38
38
  const fs = __importStar(require("node:fs"));
39
39
  const path = __importStar(require("node:path"));
40
40
  const node_child_process_1 = require("node:child_process");
@@ -143,7 +143,7 @@ function createMaintenanceAnalysisHandlers(context) {
143
143
  // (no tier, no module, no key, embed error) leaves `semantic` undefined = today's behavior.
144
144
  let semantic;
145
145
  try {
146
- const rt = (0, embedder_1.makeTierEmbedder)((0, tier_1.resolveSemanticTier)(), new vector_cache_1.VectorCache(root));
146
+ const rt = (0, embedder_1.makeTierEmbedder)((0, tier_1.resolveProjectSemanticTier)(root), new vector_cache_1.VectorCache(root)); // A-SPEC-476.1
147
147
  if (rt !== null) {
148
148
  const qv = await rt.embedQuery(a.request);
149
149
  semantic = { label: rt.label, queryVector: qv, cachedDocVector: rt.cachedDocVector };
@@ -5,7 +5,8 @@ import type { ApprovalStatus } from '../../spec/approval-status';
5
5
  /** The spec-approve request for one spec as the queue holds it now: its state and, when held, the operator's LATEST question. */
6
6
  export interface ApprovalRequestState {
7
7
  id: string;
8
- state: 'pending' | 'held' | 'granted' | 'consumed' | 'denied' | 'revoked';
8
+ /** @implements A-SPEC-779.3 — `withdrawn`: the run that filed it closed it; no operator decided it. */
9
+ state: 'pending' | 'held' | 'granted' | 'consumed' | 'denied' | 'revoked' | 'withdrawn';
9
10
  question?: string;
10
11
  reason?: string;
11
12
  ts?: string;
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.approvalRequestOf = approvalRequestOf;
37
37
  exports.nextActionOf = nextActionOf;
38
38
  exports.createOperatorInspectionHandlers = createOperatorInspectionHandlers;
39
- // @implements A-SPEC-605, A-SPEC-605.1
39
+ // @implements A-SPEC-605, A-SPEC-605.1, A-SPEC-779.3
40
40
  // @implements A-SPEC-642
41
41
  // @implements A-SPEC-631
42
42
  // @implements A-SPEC-768
@@ -92,6 +92,8 @@ function nextActionOf(described, request) {
92
92
  case 'held': return `held — the operator asks: ${request.question ?? '(no question recorded)'}. Resolve it in the spec or tests, then call spec_approve again.`;
93
93
  case 'denied': return `denied — ${request.reason ?? 'no reason recorded'}. Do not re-request the same act; report it to the user.`;
94
94
  case 'revoked': return `revoked — ${request.reason ?? 'no reason recorded'}. Do not re-request the same act; report it to the user.`;
95
+ // @implements A-SPEC-779.3
96
+ case 'withdrawn': return `withdrawn by the run that filed it — ${request.reason ?? 'no reason recorded'}. If the seal is still needed, spec_approve files a new request.`;
95
97
  case 'granted': return 'granted — call spec_approve now; the grant seals it.';
96
98
  case 'consumed': return 'the grant was consumed but this spec is not sealed — call spec_approve again, and report its refusal to the user if it refuses.';
97
99
  case 'pending': return "pending the operator's decision — wait, then call approval_status again; when sealed is true, retry spec_approve immediately.";
@@ -41,6 +41,8 @@ const fs = __importStar(require("node:fs"));
41
41
  const path = __importStar(require("node:path"));
42
42
  const phase_1 = require("../../guardrail/phase");
43
43
  const write_target_1 = require("../../guardrail/write-target");
44
+ const classification_mode_1 = require("../../guardrail/classification-mode");
45
+ const run_mode_1 = require("../../governance/run-mode");
44
46
  // @implements A-SPEC-735 — the whole corpus in one answer was 153,888 characters here, past what a
45
47
  // client accepts, so the overview could not be read. A bounded summary plus a stateless page.
46
48
  const PAGE_DEFAULT = 100;
@@ -160,7 +162,20 @@ function createPhaseQueryHandlers(context) {
160
162
  },
161
163
  async phase_check(a) {
162
164
  const specs = await context.listSpecs();
163
- const action = a.action ?? (0, phase_1.classifyAction)(a.target);
165
+ // @implements A-SPEC-775.1 — the advisory answers in the mode the hook judges in: a run or the owner's
166
+ // strict opt-in narrows test folders and makes unclassified writes code.
167
+ const bound = context.boundSpecsRoot();
168
+ let opts;
169
+ if (bound !== undefined) {
170
+ try {
171
+ const root = context.projectRootOf(bound);
172
+ opts = (0, classification_mode_1.classifyOptionsFor)(root, (0, run_mode_1.runMode)(process.env, root).run);
173
+ }
174
+ catch {
175
+ opts = undefined;
176
+ }
177
+ }
178
+ const action = a.action ?? (0, phase_1.classifyAction)(a.target, undefined, opts);
164
179
  if (!action)
165
180
  return { decision: 'allow', note: 'unclassified target' };
166
181
  return (0, phase_1.phaseCheck)(action, { specs, targetAspecId: a.targetAspecId });
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.TRIAGE_WAIT_MAX_MS = exports.TRIAGE_WAIT_MS = void 0;
37
37
  exports.triageWaitMsFrom = triageWaitMsFrom;
38
38
  exports.createRequirementTriageHandlers = createRequirementTriageHandlers;
39
- // @implements A-SPEC-743, A-SPEC-742, A-SPEC-729, A-SPEC-723, A-SPEC-719, A-SPEC-734, A-SPEC-723.1
39
+ // @implements A-SPEC-743, A-SPEC-742, A-SPEC-729, A-SPEC-723, A-SPEC-719, A-SPEC-734, A-SPEC-723.1, A-SPEC-476.1
40
40
  // @implements A-SPEC-713
41
41
  /** Read-only MCP projection of the pure requirement lifecycle triage model. */
42
42
  const crypto = __importStar(require("node:crypto"));
@@ -204,7 +204,7 @@ function createRequirementTriageHandlers(context) {
204
204
  }
205
205
  for (const value of Object.values(lineageEvidence))
206
206
  value.implementationAnchors.sort();
207
- const tier = (0, tier_1.resolveSemanticTier)();
207
+ const tier = (0, tier_1.resolveProjectSemanticTier)(root); // A-SPEC-476.1
208
208
  // A-SPEC-719: the owner's transfer switch is lexical-only for triage too — the prompt is not
209
209
  // embedded (a cloud tier would send it out); the state reads as the owner-chosen not-adopted.
210
210
  // The switch may live in only one process's env (hooks and MCP servers see different envs), so a
@@ -42,6 +42,7 @@ export interface SpecApprovalContext {
42
42
  why: string;
43
43
  subject?: string;
44
44
  risk?: string;
45
+ title?: string;
45
46
  }): string;
46
47
  foreignRootReason(root?: string): string | null;
47
48
  /** @implements A-SPEC-732 — why no in-session route was offered (unattested server), or ''. */
@@ -64,9 +65,6 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
64
65
  ok: false;
65
66
  reason: string;
66
67
  findings: import("../../spec/validator").Finding[];
67
- candidate?: undefined;
68
- digest?: undefined;
69
- parentDigests?: undefined;
70
68
  } | {
71
69
  ok: boolean;
72
70
  reason: string;
@@ -92,6 +90,8 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
92
90
  blockers?: undefined;
93
91
  approvalIntent?: undefined;
94
92
  } | {
93
+ ancestorWarning?: string | undefined;
94
+ scaffoldWarning?: string | undefined;
95
95
  dismissUnknown?: string[] | undefined;
96
96
  advisoryHistory?: import("../../rtm/advisory-outcomes").AdvisoryState[] | undefined;
97
97
  advisoryIds?: Partial<Record<string, string>> | undefined;
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createSpecApprovalHandlers = createSpecApprovalHandlers;
37
37
  exports.readProjectFile = readProjectFile;
38
- // @implements A-SPEC-718.3, A-SPEC-770.6, A-SPEC-718.1,A-SPEC-718.2, A-SPEC-718, A-SPEC-551.1, A-SPEC-551.2, A-SPEC-627.1, A-SPEC-622, A-SPEC-100.2, A-SPEC-128, A-SPEC-132, A-SPEC-133, A-SPEC-151, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245, A-SPEC-729
38
+ // @implements A-SPEC-182.3, A-SPEC-718.3, A-SPEC-770.6, A-SPEC-718.1,A-SPEC-718.2, A-SPEC-718, A-SPEC-551.1, A-SPEC-551.2, A-SPEC-627.1, A-SPEC-622, A-SPEC-100.2, A-SPEC-128, A-SPEC-132, A-SPEC-133, A-SPEC-151, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245, A-SPEC-729
39
39
  // @implements A-SPEC-631, A-SPEC-733
40
40
  const fs = __importStar(require("node:fs"));
41
41
  const compat_impact_1 = require("../../spec/compat-impact");
@@ -45,6 +45,7 @@ const transition_policy_1 = require("../../spec/transition-policy");
45
45
  const validator_1 = require("../../spec/validator");
46
46
  const elicit_approval_1 = require("../elicit-approval");
47
47
  const autonomy_1 = require("../../governance/autonomy");
48
+ const config_1 = require("../../config/config");
48
49
  const write_target_1 = require("../../guardrail/write-target");
49
50
  const delegation_1 = require("../../governance/delegation"); // @implements A-SPEC-771
50
51
  const approval_grants_1 = require("../../governance/approval-grants");
@@ -96,6 +97,8 @@ function createSpecApprovalHandlers(context) {
96
97
  // @implements A-SPEC-532.4 — the declared direction of a gate change sealed without the owner (said in the ledger).
97
98
  let sealedDirection = '';
98
99
  let subject;
100
+ // @implements A-SPEC-770.12 — the title the operator reads beside the request id.
101
+ let title;
99
102
  // @implements A-SPEC-732 (round 2) — the digest a person or the autonomy grade decided on; the
100
103
  // seal must be built from that same content.
101
104
  let decidedSubject;
@@ -118,13 +121,14 @@ function createSpecApprovalHandlers(context) {
118
121
  const target = await store.read(a.id).catch(() => null);
119
122
  // @implements A-SPEC-649 — the digest of what the operator will read rides the request.
120
123
  subject = target ? (0, spec_digest_1.specDigest)(target.spec) : undefined;
124
+ title = target?.spec.title;
121
125
  if (target) {
122
126
  // @implements A-SPEC-551.2 — a spec no approval could seal as written is answered with WHY, before
123
127
  // any channel is chosen: no elicitation, no queue entry. Measured 2026-09-30: an invalid
124
128
  // breaking_change grade graded `hitl`, went to the owner's queue, and the refusal named the approval
125
129
  // channel instead of the blocker — the agent asked the owner for an approval that could not help.
126
130
  // Same predicate `approval_status.blockers` reports. A covered act (above) keeps its own order.
127
- const blockers = (0, approval_blockers_1.approvalBlockers)(target.spec, resolver(await store.list()));
131
+ const blockers = (0, approval_blockers_1.approvalBlockers)(target.spec, resolver(await store.list()), { scaffold: scaffoldStrictFor(context.projectRootOf, a.root ?? store.specsRoot) }); // A-SPEC-182.2
128
132
  if (blockers.length > 0) {
129
133
  return {
130
134
  ok: false,
@@ -189,7 +193,21 @@ function createSpecApprovalHandlers(context) {
189
193
  })();
190
194
  if (noIntake)
191
195
  risk = 'hitl';
192
- if (autonomyOn && risk === 'hitl') {
196
+ // @implements A-SPEC-532.6 — the owner's ceiling binds every automatic seal, the delegation included: above it,
197
+ // the seal is the operator's and is routed like any operator-graded seal (dialog or queue).
198
+ let ceilingNote = null;
199
+ if (autonomyOn && autonomyRoot !== undefined) {
200
+ const ceiling = (0, config_1.loadConfig)(autonomyRoot).autonomy.ceiling;
201
+ const why = (0, autonomy_1.ceilingRefusal)(ceiling, target.spec, below);
202
+ if (why !== null) {
203
+ risk = 'hitl';
204
+ ceilingNote = `\n[autonomy: the owner's ceiling "${ceiling}" keeps this seal with the operator — ${why}]`;
205
+ }
206
+ }
207
+ if (ceilingNote !== null) {
208
+ autonomyNote = ceilingNote;
209
+ }
210
+ else if (autonomyOn && risk === 'hitl') {
193
211
  const rule = noIntake ? 'requirement-without-intake' : (0, autonomy_1.specApprovalAutonomyReason)(target.spec, resolver([target.spec]), below);
194
212
  if (rule !== null) {
195
213
  autonomyNote = `\n[autonomy: this seal is the operator's — ${rule} (${(0, autonomy_1.autonomyRuleMeaning)(rule)})]`;
@@ -277,7 +295,7 @@ function createSpecApprovalHandlers(context) {
277
295
  }
278
296
  return { ok: false, reason: (elicitExpiredMs !== undefined ? (0, elicit_approval_1.expiredNotice)(elicitExpiredMs) : '') + refusedGrants + (context.approvalRouteNote?.() ?? '') + autonomyNote
279
297
  + 'spec_approve requires an out-of-band HOLMES_APPROVAL that COVERS this act — a request-payload approval is not a channel, and an expired or elsewhere-scoped token does not open this door (scoped approvals need kind "spec-approve"). (fail-closed)'
280
- + context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', ...(subject ? { subject } : {}), ...(risk ? { risk } : {}) }) };
298
+ + context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', ...(subject ? { subject } : {}), ...(risk ? { risk } : {}), ...(title ? { title } : {}) }) };
281
299
  }
282
300
  // @implements A-SPEC-188 — destination BEFORE seal.
283
301
  // The old order (seal at :481, resolve the ledger at :483) produced both measured harms: a
@@ -360,14 +378,14 @@ function createSpecApprovalHandlers(context) {
360
378
  // Measured 2026-09-14: a grant read against "Original title" sealed "CHANGED after the grant".
361
379
  if (cur && decidedSubject !== undefined && (0, spec_digest_1.specDigest)(cur.spec) !== decidedSubject) {
362
380
  return { ok: false, reason: `spec_approve: ${a.id} changed after the decision was made — the content decided on is not the content that would be sealed. Nothing was sealed; ask again.`
363
- + context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', subject: (0, spec_digest_1.specDigest)(cur.spec) }) };
381
+ + context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', subject: (0, spec_digest_1.specDigest)(cur.spec), title: cur.spec.title }) };
364
382
  }
365
383
  if (cur && approveResolved.source === 'grant') {
366
384
  const bound = approveResolved.approval;
367
385
  if (typeof bound.subject === 'string' && bound.subject !== '' && bound.subject !== (0, spec_digest_1.specDigest)(cur.spec)) {
368
386
  const current = (0, spec_digest_1.specDigest)(cur.spec);
369
387
  return { ok: false, reason: `[grant ${bound.nonce ?? '?'} refused: stale-subject] the grant was minted for another content of ${a.id}; the operator must read the current content and decide again (revoke the stale grant with ${(0, npx_bin_1.holmesKitCommand)(a.root)} approve --revoke).`
370
- + context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', subject: current }) };
388
+ + context.refusalQueueHint(a.root, { kind: 'spec-approve', target: a.id, why: '스펙 봉인 승인', subject: current, title: cur.spec.title }) };
371
389
  }
372
390
  }
373
391
  // @implements A-SPEC-536.1 — BUG-1: a spec whose YAML is broken is dropped by read()/list(),
@@ -380,9 +398,21 @@ function createSpecApprovalHandlers(context) {
380
398
  return { ok: false, reason: (0, spec_store_1.notFoundReason)(a.id, unreadable) };
381
399
  }
382
400
  const spec = cur.spec;
383
- const prepared = (0, transition_policy_1.prepareApprovedSpec)(spec, specs, resolver, (rel) => (a.root ? readProjectFile(a.root, rel) : null));
401
+ // @implements A-SPEC-182.2 — scaffold bodies refuse the seal in a run or under strict; interactively it proceeds
402
+ // and the result names them.
403
+ const scaffoldStrict = scaffoldStrictFor(context.projectRootOf, a.root ?? store.specsRoot);
404
+ const prepared = (0, transition_policy_1.prepareApprovedSpec)(spec, specs, resolver, (rel) => (a.root ? readProjectFile(a.root, rel) : null), { scaffold: scaffoldStrict ? 'refuse' : 'allow', ancestors: scaffoldStrict ? 'refuse' : 'allow' });
384
405
  if (!prepared.ok)
385
406
  return prepared;
407
+ // @implements A-SPEC-182.3 — an ancestor above the parents that is not approved: refused in a run or under strict
408
+ // (above); interactively sealed as in 0.35.25 and named in the result.
409
+ const ancestorWarning = prepared.ancestorWarnings
410
+ ? `${prepared.ancestorWarnings.join('; ')} — sealed; a run or classification.strict refuses this`
411
+ : undefined;
412
+ const scaffoldLeft = scaffoldStrict ? [] : (0, approval_blockers_1.scaffoldSections)(prepared.candidate);
413
+ const scaffoldWarning = scaffoldLeft.length > 0
414
+ ? `${scaffoldLeft.join(', ')} still hold the spec_slice_init scaffold — sealed; a run or classification.strict refuses this`
415
+ : undefined;
386
416
  const { candidate, digest } = prepared;
387
417
  const priorDigest = (0, spec_digest_1.sealOf)(spec).approvedDigest;
388
418
  // @implements A-SPEC-188 — the seal is written only at the version this act READ. On
@@ -619,7 +649,8 @@ function createSpecApprovalHandlers(context) {
619
649
  return { approved: a.id, digest, ...(impactAdvisory ? { impactAdvisory } : {}), ...(anchorDensity ? { anchorDensity } : {}),
620
650
  ...(impactGraph ? { impactGraph } : {}), ...(impactAdvisoryUnavailable ? { impactAdvisoryUnavailable } : {}),
621
651
  ...(fttFulfilment ? { fttFulfilment } : {}), ...(killsAdvisory ? { killsAdvisory } : {}),
622
- ...(advisoryIds ? { advisoryIds } : {}), ...(advisoryHistory ? { advisoryHistory } : {}), ...(dismissUnknown ? { dismissUnknown } : {}) };
652
+ ...(advisoryIds ? { advisoryIds } : {}), ...(advisoryHistory ? { advisoryHistory } : {}), ...(dismissUnknown ? { dismissUnknown } : {}),
653
+ ...(scaffoldWarning ? { scaffoldWarning } : {}), ...(ancestorWarning ? { ancestorWarning } : {}) };
623
654
  },
624
655
  /**
625
656
  * Pin a REQ's citations: compute the content digest of every cited source that resolves inside
@@ -706,6 +737,21 @@ function createSpecApprovalHandlers(context) {
706
737
  };
707
738
  }
708
739
  /** Largest Files-to-Touch file the approval act reads (A-SPEC-733 round 3). */
740
+ /**
741
+ * @implements A-SPEC-182.2 — whether this seal is judged in a run or under classification.strict, where a
742
+ * spec_slice_init scaffold body refuses it. A root that cannot be resolved still sees a run named in the environment.
743
+ */
744
+ function scaffoldStrictFor(projectRootOf, root) {
745
+ if (typeof root === 'string' && root !== '') {
746
+ try {
747
+ const r = projectRootOf(root);
748
+ const { runMode } = require('../../governance/run-mode');
749
+ return runMode(process.env, r).run || (0, config_1.loadConfig)(r).classification.strict;
750
+ }
751
+ catch { /* fall through to the environment */ }
752
+ }
753
+ return typeof process.env.HOLMES_RUN_ID === 'string' && process.env.HOLMES_RUN_ID.trim() !== '';
754
+ }
709
755
  const PROJECT_READ_LIMIT = 2 * 1024 * 1024;
710
756
  /**
711
757
  * @implements A-SPEC-733 (round 3) — the approval act reads a Files-to-Touch path only when it is a
@@ -22,6 +22,7 @@ export interface SpecLifecycleContext {
22
22
  kind: string;
23
23
  target: string;
24
24
  why: string;
25
+ title?: string;
25
26
  }): string;
26
27
  }
27
28
  export declare function createSpecLifecycleHandlers(context: SpecLifecycleContext): {