@holmes-lab/holmes-kit 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/README.md +2 -1
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve.d.ts +14 -0
- package/dist/holmes/cli/approve.js +60 -3
- package/dist/holmes/cli/gitignore-merge.js +5 -0
- package/dist/holmes/cli/index.js +13 -1
- package/dist/holmes/governance/approval-queue.d.ts +39 -0
- package/dist/holmes/governance/approval-queue.js +105 -10
- package/dist/holmes/governance/session-context.d.ts +74 -0
- package/dist/holmes/governance/session-context.js +179 -0
- package/dist/holmes/hooks/pre-tool-use.js +5 -2
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -0
- package/dist/holmes/hooks/rtm-refresh-child.js +56 -0
- package/dist/holmes/hooks/rtm-refresh.d.ts +13 -0
- package/dist/holmes/hooks/rtm-refresh.js +76 -0
- package/dist/holmes/hooks/stop.js +42 -0
- package/dist/holmes/mcp/handlers.d.ts +5 -6
- package/dist/holmes/mcp/handlers.js +76 -2
- package/dist/holmes/mcp/server.js +12 -0
- package/dist/holmes/mcp/tool-schemas.js +1 -1
- package/dist/holmes/review/judgement-bundle.d.ts +49 -0
- package/dist/holmes/review/judgement-bundle.js +108 -0
- package/dist/holmes/review/run-replay.d.ts +5 -0
- package/dist/holmes/review/run-replay.js +32 -0
- package/dist/holmes/review/test-outcomes.d.ts +17 -2
- package/dist/holmes/review/test-outcomes.js +54 -15
- package/dist/holmes/rtm/impact-advisory.d.ts +48 -0
- package/dist/holmes/rtm/impact-advisory.js +175 -0
- package/dist/holmes/rtm/localize.js +7 -0
- package/dist/holmes/rtm/rtm-builder.d.ts +8 -0
- package/dist/holmes/rtm/rtm-builder.js +42 -1
- package/dist/holmes/rtm/rtm-graph.d.ts +16 -1
- package/dist/holmes/rtm/rtm-graph.js +34 -6
- package/dist/holmes/spec/approval-blockers.js +8 -0
- package/dist/holmes/spec/compat-impact.d.ts +31 -0
- package/dist/holmes/spec/compat-impact.js +141 -0
- package/dist/holmes/spec/spec-types.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,102 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
<!-- @implements A-SPEC-209 -->
|
|
8
|
+
## [0.16.0] - 2026-09-07
|
|
9
|
+
|
|
10
|
+
The graph learns to speak intent, and the call graph learns to speak up at sealing time. An A-SPEC
|
|
11
|
+
approval now returns what your Files-to-Touch declaration *missed* — and every spec the graph
|
|
12
|
+
names arrives with its one-sentence intent beside the id, extracted (never generated) from the
|
|
13
|
+
spec store. Two more mechanisms were benchmarked under pre-registration and honestly discarded.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **Impact advisory on approval (REQ-566)** — a successful A-SPEC `spec_approve` may now carry
|
|
17
|
+
`impactAdvisory`: files whose symbols **call into** the declared Files-to-Touch but sit outside
|
|
18
|
+
the declaration (1-hop, capped at 10, repo-relative allow-list). Advisory, never verdict: it
|
|
19
|
+
rides the response *after* the seal is committed, degrades to absence on any failure, and every
|
|
20
|
+
emission lands in an observation ledger (`.ax/ledger/impact-advisories.<replica>.jsonl` — paths,
|
|
21
|
+
ids and integers only) so its false-positive rate is measured *before* anyone proposes a hard
|
|
22
|
+
gate. The RTM graph persists at `.ax/rtm.sqlite` and keeps itself fresh: `rtm_impact` rebuilds
|
|
23
|
+
on basis drift, and the Stop hook spawns a TTL-gated detached reindex (staleness was measured as
|
|
24
|
+
the advisory's quality factor: 7 findings on an 8-day-old graph, 17 after a fresh one).
|
|
25
|
+
- **SPEC intent summaries in the graph (REQ-568)** — graph nodes gain a `summary` column (schema
|
|
26
|
+
`rtm-graph/2` → `/3`; old stores rebuild automatically on first use, no migration step). Every
|
|
27
|
+
SPEC node stores `"<title> — <first sentence of its intent section>"`, extracted
|
|
28
|
+
deterministically (REQ=Problem / Need, H-SPEC=Intent, A-SPEC=Objective; 200-char cap; title-less
|
|
29
|
+
legacy specs — 20 measured in this very store — fall back to sentence, then id). Same store,
|
|
30
|
+
byte-identical graph; measured cost +6.4% build time / +4.2% file size. `RtmGraph.summaryOf(id)`
|
|
31
|
+
reads it back, and `rtm_impact` responses add `impactedSummaries: [{id, summary}]` beside the
|
|
32
|
+
unchanged `impacted` list.
|
|
33
|
+
- **Session-context observability (REQ-564)** — the ledger records which agent/model drove a
|
|
34
|
+
session and what the governance overhead cost, per replica
|
|
35
|
+
(`.ax/ledger/session-context.<replica>.jsonl`), grounding field reports in machine attribution.
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
- **`impactAdvisory.files[].anchors` shape (REQ-568, code-interface)** — anchors are now
|
|
39
|
+
`[{id, summary}]` instead of `string[]`, so the reader sees *which intent* is at risk without a
|
|
40
|
+
spec-store round trip. Consumers parsing anchors must read `.id`. The summary is information
|
|
41
|
+
only: value tests pin that the advisory's file list, ordering and `more` count are independent
|
|
42
|
+
of the prose, and the observation ledger stays prose-free.
|
|
43
|
+
|
|
44
|
+
### Notes
|
|
45
|
+
- Two pre-registered negatives, kept as records rather than shipped: the judgement-axis
|
|
46
|
+
FACT/EVIDENCE bundle tied its bench (0.480 vs 0.478) and was discarded with its re-attempt
|
|
47
|
+
conditions sealed (REQ-567, 15th rejection); a spec-intent **vector assist** for uncited
|
|
48
|
+
requests was built, measured byte-identical to the lexical path over 441 held-out traceability
|
|
49
|
+
cases (long queries already match ~371 specs lexically; the lexical-zero segment is protected by
|
|
50
|
+
the reorder-not-admit rule), reverted, and its A/T-SPECs retired (REQ-568 S3, 16th rejection).
|
|
51
|
+
The S-491 embedding win belongs to direct query→file ranking and does not transport through the
|
|
52
|
+
spec-matching layer.
|
|
53
|
+
|
|
54
|
+
## [0.15.0] - 2026-09-06
|
|
55
|
+
|
|
56
|
+
The first field report on Holmes-Kit's own operational data (1,412 unique approval requests vs. 8
|
|
57
|
+
decisions — a 99.4% write-only backlog) drove this release: the approval queue becomes a real
|
|
58
|
+
decision inbox, the field data itself gains machine attribution, and "did you consider all three
|
|
59
|
+
harnesses and all three OSes" stops being a habit and becomes a sealing gate.
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
- **Compatibility declaration gate (REQ-565)** — sealing an A-SPEC now requires two frontmatter
|
|
63
|
+
declarations, `harness_impact:` and `os_impact:` — either `'none: <real reason>'` or a full
|
|
64
|
+
3-cell mapping (`{claude, codex, agy}` / `{windows, mac, linux}`, verdicts
|
|
65
|
+
`supported|unavailable|n-a: <grounds>`). The duty lives on the **act of approval** (the
|
|
66
|
+
`breaking_change` shape), so already-approved specs are untouched; any spec that changes
|
|
67
|
+
re-approves and acquires the fields. A `none` claim is **cross-checked by machine**: Files to
|
|
68
|
+
Touch entries on the harness surface (`hooks/`, adapters, `cli/init|agents`, `mcp/server`)
|
|
69
|
+
contradict a harness `none`, and file contents carrying OS signals (`process.platform`,
|
|
70
|
+
`'win32'`, `spawn(`, `.ps1`) contradict an os `none` — a 3-cell mapping is exempt, because it
|
|
71
|
+
already faced the axis. `spec_slice_init` scaffolds both fields as TODO so authors meet them;
|
|
72
|
+
the gate refuses the untouched scaffold. The author-facing blocker list (`approvalBlockers`)
|
|
73
|
+
pre-announces everything the act would refuse — gate/act parity held by test.
|
|
74
|
+
- **`holmes-kit approve --refusals [N]` (REQ-563)** — a read-only view of what this machine's gate
|
|
75
|
+
refused lately (newest last), so the operator can find the id a deny message named and decide it.
|
|
76
|
+
- **Per-machine field data (REQ-562)** — test outcomes now record to
|
|
77
|
+
`test-outcomes.<replica>.jsonl` (the provenance replica convention) and merge with the legacy
|
|
78
|
+
file in timestamp order, so RED→GREEN sequences survive multi-machine histories; approval-queue
|
|
79
|
+
events carry a `replica` field (`unknown` for pre-existing events). A repo-local aggregator
|
|
80
|
+
(`src/tools/field-report`, **not shipped in the package**) turns the ledgers into gate-friction,
|
|
81
|
+
queue-health and RED-first metrics.
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
- **The approval queue is a decision inbox again (REQ-563)** — measured: 1,412 unique requests,
|
|
85
|
+
8 decisions, and the two real inbox items buried under 1,404 single-shot gate refusals nobody
|
|
86
|
+
ever meant to decide. Gate refusals (shell and unknown kinds) now land in a **local, per-replica
|
|
87
|
+
refusal log** (`.ax/approvals/refusals.<replica>.jsonl`, added to the managed gitignore — raw
|
|
88
|
+
commands never leave the machine, closing the public-repo exposure where 45% of tracked targets
|
|
89
|
+
carried absolute paths). Decision-seeking kinds (`spec-approve`, `config-write`,
|
|
90
|
+
`autonomy-grant`, `spec-reappraisal`) stay in the tracked queue. `approve <id>` falls back to
|
|
91
|
+
the refusal log, so the out-of-band shell approval path survives end to end (deny → approve →
|
|
92
|
+
allow, verified); re-opening after a decision is count-based (clock-free — a millisecond tie
|
|
93
|
+
was measured losing legitimate retries), and a hold's question now reaches the retry even for
|
|
94
|
+
refusal-log ids.
|
|
95
|
+
- **Fixture pollution of real field data (REQ-563)** — the adapter parity suite ran deny scenarios
|
|
96
|
+
against the repository root: 774 `rm -rf /` requested-events over ten days, the single largest
|
|
97
|
+
item in the first field report. The suite now uses governed tmp roots; measured after: a full
|
|
98
|
+
suite run adds **zero** events to the real ledgers.
|
|
99
|
+
|
|
100
|
+
### Notes
|
|
101
|
+
- Version bump is **minor** with two `gate-behavior` changes aboard; the release classifier
|
|
102
|
+
routes this to HITL by design. The compat gate applies to **newly sealed** A-SPECs only.
|
|
103
|
+
|
|
8
104
|
## [0.14.0] - 2026-09-06
|
|
9
105
|
|
|
10
106
|
Closes the gate's oldest blind spot: it judged *where* a change landed, never *what kind* of change it
|
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
- 🤖 **Autonomous Approval — three layers, always bounded** *(reworked in 0.13.0; foundation 0.8.0)*: for teams that want the agent to self-drive the SDLC, autonomy is a posture the agent holds at two scopes — a **project default** you opt into at `holmes-kit init --autonomy` (persisted as the `HOLMES_AUTONOMOUS_APPROVAL` env in `.mcp.json`), and a **per-session envelope** you grant on the spot with `holmes-kit autonomy on --for 2h` (an expiring marker under the agent-write-protected `.ax/state/`). Under either, the agent seals **low-risk** specs itself (ledgered under an `autonomous:<client>` actor); every **governance-critical, high-risk, or irreversible** decision — `gate-behavior`/breaking A-SPECs, architecture/gate/taint files, and every upstream `REQ`/`H-SPEC`/`C-SPEC` — is instead **refused and routed to the out-of-band `holmes-kit approve` queue** for a human, never silently self-approved. The active posture is **surfaced at every session start** so it can't be forgotten *(0.14.0: the hook side now reads the project default out of `.mcp.json` directly, so an `init --autonomy` project sees its banner and escalations without an env round-trip)*, and an agent can never grant it to itself: the env is env-only (blocked like `HOLMES_ROLE`), the session command needs a real TTY or an out-of-band `HOLMES_APPROVAL`, and the marker lives where agents can't write. Off = byte-identical to a fully human-gated project. *(new in 0.10.0)* `HOLMES_ELICIT=off` routes every decision straight to the same queue.
|
|
26
26
|
- 🧭 **Spec-Evolution Trigger** *(new in 0.14.0)*: the gate used to judge only *where* a change lands (file ∈ Files-to-Touch, anchored, approved) — never *what kind* of change it is, so a real architecture swap inside an approved scope passed unreviewed. Now, when a changed in-scope source **newly introduces an external dependency** (a swapped engine, a new runtime), Holmes-Kit raises a **spec-reappraisal**: manual mode warns at the turn boundary, and under autonomy it also files the drift in the out-of-band `holmes-kit approve` queue so the owner sees it — a decided reappraisal is never re-raised for the same drift. Observe-first by design: it never blocks a turn. Detection is TS/JS + Python, string- and comment-safe (prettier multiline imports, CRLF files, docstrings and template literals all judged correctly).
|
|
27
27
|
- 🚢 **Release Autonomy + Docs-Currency Gate** *(new in 0.13.0)*: publishing is irreversible and outward, so `npm publish` stays **human-approved by default** — but a deterministic classifier (`releaseAutonomy`, reusing the same per-spec risk grade) lets a **low-risk** release (patch/minor, every spec auto-grade, autonomy on) self-publish under the ledger, while a **major** bump, any `gate-behavior`/security/architecture spec, or an upstream `REQ`/`H-SPEC` forces HITL. The `holmes-publish` playbook also gains a **docs-currency gate**: before any release it diffs the specs since the last tag and blocks if a user-facing change never reached `README`/`CHANGELOG` — a stale doc is a false claim.
|
|
28
|
+
- 🧭 **Compatibility declaration gate** *(new in 0.15.0)*: Holmes-Kit runs on three agent harnesses (Claude Code, Codex, Antigravity) and three OSes (Windows/macOS/Linux) — and now the **sealing act itself asks whether you considered them**. A new A-SPEC approves only with `harness_impact:` and `os_impact:` declared (`'none: <reason>'` or a full 3-cell mapping with `supported|unavailable|n-a` verdicts); a `none` claim is machine-cross-checked against Files-to-Touch (harness-surface paths, OS-signal file contents), the slice scaffold plants both fields as TODO the gate refuses untouched, and already-sealed specs are untouched — the duty arrives with the next re-approval, exactly like `breaking_change`.
|
|
28
29
|
- 🌐 **English CLI & hook surface** *(new in 0.13.0)*: the operator-facing CLI and hook messages — `doctor` output, the CLI usage/errors, the hook `deny` reasons and ART citations, and the interactive `approve`/`init`/`upgrade`/`semantic-key` prompts — are now English, guarded by a hangul-absence test over the **rendered runtime output** (not just a source scan, which misses `\u`-escaped strings). The MCP tool responses (`spec_create`/`spec_approve`/ledger/review) are still being migrated and are next.
|
|
29
30
|
- 🪧 **Session Banner + Update Notice** *(new in 0.8.0; refresh implemented + made uniform in 0.12.2)*: every session start emits an English intro (version + governance rule + npm URL) to both the human transcript and the agent context (SessionStart hook + MCP `instructions`); when a newer published version is on npm, an install-mode-aware `holmes-kit upgrade` command is appended. The registry refresh (dist-tags query → cached in `~/.holmes/update-check.json`) is detached, TTL-gated, and fail-silent, and now fires from **every harness's MCP-server startup** — not just Claude's SessionStart hook — so Claude / Antigravity / Codex are notified alike. Opts out via `HOLMES_NO_UPDATE_CHECK`/`CI`. Upgrade execution stays your explicit choice (`holmes-kit upgrade`), never a silent auto-install.
|
|
30
31
|
- 🧱 **Deterministic Gate, Hardened** *(new in 0.8.0; further hardened in 0.13.0)*: shell writes are judged at the segment's **effective working directory** (`cd sub && cat > ../src/x.ts` is sealed, legitimate out-of-tree scratch writes are freed); the governing anchor is the **whole set**, not the first match. *(0.13.0)* Two more bypasses are closed: the gate treats a project as **governed when any spec exists** (a fresh project holding only unapproved drafts is no longer an ungoverned free-for-all), and it classifies `cp`/`mv` by their **destination** (a copy/move landing on a source path is sealed even when the source file isn't code). Every gate change ships with two consecutive clean adversarial rounds.
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
- 🐞 **Causal Defect Localization & CPG** *(equalized in 0.5–0.7)*: AST Code Property Graph (CFG/DDG/CDG) & Dataflow Taint reachability across 7 languages (TS/JS, Python, Go, Rust, Java, C/C++, C#) — **42 language×layer cells graded on measured evidence** (11 corpora, 39,344 functions, zero invariant violations; C++ conditional on 67.9% parse coverage, disclosed in the matrix).
|
|
34
35
|
- 📏 **Measured, Not Claimed** *(new in 0.3.x)*: performance is judged against a pre-registered modeled-human band (R 0.67–0.78 / P ≈0.9±). Current official grade: **band entry on recall; division-of-labor precision 0.727 = 81% of the modeled human — reproduced by an independent context-free judge on a fresh blind window.** No superhuman claims until both metrics exceed the band.
|
|
35
36
|
- 🧪 **Self-Healing & Diagnostic Doctor**: Automated integrity checks and self-healing auto-fix remediation (`holmes-kit doctor --fix` & `spec_remediate`) — wiring-handshake checks run on Windows natively as of 0.3.2. As of 0.9.0, doctor also reports holmes-kit's own advertised **MCP schema token cost** (computed live) and warns when `HOLMES_MCP_PROFILE=full` needlessly re-advertises the hook-enforced gate-duplicate tools.
|
|
36
|
-
- 🔔 **Approval UX** *(new in 0.3.1)*: in-session approval dialogs forewarn their 120s deadline and, on expiry, the refusal says exactly where the decision went (`npx holmes-kit approve` out-of-band queue) — no more silently dead dialogs.
|
|
37
|
+
- 🔔 **Approval UX** *(new in 0.3.1; inbox split 0.15.0)*: in-session approval dialogs forewarn their 120s deadline and, on expiry, the refusal says exactly where the decision went (`npx holmes-kit approve` out-of-band queue) — no more silently dead dialogs. Since 0.15.0 the tracked queue holds **decision-seeking requests only**; plain gate refusals live in a local per-machine refusal log (raw commands never leave the machine), browsable with `approve --refusals` and still decidable by id — measured before the split, 1,404 single-shot refusals were burying a 2-item inbox.
|
|
37
38
|
- 🚦 **Push & Server-Side Re-Validation** *(hardened in 0.8.0)*: a local `pre-push` evidence gate (test-run ledger head == push HEAD, green, executed > 0) plus a **server-side CI workflow** that re-runs `npm ci → build → full suite → tarball install probe`, so a `--no-verify` push or a hook-less clone is still caught.
|
|
38
39
|
- 📊 **Automated RTM & Taint Heatmap**: Interactive standalone HTML/SVG report generation (`generateRtmHeatmap`) for spec coverage and security dataflow reachability.
|
|
39
40
|
- 🤖 **CLI-First AI Harness Matrix**: Native process hook gating for Claude Code, Antigravity CLI (AGY), Codex CLI, and Google Antigravity SDK.
|
package/dist/.build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
b540876-mtqeiitb
|
|
@@ -83,6 +83,20 @@ export declare function decisionDetail(p: PendingRequest, tail?: string): string
|
|
|
83
83
|
* must transcribe: [noguess]. An empty queue yields an empty hint — nothing to act on, nothing to
|
|
84
84
|
* advise. `renderPending` itself stays hint-free: the explicit `--list` output is for scripts.
|
|
85
85
|
*/
|
|
86
|
+
/**
|
|
87
|
+
* @implements A-SPEC-563.2
|
|
88
|
+
* The read-only refusal view: what THIS machine's gate refused lately, newest last. The raw target
|
|
89
|
+
* appears on the operator's SCREEN only — the refusal log never leaves the machine (A-SPEC-563.1),
|
|
90
|
+
* and this renderer is the reason an operator can find the id the deny message named. Row width
|
|
91
|
+
* follows the decision list's screen-safe discipline.
|
|
92
|
+
*/
|
|
93
|
+
export declare function renderRefusals(refusals: Array<{
|
|
94
|
+
id: string;
|
|
95
|
+
kind: string;
|
|
96
|
+
target: string;
|
|
97
|
+
why: string;
|
|
98
|
+
ts: string;
|
|
99
|
+
}>, limit?: number): string;
|
|
86
100
|
export declare function renderNonTtyHint(state: QueueState): string;
|
|
87
101
|
export interface ApproveIO {
|
|
88
102
|
print: (s: string) => void;
|
|
@@ -42,6 +42,7 @@ exports.subjectCells = subjectCells;
|
|
|
42
42
|
exports.subjectRoom = subjectRoom;
|
|
43
43
|
exports.decisionSubject = decisionSubject;
|
|
44
44
|
exports.decisionDetail = decisionDetail;
|
|
45
|
+
exports.renderRefusals = renderRefusals;
|
|
45
46
|
exports.renderNonTtyHint = renderNonTtyHint;
|
|
46
47
|
exports.runInteractive = runInteractive;
|
|
47
48
|
// @implements A-SPEC-246
|
|
@@ -78,7 +79,44 @@ const MAX_TTL_MINUTES = 7 * 24 * 60;
|
|
|
78
79
|
const DEFAULT_RATIONALE = 'approved via holmes-kit approve';
|
|
79
80
|
const findPending = (root, id) => {
|
|
80
81
|
const state = (0, approval_queue_1.readQueue)(root);
|
|
81
|
-
|
|
82
|
+
const pending = state.pending.find((p) => p.id === id);
|
|
83
|
+
if (pending)
|
|
84
|
+
return { entry: pending, state };
|
|
85
|
+
// @implements A-SPEC-563.2 — the refusal-log fallback. Shell refusals no longer sit in the tracked
|
|
86
|
+
// inbox (A-SPEC-563.1), but the out-of-band approval story must survive: the operator saw the deny
|
|
87
|
+
// in session, the deny named this id, and the RAW target lives in this machine's local refusal log
|
|
88
|
+
// — exactly the "grant is for what the human saw" contract. A decided id never promotes: the
|
|
89
|
+
// granted/denied event in the queue closes the request, same single-use convention as pending.
|
|
90
|
+
try {
|
|
91
|
+
const { readRefusals } = require('../governance/approval-queue');
|
|
92
|
+
let mine = readRefusals(root).filter((r) => r.id === id);
|
|
93
|
+
// A decided id closes the request — UNLESS the gate refused it again afterwards. The fold has
|
|
94
|
+
// the same rule for pending (a later `requested` re-inserts after granted/denied): a human may
|
|
95
|
+
// change their mind, and the retry is what re-opens the question.
|
|
96
|
+
const decided = state.decisions[id];
|
|
97
|
+
if (decided) {
|
|
98
|
+
// Clock-free reopening: the decision recorded HOW MANY occurrences it covered, so a retry is
|
|
99
|
+
// simply everything past that count — millisecond ties (measured flaky under the full suite)
|
|
100
|
+
// cannot lose it. Legacy decisions without the count fall back to the timestamp rule.
|
|
101
|
+
if (typeof decided.covered === 'number')
|
|
102
|
+
mine = mine.slice(decided.covered);
|
|
103
|
+
else
|
|
104
|
+
mine = mine.filter((r) => r.ts > decided.ts);
|
|
105
|
+
}
|
|
106
|
+
if (mine.length > 0) {
|
|
107
|
+
const latest = mine[mine.length - 1];
|
|
108
|
+
return {
|
|
109
|
+
entry: {
|
|
110
|
+
id, kind: latest.kind, target: latest.target, why: latest.why,
|
|
111
|
+
count: mine.length, firstTs: mine[0].ts, lastTs: latest.ts,
|
|
112
|
+
...(latest.replica ? { replica: latest.replica } : {}),
|
|
113
|
+
},
|
|
114
|
+
state,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch { /* a broken refusal log must not break the decision surface */ }
|
|
119
|
+
return { entry: undefined, state };
|
|
82
120
|
};
|
|
83
121
|
/** CLI-side event writer. The CLI runs in the operator's terminal, outside the session gates. */
|
|
84
122
|
/**
|
|
@@ -186,7 +224,7 @@ function grantRequest(root, id, opts) {
|
|
|
186
224
|
// class round-6 closed in findingContext, three files over.
|
|
187
225
|
return { ok: false, reason: `cannot write the grant file:\n ${(0, screen_safe_1.rowField)(e instanceof Error ? e.message : String(e), 76)}` };
|
|
188
226
|
}
|
|
189
|
-
if (!appendEvent(root, { event: 'granted', id, actor: opts.actor, expires })) {
|
|
227
|
+
if (!appendEvent(root, { event: 'granted', id, actor: opts.actor, expires, covered: entry.count })) {
|
|
190
228
|
try {
|
|
191
229
|
fs.rmSync(tmp, { force: true });
|
|
192
230
|
}
|
|
@@ -212,7 +250,7 @@ function denyRequest(root, id, reason, actor) {
|
|
|
212
250
|
// The event IS the decision here (there is no second artefact), so a failed append is a failed
|
|
213
251
|
// decision — round-5: ✓ and exit 0 were printed over a read-only queue while nothing was recorded,
|
|
214
252
|
// and the agent, never seeing the denial, retried forever.
|
|
215
|
-
if (!appendEvent(root, { event: 'denied', id, reason, actor })) {
|
|
253
|
+
if (!appendEvent(root, { event: 'denied', id, reason, actor, covered: entry.count })) {
|
|
216
254
|
return { ok: false, reason: 'could not write the denial record (queue event) — check write permission on .ax/approvals. Nothing was recorded' };
|
|
217
255
|
}
|
|
218
256
|
return { ok: true };
|
|
@@ -366,6 +404,25 @@ function decisionDetail(p, tail = '') {
|
|
|
366
404
|
* must transcribe: [noguess]. An empty queue yields an empty hint — nothing to act on, nothing to
|
|
367
405
|
* advise. `renderPending` itself stays hint-free: the explicit `--list` output is for scripts.
|
|
368
406
|
*/
|
|
407
|
+
/**
|
|
408
|
+
* @implements A-SPEC-563.2
|
|
409
|
+
* The read-only refusal view: what THIS machine's gate refused lately, newest last. The raw target
|
|
410
|
+
* appears on the operator's SCREEN only — the refusal log never leaves the machine (A-SPEC-563.1),
|
|
411
|
+
* and this renderer is the reason an operator can find the id the deny message named. Row width
|
|
412
|
+
* follows the decision list's screen-safe discipline.
|
|
413
|
+
*/
|
|
414
|
+
function renderRefusals(refusals, limit = 20) {
|
|
415
|
+
if (refusals.length === 0)
|
|
416
|
+
return '◆ no refusals recorded on this machine';
|
|
417
|
+
const recent = refusals.slice(-Math.max(1, limit));
|
|
418
|
+
const lines = [`◆ ${refusals.length} refusal(s) on this machine — showing ${recent.length} (newest last)`, ''];
|
|
419
|
+
for (const r of recent) {
|
|
420
|
+
lines.push(`${(0, screen_safe_1.rowField)(r.id, 20)} ${(0, screen_safe_1.rowField)(r.kind, screen_safe_1.KIND_COLS)} ${(0, screen_safe_1.rowField)(r.target, 40)}`);
|
|
421
|
+
lines.push(` \u2502 ${(0, screen_safe_1.rowField)(r.why, 66)} ${(0, screen_safe_1.rowField)(r.ts, 24)}`);
|
|
422
|
+
}
|
|
423
|
+
lines.push('', `decide one: ${(0, npx_bin_1.npxBin)()} holmes-kit approve <id>`);
|
|
424
|
+
return lines.join('\n');
|
|
425
|
+
}
|
|
369
426
|
function renderNonTtyHint(state) {
|
|
370
427
|
if (state.pending.length === 0)
|
|
371
428
|
return '';
|
|
@@ -36,6 +36,11 @@ exports.IGNORE_LINES = [
|
|
|
36
36
|
// project content — left untracked they show up in `git status` and read as install damage.
|
|
37
37
|
'.ax/state/',
|
|
38
38
|
'*.holmes-bak-*',
|
|
39
|
+
// @implements A-SPEC-563.1 — the per-replica refusal log carries RAW refused commands (absolute
|
|
40
|
+
// paths measured in 45% of them), and the grant contract needs them raw ("the grant is for what
|
|
41
|
+
// the human saw" — round-14, exact match). Raw-and-local is the only shape that serves both ADR-012
|
|
42
|
+
// and approvals: the file never leaves the machine, and `holmes-kit approve` reads it right there.
|
|
43
|
+
'.ax/approvals/refusals*.jsonl',
|
|
39
44
|
// @implements A-SPEC-193 — 하네스 배선물은 이 **설치본의 절대 경로**를 담는다(훅은 hooks.json
|
|
40
45
|
// 이 있는 디렉터리를 cwd 로 돌고, 패키지가 어디 설치됐는지는 기계마다 다르다). 그 경로가
|
|
41
46
|
// VCS 에 들어가면 다른 기계에서 남의 설치를 부르거나 아무것도 부르지 못한다. 팀과 공유하고
|
package/dist/holmes/cli/index.js
CHANGED
|
@@ -78,7 +78,7 @@ const KNOWN_FLAGS = {
|
|
|
78
78
|
skills: ['help', 'target'],
|
|
79
79
|
ci: ['help', 'target', 'specs-dir', 'json'],
|
|
80
80
|
serve: ['help', 'target', 'port'],
|
|
81
|
-
approve: ['help', 'target', 'list', 'grant', 'deny', 'ask', 'reason', 'question', 'ttl', 'rationale', 'watch', 'poll-ms'],
|
|
81
|
+
approve: ['help', 'target', 'list', 'refusals', 'grant', 'deny', 'ask', 'reason', 'question', 'ttl', 'rationale', 'watch', 'poll-ms'],
|
|
82
82
|
ledger: ['help', 'target', 'ref', 'dry-run'],
|
|
83
83
|
// @implements A-SPEC-477 — the human's opt-in act for the cloud semantic tier.
|
|
84
84
|
'semantic-key': ['help'],
|
|
@@ -839,6 +839,18 @@ async function main(argv) {
|
|
|
839
839
|
process.stdout.write(renderPending(readQueue(root, queueOpts), listView) + '\n');
|
|
840
840
|
return 0;
|
|
841
841
|
}
|
|
842
|
+
// @implements A-SPEC-563.2 — the read-only refusal view (local log; raw targets stay on-screen).
|
|
843
|
+
if (flags.refusals !== undefined) {
|
|
844
|
+
const { renderRefusals } = require('./approve');
|
|
845
|
+
const { readRefusals } = require('../governance/approval-queue');
|
|
846
|
+
const limit = typeof flags.refusals === 'string' ? Number(flags.refusals) : 20;
|
|
847
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
848
|
+
process.stderr.write(`✗ --refusals expects a positive integer count — received: ${flags.refusals}\n`);
|
|
849
|
+
return 1;
|
|
850
|
+
}
|
|
851
|
+
process.stdout.write(renderRefusals(readRefusals(root), limit) + '\n');
|
|
852
|
+
return 0;
|
|
853
|
+
}
|
|
842
854
|
// @implements A-SPEC-262.2 — the RESIDENT surface. Validate --poll-ms first (so a bad value is
|
|
843
855
|
// named even on a non-TTY), then refuse a non-TTY (a resident interactive loop needs a terminal),
|
|
844
856
|
// then run the loop. SIGINT and readline close both abort it — the operator leaving, either way,
|
|
@@ -18,6 +18,24 @@
|
|
|
18
18
|
* provenance chain already use, so a reader learns no new model.
|
|
19
19
|
*/
|
|
20
20
|
export declare const QUEUE_RELPATH: string;
|
|
21
|
+
export declare const DECISION_KINDS: ReadonlySet<string>;
|
|
22
|
+
export interface RefusalRecord {
|
|
23
|
+
event: 'requested';
|
|
24
|
+
id: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
target: string;
|
|
27
|
+
why: string;
|
|
28
|
+
ts: string;
|
|
29
|
+
replica?: string;
|
|
30
|
+
/** @implements A-SPEC-564.2 — the byte size of the deny feedback this refusal put back into the
|
|
31
|
+
* conversation (base reason + queue hint). Observation only; absent on legacy records. */
|
|
32
|
+
reasonBytes?: number;
|
|
33
|
+
}
|
|
34
|
+
export declare function refusalsFilename(replica: string): string;
|
|
35
|
+
/** Born split: there is no legacy single `refusals.jsonl` — the file did not exist before replicas did. */
|
|
36
|
+
export declare function isRefusalsFilename(name: string): boolean;
|
|
37
|
+
/** All replica refusal logs of this project, merged in ts order (stable). Missing dir → []. */
|
|
38
|
+
export declare function readRefusals(root: string): RefusalRecord[];
|
|
21
39
|
export interface PendingRequest {
|
|
22
40
|
id: string;
|
|
23
41
|
kind: string;
|
|
@@ -28,6 +46,13 @@ export interface PendingRequest {
|
|
|
28
46
|
lastTs: string;
|
|
29
47
|
hold?: boolean;
|
|
30
48
|
question?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @implements A-SPEC-562.2
|
|
51
|
+
* Which machine raised this request (`resolveReplicaId`), or `'unknown'` for the events written
|
|
52
|
+
* before attribution existed. Display and aggregation ONLY — no gate, grant or approval decision
|
|
53
|
+
* reads it, so an absent or wrong value can never change a verdict.
|
|
54
|
+
*/
|
|
55
|
+
replica?: string;
|
|
31
56
|
}
|
|
32
57
|
export interface QueueState {
|
|
33
58
|
pending: PendingRequest[];
|
|
@@ -53,6 +78,17 @@ export interface QueueState {
|
|
|
53
78
|
event: 'granted' | 'denied';
|
|
54
79
|
reason?: string;
|
|
55
80
|
ts: string;
|
|
81
|
+
covered?: number;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* @implements A-SPEC-563.2
|
|
85
|
+
* Live holds by id, INDEPENDENT of pending: a shell refusal is no longer a pending entry
|
|
86
|
+
* (A-SPEC-563.1), but the operator's hold question must still reach the agent's next retry.
|
|
87
|
+
* A later decision clears the hold — an answered question is not still being asked.
|
|
88
|
+
*/
|
|
89
|
+
holds: Record<string, {
|
|
90
|
+
question?: string;
|
|
91
|
+
ts: string;
|
|
56
92
|
}>;
|
|
57
93
|
}
|
|
58
94
|
/**
|
|
@@ -88,6 +124,7 @@ export declare function enqueueApprovalRequest(root: string, req: {
|
|
|
88
124
|
kind: string;
|
|
89
125
|
target: string;
|
|
90
126
|
why: string;
|
|
127
|
+
reasonBytes?: number;
|
|
91
128
|
}): boolean;
|
|
92
129
|
/** Read and fold the queue on disk. A missing file is an empty queue, not an error. */
|
|
93
130
|
export declare function readQueue(root: string, opts?: {
|
|
@@ -104,4 +141,6 @@ export declare function queueHint(root: string, req: {
|
|
|
104
141
|
kind: string;
|
|
105
142
|
target: string;
|
|
106
143
|
why: string;
|
|
144
|
+
}, opts?: {
|
|
145
|
+
baseReasonBytes?: number;
|
|
107
146
|
}): string;
|
|
@@ -33,7 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.QUEUE_RELPATH = void 0;
|
|
36
|
+
exports.DECISION_KINDS = exports.QUEUE_RELPATH = void 0;
|
|
37
|
+
exports.refusalsFilename = refusalsFilename;
|
|
38
|
+
exports.isRefusalsFilename = isRefusalsFilename;
|
|
39
|
+
exports.readRefusals = readRefusals;
|
|
37
40
|
exports.approvalRequestId = approvalRequestId;
|
|
38
41
|
exports.foldQueue = foldQueue;
|
|
39
42
|
exports.enqueueApprovalRequest = enqueueApprovalRequest;
|
|
@@ -45,6 +48,7 @@ const npx_bin_1 = require("../project/npx-bin");
|
|
|
45
48
|
const fs = __importStar(require("node:fs"));
|
|
46
49
|
const path = __importStar(require("node:path"));
|
|
47
50
|
const screen_safe_1 = require("../cli/screen-safe");
|
|
51
|
+
const replica_id_1 = require("./replica-id");
|
|
48
52
|
/**
|
|
49
53
|
* The approval request queue — the review list a human batches decisions over.
|
|
50
54
|
*
|
|
@@ -65,6 +69,58 @@ const screen_safe_1 = require("../cli/screen-safe");
|
|
|
65
69
|
* provenance chain already use, so a reader learns no new model.
|
|
66
70
|
*/
|
|
67
71
|
exports.QUEUE_RELPATH = path.join('.ax', 'approvals', 'queue.jsonl');
|
|
72
|
+
// @implements A-SPEC-563.1 — the tracked queue is a DECISION INBOX, not a refusal log. Measured
|
|
73
|
+
// (field report, 2026-09-06): 1,412 unique requests vs 8 decisions — 99.8% of the backlog was
|
|
74
|
+
// single-shot gate refusals nobody ever meant to decide, burying the real inbox (spec-approve 9,
|
|
75
|
+
// config-write 1) and accumulating raw shell commands in a tracked file. Only these kinds seek a
|
|
76
|
+
// decision; everything else routes to the local per-replica refusal log below. Wired RED-first.
|
|
77
|
+
exports.DECISION_KINDS = new Set([
|
|
78
|
+
'spec-approve', 'config-write', 'autonomy-grant', 'spec-reappraisal',
|
|
79
|
+
]);
|
|
80
|
+
const REFUSALS_FILE_RE = /^refusals\.([^.]+)\.jsonl$/;
|
|
81
|
+
function refusalsFilename(replica) {
|
|
82
|
+
return `refusals.${replica}.jsonl`;
|
|
83
|
+
}
|
|
84
|
+
/** Born split: there is no legacy single `refusals.jsonl` — the file did not exist before replicas did. */
|
|
85
|
+
function isRefusalsFilename(name) {
|
|
86
|
+
return REFUSALS_FILE_RE.test(name);
|
|
87
|
+
}
|
|
88
|
+
/** All replica refusal logs of this project, merged in ts order (stable). Missing dir → []. */
|
|
89
|
+
function readRefusals(root) {
|
|
90
|
+
const dir = path.join(root, '.ax', 'approvals');
|
|
91
|
+
let names;
|
|
92
|
+
try {
|
|
93
|
+
names = fs.readdirSync(dir).filter(isRefusalsFilename).sort();
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
const out = [];
|
|
99
|
+
let i = 0;
|
|
100
|
+
for (const name of names) {
|
|
101
|
+
let text;
|
|
102
|
+
try {
|
|
103
|
+
text = fs.readFileSync(path.join(dir, name), 'utf8');
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
for (const line of text.split('\n')) {
|
|
109
|
+
const s = line.trim();
|
|
110
|
+
if (!s)
|
|
111
|
+
continue;
|
|
112
|
+
try {
|
|
113
|
+
const r = JSON.parse(s);
|
|
114
|
+
if (r && typeof r === 'object' && r.event === 'requested' && typeof r.id === 'string'
|
|
115
|
+
&& typeof r.kind === 'string' && typeof r.target === 'string' && typeof r.ts === 'string') {
|
|
116
|
+
out.push({ r: r, i: i++ });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch { /* a corrupt line never breaks the read */ }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return out.sort((a, b) => (a.r.ts < b.r.ts ? -1 : a.r.ts > b.r.ts ? 1 : a.i - b.i)).map((e) => e.r);
|
|
123
|
+
}
|
|
68
124
|
/**
|
|
69
125
|
* Deterministic request id from the action's identity.
|
|
70
126
|
*
|
|
@@ -87,6 +143,7 @@ function approvalRequestId(kind, target) {
|
|
|
87
143
|
function foldQueue(lines, opts) {
|
|
88
144
|
const pending = new Map();
|
|
89
145
|
const decisions = {};
|
|
146
|
+
const holds = {};
|
|
90
147
|
let malformedLines = 0;
|
|
91
148
|
for (const raw of Array.isArray(lines) ? lines : []) {
|
|
92
149
|
const line = String(raw ?? '').trim();
|
|
@@ -127,6 +184,9 @@ function foldQueue(lines, opts) {
|
|
|
127
184
|
count: 1,
|
|
128
185
|
firstTs: ts,
|
|
129
186
|
lastTs: ts,
|
|
187
|
+
// @implements A-SPEC-562.2 — events written before attribution existed have no field;
|
|
188
|
+
// `unknown` names that honestly instead of pretending they came from this machine.
|
|
189
|
+
replica: typeof e.replica === 'string' && e.replica !== '' ? e.replica : 'unknown',
|
|
130
190
|
});
|
|
131
191
|
}
|
|
132
192
|
break;
|
|
@@ -135,10 +195,12 @@ function foldQueue(lines, opts) {
|
|
|
135
195
|
case 'denied':
|
|
136
196
|
if (id) {
|
|
137
197
|
pending.delete(id);
|
|
198
|
+
delete holds[id]; // @implements A-SPEC-563.2 — a decision answers the question
|
|
138
199
|
decisions[id] = {
|
|
139
200
|
event: e.event,
|
|
140
201
|
...(typeof e.reason === 'string' ? { reason: e.reason } : {}),
|
|
141
202
|
ts: typeof e.ts === 'string' ? e.ts : '',
|
|
203
|
+
...(typeof e.covered === 'number' ? { covered: e.covered } : {}),
|
|
142
204
|
};
|
|
143
205
|
}
|
|
144
206
|
break;
|
|
@@ -149,6 +211,10 @@ function foldQueue(lines, opts) {
|
|
|
149
211
|
if (typeof e.question === 'string')
|
|
150
212
|
entry.question = e.question;
|
|
151
213
|
}
|
|
214
|
+
// @implements A-SPEC-563.2 — record the hold by id too: a refusal-log request has no pending
|
|
215
|
+
// entry to hang the question on, and the question must still reach the retry.
|
|
216
|
+
if (id)
|
|
217
|
+
holds[id] = { ...(typeof e.question === 'string' ? { question: e.question } : {}), ts: typeof e.ts === 'string' ? e.ts : '' };
|
|
152
218
|
break;
|
|
153
219
|
}
|
|
154
220
|
default:
|
|
@@ -158,7 +224,7 @@ function foldQueue(lines, opts) {
|
|
|
158
224
|
}
|
|
159
225
|
const all = [...pending.values()];
|
|
160
226
|
if (!opts)
|
|
161
|
-
return { pending: all, expired: [], malformedLines, decisions };
|
|
227
|
+
return { pending: all, expired: [], malformedLines, decisions, holds };
|
|
162
228
|
// @implements A-SPEC-507.1 — strict excess only, and an unparseable lastTs stays ACTIVE: a
|
|
163
229
|
// clockless entry must never be silently hidden by a clock it does not carry.
|
|
164
230
|
const expired = [];
|
|
@@ -167,7 +233,7 @@ function foldQueue(lines, opts) {
|
|
|
167
233
|
const last = Date.parse(p.lastTs);
|
|
168
234
|
(Number.isFinite(last) && last + opts.ttlMs < opts.now ? expired : active).push(p);
|
|
169
235
|
}
|
|
170
|
-
return { pending: active, expired, malformedLines, decisions };
|
|
236
|
+
return { pending: active, expired, malformedLines, decisions, holds };
|
|
171
237
|
}
|
|
172
238
|
/**
|
|
173
239
|
* Append a request event. Fire-and-forget.
|
|
@@ -186,8 +252,27 @@ function enqueueApprovalRequest(root, req) {
|
|
|
186
252
|
// An ungoverned directory gets no queue and no hint; it is not part of the system.
|
|
187
253
|
if (!fs.existsSync(path.join(root, '.ax')))
|
|
188
254
|
return false;
|
|
189
|
-
|
|
255
|
+
// @implements A-SPEC-563.1 — kind routing: only decision-seeking kinds enter the tracked inbox;
|
|
256
|
+
// a gate refusal (shell, or any future kind — fail-safe toward a clean inbox) goes to this
|
|
257
|
+
// machine's LOCAL refusal log, raw target and all, where the approve fallback can still find it.
|
|
258
|
+
let refusalReplica = 'local';
|
|
259
|
+
try {
|
|
260
|
+
refusalReplica = (0, replica_id_1.resolveReplicaId)(root) || 'local';
|
|
261
|
+
}
|
|
262
|
+
catch { /* keep the fallback */ }
|
|
263
|
+
const file = exports.DECISION_KINDS.has(req.kind)
|
|
264
|
+
? path.join(root, exports.QUEUE_RELPATH)
|
|
265
|
+
: path.join(root, '.ax', 'approvals', refusalsFilename(refusalReplica));
|
|
190
266
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
267
|
+
// @implements A-SPEC-562.2 — stamp the machine. Best-effort: a resolver failure omits the field
|
|
268
|
+
// rather than losing the request, because the queue is the channel a refusal depends on.
|
|
269
|
+
let replica;
|
|
270
|
+
try {
|
|
271
|
+
replica = (0, replica_id_1.resolveReplicaId)(root);
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
replica = undefined;
|
|
275
|
+
}
|
|
191
276
|
const event = {
|
|
192
277
|
event: 'requested',
|
|
193
278
|
id: approvalRequestId(req.kind, req.target),
|
|
@@ -195,6 +280,11 @@ function enqueueApprovalRequest(root, req) {
|
|
|
195
280
|
target: req.target,
|
|
196
281
|
why: req.why,
|
|
197
282
|
ts: new Date().toISOString(),
|
|
283
|
+
...(replica !== undefined && replica !== '' ? { replica } : {}),
|
|
284
|
+
// @implements A-SPEC-564.2 — only the refusal log carries the feedback cost; inbox kinds have
|
|
285
|
+
// no deny text to measure.
|
|
286
|
+
...(!exports.DECISION_KINDS.has(req.kind) && typeof req.reasonBytes === 'number' && Number.isFinite(req.reasonBytes)
|
|
287
|
+
? { reasonBytes: Math.max(0, Math.round(req.reasonBytes)) } : {}),
|
|
198
288
|
};
|
|
199
289
|
// TYPE BEFORE WRITE, for the same reason as the read (round-7): `appendFileSync` on a FIFO with
|
|
200
290
|
// no reader blocks in open(2) forever. Guarding only the reader left the GATE wedged — measured:
|
|
@@ -244,12 +334,12 @@ function readQueue(root, opts) {
|
|
|
244
334
|
// hook, the stop hook and the MCP handlers, not just the CLI. `approve-context.ts` has guarded
|
|
245
335
|
// this since the 2026-08-24 hang; the queue reader, which far more code depends on, did not.
|
|
246
336
|
if (!fs.lstatSync(file).isFile())
|
|
247
|
-
return { pending: [], expired: [], malformedLines: 1, decisions: {} };
|
|
337
|
+
return { pending: [], expired: [], malformedLines: 1, decisions: {}, holds: {} };
|
|
248
338
|
const raw = fs.readFileSync(file, 'utf8');
|
|
249
339
|
return foldQueue(raw.split('\n'), opts);
|
|
250
340
|
}
|
|
251
341
|
catch {
|
|
252
|
-
return { pending: [], expired: [], malformedLines: 0, decisions: {} };
|
|
342
|
+
return { pending: [], expired: [], malformedLines: 0, decisions: {}, holds: {} };
|
|
253
343
|
}
|
|
254
344
|
}
|
|
255
345
|
/**
|
|
@@ -258,7 +348,7 @@ function readQueue(root, opts) {
|
|
|
258
348
|
* Appended ONLY when the enqueue succeeded: a hint naming an id that was never written would send
|
|
259
349
|
* the operator to an empty list.
|
|
260
350
|
*/
|
|
261
|
-
function queueHint(root, req) {
|
|
351
|
+
function queueHint(root, req, opts) {
|
|
262
352
|
const id = approvalRequestId(req.kind, req.target);
|
|
263
353
|
// @implements A-SPEC-246
|
|
264
354
|
// Decisions are read BEFORE filing, so a human's answer reaches the agent in the very refusal
|
|
@@ -271,7 +361,8 @@ function queueHint(root, req) {
|
|
|
271
361
|
// text is read twice: printed in the operator's terminal AND carried in the agent's refusal. Raw,
|
|
272
362
|
// a held request could erase the screen and paint a line claiming the operator had approved. The
|
|
273
363
|
// decision surface's rule applies here too — line structure belongs to the template.
|
|
274
|
-
const held = state.pending.find((p) => p.id === id && p.hold)
|
|
364
|
+
const held = state.pending.find((p) => p.id === id && p.hold)
|
|
365
|
+
?? (state.holds[id] ? { question: state.holds[id].question } : undefined); // @implements A-SPEC-563.2
|
|
275
366
|
// Round-5: folded to terminal rows. This text is read in a terminal by the operator as well, and
|
|
276
367
|
// an unfolded hint carrying 300 columns of agent-authored question wraps unpredictably around
|
|
277
368
|
// whatever the gate printed before it.
|
|
@@ -288,7 +379,11 @@ function queueHint(root, req) {
|
|
|
288
379
|
const denialLine = decided?.event === 'denied'
|
|
289
380
|
? (0, screen_safe_1.wrapColumns)(`\n[거부됨${decided.reason ? `: ${(0, screen_safe_1.flattenField)(decided.reason, 300)}` : ''}] 같은 요청을 반복하지 말고 거부 사유를 해소해 사용자와 상의하십시오.`, 76, ' \u2502 ')
|
|
290
381
|
: '';
|
|
291
|
-
|
|
292
|
-
|
|
382
|
+
// @implements A-SPEC-564.2 — the hint is composed BEFORE the enqueue so the refusal record can
|
|
383
|
+
// carry its own feedback cost: reasonBytes = the caller's base reason + this hint, i.e. the text
|
|
384
|
+
// that actually re-enters the conversation. Observation only — nothing reads it on a gate path.
|
|
385
|
+
const hint = `${denialLine}\n[승인 대기 ${id}] 운영자: ${(0, npx_bin_1.npxBin)()} holmes-kit approve`;
|
|
386
|
+
return enqueueApprovalRequest(root, { ...req, reasonBytes: (opts?.baseReasonBytes ?? 0) + hint.length })
|
|
387
|
+
? hint
|
|
293
388
|
: denialLine;
|
|
294
389
|
}
|