@coderifts/agent-guard 1.8.0 → 2.0.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/README.md +68 -23
- package/dist/cjs/deploy-gate.d.ts +10 -3
- package/dist/cjs/deploy-gate.d.ts.map +1 -1
- package/dist/cjs/deploy-gate.js +7 -0
- package/dist/cjs/deploy-gate.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/merge-gate.d.ts +10 -3
- package/dist/cjs/merge-gate.d.ts.map +1 -1
- package/dist/cjs/merge-gate.js +6 -0
- package/dist/cjs/merge-gate.js.map +1 -1
- package/dist/cjs/tool-registry.d.ts.map +1 -1
- package/dist/cjs/tool-registry.js +7 -0
- package/dist/cjs/tool-registry.js.map +1 -1
- package/dist/cjs/with-coderifts.d.ts +108 -87
- package/dist/cjs/with-coderifts.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.js +129 -114
- package/dist/cjs/with-coderifts.js.map +1 -1
- package/dist/esm/deploy-gate.d.ts +10 -3
- package/dist/esm/deploy-gate.d.ts.map +1 -1
- package/dist/esm/deploy-gate.js +7 -0
- package/dist/esm/deploy-gate.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/merge-gate.d.ts +10 -3
- package/dist/esm/merge-gate.d.ts.map +1 -1
- package/dist/esm/merge-gate.js +6 -0
- package/dist/esm/merge-gate.js.map +1 -1
- package/dist/esm/tool-registry.d.ts.map +1 -1
- package/dist/esm/tool-registry.js +7 -0
- package/dist/esm/tool-registry.js.map +1 -1
- package/dist/esm/with-coderifts.d.ts +108 -87
- package/dist/esm/with-coderifts.d.ts.map +1 -1
- package/dist/esm/with-coderifts.js +126 -113
- package/dist/esm/with-coderifts.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,104 +15,51 @@
|
|
|
15
15
|
* `composition_assurance` so the trace survives into any later coverageReport consumer. S2 adds NO
|
|
16
16
|
* enforcement at call time.
|
|
17
17
|
*
|
|
18
|
-
* COMPOSITION OBSERVATION
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* coverage, residuals, or whether any tool runs.
|
|
18
|
+
* COMPOSITION OBSERVATION: optional `onEvent` is forwarded UNCHANGED onto the guard config.
|
|
19
|
+
* Optional `onSettledCall` is a composition-level hook: it fires EXACTLY ONCE for every SETTLED
|
|
20
|
+
* call through the RETURNED tool table (GUARDED | PASSTHROUGH | BYPASSED × RETURNED | THREW).
|
|
21
|
+
* Discriminant is an EXPLICIT TAG (`kind: 'settled_call'` plus route/terminal), never the absence of
|
|
22
|
+
* a field. On the GUARDED+RETURNED arm, `outcome` is non-optional. Observation is NOT enforcement —
|
|
23
|
+
* it does not change COMPOSITION_CALL_POLICY_COMPLETE, coverage, residuals, or whether any tool runs.
|
|
24
|
+
* The package holds NO counters and computes NO ratios at runtime; pure fold helpers are optional
|
|
25
|
+
* host-side tools (see foldTableSettledCalls / guardedFractionAmongRoutes).
|
|
24
26
|
*
|
|
25
27
|
* TELEMETRY GAPS (honest boundaries — read before claiming "every mutation was checked"):
|
|
26
28
|
* - onEvent does NOT emit a dedicated event for BLOCK or REQUIRE_APPROVAL; after preflight_result
|
|
27
|
-
* those paths return blocked with no further emit. Those outcomes ARE visible via
|
|
28
|
-
* (outcome.executed === false, outcome.verdict.kind === 'BLOCK' | 'APPROVAL')
|
|
29
|
+
* those paths return blocked with no further emit. Those outcomes ARE visible via onSettledCall
|
|
30
|
+
* on the GUARDED arm (outcome.executed === false, outcome.verdict.kind === 'BLOCK' | 'APPROVAL').
|
|
29
31
|
* - The GuardEvent payload carries no envelope, receipt, or fingerprint — only optional decisionId
|
|
30
|
-
* (and action/cause/signals/…).
|
|
31
|
-
* outcome.verdict.envelope where the frozen path attached one
|
|
32
|
-
* -
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* (and action/cause/signals/…). GUARDED+RETURNED onSettledCall carries the full GuardOutcome,
|
|
33
|
+
* including outcome.verdict.envelope where the frozen path attached one.
|
|
34
|
+
* - onSettledCall sees ONLY calls through the table withCodeRifts returned. Host-invoked raw tools
|
|
35
|
+
* outside that table are invisible. Never treat observation as "total operations" or "100%
|
|
36
|
+
* enforcement coverage".
|
|
35
37
|
* - onEvent is partial even for other branches (e.g. closed-availability stops may emit only
|
|
36
38
|
* preflight_start; the declared type 'execution_skipped' is never emitted by the frozen core).
|
|
37
39
|
* - Neither hook alone is a complete substrate for receipt carry-forward: onEvent lacks the
|
|
38
|
-
* envelope/receipt;
|
|
39
|
-
* across calls (that is a later slice).
|
|
40
|
+
* envelope/receipt; onSettledCall exposes them when present on the GUARDED+RETURNED arm but does
|
|
41
|
+
* not retain or re-inject them across calls (that is a later slice).
|
|
40
42
|
*
|
|
41
43
|
* S2 does NOT re-guard what the registry already fails closed on. A `forceReadonly`/`classify`
|
|
42
44
|
* downgrade of a heuristic mutator is, under the registry's default `failOnUnguardedMutator:true`,
|
|
43
45
|
* already a thrown `FORCE_READONLY_MUTATOR` (no report exists); when the caller passes
|
|
44
46
|
* `failOnUnguardedMutator:false` it is already registry coverage 'BYPASSED', which fails any
|
|
45
|
-
* `requireCoverage` above BYPASSED by the ordering alone.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* composition_unknown_treated_as_readonly) so the reason the composition is narrower than it looks is
|
|
49
|
-
* preserved on the assurance object. Registry-thrown errors propagate UNCHANGED (never wrapped or
|
|
50
|
-
* swallowed).
|
|
51
|
-
*
|
|
52
|
-
* How the weakening residuals are derived, and their KNOWN LIMITATION (a frozen-registry property, not
|
|
53
|
-
* a composition property): both residuals are read SOLELY from `registry_report.warnings` — the
|
|
54
|
-
* composition never recomputes classification. The registry emits `force_readonly_on_mutator_heuristic`
|
|
55
|
-
* ONLY for the downgrade of a HEURISTIC-classified mutator (a tool with no `classify` entry and no
|
|
56
|
-
* `mutationClass`, whose NAME heuristic is mutating), reached via `forceReadonly` OR a `classify`
|
|
57
|
-
* entry. Crucially, `forceReadonly` has NO effect on a tool the caller declared with an explicit
|
|
58
|
-
* `mutationClass`: `resolveClass` (tool-registry.ts:154-165) returns on `tool.mutationClass` at :157,
|
|
59
|
-
* BEFORE `forceReadonly` is consulted at :158 — so such a tool resolves `mutating`, stays guarded,
|
|
60
|
-
* yields coverage 'COMPLETE', and emits NO warning. The composition therefore produces NO residual in
|
|
61
|
-
* that case and CANNOT detect it: the caller's `forceReadonly` was silently ignored by the frozen
|
|
62
|
-
* registry. This is a limitation of the frozen registry surface, recorded (not worked around) here and
|
|
63
|
-
* pinned by a "documented limitation" test. The residual is named
|
|
64
|
-
* `composition_forced_readonly_on_heuristic_mutator` so it does not promise coverage of the case it
|
|
65
|
-
* cannot see.
|
|
47
|
+
* `requireCoverage` above BYPASSED by the ordering alone. The composition RECORDS residuals from
|
|
48
|
+
* registry warnings. When forceReadonly lists a tool that declared explicit mutationClass, the
|
|
49
|
+
* registry emits `force_readonly_ignored_explicit_mutation_class:<name>` (break-glass ignored).
|
|
66
50
|
*
|
|
67
51
|
* COMPOSITION_CALL_POLICY_COMPLETE (when the composition may claim product-level runtime
|
|
68
52
|
* inescapability) requires ALL of the following — do not flip the constant when only a subset lands:
|
|
69
53
|
* (1) Automatic binders for call shapes that ALREADY carry both sides of the change (old_string/
|
|
70
|
-
* new_string, edits[]) — DONE
|
|
71
|
-
* every real agent edit shape.
|
|
54
|
+
* new_string, edits[]) — DONE. Not the same as covering every real agent edit shape.
|
|
72
55
|
* (2) Receipt carry-forward (S5) — host-threaded chaining is POSSIBLE (optional previousReceipt +
|
|
73
|
-
* verifyReceiptChainLinkage
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* where the host never supplied `before` — NOT done. The package performs no IO, so a prior it
|
|
77
|
-
* was not given cannot be obtained; inventing one (including empty-string before) would send a
|
|
78
|
-
* fabricated artifact to the oracle. That needs a host/guard freshness protocol, not another
|
|
79
|
-
* binder rename. Flipping this constant on (1)+(2) alone is incorrect.
|
|
80
|
-
*
|
|
81
|
-
* STILL DELIBERATELY OUT OF SCOPE (later slices; not stubbed, not implied here): receipt carry-forward;
|
|
82
|
-
* freshness-safe prior content for write-style calls; call-time STOP re-implementation (already
|
|
83
|
-
* complete in the frozen guardToolCall path); WARN monitoring policy beyond the frozen sink gate;
|
|
84
|
-
* framework adapters. (Both-sides edit-side lifting in defaultBinder is landed — see (1) above.)
|
|
56
|
+
* verifyReceiptChainLinkage). NOT met for this constant: the composition holds no cursor.
|
|
57
|
+
* (3) A freshness-safe source of prior content for write-style calls (path + new content only) —
|
|
58
|
+
* NOT done.
|
|
85
59
|
*
|
|
86
60
|
* THE TWO-SCOPE RULE (never merged):
|
|
87
|
-
* - `registry_report` is EXACTLY what `guardToolRegistry` returned, passed through untouched.
|
|
88
|
-
*
|
|
89
|
-
* tool-boundary's own honest truth (Placement A).
|
|
90
|
-
* - `composition_assurance` is the narrower PRODUCT-level statement — what withCodeRifts as a whole
|
|
91
|
-
* is willing to claim today. It is computed SEPARATELY and never rewrites the registry's verdict.
|
|
92
|
-
* Its S1 semantics are UNCHANGED in S2 and under observation: coverage stays 'PARTIAL',
|
|
93
|
-
* inescapable_runtime stays false via the same COMPOSITION_CALL_POLICY_COMPLETE conjunction.
|
|
94
|
-
* The two truths coexist; neither is derived by mutating the other.
|
|
95
|
-
*
|
|
96
|
-
* `requireCoverage` scope (read this before trusting a green construction): it constrains the
|
|
97
|
-
* REGISTRY-level coverage ONLY. It CANNOT be used to demand composition-level runtime inescapability —
|
|
98
|
-
* that remains unreachable while COMPOSITION_CALL_POLICY_COMPLETE is false (see the three conditions
|
|
99
|
-
* above, not merely "binders + receipts"). A caller passing `requireCoverage:'COMPLETE'` is asserting
|
|
100
|
-
* an expectation about the registry tool-boundary surface — NOT a product-level guarantee. The abort
|
|
101
|
-
* text and this doc say so explicitly so nobody reads a green construction as product-level
|
|
102
|
-
* enforcement.
|
|
103
|
-
*
|
|
104
|
-
* Operation semantics (accurate scope): `operationForClass` (tool-registry.ts) already derives a
|
|
105
|
-
* per-tool operation from the tool's mutation class, OVERRIDING the guard config for specialised
|
|
106
|
-
* classes (deploy→'deploy', publish→'publish', vcs-merge→'merge', …). The mandatory `operation` here
|
|
107
|
-
* therefore governs generic mutating tools and acts as the session-level default; it does NOT override
|
|
108
|
-
* a deploy-class tool's 'deploy'. It is mandatory because receipts bind to an operation and
|
|
109
|
-
* merge != deploy: a silent default would risk evaluating a deploy under merge semantics.
|
|
110
|
-
*
|
|
111
|
-
* Abort discipline: pre-registry input problems (missing/empty operation, missing client, an invalid
|
|
112
|
-
* requireCoverage value) are collected and thrown as ONE error listing ALL of them. The
|
|
113
|
-
* requireCoverage-vs-actual check is necessarily sequenced AFTER the registry call (it needs the
|
|
114
|
-
* registry's coverage), so it is its own abort; it cannot be batched with the pre-registry problems
|
|
115
|
-
* because a valid operation+client are required even to reach the registry.
|
|
61
|
+
* - `registry_report` is EXACTLY what `guardToolRegistry` returned, passed through untouched.
|
|
62
|
+
* - `composition_assurance` is the narrower PRODUCT-level statement, computed SEPARATELY.
|
|
116
63
|
*/
|
|
117
64
|
import type { RawTool, ProtectedTool, EnforcementCoverage, RegistryCoverageReport, ToolBinder, ToolMutationClass } from './tool-registry.js';
|
|
118
65
|
import type { GuardConfig, GuardEvent, GuardOutcome } from './types.js';
|
|
@@ -124,14 +71,87 @@ export type WithCodeRiftsRegistryConfig = {
|
|
|
124
71
|
forceReadonly?: string[];
|
|
125
72
|
failOnUnguardedMutator?: boolean;
|
|
126
73
|
};
|
|
74
|
+
/** Route of a settled call through the returned table. Explicit tag values — never inferred by field absence. */
|
|
75
|
+
export type CallRoute = 'GUARDED' | 'PASSTHROUGH' | 'BYPASSED';
|
|
76
|
+
/** How a settled call finished. Explicit tag values. */
|
|
77
|
+
export type CallTerminal = 'RETURNED' | 'THREW';
|
|
127
78
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
79
|
+
* One settled call through the tool table withCodeRifts returned.
|
|
80
|
+
*
|
|
81
|
+
* Discriminant is the EXPLICIT `kind: 'settled_call'` plus `route` and `terminal` tags — never
|
|
82
|
+
* "outcome present vs missing". On GUARDED+RETURNED, `outcome` is required (non-optional).
|
|
83
|
+
*
|
|
84
|
+
* Replaces the former `ObservedOutcome` (`{ toolName, outcome }` only for guarded returns). The old
|
|
85
|
+
* name implied every observation carried a GuardOutcome and that only guarded tools were visible;
|
|
86
|
+
* both were false once passthrough/threw routes ship, so the name is retired rather than overloaded.
|
|
131
87
|
*/
|
|
132
|
-
export type
|
|
88
|
+
export type SettledCallObservation = {
|
|
89
|
+
kind: 'settled_call';
|
|
90
|
+
route: 'GUARDED';
|
|
91
|
+
terminal: 'RETURNED';
|
|
133
92
|
toolName: string;
|
|
134
93
|
outcome: GuardOutcome<unknown>;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'settled_call';
|
|
96
|
+
route: 'GUARDED';
|
|
97
|
+
terminal: 'THREW';
|
|
98
|
+
toolName: string;
|
|
99
|
+
error: unknown;
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'settled_call';
|
|
102
|
+
route: 'PASSTHROUGH';
|
|
103
|
+
terminal: 'RETURNED';
|
|
104
|
+
toolName: string;
|
|
105
|
+
result: unknown;
|
|
106
|
+
} | {
|
|
107
|
+
kind: 'settled_call';
|
|
108
|
+
route: 'PASSTHROUGH';
|
|
109
|
+
terminal: 'THREW';
|
|
110
|
+
toolName: string;
|
|
111
|
+
error: unknown;
|
|
112
|
+
} | {
|
|
113
|
+
kind: 'settled_call';
|
|
114
|
+
route: 'BYPASSED';
|
|
115
|
+
terminal: 'RETURNED';
|
|
116
|
+
toolName: string;
|
|
117
|
+
result: unknown;
|
|
118
|
+
} | {
|
|
119
|
+
kind: 'settled_call';
|
|
120
|
+
route: 'BYPASSED';
|
|
121
|
+
terminal: 'THREW';
|
|
122
|
+
toolName: string;
|
|
123
|
+
error: unknown;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Counts of settled-call routes from a host-collected event list.
|
|
127
|
+
* Names are route tags only — not "total operations" or "enforcement coverage".
|
|
128
|
+
*/
|
|
129
|
+
export type TableSettledCallRouteCounts = {
|
|
130
|
+
GUARDED: number;
|
|
131
|
+
PASSTHROUGH: number;
|
|
132
|
+
BYPASSED: number;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Pure fold: count routes in a host-owned list of settled-call observations.
|
|
136
|
+
* The package never accumulates these at runtime.
|
|
137
|
+
*/
|
|
138
|
+
export declare function foldTableSettledCalls(events: readonly SettledCallObservation[]): TableSettledCallRouteCounts;
|
|
139
|
+
/**
|
|
140
|
+
* Fraction of GUARDED among observed routes, or ABSENT when a ratio would be misleading.
|
|
141
|
+
*
|
|
142
|
+
* Returns `kind: 'absent'` (not zero) when:
|
|
143
|
+
* - no settled calls were observed, or
|
|
144
|
+
* - only a single route tag has a non-zero count (one-sided observation).
|
|
145
|
+
*
|
|
146
|
+
* Never returns a number that could be read as "0% enforcement" or "100% coverage" from partial data.
|
|
147
|
+
* The package does not call this automatically.
|
|
148
|
+
*/
|
|
149
|
+
export declare function guardedFractionAmongRoutes(counts: TableSettledCallRouteCounts): {
|
|
150
|
+
kind: 'absent';
|
|
151
|
+
why: 'no_settled_calls' | 'one_route_only';
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'present';
|
|
154
|
+
fraction: number;
|
|
135
155
|
};
|
|
136
156
|
export type WithCodeRiftsInput = {
|
|
137
157
|
/** Raw tool list handed to the frozen guardToolRegistry (required). */
|
|
@@ -163,11 +183,12 @@ export type WithCodeRiftsInput = {
|
|
|
163
183
|
*/
|
|
164
184
|
onEvent?: (e: GuardEvent) => void;
|
|
165
185
|
/**
|
|
166
|
-
* Optional. Invoked
|
|
167
|
-
*
|
|
168
|
-
* swallowed so observation never changes host-visible execution.
|
|
186
|
+
* Optional. Invoked once per SETTLED call through the returned tool table (every route and both
|
|
187
|
+
* terminals). Discriminated union — see SettledCallObservation. Throws and rejected promises are
|
|
188
|
+
* swallowed so observation never changes host-visible execution. Replaces the former `onOutcome`
|
|
189
|
+
* (guarded-only) hook.
|
|
169
190
|
*/
|
|
170
|
-
|
|
191
|
+
onSettledCall?: (o: SettledCallObservation) => void | PromiseLike<void>;
|
|
171
192
|
/**
|
|
172
193
|
* Optional prior chain-receipt token (or getter) forwarded onto GuardConfig.previousReceipt.
|
|
173
194
|
* Host-owned; the composition does not retain or advance it between calls.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-coderifts.d.ts","sourceRoot":"","sources":["../../src/with-coderifts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"with-coderifts.d.ts","sourceRoot":"","sources":["../../src/with-coderifts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EAEtB,UAAU,EACV,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAExE,2FAA2F;AAC3F,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AA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AC7B,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,mGAAmG;IACnG,eAAe,EAAE,sBAAsB,CAAC;IACxC,yEAAyE;IACzE,qBAAqB,EAAE,oBAAoB,CAAC;IAC5C,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAmIF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAmH5E"}
|
|
@@ -16,108 +16,92 @@
|
|
|
16
16
|
* `composition_assurance` so the trace survives into any later coverageReport consumer. S2 adds NO
|
|
17
17
|
* enforcement at call time.
|
|
18
18
|
*
|
|
19
|
-
* COMPOSITION OBSERVATION
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* coverage, residuals, or whether any tool runs.
|
|
19
|
+
* COMPOSITION OBSERVATION: optional `onEvent` is forwarded UNCHANGED onto the guard config.
|
|
20
|
+
* Optional `onSettledCall` is a composition-level hook: it fires EXACTLY ONCE for every SETTLED
|
|
21
|
+
* call through the RETURNED tool table (GUARDED | PASSTHROUGH | BYPASSED × RETURNED | THREW).
|
|
22
|
+
* Discriminant is an EXPLICIT TAG (`kind: 'settled_call'` plus route/terminal), never the absence of
|
|
23
|
+
* a field. On the GUARDED+RETURNED arm, `outcome` is non-optional. Observation is NOT enforcement —
|
|
24
|
+
* it does not change COMPOSITION_CALL_POLICY_COMPLETE, coverage, residuals, or whether any tool runs.
|
|
25
|
+
* The package holds NO counters and computes NO ratios at runtime; pure fold helpers are optional
|
|
26
|
+
* host-side tools (see foldTableSettledCalls / guardedFractionAmongRoutes).
|
|
25
27
|
*
|
|
26
28
|
* TELEMETRY GAPS (honest boundaries — read before claiming "every mutation was checked"):
|
|
27
29
|
* - onEvent does NOT emit a dedicated event for BLOCK or REQUIRE_APPROVAL; after preflight_result
|
|
28
|
-
* those paths return blocked with no further emit. Those outcomes ARE visible via
|
|
29
|
-
* (outcome.executed === false, outcome.verdict.kind === 'BLOCK' | 'APPROVAL')
|
|
30
|
+
* those paths return blocked with no further emit. Those outcomes ARE visible via onSettledCall
|
|
31
|
+
* on the GUARDED arm (outcome.executed === false, outcome.verdict.kind === 'BLOCK' | 'APPROVAL').
|
|
30
32
|
* - The GuardEvent payload carries no envelope, receipt, or fingerprint — only optional decisionId
|
|
31
|
-
* (and action/cause/signals/…).
|
|
32
|
-
* outcome.verdict.envelope where the frozen path attached one
|
|
33
|
-
* -
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* (and action/cause/signals/…). GUARDED+RETURNED onSettledCall carries the full GuardOutcome,
|
|
34
|
+
* including outcome.verdict.envelope where the frozen path attached one.
|
|
35
|
+
* - onSettledCall sees ONLY calls through the table withCodeRifts returned. Host-invoked raw tools
|
|
36
|
+
* outside that table are invisible. Never treat observation as "total operations" or "100%
|
|
37
|
+
* enforcement coverage".
|
|
36
38
|
* - onEvent is partial even for other branches (e.g. closed-availability stops may emit only
|
|
37
39
|
* preflight_start; the declared type 'execution_skipped' is never emitted by the frozen core).
|
|
38
40
|
* - Neither hook alone is a complete substrate for receipt carry-forward: onEvent lacks the
|
|
39
|
-
* envelope/receipt;
|
|
40
|
-
* across calls (that is a later slice).
|
|
41
|
+
* envelope/receipt; onSettledCall exposes them when present on the GUARDED+RETURNED arm but does
|
|
42
|
+
* not retain or re-inject them across calls (that is a later slice).
|
|
41
43
|
*
|
|
42
44
|
* S2 does NOT re-guard what the registry already fails closed on. A `forceReadonly`/`classify`
|
|
43
45
|
* downgrade of a heuristic mutator is, under the registry's default `failOnUnguardedMutator:true`,
|
|
44
46
|
* already a thrown `FORCE_READONLY_MUTATOR` (no report exists); when the caller passes
|
|
45
47
|
* `failOnUnguardedMutator:false` it is already registry coverage 'BYPASSED', which fails any
|
|
46
|
-
* `requireCoverage` above BYPASSED by the ordering alone.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* composition_unknown_treated_as_readonly) so the reason the composition is narrower than it looks is
|
|
50
|
-
* preserved on the assurance object. Registry-thrown errors propagate UNCHANGED (never wrapped or
|
|
51
|
-
* swallowed).
|
|
52
|
-
*
|
|
53
|
-
* How the weakening residuals are derived, and their KNOWN LIMITATION (a frozen-registry property, not
|
|
54
|
-
* a composition property): both residuals are read SOLELY from `registry_report.warnings` — the
|
|
55
|
-
* composition never recomputes classification. The registry emits `force_readonly_on_mutator_heuristic`
|
|
56
|
-
* ONLY for the downgrade of a HEURISTIC-classified mutator (a tool with no `classify` entry and no
|
|
57
|
-
* `mutationClass`, whose NAME heuristic is mutating), reached via `forceReadonly` OR a `classify`
|
|
58
|
-
* entry. Crucially, `forceReadonly` has NO effect on a tool the caller declared with an explicit
|
|
59
|
-
* `mutationClass`: `resolveClass` (tool-registry.ts:154-165) returns on `tool.mutationClass` at :157,
|
|
60
|
-
* BEFORE `forceReadonly` is consulted at :158 — so such a tool resolves `mutating`, stays guarded,
|
|
61
|
-
* yields coverage 'COMPLETE', and emits NO warning. The composition therefore produces NO residual in
|
|
62
|
-
* that case and CANNOT detect it: the caller's `forceReadonly` was silently ignored by the frozen
|
|
63
|
-
* registry. This is a limitation of the frozen registry surface, recorded (not worked around) here and
|
|
64
|
-
* pinned by a "documented limitation" test. The residual is named
|
|
65
|
-
* `composition_forced_readonly_on_heuristic_mutator` so it does not promise coverage of the case it
|
|
66
|
-
* cannot see.
|
|
48
|
+
* `requireCoverage` above BYPASSED by the ordering alone. The composition RECORDS residuals from
|
|
49
|
+
* registry warnings. When forceReadonly lists a tool that declared explicit mutationClass, the
|
|
50
|
+
* registry emits `force_readonly_ignored_explicit_mutation_class:<name>` (break-glass ignored).
|
|
67
51
|
*
|
|
68
52
|
* COMPOSITION_CALL_POLICY_COMPLETE (when the composition may claim product-level runtime
|
|
69
53
|
* inescapability) requires ALL of the following — do not flip the constant when only a subset lands:
|
|
70
54
|
* (1) Automatic binders for call shapes that ALREADY carry both sides of the change (old_string/
|
|
71
|
-
* new_string, edits[]) — DONE
|
|
72
|
-
* every real agent edit shape.
|
|
55
|
+
* new_string, edits[]) — DONE. Not the same as covering every real agent edit shape.
|
|
73
56
|
* (2) Receipt carry-forward (S5) — host-threaded chaining is POSSIBLE (optional previousReceipt +
|
|
74
|
-
* verifyReceiptChainLinkage
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* where the host never supplied `before` — NOT done. The package performs no IO, so a prior it
|
|
78
|
-
* was not given cannot be obtained; inventing one (including empty-string before) would send a
|
|
79
|
-
* fabricated artifact to the oracle. That needs a host/guard freshness protocol, not another
|
|
80
|
-
* binder rename. Flipping this constant on (1)+(2) alone is incorrect.
|
|
81
|
-
*
|
|
82
|
-
* STILL DELIBERATELY OUT OF SCOPE (later slices; not stubbed, not implied here): receipt carry-forward;
|
|
83
|
-
* freshness-safe prior content for write-style calls; call-time STOP re-implementation (already
|
|
84
|
-
* complete in the frozen guardToolCall path); WARN monitoring policy beyond the frozen sink gate;
|
|
85
|
-
* framework adapters. (Both-sides edit-side lifting in defaultBinder is landed — see (1) above.)
|
|
57
|
+
* verifyReceiptChainLinkage). NOT met for this constant: the composition holds no cursor.
|
|
58
|
+
* (3) A freshness-safe source of prior content for write-style calls (path + new content only) —
|
|
59
|
+
* NOT done.
|
|
86
60
|
*
|
|
87
61
|
* THE TWO-SCOPE RULE (never merged):
|
|
88
|
-
* - `registry_report` is EXACTLY what `guardToolRegistry` returned, passed through untouched.
|
|
89
|
-
*
|
|
90
|
-
* tool-boundary's own honest truth (Placement A).
|
|
91
|
-
* - `composition_assurance` is the narrower PRODUCT-level statement — what withCodeRifts as a whole
|
|
92
|
-
* is willing to claim today. It is computed SEPARATELY and never rewrites the registry's verdict.
|
|
93
|
-
* Its S1 semantics are UNCHANGED in S2 and under observation: coverage stays 'PARTIAL',
|
|
94
|
-
* inescapable_runtime stays false via the same COMPOSITION_CALL_POLICY_COMPLETE conjunction.
|
|
95
|
-
* The two truths coexist; neither is derived by mutating the other.
|
|
96
|
-
*
|
|
97
|
-
* `requireCoverage` scope (read this before trusting a green construction): it constrains the
|
|
98
|
-
* REGISTRY-level coverage ONLY. It CANNOT be used to demand composition-level runtime inescapability —
|
|
99
|
-
* that remains unreachable while COMPOSITION_CALL_POLICY_COMPLETE is false (see the three conditions
|
|
100
|
-
* above, not merely "binders + receipts"). A caller passing `requireCoverage:'COMPLETE'` is asserting
|
|
101
|
-
* an expectation about the registry tool-boundary surface — NOT a product-level guarantee. The abort
|
|
102
|
-
* text and this doc say so explicitly so nobody reads a green construction as product-level
|
|
103
|
-
* enforcement.
|
|
104
|
-
*
|
|
105
|
-
* Operation semantics (accurate scope): `operationForClass` (tool-registry.ts) already derives a
|
|
106
|
-
* per-tool operation from the tool's mutation class, OVERRIDING the guard config for specialised
|
|
107
|
-
* classes (deploy→'deploy', publish→'publish', vcs-merge→'merge', …). The mandatory `operation` here
|
|
108
|
-
* therefore governs generic mutating tools and acts as the session-level default; it does NOT override
|
|
109
|
-
* a deploy-class tool's 'deploy'. It is mandatory because receipts bind to an operation and
|
|
110
|
-
* merge != deploy: a silent default would risk evaluating a deploy under merge semantics.
|
|
111
|
-
*
|
|
112
|
-
* Abort discipline: pre-registry input problems (missing/empty operation, missing client, an invalid
|
|
113
|
-
* requireCoverage value) are collected and thrown as ONE error listing ALL of them. The
|
|
114
|
-
* requireCoverage-vs-actual check is necessarily sequenced AFTER the registry call (it needs the
|
|
115
|
-
* registry's coverage), so it is its own abort; it cannot be batched with the pre-registry problems
|
|
116
|
-
* because a valid operation+client are required even to reach the registry.
|
|
62
|
+
* - `registry_report` is EXACTLY what `guardToolRegistry` returned, passed through untouched.
|
|
63
|
+
* - `composition_assurance` is the narrower PRODUCT-level statement, computed SEPARATELY.
|
|
117
64
|
*/
|
|
118
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
exports.foldTableSettledCalls = foldTableSettledCalls;
|
|
67
|
+
exports.guardedFractionAmongRoutes = guardedFractionAmongRoutes;
|
|
119
68
|
exports.withCodeRifts = withCodeRifts;
|
|
120
69
|
const tool_registry_js_1 = require("./tool-registry.js");
|
|
70
|
+
/**
|
|
71
|
+
* Pure fold: count routes in a host-owned list of settled-call observations.
|
|
72
|
+
* The package never accumulates these at runtime.
|
|
73
|
+
*/
|
|
74
|
+
function foldTableSettledCalls(events) {
|
|
75
|
+
const counts = { GUARDED: 0, PASSTHROUGH: 0, BYPASSED: 0 };
|
|
76
|
+
for (const e of events) {
|
|
77
|
+
if (e.kind !== 'settled_call')
|
|
78
|
+
continue;
|
|
79
|
+
counts[e.route] += 1;
|
|
80
|
+
}
|
|
81
|
+
return counts;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Fraction of GUARDED among observed routes, or ABSENT when a ratio would be misleading.
|
|
85
|
+
*
|
|
86
|
+
* Returns `kind: 'absent'` (not zero) when:
|
|
87
|
+
* - no settled calls were observed, or
|
|
88
|
+
* - only a single route tag has a non-zero count (one-sided observation).
|
|
89
|
+
*
|
|
90
|
+
* Never returns a number that could be read as "0% enforcement" or "100% coverage" from partial data.
|
|
91
|
+
* The package does not call this automatically.
|
|
92
|
+
*/
|
|
93
|
+
function guardedFractionAmongRoutes(counts) {
|
|
94
|
+
const routesWithCalls = ['GUARDED', 'PASSTHROUGH', 'BYPASSED']
|
|
95
|
+
.filter((r) => counts[r] > 0);
|
|
96
|
+
if (routesWithCalls.length === 0) {
|
|
97
|
+
return { kind: 'absent', why: 'no_settled_calls' };
|
|
98
|
+
}
|
|
99
|
+
if (routesWithCalls.length === 1) {
|
|
100
|
+
return { kind: 'absent', why: 'one_route_only' };
|
|
101
|
+
}
|
|
102
|
+
const sum = counts.GUARDED + counts.PASSTHROUGH + counts.BYPASSED;
|
|
103
|
+
return { kind: 'present', fraction: counts.GUARDED / sum };
|
|
104
|
+
}
|
|
121
105
|
/**
|
|
122
106
|
* Whether the composition's call-time / content policy is complete enough to claim product-level
|
|
123
107
|
* runtime inescapability. Stays FALSE until EVERY condition below is delivered — later slices ADD
|
|
@@ -125,23 +109,15 @@ const tool_registry_js_1 = require("./tool-registry.js");
|
|
|
125
109
|
*
|
|
126
110
|
* Conditions (all required; do NOT flip this constant because a subset landed):
|
|
127
111
|
* (1) DONE — automatic binders for shapes that already carry both edit sides (old_string/new_string,
|
|
128
|
-
* edits[] → artifacts).
|
|
112
|
+
* edits[] → artifacts). Does NOT cover write-style path+new-content-only calls.
|
|
129
113
|
* (2) NOT DONE — receipt carry-forward (S5).
|
|
130
|
-
* (3) NOT DONE — freshness-safe prior content for write-style calls.
|
|
131
|
-
* `before` the host never supplied cannot be obtained; inventing one (including empty string)
|
|
132
|
-
* fabricates an oracle input. Needs a host/guard freshness protocol, not binder renaming.
|
|
133
|
-
*
|
|
134
|
-
* Historically this comment named only (1) and (2). That wording is narrower than reality: after (1)
|
|
135
|
-
* shipped, a reader could think "binders + S5" was enough and flip the flag incorrectly. Do not.
|
|
114
|
+
* (3) NOT DONE — freshness-safe prior content for write-style calls.
|
|
136
115
|
*
|
|
137
116
|
* UNCHANGED by S2 / composition observation (observing ≠ enforcing). Value stays false until all three.
|
|
138
117
|
*/
|
|
139
118
|
const COMPOSITION_CALL_POLICY_COMPLETE = false;
|
|
140
119
|
const RESIDUAL_CALL_POLICY_INCOMPLETE = 'composition_call_policy_incomplete';
|
|
141
120
|
// S2 weakening-override residuals — derived SOLELY from registry report.warnings (never recomputed).
|
|
142
|
-
// The name says "heuristic_mutator" on purpose: the registry only emits the underlying warning for a
|
|
143
|
-
// downgrade of a HEURISTIC-classified mutator (see the header limitation), so the residual must not
|
|
144
|
-
// promise coverage of a downgrade it cannot see (an explicit-mutationClass tool).
|
|
145
121
|
const RESIDUAL_FORCED_READONLY = 'composition_forced_readonly_on_heuristic_mutator';
|
|
146
122
|
const RESIDUAL_UNKNOWN_READONLY = 'composition_unknown_treated_as_readonly';
|
|
147
123
|
/**
|
|
@@ -164,25 +140,23 @@ function coverageRank(coverage) {
|
|
|
164
140
|
: undefined;
|
|
165
141
|
}
|
|
166
142
|
/**
|
|
167
|
-
* Invoke
|
|
143
|
+
* Invoke onSettledCall without affecting the host call. Swallows synchronous throws AND rejected
|
|
168
144
|
* promises (unlike the frozen emit hook, which only try/catches sync throws and ignores returned
|
|
169
145
|
* promises — that host-side footgun is deliberately not reproduced here).
|
|
170
146
|
*/
|
|
171
|
-
async function
|
|
147
|
+
async function safeOnSettledCall(onSettledCall, payload) {
|
|
172
148
|
try {
|
|
173
|
-
await Promise.resolve(
|
|
149
|
+
await Promise.resolve(onSettledCall(payload));
|
|
174
150
|
}
|
|
175
151
|
catch {
|
|
176
152
|
/* observation never changes execution */
|
|
177
153
|
}
|
|
178
154
|
}
|
|
179
155
|
/**
|
|
180
|
-
* Build a NEW ProtectedTool shell
|
|
181
|
-
*
|
|
182
|
-
* copied by reference (the _coderifts bag is already frozen by the registry). The new shell is
|
|
183
|
-
* frozen for parity with registry tools.
|
|
156
|
+
* Build a NEW ProtectedTool shell so we can observe settle without mutating the frozen registry object.
|
|
157
|
+
* name / description / inputSchema / meta / _coderifts are copied by reference.
|
|
184
158
|
*/
|
|
185
|
-
function
|
|
159
|
+
function wrapForSettledCallObservation(tool, route, onSettledCall) {
|
|
186
160
|
const innerExecute = tool.execute;
|
|
187
161
|
const toolName = tool.name;
|
|
188
162
|
const shell = {
|
|
@@ -192,22 +166,63 @@ function wrapGuardedForObservation(tool, onOutcome) {
|
|
|
192
166
|
meta: tool.meta,
|
|
193
167
|
_coderifts: tool._coderifts,
|
|
194
168
|
execute: async (args) => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
169
|
+
try {
|
|
170
|
+
const result = await innerExecute(args);
|
|
171
|
+
if (route === 'GUARDED') {
|
|
172
|
+
await safeOnSettledCall(onSettledCall, {
|
|
173
|
+
kind: 'settled_call',
|
|
174
|
+
route: 'GUARDED',
|
|
175
|
+
terminal: 'RETURNED',
|
|
176
|
+
toolName,
|
|
177
|
+
// Guarded execute always returns a GuardOutcome from guardToolCall.
|
|
178
|
+
outcome: result,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
await safeOnSettledCall(onSettledCall, {
|
|
183
|
+
kind: 'settled_call',
|
|
184
|
+
route,
|
|
185
|
+
terminal: 'RETURNED',
|
|
186
|
+
toolName,
|
|
187
|
+
result,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// Host must receive the same object/value the unwrapped tool returned (reference-identical for objects).
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
await safeOnSettledCall(onSettledCall, {
|
|
195
|
+
kind: 'settled_call',
|
|
196
|
+
route,
|
|
197
|
+
terminal: 'THREW',
|
|
198
|
+
toolName,
|
|
199
|
+
error,
|
|
200
|
+
});
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
204
203
|
},
|
|
205
204
|
};
|
|
206
|
-
// Match registry freeze discipline: freeze _coderifts if not already, freeze the shell.
|
|
207
205
|
if (!Object.isFrozen(shell._coderifts))
|
|
208
206
|
Object.freeze(shell._coderifts);
|
|
209
207
|
return Object.freeze(shell);
|
|
210
208
|
}
|
|
209
|
+
/** Tools forced to readonly via heuristic break-glass — observed as BYPASSED, not true PASSTHROUGH. */
|
|
210
|
+
function bypassedToolNames(report) {
|
|
211
|
+
const names = new Set();
|
|
212
|
+
for (const w of report.warnings) {
|
|
213
|
+
const prefix = 'force_readonly_on_mutator_heuristic:';
|
|
214
|
+
if (w.startsWith(prefix))
|
|
215
|
+
names.add(w.slice(prefix.length));
|
|
216
|
+
}
|
|
217
|
+
return names;
|
|
218
|
+
}
|
|
219
|
+
function routeForTool(tool, bypassed) {
|
|
220
|
+
if (tool._coderifts.guarded)
|
|
221
|
+
return 'GUARDED';
|
|
222
|
+
if (bypassed.has(tool.name))
|
|
223
|
+
return 'BYPASSED';
|
|
224
|
+
return 'PASSTHROUGH';
|
|
225
|
+
}
|
|
211
226
|
/**
|
|
212
227
|
* Wrap guardToolRegistry with a mandatory operation and a separately-computed composition assurance.
|
|
213
228
|
* Fails at CONSTRUCTION (never at first tool call) for a missing client, a missing/empty operation, an
|
|
@@ -297,14 +312,14 @@ function withCodeRifts(input) {
|
|
|
297
312
|
inescapable_runtime: compositionInescapableRuntime,
|
|
298
313
|
residuals,
|
|
299
314
|
};
|
|
300
|
-
//
|
|
301
|
-
// We cannot reassign execute on a frozen tool, so we build NEW shells for
|
|
302
|
-
//
|
|
303
|
-
// The tools ARRAY is also frozen by the registry — always return a fresh array when we wrap.
|
|
315
|
+
// Settled-call observation: registry returns FROZEN ProtectedTool objects (and a frozen tools array).
|
|
316
|
+
// We cannot reassign execute on a frozen tool, so we build NEW shells for EVERY tool in the table
|
|
317
|
+
// when onSettledCall is provided — including passthrough and forced-bypass (readonly) tools.
|
|
304
318
|
let toolsOut = tools;
|
|
305
|
-
if (input.
|
|
306
|
-
const
|
|
307
|
-
|
|
319
|
+
if (input.onSettledCall) {
|
|
320
|
+
const onSettledCall = input.onSettledCall;
|
|
321
|
+
const bypassed = bypassedToolNames(report);
|
|
322
|
+
toolsOut = Object.freeze(tools.map((t) => wrapForSettledCallObservation(t, routeForTool(t, bypassed), onSettledCall)));
|
|
308
323
|
}
|
|
309
324
|
const result = {
|
|
310
325
|
tools: toolsOut,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-coderifts.js","sourceRoot":"","sources":["../../src/with-coderifts.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"with-coderifts.js","sourceRoot":"","sources":["../../src/with-coderifts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;;AAiGH,sDASC;AAYD,gEAeC;AAqMD,sCAm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