@memnexus-ai/mx-agent-cli 0.1.292 → 0.1.294-next.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/dist/__tests__/config-sync.test.js +54 -1
- package/dist/__tests__/config-sync.test.js.map +1 -1
- package/dist/__tests__/decision-check.test.d.ts +2 -0
- package/dist/__tests__/decision-check.test.d.ts.map +1 -0
- package/dist/__tests__/decision-check.test.js +105 -0
- package/dist/__tests__/decision-check.test.js.map +1 -0
- package/dist/__tests__/doctor-framework-version.test.d.ts +2 -0
- package/dist/__tests__/doctor-framework-version.test.d.ts.map +1 -0
- package/dist/__tests__/doctor-framework-version.test.js +146 -0
- package/dist/__tests__/doctor-framework-version.test.js.map +1 -0
- package/dist/__tests__/harness-extract.test.d.ts +19 -0
- package/dist/__tests__/harness-extract.test.d.ts.map +1 -0
- package/dist/__tests__/harness-extract.test.js +566 -0
- package/dist/__tests__/harness-extract.test.js.map +1 -0
- package/dist/__tests__/harness-wiring.test.d.ts +16 -0
- package/dist/__tests__/harness-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/harness-wiring.test.js +469 -0
- package/dist/__tests__/harness-wiring.test.js.map +1 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts +2 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts.map +1 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js +256 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +1 -0
- package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts +2 -0
- package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts.map +1 -0
- package/dist/__tests__/mx-agent-cli-version-pin.test.js +290 -0
- package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +1 -0
- package/dist/__tests__/report-format.test.d.ts +2 -0
- package/dist/__tests__/report-format.test.d.ts.map +1 -0
- package/dist/__tests__/report-format.test.js +219 -0
- package/dist/__tests__/report-format.test.js.map +1 -0
- package/dist/__tests__/standards-injection.test.d.ts +2 -0
- package/dist/__tests__/standards-injection.test.d.ts.map +1 -0
- package/dist/__tests__/standards-injection.test.js +157 -0
- package/dist/__tests__/standards-injection.test.js.map +1 -0
- package/dist/agent-config/hooks/auto-capture-precompact.sh +74 -4
- package/dist/agent-config/hooks/auto-capture-session-end.sh +106 -4
- package/dist/agent-config/hooks/auto-checkpoint.sh +75 -5
- package/dist/agent-config/hooks/observability-sync.sh +46 -9
- package/dist/commands/config-sync.d.ts +37 -0
- package/dist/commands/config-sync.d.ts.map +1 -1
- package/dist/commands/config-sync.js +36 -18
- package/dist/commands/config-sync.js.map +1 -1
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +10 -2
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/decision.d.ts +20 -0
- package/dist/commands/decision.d.ts.map +1 -0
- package/dist/commands/decision.js +54 -0
- package/dist/commands/decision.js.map +1 -0
- package/dist/commands/doctor.d.ts +18 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +41 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/monitor.d.ts.map +1 -1
- package/dist/commands/monitor.js +8 -2
- package/dist/commands/monitor.js.map +1 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +15 -1
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/report.d.ts +33 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +73 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/start.d.ts +4 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +6 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/update.d.ts +13 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +50 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-session.d.ts +12 -0
- package/dist/lib/agent-session.d.ts.map +1 -1
- package/dist/lib/agent-session.js +183 -41
- package/dist/lib/agent-session.js.map +1 -1
- package/dist/lib/claude.d.ts +12 -0
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +29 -2
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/decision-check.d.ts +48 -0
- package/dist/lib/decision-check.d.ts.map +1 -0
- package/dist/lib/decision-check.js +149 -0
- package/dist/lib/decision-check.js.map +1 -0
- package/dist/lib/framework-version.d.ts +144 -0
- package/dist/lib/framework-version.d.ts.map +1 -0
- package/dist/lib/framework-version.js +270 -0
- package/dist/lib/framework-version.js.map +1 -0
- package/dist/lib/harness/console/announce.d.ts +45 -0
- package/dist/lib/harness/console/announce.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.js +48 -0
- package/dist/lib/harness/console/announce.js.map +1 -0
- package/dist/lib/harness/console/announce.test.d.ts +2 -0
- package/dist/lib/harness/console/announce.test.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.test.js +104 -0
- package/dist/lib/harness/console/announce.test.js.map +1 -0
- package/dist/lib/harness/console/by-session.d.ts +50 -0
- package/dist/lib/harness/console/by-session.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.js +83 -0
- package/dist/lib/harness/console/by-session.js.map +1 -0
- package/dist/lib/harness/console/by-session.test.d.ts +2 -0
- package/dist/lib/harness/console/by-session.test.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.test.js +86 -0
- package/dist/lib/harness/console/by-session.test.js.map +1 -0
- package/dist/lib/harness/console/console.d.ts +67 -0
- package/dist/lib/harness/console/console.d.ts.map +1 -0
- package/dist/lib/harness/console/console.js +373 -0
- package/dist/lib/harness/console/console.js.map +1 -0
- package/dist/lib/harness/console/console.test.d.ts +2 -0
- package/dist/lib/harness/console/console.test.d.ts.map +1 -0
- package/dist/lib/harness/console/console.test.js +269 -0
- package/dist/lib/harness/console/console.test.js.map +1 -0
- package/dist/lib/harness/console/decision-request.d.ts +32 -0
- package/dist/lib/harness/console/decision-request.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.js +112 -0
- package/dist/lib/harness/console/decision-request.js.map +1 -0
- package/dist/lib/harness/console/decision-request.test.d.ts +2 -0
- package/dist/lib/harness/console/decision-request.test.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.test.js +75 -0
- package/dist/lib/harness/console/decision-request.test.js.map +1 -0
- package/dist/lib/harness/console/fixtures.d.ts +16 -0
- package/dist/lib/harness/console/fixtures.d.ts.map +1 -0
- package/dist/lib/harness/console/fixtures.js +49 -0
- package/dist/lib/harness/console/fixtures.js.map +1 -0
- package/dist/lib/harness/console/index.d.ts +15 -0
- package/dist/lib/harness/console/index.d.ts.map +1 -0
- package/dist/lib/harness/console/index.js +14 -0
- package/dist/lib/harness/console/index.js.map +1 -0
- package/dist/lib/harness/console/rank.d.ts +73 -0
- package/dist/lib/harness/console/rank.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.js +113 -0
- package/dist/lib/harness/console/rank.js.map +1 -0
- package/dist/lib/harness/console/rank.test.d.ts +2 -0
- package/dist/lib/harness/console/rank.test.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.test.js +124 -0
- package/dist/lib/harness/console/rank.test.js.map +1 -0
- package/dist/lib/harness/console/render.d.ts +22 -0
- package/dist/lib/harness/console/render.d.ts.map +1 -0
- package/dist/lib/harness/console/render.js +65 -0
- package/dist/lib/harness/console/render.js.map +1 -0
- package/dist/lib/harness/console/render.test.d.ts +2 -0
- package/dist/lib/harness/console/render.test.d.ts.map +1 -0
- package/dist/lib/harness/console/render.test.js +96 -0
- package/dist/lib/harness/console/render.test.js.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts +2 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.js +96 -0
- package/dist/lib/harness/console/replay-cli.test.js.map +1 -0
- package/dist/lib/harness/console/replay.d.ts +36 -0
- package/dist/lib/harness/console/replay.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.js +59 -0
- package/dist/lib/harness/console/replay.js.map +1 -0
- package/dist/lib/harness/console/replay.test.d.ts +2 -0
- package/dist/lib/harness/console/replay.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.test.js +81 -0
- package/dist/lib/harness/console/replay.test.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.d.ts +50 -0
- package/dist/lib/harness/console/turn-reader.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.js +184 -0
- package/dist/lib/harness/console/turn-reader.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts +2 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.js +108 -0
- package/dist/lib/harness/console/turn-reader.test.js.map +1 -0
- package/dist/lib/harness/console/types.d.ts +109 -0
- package/dist/lib/harness/console/types.d.ts.map +1 -0
- package/dist/lib/harness/console/types.js +2 -0
- package/dist/lib/harness/console/types.js.map +1 -0
- package/dist/lib/harness/contract.d.ts +229 -0
- package/dist/lib/harness/contract.d.ts.map +1 -0
- package/dist/lib/harness/contract.js +22 -0
- package/dist/lib/harness/contract.js.map +1 -0
- package/dist/lib/harness/credential.d.ts +23 -0
- package/dist/lib/harness/credential.d.ts.map +1 -0
- package/dist/lib/harness/credential.js +81 -0
- package/dist/lib/harness/credential.js.map +1 -0
- package/dist/lib/harness/credential.test.d.ts +2 -0
- package/dist/lib/harness/credential.test.d.ts.map +1 -0
- package/dist/lib/harness/credential.test.js +74 -0
- package/dist/lib/harness/credential.test.js.map +1 -0
- package/dist/lib/harness/evaluate.d.ts +390 -0
- package/dist/lib/harness/evaluate.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.js +988 -0
- package/dist/lib/harness/evaluate.js.map +1 -0
- package/dist/lib/harness/evaluate.test.d.ts +2 -0
- package/dist/lib/harness/evaluate.test.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.test.js +621 -0
- package/dist/lib/harness/evaluate.test.js.map +1 -0
- package/dist/lib/harness/extract.d.ts +152 -0
- package/dist/lib/harness/extract.d.ts.map +1 -0
- package/dist/lib/harness/extract.js +1601 -0
- package/dist/lib/harness/extract.js.map +1 -0
- package/dist/lib/harness/gate.d.ts +48 -0
- package/dist/lib/harness/gate.d.ts.map +1 -0
- package/dist/lib/harness/gate.js +60 -0
- package/dist/lib/harness/gate.js.map +1 -0
- package/dist/lib/harness/gate.test.d.ts +2 -0
- package/dist/lib/harness/gate.test.d.ts.map +1 -0
- package/dist/lib/harness/gate.test.js +111 -0
- package/dist/lib/harness/gate.test.js.map +1 -0
- package/dist/lib/harness/self-check.d.ts +59 -0
- package/dist/lib/harness/self-check.d.ts.map +1 -0
- package/dist/lib/harness/self-check.js +56 -0
- package/dist/lib/harness/self-check.js.map +1 -0
- package/dist/lib/harness/self-check.test.d.ts +2 -0
- package/dist/lib/harness/self-check.test.d.ts.map +1 -0
- package/dist/lib/harness/self-check.test.js +43 -0
- package/dist/lib/harness/self-check.test.js.map +1 -0
- package/dist/lib/harness/transcript.d.ts +65 -0
- package/dist/lib/harness/transcript.d.ts.map +1 -0
- package/dist/lib/harness/transcript.js +144 -0
- package/dist/lib/harness/transcript.js.map +1 -0
- package/dist/lib/harness/transcript.test.d.ts +2 -0
- package/dist/lib/harness/transcript.test.d.ts.map +1 -0
- package/dist/lib/harness/transcript.test.js +118 -0
- package/dist/lib/harness/transcript.test.js.map +1 -0
- package/dist/lib/harness-wiring.d.ts +145 -0
- package/dist/lib/harness-wiring.d.ts.map +1 -0
- package/dist/lib/harness-wiring.js +280 -0
- package/dist/lib/harness-wiring.js.map +1 -0
- package/dist/lib/report-format.d.ts +132 -0
- package/dist/lib/report-format.d.ts.map +1 -0
- package/dist/lib/report-format.js +317 -0
- package/dist/lib/report-format.js.map +1 -0
- package/dist/lib/standards.d.ts +90 -0
- package/dist/lib/standards.d.ts.map +1 -0
- package/dist/lib/standards.js +194 -0
- package/dist/lib/standards.js.map +1 -0
- package/dist/lib/templates.d.ts +26 -0
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +81 -3
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/terminal-ui.d.ts.map +1 -1
- package/dist/lib/terminal-ui.js +12 -1
- package/dist/lib/terminal-ui.js.map +1 -1
- package/dist/standards/decision-request.md +90 -0
- package/dist/standards/fail-loud-standard.md +495 -0
- package/dist/standards/report-format.md +120 -0
- package/dist/standards/writing-standard.md +240 -0
- package/package.json +3 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { mkdtempSync, writeFileSync, rmSync } from 'fs';
|
|
3
|
+
import { tmpdir } from 'os';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { checkCredential, refuseToStart } from './credential.js';
|
|
6
|
+
const NONE = join(tmpdir(), 'mx-no-such-credential-file.json');
|
|
7
|
+
describe('checkCredential', () => {
|
|
8
|
+
it('reports metered when an API key is set', () => {
|
|
9
|
+
const c = checkCredential({ env: { ANTHROPIC_API_KEY: 'x' }, credentialsFile: NONE });
|
|
10
|
+
expect(c.kind).toBe('api-key');
|
|
11
|
+
expect(c.source).toContain('ANTHROPIC_API_KEY');
|
|
12
|
+
});
|
|
13
|
+
it('never returns the credential value itself', () => {
|
|
14
|
+
const secret = 'sk-ant-super-secret-value';
|
|
15
|
+
const c = checkCredential({ env: { ANTHROPIC_API_KEY: secret }, credentialsFile: NONE });
|
|
16
|
+
expect(JSON.stringify(c)).not.toContain(secret);
|
|
17
|
+
});
|
|
18
|
+
it('treats an empty variable as unset', () => {
|
|
19
|
+
const c = checkCredential({ env: { ANTHROPIC_API_KEY: ' ' }, credentialsFile: NONE });
|
|
20
|
+
expect(c.kind).toBe('unknown');
|
|
21
|
+
});
|
|
22
|
+
it('reports metered when both a key and a subscription file are present', () => {
|
|
23
|
+
const dir = mkdtempSync(join(tmpdir(), 'mx-cred-'));
|
|
24
|
+
const file = join(dir, '.credentials.json');
|
|
25
|
+
writeFileSync(file, '{}');
|
|
26
|
+
try {
|
|
27
|
+
const c = checkCredential({ env: { ANTHROPIC_API_KEY: 'x' }, credentialsFile: file });
|
|
28
|
+
expect(c.kind).toBe('api-key');
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
rmSync(dir, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
it('reports subscription from the credential file when no key is set', () => {
|
|
35
|
+
const dir = mkdtempSync(join(tmpdir(), 'mx-cred-'));
|
|
36
|
+
const file = join(dir, '.credentials.json');
|
|
37
|
+
writeFileSync(file, '{}');
|
|
38
|
+
try {
|
|
39
|
+
const c = checkCredential({ env: {}, credentialsFile: file });
|
|
40
|
+
expect(c.kind).toBe('subscription');
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
rmSync(dir, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
it('reports unknown when nothing identifies a credential', () => {
|
|
47
|
+
expect(checkCredential({ env: {}, credentialsFile: NONE }).kind).toBe('unknown');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('refuseToStart', () => {
|
|
51
|
+
it('refuses a metered session by default', () => {
|
|
52
|
+
const r = refuseToStart({ kind: 'api-key', source: 'ANTHROPIC_API_KEY set' });
|
|
53
|
+
expect(r.refuse).toBe(true);
|
|
54
|
+
expect(r.message).toContain('uncapped');
|
|
55
|
+
});
|
|
56
|
+
it('allows metered when the operator asked for it', () => {
|
|
57
|
+
const r = refuseToStart({ kind: 'api-key', source: 'x' }, { allowMetered: true });
|
|
58
|
+
expect(r.refuse).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
it('starts on subscription and says nothing', () => {
|
|
61
|
+
const r = refuseToStart({ kind: 'subscription', source: 'x' });
|
|
62
|
+
expect(r.refuse).toBe(false);
|
|
63
|
+
expect(r.message).toBeUndefined();
|
|
64
|
+
});
|
|
65
|
+
// A live proof run started on `unknown` and died thirty seconds later with
|
|
66
|
+
// "Not logged in". The classification was right and the silence was wrong.
|
|
67
|
+
it('starts on unknown but warns that it expects an authentication failure', () => {
|
|
68
|
+
const r = refuseToStart({ kind: 'unknown', source: 'no credential file' });
|
|
69
|
+
expect(r.refuse).toBe(false);
|
|
70
|
+
expect(r.message).toContain('probably fail to authenticate');
|
|
71
|
+
expect(r.message).toContain('no credential file');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=credential.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.test.js","sourceRoot":"","sources":["../../../src/lib/harness/credential.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,iCAAiC,CAAC,CAAC;AAE/D,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,GAAG,eAAe,CAAC,EAAE,GAAG,EAAE,EAAE,iBAAiB,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QACtF,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAClD,CAAC,CAAC,C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5
|
+
* extractor and decides on them. That division is the reason the 41 deny
|
|
6
|
+
* entries in `settings.json` collapse to about 14 decisions: 18 of those
|
|
7
|
+
* entries are the single sentence "a team stays off main" written as 18 string
|
|
8
|
+
* patterns, and a rule that decides on a parsed operation and a resolved path
|
|
9
|
+
* needs one.
|
|
10
|
+
*
|
|
11
|
+
* `attrs.command` exists on the contract for the record and for the operator.
|
|
12
|
+
* Nothing below reads it, and a test asserts that.
|
|
13
|
+
*
|
|
14
|
+
* Two stages, both in this file:
|
|
15
|
+
*
|
|
16
|
+
* RuleSource[] ──▶ compileRuleset() ──▶ CompiledEvaluator
|
|
17
|
+
* │ │
|
|
18
|
+
* Refusal[] (throws) evaluate(attrs, principal, surface)
|
|
19
|
+
*
|
|
20
|
+
* The compiler refuses. It does not warn, on the three cases the fleet has
|
|
21
|
+
* already paid for:
|
|
22
|
+
*
|
|
23
|
+
* 1. A rule bound to a surface that observes none of the rule's operations.
|
|
24
|
+
* The permission callback never received `Read`, `Glob` or the delegation
|
|
25
|
+
* call across POC-1c, so a read rule bound to it reports healthy and
|
|
26
|
+
* refuses nothing. That is the 2026-08-01 shape: present, registered,
|
|
27
|
+
* green, inert. A rule that silently never fires is worse than no rule,
|
|
28
|
+
* because it also occupies the slot where a working rule would go.
|
|
29
|
+
* 2. Two rules on one team claiming the same write scope. Which one decides a
|
|
30
|
+
* write under that scope is then a question the ruleset does not answer,
|
|
31
|
+
* and the answer would depend on declaration order.
|
|
32
|
+
* 3. A rule with no rationale. A rule nobody can explain is a rule nobody can
|
|
33
|
+
* challenge, and the challenge path is what stops a wrong rule from
|
|
34
|
+
* outliving the reason somebody wrote it.
|
|
35
|
+
*
|
|
36
|
+
* Twelve further refusals follow the same standard and are listed on
|
|
37
|
+
* `RefusalCode`.
|
|
38
|
+
*/
|
|
39
|
+
import type { Attributes, Decision, Effect, Evaluator, Principal, Rule, Surface } from './contract.js';
|
|
40
|
+
/**
|
|
41
|
+
* The vocabulary `extract.ts` produces, read from that file rather than
|
|
42
|
+
* assumed. This file decides on these names and knows nothing about the tool
|
|
43
|
+
* names or the shell text behind them.
|
|
44
|
+
*
|
|
45
|
+
* write any file mutation, from Write, Edit, MultiEdit, NotebookEdit,
|
|
46
|
+
* a shell redirect, `sed -i`, `cp`, `tee` and the rest
|
|
47
|
+
* read any read, from Read, NotebookRead, Glob, Grep or `cat`
|
|
48
|
+
* chmod a mode change
|
|
49
|
+
* chdir a `cd` that moved the working directory
|
|
50
|
+
* unknown a command whose effect the extractor could not determine
|
|
51
|
+
* noop a command that touches nothing
|
|
52
|
+
* git.<verb> a parsed git operation, e.g. `git.reset-hard`, `git.push-main`
|
|
53
|
+
* tool.<Name> a tool the extractor does not model, and `tool.Task`
|
|
54
|
+
* change a completed change at merge time. No tool call produces it,
|
|
55
|
+
* and the integration lane that would is not built
|
|
56
|
+
*
|
|
57
|
+
* One operation names a call even when the call did several things, and the
|
|
58
|
+
* extractor picks the most consequential. `writes` and `reads` hold the union
|
|
59
|
+
* either way, so a rule that decides on paths loses nothing by that choice.
|
|
60
|
+
*
|
|
61
|
+
* Two consequences a rule author has to know.
|
|
62
|
+
*
|
|
63
|
+
* A `write` operation could be a Write tool call or a shell redirect, and the
|
|
64
|
+
* two reach different surfaces.
|
|
65
|
+
*
|
|
66
|
+
* Uncertainty is not one thing, and the operation separates the two kinds. A
|
|
67
|
+
* write whose target could not be resolved folds to `write` with `uncertain`
|
|
68
|
+
* set: `echo hi > $(pick)`, `sed -i s/a/b/ $TARGET`, `cd $X && rm -rf build`,
|
|
69
|
+
* and a Write tool call with no path. A command the extractor does not model
|
|
70
|
+
* folds to `unknown` or `chdir` with `uncertain` set: `npm test`, `pytest -q`,
|
|
71
|
+
* `make build`. A write rule that lists `unknown` escalates on every test run,
|
|
72
|
+
* which is an escalation nobody can act on. The rules below list the first kind
|
|
73
|
+
* and leave the second alone, and state that gap in their rationale.
|
|
74
|
+
*/
|
|
75
|
+
export declare const OPERATIONS_THAT_CAN_WRITE: readonly ["write", "chmod", "git.*"];
|
|
76
|
+
export interface SurfaceCapability {
|
|
77
|
+
/** Operation patterns this surface observes. */
|
|
78
|
+
observes: string[];
|
|
79
|
+
/** False when the surface does not exist yet. A blocking rule needs one that does. */
|
|
80
|
+
available: boolean;
|
|
81
|
+
/** Where the entry comes from. Every claim here is measured or read from config. */
|
|
82
|
+
basis: string;
|
|
83
|
+
}
|
|
84
|
+
export declare const SURFACES: Record<Surface, SurfaceCapability>;
|
|
85
|
+
/**
|
|
86
|
+
* What to do when the extractor could not determine the targets.
|
|
87
|
+
*
|
|
88
|
+
* skip the rule does not match. Use only where uncertainty is harmless.
|
|
89
|
+
* escalate the rule matches and the decision becomes `ask`.
|
|
90
|
+
* match the rule matches and its own effect applies.
|
|
91
|
+
*
|
|
92
|
+
* Required on any rule with a path condition. `git-mutation-guard.sh` fails
|
|
93
|
+
* open when it cannot parse its input (#5434), which is what happens when
|
|
94
|
+
* uncertainty is allowed to look like safety.
|
|
95
|
+
*/
|
|
96
|
+
export type UncertaintyHandling = 'skip' | 'escalate' | 'match';
|
|
97
|
+
export interface PathCondition {
|
|
98
|
+
/** Matches when a target path is outside every one of these roots. */
|
|
99
|
+
outside?: string[];
|
|
100
|
+
/** Matches when a target path is inside one of these roots. */
|
|
101
|
+
inside?: string[];
|
|
102
|
+
/** Matches when a target path matches one of these globs. `**` crosses directories. */
|
|
103
|
+
globs?: string[];
|
|
104
|
+
}
|
|
105
|
+
export interface MatchSpec {
|
|
106
|
+
/** Operations this rule is about. Required: the surface check reads it. */
|
|
107
|
+
operations: string[];
|
|
108
|
+
writes?: PathCondition;
|
|
109
|
+
reads?: PathCondition;
|
|
110
|
+
/**
|
|
111
|
+
* Tests where the call worked, after any `cd` and any `git -C`, rather than
|
|
112
|
+
* what it read. A `reads` condition cannot express this: `reads` holds the
|
|
113
|
+
* working directory and every file the call opened, so `outside` on it
|
|
114
|
+
* refuses `cat /home/vscode/.claude/settings.json` as well as
|
|
115
|
+
* `cd /workspace`, and the control set holds the first.
|
|
116
|
+
*
|
|
117
|
+
* Does not match when `attrs.workingDir` is absent, so an extractor that does
|
|
118
|
+
* not report it disables this clause rather than refusing every call. The
|
|
119
|
+
* compiler warns when a rule names it, because a clause that can be disabled
|
|
120
|
+
* from outside the ruleset is a clause an operator should know about.
|
|
121
|
+
*/
|
|
122
|
+
workingDir?: PathCondition;
|
|
123
|
+
onUncertain?: UncertaintyHandling;
|
|
124
|
+
}
|
|
125
|
+
/** Who owns a rule and what its subject may do about it. */
|
|
126
|
+
export interface ChangeControl {
|
|
127
|
+
owner: string;
|
|
128
|
+
subjectMayPropose: boolean;
|
|
129
|
+
subjectMayApply: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* An example is an attribute fixture, not a command string. Turning
|
|
133
|
+
* `Bash("git reset --hard")` into attributes is the extractor's job and the
|
|
134
|
+
* extractor's test. Writing these as commands would put a shell parser in the
|
|
135
|
+
* evaluator, which is the one thing this file must not hold.
|
|
136
|
+
*/
|
|
137
|
+
export interface RuleExample {
|
|
138
|
+
attrs: Attributes;
|
|
139
|
+
principal?: Partial<Principal>;
|
|
140
|
+
/** Defaults to the rule's first surface. */
|
|
141
|
+
surface?: Surface;
|
|
142
|
+
expect: Effect;
|
|
143
|
+
expectObservedOnly?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface RuleSource extends Rule {
|
|
146
|
+
match: MatchSpec;
|
|
147
|
+
/**
|
|
148
|
+
* The write scope this rule claims authority over. Required whenever the rule
|
|
149
|
+
* has a write condition, because the duplicate-claim check reads it.
|
|
150
|
+
*/
|
|
151
|
+
claims?: {
|
|
152
|
+
writeScope: string[];
|
|
153
|
+
};
|
|
154
|
+
/** What the rule writes when it executes. */
|
|
155
|
+
records: string[];
|
|
156
|
+
changeControl: ChangeControl;
|
|
157
|
+
examples: RuleExample[];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The assignment half of the format. A definition states what a rule decides.
|
|
161
|
+
* The context states where it applies, which is what lets one definition run
|
|
162
|
+
* against every team without naming a team's path.
|
|
163
|
+
*/
|
|
164
|
+
export interface PolicyContext {
|
|
165
|
+
/** Absolute path of the acting team's worktree. */
|
|
166
|
+
worktreeRoot: string;
|
|
167
|
+
/** Absolute path of the repository root. */
|
|
168
|
+
repoRoot: string;
|
|
169
|
+
/** Paths and globs of the files that define policy. */
|
|
170
|
+
governingRulePaths: string[];
|
|
171
|
+
/** Paths a project has placed under the tests-first rule. May be empty. */
|
|
172
|
+
testGuardedPaths: string[];
|
|
173
|
+
/**
|
|
174
|
+
* Where an agent may write without leaving its scope: the scratch tree the
|
|
175
|
+
* fleet gives each session.
|
|
176
|
+
*
|
|
177
|
+
* Measured need. Replaying the shipped rules against 600 ordinary commands
|
|
178
|
+
* refused 10, and every one of the 10 wrote only to `/tmp/claude-1000/…/
|
|
179
|
+
* scratchpad` (`docs/gate-coverage.md` section 4). Every guard these rules
|
|
180
|
+
* replace exempts it: `worktree-guard.sh` exempts `/tmp`, the deleted
|
|
181
|
+
* `checkWorktreeGuard` exempted `/tmp` and `/var/tmp`, and `boundaryRisk()`
|
|
182
|
+
* in evidence-tools exempts `/tmp` and any `scratchpad` path.
|
|
183
|
+
*
|
|
184
|
+
* Optional so that an existing caller keeps compiling. The default is the
|
|
185
|
+
* fleet's, and a project that puts scratch elsewhere says so here rather than
|
|
186
|
+
* discovering it as a refusal.
|
|
187
|
+
*/
|
|
188
|
+
scratchRoots?: string[];
|
|
189
|
+
}
|
|
190
|
+
/** Used when a `PolicyContext` does not name its own. */
|
|
191
|
+
export declare const DEFAULT_SCRATCH_ROOTS: string[];
|
|
192
|
+
/**
|
|
193
|
+
* Scratch roots that do not swallow the worktree.
|
|
194
|
+
*
|
|
195
|
+
* A root containing the worktree exempts every write the rule exists to bind,
|
|
196
|
+
* so the rule compiles, reports healthy, and refuses nothing. That is the shape
|
|
197
|
+
* this compiler refuses elsewhere, and it is reachable by accident: a worktree
|
|
198
|
+
* created under `/tmp` sits inside the default root. Found on 2026-08-18 by a
|
|
199
|
+
* live-session proof whose scratch worktree was under the system temp
|
|
200
|
+
* directory, where the rule's own examples stopped denying.
|
|
201
|
+
*/
|
|
202
|
+
export declare function effectiveScratchRoots(ctx: PolicyContext): string[];
|
|
203
|
+
export interface Expansion {
|
|
204
|
+
paths: string[];
|
|
205
|
+
errors: string[];
|
|
206
|
+
}
|
|
207
|
+
export declare function expandPaths(entries: string[], ctx: PolicyContext): Expansion;
|
|
208
|
+
/**
|
|
209
|
+
* Lexical normalisation. Collapses separators, `.` and `..`, and drops a
|
|
210
|
+
* trailing slash. Resolving `..` matters: `/work/team/../other/x` and
|
|
211
|
+
* `/work/other/x` name one file, and a rule that compared the strings would
|
|
212
|
+
* refuse one and allow the other.
|
|
213
|
+
*/
|
|
214
|
+
export declare function normalizePath(p: string): string;
|
|
215
|
+
/** True when `p` is `root` or lies under it. `/work/team-other` is not under `/work/team`. */
|
|
216
|
+
export declare function isInside(root: string, p: string): boolean;
|
|
217
|
+
/** `**` crosses directories, `*` and `?` do not. */
|
|
218
|
+
export declare function globToRegExp(glob: string): RegExp;
|
|
219
|
+
interface ExpandedCondition {
|
|
220
|
+
outside: string[];
|
|
221
|
+
inside: string[];
|
|
222
|
+
globs: RegExp[];
|
|
223
|
+
globSource: string[];
|
|
224
|
+
}
|
|
225
|
+
interface ExpandedMatch {
|
|
226
|
+
writes?: ExpandedCondition;
|
|
227
|
+
reads?: ExpandedCondition;
|
|
228
|
+
workingDir?: ExpandedCondition;
|
|
229
|
+
}
|
|
230
|
+
export type RefusalCode =
|
|
231
|
+
/** Two rules share an id, so a decision could not name which one produced it. */
|
|
232
|
+
'duplicate-id'
|
|
233
|
+
/** No statement. Nothing to show the agent whose call it refused. */
|
|
234
|
+
| 'missing-statement'
|
|
235
|
+
/** No rationale. A rule nobody can explain is a rule nobody can challenge. */
|
|
236
|
+
| 'missing-rationale'
|
|
237
|
+
/** Names no surface, so nothing would ever run it. */
|
|
238
|
+
| 'no-surface'
|
|
239
|
+
/** Names a surface that observes none of the rule's operations. */
|
|
240
|
+
| 'unenforceable-surface'
|
|
241
|
+
/** Blocks, but every surface that could observe it is not built yet. */
|
|
242
|
+
| 'blocking-on-unavailable-surface'
|
|
243
|
+
/** Names no operation, so the surface check has nothing to check. */
|
|
244
|
+
| 'no-operations'
|
|
245
|
+
/** Has a path condition and does not say what to do when the extractor is unsure. */
|
|
246
|
+
| 'missing-uncertainty-handling'
|
|
247
|
+
/** Has a write condition and claims no write scope, so conflicts stay invisible. */
|
|
248
|
+
| 'missing-write-scope'
|
|
249
|
+
/** Two rules on one team claim the same write scope. */
|
|
250
|
+
| 'duplicate-write-scope'
|
|
251
|
+
/** A path condition that expands to nothing, so it can never match. */
|
|
252
|
+
| 'empty-path-condition'
|
|
253
|
+
/** An unknown or misplaced path token. */
|
|
254
|
+
| 'bad-path-token'
|
|
255
|
+
/** No change control owner. */
|
|
256
|
+
| 'missing-change-control'
|
|
257
|
+
/** No examples, so nothing tests the rule. */
|
|
258
|
+
| 'no-examples'
|
|
259
|
+
/** An example does not produce the effect it states. */
|
|
260
|
+
| 'example-disagrees';
|
|
261
|
+
export interface Refusal {
|
|
262
|
+
code: RefusalCode;
|
|
263
|
+
ruleId: string;
|
|
264
|
+
detail: string;
|
|
265
|
+
}
|
|
266
|
+
export interface CompileWarning {
|
|
267
|
+
ruleId: string;
|
|
268
|
+
detail: string;
|
|
269
|
+
}
|
|
270
|
+
export declare class RulesetRefused extends Error {
|
|
271
|
+
readonly refusals: Refusal[];
|
|
272
|
+
constructor(refusals: Refusal[]);
|
|
273
|
+
}
|
|
274
|
+
interface CompiledRule {
|
|
275
|
+
source: RuleSource;
|
|
276
|
+
expanded: ExpandedMatch;
|
|
277
|
+
/** Team and role bindings scored, so a decision reports the most specific first. */
|
|
278
|
+
specificity: number;
|
|
279
|
+
/** Normalised write scope claims, for the duplicate check and for the operator. */
|
|
280
|
+
writeScope: string[];
|
|
281
|
+
}
|
|
282
|
+
export declare class CompiledEvaluator implements Evaluator {
|
|
283
|
+
private readonly rules;
|
|
284
|
+
readonly context: PolicyContext;
|
|
285
|
+
readonly warnings: CompileWarning[];
|
|
286
|
+
constructor(rules: CompiledRule[], context: PolicyContext, warnings?: CompileWarning[]);
|
|
287
|
+
/**
|
|
288
|
+
* Decides. Never parses.
|
|
289
|
+
*
|
|
290
|
+
* A rule in observe mode matches, reports and enforces nothing. When every
|
|
291
|
+
* matching rule observes, the effect is `allow` and `observedOnly` is true,
|
|
292
|
+
* and that is the only case where the flag is set. When any matching rule
|
|
293
|
+
* blocks, the most restrictive of the blocking effects wins, so a specific
|
|
294
|
+
* allow does not punch a hole in a broader deny. Specificity orders what the
|
|
295
|
+
* decision reports rather than which effect wins.
|
|
296
|
+
*/
|
|
297
|
+
evaluate(attrs: Attributes, principal: Principal, surface: Surface): Decision;
|
|
298
|
+
/**
|
|
299
|
+
* Rules this ruleset holds that the given surface cannot enforce, either
|
|
300
|
+
* because no rule binds them to it or because it observes none of their
|
|
301
|
+
* operations. An operator running one surface reads this to see what that
|
|
302
|
+
* surface is not enforcing.
|
|
303
|
+
*/
|
|
304
|
+
unenforceableOn(surface: Surface): Rule[];
|
|
305
|
+
/** Who owns a rule and whether its subject may propose or apply a change to it. */
|
|
306
|
+
changeControlFor(ruleId: string): ChangeControl | undefined;
|
|
307
|
+
/** Write scopes claimed, by rule. The operator's view of which rule owns what. */
|
|
308
|
+
claimedWriteScopes(): Array<{
|
|
309
|
+
ruleId: string;
|
|
310
|
+
scope: string[];
|
|
311
|
+
}>;
|
|
312
|
+
get ruleIds(): string[];
|
|
313
|
+
}
|
|
314
|
+
export interface CompileOutcome {
|
|
315
|
+
evaluator: CompiledEvaluator | null;
|
|
316
|
+
refusals: Refusal[];
|
|
317
|
+
warnings: CompileWarning[];
|
|
318
|
+
}
|
|
319
|
+
/** Compiles and reports. `compileRuleset` is the form that refuses by throwing. */
|
|
320
|
+
export declare function checkRuleset(sources: RuleSource[], context: PolicyContext): CompileOutcome;
|
|
321
|
+
/** Throws `RulesetRefused` listing every refusal, rather than the first one found. */
|
|
322
|
+
export declare function compileRuleset(sources: RuleSource[], context: PolicyContext): CompiledEvaluator;
|
|
323
|
+
/** Fills the attribute fields an example does not need to state. */
|
|
324
|
+
export declare function attributes(partial: Partial<Attributes> & {
|
|
325
|
+
operation: string;
|
|
326
|
+
}): Attributes;
|
|
327
|
+
/**
|
|
328
|
+
* Section 5 of `docs/rule-format-proposal.md` writes five rules. Four compile.
|
|
329
|
+
* The fifth is in `WITHHELD_RULES` below with the reason, because every surface
|
|
330
|
+
* the contract defines refuses it and that refusal is the honest result rather
|
|
331
|
+
* than a defect.
|
|
332
|
+
*/
|
|
333
|
+
/** (a) A team may not write outside its worktree. */
|
|
334
|
+
export declare const TEAMS_STAY_IN_OWN_WORKTREE: RuleSource;
|
|
335
|
+
/**
|
|
336
|
+
* (b) Destructive git operations are refused.
|
|
337
|
+
*
|
|
338
|
+
* One decision replaces 24 permission patterns. Every operation named here is a
|
|
339
|
+
* name `extract.ts` produces, checked against that file rather than invented,
|
|
340
|
+
* because a rule naming an operation nothing emits is the silent-never-fires
|
|
341
|
+
* case in a different disguise.
|
|
342
|
+
*
|
|
343
|
+
* The branch half of the proposal's statement survives for push and not for
|
|
344
|
+
* checkout. The extractor resolves a push that names main into
|
|
345
|
+
* `git.push-main` and `git.push-force-main`, so this rule refuses both. It does
|
|
346
|
+
* not name main on a checkout or a switch, so "a team stays off main" is
|
|
347
|
+
* enforced here for a push and left to branch protection at the code host for
|
|
348
|
+
* everything else, which is why `remote` is a surface.
|
|
349
|
+
*/
|
|
350
|
+
export declare const NO_DESTRUCTIVE_GIT: RuleSource;
|
|
351
|
+
/**
|
|
352
|
+
* (d) A change under given paths needs a failing test first.
|
|
353
|
+
*
|
|
354
|
+
* Observe only, and it cannot move to block for two reasons the format states
|
|
355
|
+
* rather than hides. The integration lane is the surface that decides a
|
|
356
|
+
* completed change and it is not built. The decision needs test history, which
|
|
357
|
+
* no fact provider supplies, so the rule reports every change under the guarded
|
|
358
|
+
* paths and cannot confirm whether a failing test preceded one. It over-reports
|
|
359
|
+
* on purpose, and that is the honest mode for it now.
|
|
360
|
+
*/
|
|
361
|
+
export declare const TESTS_FIRST_UNDER_SCOPED_PATHS: RuleSource;
|
|
362
|
+
/** (e) An agent may not edit the rules that govern it. */
|
|
363
|
+
export declare const RULES_ARE_NOT_SELF_EDITABLE: RuleSource;
|
|
364
|
+
/**
|
|
365
|
+
* (c) A tester may not read the implementation.
|
|
366
|
+
*
|
|
367
|
+
* Held out of the starter set, and this is the point of the `surfaces` field
|
|
368
|
+
* rather than a gap in it. The permission callback never received `Read` or
|
|
369
|
+
* `Glob` across POC-1c, and `Grep` was not measured. A shell read does reach
|
|
370
|
+
* the callback, so a binding there would refuse `cat src/billing.ts` and allow
|
|
371
|
+
* `Read("src/billing.ts")`, which a tester needs one turn to discover. No
|
|
372
|
+
* surface the contract defines observes a read it can rely on, so every binding
|
|
373
|
+
* this rule could declare refuses at compile time. The only surface that could
|
|
374
|
+
* enforce it is the context assembler, which supplies the requirement and the
|
|
375
|
+
* public interface and withholds the implementation, and the PRD records that
|
|
376
|
+
* component as Absent.
|
|
377
|
+
*
|
|
378
|
+
* Writing it out is how the gap stays visible. Shipping it bound to the
|
|
379
|
+
* permission callback would produce a rule that reports healthy and refuses
|
|
380
|
+
* nothing, which is what a tester's suite passing for a month costs.
|
|
381
|
+
*/
|
|
382
|
+
export declare const TESTER_WORKS_FROM_THE_REQUIREMENT: RuleSource;
|
|
383
|
+
/** The four rules of section 5 that compile and run. */
|
|
384
|
+
export declare const STARTER_RULES: RuleSource[];
|
|
385
|
+
/** The rule of section 5 that no surface can enforce. The compiler refuses it. */
|
|
386
|
+
export declare const WITHHELD_RULES: RuleSource[];
|
|
387
|
+
/** All five, for the test that proves why the fifth stays out. */
|
|
388
|
+
export declare const SECTION_5_RULES: RuleSource[];
|
|
389
|
+
export {};
|
|
390
|
+
//# sourceMappingURL=evaluate.d.ts.map
|
|
@@ -0,0 +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