rungate 0.8.1 → 0.8.3
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/bin/rungate.ts +11 -6
- package/config/prove-evidence.schema.json +21 -3
- package/gates/.gate-salt +1 -1
- package/gates/gate-executor.ts +153 -1
- package/gates/prove.test.ts +12 -6
- package/gates/schema.ts +69 -6
- package/gates/workflow.test.ts +12 -5
- package/hooks/BashWriteGuard.hook.ts +19 -0
- package/hooks/DocHygiene.hook.ts +2 -1
- package/hooks/GateResultProtection.hook.ts +28 -7
- package/hooks/HookCurrency.hook.ts +48 -1
- package/hooks/VerifyPhaseLock.hook.ts +68 -11
- package/hooks/WorkflowStateGuard.hook.ts +24 -7
- package/lib/ai-review-jury.ts +725 -0
- package/lib/ai-review-rounds.ts +1249 -0
- package/lib/ai-review-unmeasured.ts +361 -0
- package/lib/bash-file-read.ts +17 -3
- package/lib/bash-write-guard.ts +2165 -51
- package/lib/cli-commands.ts +252 -11
- package/lib/closing-reference-audit.ts +163 -0
- package/lib/conformity.ts +12 -0
- package/lib/create-sc.ts +45 -12
- package/lib/derived-spec.ts +206 -0
- package/lib/distribution-standing.ts +75 -4
- package/lib/failure-intake.ts +12 -4
- package/lib/file-claims.ts +335 -0
- package/lib/file-extensions.ts +81 -0
- package/lib/finding-arbiter.ts +1489 -0
- package/lib/finding-jury.ts +584 -0
- package/lib/finding-pr-routing.ts +333 -0
- package/lib/frontmatter.ts +16 -0
- package/lib/gate-check-audit.ts +259 -0
- package/lib/generators/agents-md.ts +29 -0
- package/lib/github.ts +160 -0
- package/lib/hook-tree-currency.ts +494 -0
- package/lib/interpreters.ts +64 -0
- package/lib/issue-closure-audit.ts +161 -14
- package/lib/issue-create-override.ts +122 -11
- package/lib/issue-filing-gate.ts +1602 -0
- package/lib/local-review-rounds.ts +523 -0
- package/lib/organize.ts +10 -0
- package/lib/project-state-shape.ts +56 -5
- package/lib/publish-window.ts +287 -0
- package/lib/repo-path.ts +94 -0
- package/lib/report-provenance.ts +65 -3
- package/lib/risk-tier.ts +302 -0
- package/lib/rounds-to-pass.ts +274 -0
- package/lib/rule-row-drift.ts +199 -0
- package/lib/sc-claim-forms.ts +33 -5
- package/lib/sc-guard.ts +11 -1
- package/lib/sc-id-cross-tree.ts +17 -2
- package/lib/sc-ids.ts +71 -6
- package/lib/sc-reservations.ts +158 -14
- package/lib/scaffold/ai-review-findings.ts +1157 -18
- package/lib/scaffold/ai-review-step.ts +4672 -85
- package/lib/scaffold/ai-review-unmeasured-workflow.ts +243 -0
- package/lib/scaffold/managed-workflow.ts +163 -4
- package/lib/scaffold/owned-files.ts +14 -0
- package/lib/scaffold/steps.ts +462 -108
- package/lib/scanner.ts +10 -3
- package/lib/scratch-roots.ts +93 -3
- package/lib/spec-updater.ts +16 -0
- package/lib/ticked-sc-symbols.ts +361 -0
- package/lib/validators/spec-validators.ts +28 -2
- package/lib/workflow-actions.ts +18 -0
- package/package.json +3 -1
- package/scripts/ai-review-findings.ts +41 -1
- package/scripts/arbitrate-finding.ts +542 -0
- package/scripts/audit-specs.ts +225 -23
- package/scripts/create-sc.ts +11 -0
- package/scripts/detect-sc-drift.ts +10 -2
- package/scripts/generate-code-map.ts +6 -3
- package/scripts/record-ai-review-unmeasured.ts +370 -0
- package/scripts/split-spec.ts +12 -0
- package/scripts/sync-sc-status.ts +93 -8
|
@@ -5,21 +5,33 @@
|
|
|
5
5
|
* SC-370 (HOOK-ARCHITECTURE-SPEC): Hook SC traceability
|
|
6
6
|
* SC-371 (HOOK-ARCHITECTURE-SPEC): No hook exceeds 150 lines
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* TWO independent gates on one chokepoint — `gh issue create` reaching Bash.
|
|
9
|
+
* Both decisions live in lib/ and not here (#365, HOOK-ARCHITECTURE-SPEC:
|
|
10
|
+
* hooks are thin triggers).
|
|
11
11
|
*
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* 1. **The VERIFY-phase lock** (#443, #365). Workflow discipline: during
|
|
13
|
+
* VERIFY, use verifyBlockers[] instead. Waived by the override labels in
|
|
14
|
+
* lib/issue-create-override.ts. It used to be a substring test on the
|
|
15
|
+
* whole command, which a `follow-up` in an issue TITLE satisfied.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
+
* 2. **The finding adjudication** (#1261), on every phase. Asks whether the
|
|
18
|
+
* finding earned a filing — duplicate, or a dropped category — through
|
|
19
|
+
* lib/finding-arbiter.ts's own bindings. Before this, the only question
|
|
20
|
+
* asked at this chokepoint was gate 1's, and gate 1 tests whether an agent
|
|
21
|
+
* typed a label. lib/issue-filing-gate.ts has the measurement and the
|
|
22
|
+
* reason the two gates do not share an override label.
|
|
23
|
+
*
|
|
24
|
+
* Asked in that order because gate 1 is a cheap local read and gate 2 may pay
|
|
25
|
+
* for a `gh issue list`.
|
|
26
|
+
*
|
|
27
|
+
* Issue: #443, #1261
|
|
17
28
|
*/
|
|
18
29
|
|
|
19
30
|
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
20
31
|
import { join } from 'path';
|
|
21
32
|
import { parseHookInput } from './lib/parseStdin';
|
|
22
33
|
import { verifyPhaseRefusal } from '../lib/issue-create-override';
|
|
34
|
+
import { filingGate, ledgerPath, recordAdjudication } from '../lib/issue-filing-gate';
|
|
23
35
|
|
|
24
36
|
const WORK_DIR = process.env.RUNGATE_WORK_DIR || process.env.PAI_WORK_DIR || join(process.env.HOME!, '.rungate');
|
|
25
37
|
|
|
@@ -69,15 +81,60 @@ async function main() {
|
|
|
69
81
|
|
|
70
82
|
const cmd = payload.tool_input?.command || '';
|
|
71
83
|
|
|
84
|
+
// ── 1. the VERIFY-phase lock ──
|
|
85
|
+
//
|
|
72
86
|
// Ask the owner BEFORE reading the workflow state. Cheap, and it keeps the
|
|
73
87
|
// whole decision in one place rather than half here and half in lib/.
|
|
74
88
|
const refusal = verifyPhaseRefusal(cmd);
|
|
75
|
-
if (refusal
|
|
89
|
+
if (refusal !== null) {
|
|
90
|
+
const wf = findActiveWorkflow();
|
|
91
|
+
if (wf && wf.data.phase === 'VERIFY') {
|
|
92
|
+
console.log(JSON.stringify({ decision: "block", reason: refusal }));
|
|
93
|
+
process.exit(0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
76
96
|
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
// ── 2. the finding adjudication (#1261) ──
|
|
98
|
+
//
|
|
99
|
+
// Every phase, and not only VERIFY: #1261's measurement is that filing is
|
|
100
|
+
// unadjudicated generally — open issues sat flat at 32 across three
|
|
101
|
+
// readings while 8 closed and 8 were filed — so a gate that only runs
|
|
102
|
+
// inside one phase would leave the intake rate untouched.
|
|
103
|
+
const gate = await filingGate(cmd, { projectRoot: process.cwd() });
|
|
104
|
+
const unrecorded = gate.rows.filter(row => !recordAdjudication(row)).length;
|
|
105
|
+
// A refusal says the override "is recorded beside the refusal it waived".
|
|
106
|
+
// When the write failed that sentence is false, and a security control
|
|
107
|
+
// asserting a guarantee it is not providing is worse than one that says
|
|
108
|
+
// nothing — so the unrecorded notice rides ON the refusal rather than
|
|
109
|
+
// being skipped by the early exit, which is where it used to go.
|
|
110
|
+
const unrecordedNote =
|
|
111
|
+
unrecorded > 0
|
|
112
|
+
? `[FindingArbiter] ${unrecorded} adjudication(s) could NOT be written to ${ledgerPath()}, ` +
|
|
113
|
+
"so they are not in the population that prices this gate and any claim below that " +
|
|
114
|
+
"a decision was recorded does not hold for them."
|
|
115
|
+
: null;
|
|
79
116
|
|
|
80
|
-
|
|
117
|
+
// `gate.note` rides on the refusal for the same reason `unrecordedNote`
|
|
118
|
+
// does, and it was missed when that one was fixed: a `decision: "block"`
|
|
119
|
+
// payload has ONE text field, so anything not folded into `reason` here is
|
|
120
|
+
// discarded by the early exit and never reaches the agent.
|
|
121
|
+
//
|
|
122
|
+
// The note that mattered is the corpus-drop one. A refusal computed against
|
|
123
|
+
// a tracker three issues short is exactly where the shortfall needs saying
|
|
124
|
+
// — the agent is being told its finding is already filed, by a comparison
|
|
125
|
+
// that did not read the whole tracker — and that was the one path on which
|
|
126
|
+
// it was silently dropped. `FG-60` is the case; it went red here first.
|
|
127
|
+
if (gate.refusal !== null) {
|
|
128
|
+
const riders = [gate.note, unrecordedNote].filter((n): n is string => n !== null);
|
|
129
|
+
const reason = [gate.refusal, ...riders].join("\n\n");
|
|
130
|
+
console.log(JSON.stringify({ decision: "block", reason }));
|
|
131
|
+
process.exit(0);
|
|
132
|
+
}
|
|
133
|
+
// systemMessage and not stderr: stderr from a hook that exits 0 is not
|
|
134
|
+
// shown. An UNMEASURED nobody sees is a silent pass, which is the one thing
|
|
135
|
+
// lib/issue-filing-gate.ts's header says this must not become.
|
|
136
|
+
const notes = [gate.note, unrecordedNote].filter((n): n is string => n !== null);
|
|
137
|
+
if (notes.length > 0) console.log(JSON.stringify({ systemMessage: notes.join("\n\n") }));
|
|
81
138
|
process.exit(0);
|
|
82
139
|
}
|
|
83
140
|
|
|
@@ -19,12 +19,22 @@
|
|
|
19
19
|
* - `GateResultProtection` is authoritative for **what a permitted write may
|
|
20
20
|
* contain** — forged, erased or changed gate results, and `phase` DONE.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* THIS hook is the one that ships (`deployToConsumers: true`); the specific
|
|
23
|
+
* guard is OPT-IN and a scaffolded consumer does not get it. So on a consumer
|
|
24
|
+
* tree this is the ONLY guard on the artifact, and that is why its matcher
|
|
25
|
+
* being case-SENSITIVE while the specific guard's was case-folded (#1184) was
|
|
26
|
+
* a consumer-reachable gap and not a tidiness question. #1211 closed it: the
|
|
27
|
+
* matcher below case-folds, so the two predicates now agree on WHICH paths are
|
|
28
|
+
* the artifact and differ only in reach — `.includes()` here against
|
|
29
|
+
* `.endsWith()` there.
|
|
30
|
+
*
|
|
31
|
+
* The specific guard's refusals are therefore a SUBSET of this hook's. That is
|
|
32
|
+
* the safe direction and it is asserted, not assumed: this hook refusing every
|
|
33
|
+
* Write/Edit of the artifact means a consumer tree is covered for the question
|
|
34
|
+
* "may a tool call write this at all", which is the only question a consumer
|
|
35
|
+
* tree has a guard for. Subsumed is not dead — the two do not ship to the same
|
|
36
|
+
* trees, and the specific guard's refusal messages name the forgery while this
|
|
37
|
+
* one names the sanctioned writer.
|
|
28
38
|
*
|
|
29
39
|
* The contract is executed, not described:
|
|
30
40
|
* `test/workflow-state-write-contract.test.ts` runs both hooks over one corpus
|
|
@@ -47,7 +57,14 @@ async function main() {
|
|
|
47
57
|
// Write tool uses file_path; Edit tool uses file_path
|
|
48
58
|
const path = (toolInput.file_path as string) || (toolInput.path as string) || '';
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
// Case-FOLDED (#1211). `WORKFLOW-STATE.JSON` and `workflow-state.json` are one
|
|
61
|
+
// file on a case-insensitive filesystem — measured in #1184, which closed this
|
|
62
|
+
// in GateResultProtection and never carried the fix here. This is the guard
|
|
63
|
+
// that ships, so the uppercase spelling was reaching a consumer's disk with no
|
|
64
|
+
// guard at all. The population the fold newly claims is enumerated and bounded
|
|
65
|
+
// in test/workflow-state-guard-case.test.ts; it is case-variants of this name
|
|
66
|
+
// and nothing else.
|
|
67
|
+
if (!path.toLowerCase().includes('workflow-state.json')) process.exit(0);
|
|
51
68
|
|
|
52
69
|
// Block the write
|
|
53
70
|
const reason = [
|