@osstack/protocol 0.10.0 → 0.15.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/LICENSE +21 -0
- package/dist/autonomy.d.ts +1300 -0
- package/dist/autonomy.d.ts.map +1 -0
- package/dist/autonomy.js +270 -0
- package/dist/autonomy.js.map +1 -0
- package/dist/envelope.d.ts +8 -8
- package/dist/event.d.ts +2 -2
- package/dist/generate.d.ts +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +30 -1
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts +2 -2
- package/package.json +9 -9
- package/schemas/autonomy-risk-decision.schema.json +86 -0
- package/schemas/autonomy-risk-level.schema.json +12 -0
- package/schemas/autonomy-run-state.schema.json +35 -0
- package/schemas/scoped-approval-decision.schema.json +131 -0
- package/schemas/scoped-approval-request.schema.json +73 -0
- package/dist/protocol.test.d.ts +0 -2
- package/dist/protocol.test.d.ts.map +0 -1
- package/dist/protocol.test.js +0 -251
- package/dist/protocol.test.js.map +0 -1
- package/dist/schemas.test.d.ts +0 -2
- package/dist/schemas.test.d.ts.map +0 -1
- package/dist/schemas.test.js +0 -34
- package/dist/schemas.test.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Osstack Guarded Autonomy Run State",
|
|
4
|
+
"type": "string",
|
|
5
|
+
"enum": [
|
|
6
|
+
"queued",
|
|
7
|
+
"classifying",
|
|
8
|
+
"awaiting_approval",
|
|
9
|
+
"blocked",
|
|
10
|
+
"preparing",
|
|
11
|
+
"building",
|
|
12
|
+
"verifying",
|
|
13
|
+
"repairing",
|
|
14
|
+
"reviewing",
|
|
15
|
+
"post_classifying",
|
|
16
|
+
"candidate_proof",
|
|
17
|
+
"committing",
|
|
18
|
+
"pushing",
|
|
19
|
+
"opening_pr",
|
|
20
|
+
"waiting_ci",
|
|
21
|
+
"merging",
|
|
22
|
+
"deploying_staging",
|
|
23
|
+
"verifying_staging",
|
|
24
|
+
"deploying_production",
|
|
25
|
+
"health_checking",
|
|
26
|
+
"rolling_back",
|
|
27
|
+
"deploy_frozen",
|
|
28
|
+
"final_proof",
|
|
29
|
+
"blocked_delivery",
|
|
30
|
+
"delivery_evidence_failed",
|
|
31
|
+
"escalated",
|
|
32
|
+
"cancelled",
|
|
33
|
+
"completed"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Osstack Guarded Autonomy Signed Scoped Approval Decision",
|
|
4
|
+
"$comment": "Human-actor and validity-window constraints are additionally enforced by @osstack/protocol Zod refinements; signature verification and replay defense belong to the runtime autonomy verifier.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"payload": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"approval_id": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"minLength": 1
|
|
13
|
+
},
|
|
14
|
+
"request_sha256": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
17
|
+
},
|
|
18
|
+
"autonomy_run_id": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"minLength": 1
|
|
21
|
+
},
|
|
22
|
+
"phase": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": [
|
|
25
|
+
"preflight",
|
|
26
|
+
"post_diff"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"contract_sha256": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
32
|
+
},
|
|
33
|
+
"diff_sha256": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
36
|
+
},
|
|
37
|
+
"action_scope": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"minLength": 1
|
|
42
|
+
},
|
|
43
|
+
"minItems": 1
|
|
44
|
+
},
|
|
45
|
+
"decision": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"enum": [
|
|
48
|
+
"approve",
|
|
49
|
+
"reject"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"nonce": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"minLength": 1
|
|
55
|
+
},
|
|
56
|
+
"issued_at": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"format": "date-time"
|
|
59
|
+
},
|
|
60
|
+
"expires_at": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"format": "date-time"
|
|
63
|
+
},
|
|
64
|
+
"decided_by": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"properties": {
|
|
67
|
+
"type": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"enum": [
|
|
70
|
+
"human",
|
|
71
|
+
"agent"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"id": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"minLength": 1
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": [
|
|
80
|
+
"type",
|
|
81
|
+
"id"
|
|
82
|
+
],
|
|
83
|
+
"additionalProperties": false
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"required": [
|
|
87
|
+
"approval_id",
|
|
88
|
+
"request_sha256",
|
|
89
|
+
"autonomy_run_id",
|
|
90
|
+
"phase",
|
|
91
|
+
"contract_sha256",
|
|
92
|
+
"diff_sha256",
|
|
93
|
+
"action_scope",
|
|
94
|
+
"decision",
|
|
95
|
+
"nonce",
|
|
96
|
+
"issued_at",
|
|
97
|
+
"expires_at",
|
|
98
|
+
"decided_by"
|
|
99
|
+
],
|
|
100
|
+
"additionalProperties": false
|
|
101
|
+
},
|
|
102
|
+
"signature": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"algorithm": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"const": "Ed25519"
|
|
108
|
+
},
|
|
109
|
+
"key_id": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"minLength": 1
|
|
112
|
+
},
|
|
113
|
+
"value_base64url": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"pattern": "^[A-Za-z0-9_-]{86}$"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"required": [
|
|
119
|
+
"algorithm",
|
|
120
|
+
"key_id",
|
|
121
|
+
"value_base64url"
|
|
122
|
+
],
|
|
123
|
+
"additionalProperties": false
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"required": [
|
|
127
|
+
"payload",
|
|
128
|
+
"signature"
|
|
129
|
+
],
|
|
130
|
+
"additionalProperties": false
|
|
131
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Osstack Guarded Autonomy Scoped Approval Request",
|
|
4
|
+
"$comment": "Preflight empty-diff binding, build/verify-only scope, canonical action ordering, and validity windows are additionally enforced by @osstack/protocol Zod refinements.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"approval_id": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"minLength": 1
|
|
10
|
+
},
|
|
11
|
+
"autonomy_run_id": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"minLength": 1
|
|
14
|
+
},
|
|
15
|
+
"phase": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"enum": [
|
|
18
|
+
"preflight",
|
|
19
|
+
"post_diff"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"contract_sha256": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
25
|
+
},
|
|
26
|
+
"diff_sha256": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
29
|
+
},
|
|
30
|
+
"action_scope": {
|
|
31
|
+
"type": "array",
|
|
32
|
+
"items": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1
|
|
35
|
+
},
|
|
36
|
+
"minItems": 1
|
|
37
|
+
},
|
|
38
|
+
"risk": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"const": "R3"
|
|
41
|
+
},
|
|
42
|
+
"nonce": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"minLength": 1
|
|
45
|
+
},
|
|
46
|
+
"requested_at": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"format": "date-time"
|
|
49
|
+
},
|
|
50
|
+
"expires_at": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"format": "date-time"
|
|
53
|
+
},
|
|
54
|
+
"request_sha256": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"required": [
|
|
60
|
+
"approval_id",
|
|
61
|
+
"autonomy_run_id",
|
|
62
|
+
"phase",
|
|
63
|
+
"contract_sha256",
|
|
64
|
+
"diff_sha256",
|
|
65
|
+
"action_scope",
|
|
66
|
+
"risk",
|
|
67
|
+
"nonce",
|
|
68
|
+
"requested_at",
|
|
69
|
+
"expires_at",
|
|
70
|
+
"request_sha256"
|
|
71
|
+
],
|
|
72
|
+
"additionalProperties": false
|
|
73
|
+
}
|
package/dist/protocol.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.test.d.ts","sourceRoot":"","sources":["../src/protocol.test.ts"],"names":[],"mappings":""}
|
package/dist/protocol.test.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
// Protocol contract tests: fixture parsing, invalid rejection, backward-compat
|
|
2
|
-
// corpus, consumer-lenient parsing, and the A-003 status<->code mapping.
|
|
3
|
-
import { readFileSync, readdirSync } from "node:fs";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import { AgentCommand, AgentCommandResult, ApprovalDecision, ApprovalRequest, EventEnvelope, EvidenceRef, parseInboundAgentCommand, parseInboundAgentCommandResult, PolicyDecision, RunSummary, Task, } from "./index.js";
|
|
7
|
-
const VALID_DIR = fileURLToPath(new URL("../fixtures/valid", import.meta.url));
|
|
8
|
-
const INVALID_DIR = fileURLToPath(new URL("../fixtures/invalid", import.meta.url));
|
|
9
|
-
/** Maps a fixture's schema key to the strict schema that must validate it. */
|
|
10
|
-
const SCHEMA_BY_KEY = {
|
|
11
|
-
task: Task,
|
|
12
|
-
"run-summary": RunSummary,
|
|
13
|
-
"event-envelope": EventEnvelope,
|
|
14
|
-
"evidence-ref": EvidenceRef,
|
|
15
|
-
"approval-request": ApprovalRequest,
|
|
16
|
-
"approval-decision": ApprovalDecision,
|
|
17
|
-
"policy-decision": PolicyDecision,
|
|
18
|
-
"agent-command": AgentCommand,
|
|
19
|
-
"agent-command-result": AgentCommandResult,
|
|
20
|
-
};
|
|
21
|
-
/** Fixture filename -> schema key: strip the .(valid|invalid).json suffix, then
|
|
22
|
-
* drop any `__variant` discriminator (e.g. agent-command-result__blocked). */
|
|
23
|
-
function schemaKeyOf(filename) {
|
|
24
|
-
const base = filename.replace(/\.(valid|invalid)\.json$/, "");
|
|
25
|
-
return base.split("__")[0];
|
|
26
|
-
}
|
|
27
|
-
function readJson(dir, filename) {
|
|
28
|
-
return JSON.parse(readFileSync(`${dir}/${filename}`, "utf-8"));
|
|
29
|
-
}
|
|
30
|
-
function schemaFor(filename) {
|
|
31
|
-
const key = schemaKeyOf(filename);
|
|
32
|
-
const schema = SCHEMA_BY_KEY[key];
|
|
33
|
-
if (!schema)
|
|
34
|
-
throw new Error(`no schema registered for key '${key}' (fixture ${filename})`);
|
|
35
|
-
return schema;
|
|
36
|
-
}
|
|
37
|
-
const validFiles = readdirSync(VALID_DIR).filter((f) => f.endsWith(".valid.json")).sort();
|
|
38
|
-
const invalidFiles = readdirSync(INVALID_DIR).filter((f) => f.endsWith(".invalid.json")).sort();
|
|
39
|
-
// ── Backward-compatibility corpus (A-007) ─────────────────────────────────
|
|
40
|
-
// APPEND-ONLY. Every fixture published for protocol major 1 MUST parse against
|
|
41
|
-
// all later minors, forever. Never delete or mutate an entry; a breaking change
|
|
42
|
-
// is a new MAJOR with a new fixture directory. Adding a row is allowed.
|
|
43
|
-
const FROZEN_V1_FIXTURES = [
|
|
44
|
-
"agent-command-result.valid.json",
|
|
45
|
-
"agent-command-result__blocked.valid.json",
|
|
46
|
-
"agent-command-result__error.valid.json",
|
|
47
|
-
"agent-command-result__needs-approval.valid.json",
|
|
48
|
-
"agent-command.valid.json",
|
|
49
|
-
"approval-decision.valid.json",
|
|
50
|
-
"approval-request.valid.json",
|
|
51
|
-
"event-envelope.valid.json",
|
|
52
|
-
"evidence-ref.valid.json",
|
|
53
|
-
"policy-decision.valid.json",
|
|
54
|
-
"run-summary.valid.json",
|
|
55
|
-
"task.valid.json",
|
|
56
|
-
];
|
|
57
|
-
describe("valid fixtures parse with their schema", () => {
|
|
58
|
-
it("covers at least one fixture per protocol type", () => {
|
|
59
|
-
const keys = new Set(validFiles.map(schemaKeyOf));
|
|
60
|
-
for (const key of Object.keys(SCHEMA_BY_KEY)) {
|
|
61
|
-
expect(keys, `missing a valid fixture for '${key}'`).toContain(key);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
for (const filename of validFiles) {
|
|
65
|
-
it(`parses ${filename}`, () => {
|
|
66
|
-
const result = schemaFor(filename).safeParse(readJson(VALID_DIR, filename));
|
|
67
|
-
if (!result.success) {
|
|
68
|
-
throw new Error(`${filename} should parse but failed:\n${result.error.toString()}`);
|
|
69
|
-
}
|
|
70
|
-
expect(result.success).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
describe("invalid fixtures are rejected and document why", () => {
|
|
75
|
-
it("covers at least one invalid fixture per protocol type", () => {
|
|
76
|
-
const keys = new Set(invalidFiles.map(schemaKeyOf));
|
|
77
|
-
for (const key of Object.keys(SCHEMA_BY_KEY)) {
|
|
78
|
-
expect(keys, `missing an invalid fixture for '${key}'`).toContain(key);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
for (const filename of invalidFiles) {
|
|
82
|
-
it(`rejects ${filename}`, () => {
|
|
83
|
-
const fixture = readJson(INVALID_DIR, filename);
|
|
84
|
-
expect(typeof fixture.$reason, `${filename} must document a $reason`).toBe("string");
|
|
85
|
-
expect(fixture.$reason.length).toBeGreaterThan(0);
|
|
86
|
-
expect("value" in fixture, `${filename} must carry a value`).toBe(true);
|
|
87
|
-
const result = schemaFor(filename).safeParse(fixture.value);
|
|
88
|
-
expect(result.success, `${filename} should be rejected but parsed`).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
describe("backward-compatibility corpus (A-007, append-only)", () => {
|
|
93
|
-
it("the on-disk valid corpus exactly matches FROZEN_V1_FIXTURES", () => {
|
|
94
|
-
// Two-way equality: nothing added without registering, nothing frozen removed.
|
|
95
|
-
expect(validFiles).toEqual([...FROZEN_V1_FIXTURES].sort());
|
|
96
|
-
});
|
|
97
|
-
it("every frozen fixture still parses under the current schemas", () => {
|
|
98
|
-
for (const filename of FROZEN_V1_FIXTURES) {
|
|
99
|
-
const result = schemaFor(filename).safeParse(readJson(VALID_DIR, filename));
|
|
100
|
-
expect(result.success, `${filename} broke backward compatibility`).toBe(true);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("consumer-lenient vs producer-strict (A-007)", () => {
|
|
105
|
-
it("an unknown extra field fails the strict schema but passes the lenient parser", () => {
|
|
106
|
-
const fixture = readJson(INVALID_DIR, "agent-command__unknown-field.invalid.json");
|
|
107
|
-
// Producer-strict rejects the unknown field.
|
|
108
|
-
expect(AgentCommand.safeParse(fixture.value).success).toBe(false);
|
|
109
|
-
// Consumer-lenient accepts it and preserves the passthrough field.
|
|
110
|
-
const parsed = parseInboundAgentCommand(fixture.value);
|
|
111
|
-
expect(parsed.command).toBe("portfolio.daily");
|
|
112
|
-
expect(parsed.debug).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
it("the lenient result parser tolerates unknown fields but still enforces A-003", () => {
|
|
115
|
-
const okWithExtra = {
|
|
116
|
-
protocol_version: "1.0",
|
|
117
|
-
status: "ok",
|
|
118
|
-
result: {},
|
|
119
|
-
trace_id: "abc",
|
|
120
|
-
};
|
|
121
|
-
expect(AgentCommandResult.safeParse(okWithExtra).success).toBe(false); // strict rejects extra
|
|
122
|
-
expect(() => parseInboundAgentCommandResult(okWithExtra)).not.toThrow(); // lenient accepts
|
|
123
|
-
// Business rule still enforced by the lenient parser.
|
|
124
|
-
expect(() => parseInboundAgentCommandResult({ protocol_version: "1.0", status: "error", trace_id: "x" })).toThrow();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
describe("deep consumer leniency (A-007 — unknown fields in NESTED objects)", () => {
|
|
128
|
-
it("v1.1-style unknown field inside actor: lenient accepts, strict rejects", () => {
|
|
129
|
-
const command = {
|
|
130
|
-
protocol_version: "1.1",
|
|
131
|
-
command: "portfolio.daily",
|
|
132
|
-
actor: { type: "human", id: "osborn", display_name: "Osborn" },
|
|
133
|
-
input: {},
|
|
134
|
-
};
|
|
135
|
-
expect(AgentCommand.safeParse(command).success).toBe(false);
|
|
136
|
-
const parsed = parseInboundAgentCommand(command);
|
|
137
|
-
expect(parsed.actor.id).toBe("osborn");
|
|
138
|
-
expect(parsed.actor.display_name).toBe("Osborn");
|
|
139
|
-
});
|
|
140
|
-
it("unknown field inside scope: lenient accepts, strict rejects", () => {
|
|
141
|
-
const command = {
|
|
142
|
-
protocol_version: "1.1",
|
|
143
|
-
command: "delivery.start",
|
|
144
|
-
actor: { type: "agent", id: "claude-code" },
|
|
145
|
-
scope: { repo_id: "osborn-pa", branch: "main" },
|
|
146
|
-
input: {},
|
|
147
|
-
};
|
|
148
|
-
expect(AgentCommand.safeParse(command).success).toBe(false);
|
|
149
|
-
expect(() => parseInboundAgentCommand(command)).not.toThrow();
|
|
150
|
-
});
|
|
151
|
-
it("unknown field inside an ApprovalRequest item: lenient accepts, strict rejects", () => {
|
|
152
|
-
const result = {
|
|
153
|
-
protocol_version: "1.1",
|
|
154
|
-
status: "needs_approval",
|
|
155
|
-
required_approvals: [
|
|
156
|
-
{
|
|
157
|
-
approval_id: "appr_01",
|
|
158
|
-
action: "Deploy to production",
|
|
159
|
-
risk: "high",
|
|
160
|
-
requested_at: "2026-07-11T09:05:00.000Z",
|
|
161
|
-
expires_at: "2026-07-12T09:05:00.000Z",
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
};
|
|
165
|
-
expect(AgentCommandResult.safeParse(result).success).toBe(false);
|
|
166
|
-
expect(() => parseInboundAgentCommandResult(result)).not.toThrow();
|
|
167
|
-
});
|
|
168
|
-
it("unknown field inside an EvidenceRef item: lenient accepts, strict rejects", () => {
|
|
169
|
-
const result = {
|
|
170
|
-
protocol_version: "1.1",
|
|
171
|
-
status: "ok",
|
|
172
|
-
evidence_refs: [{ kind: "proof", ref: "release/proof/", bytes: 1024 }],
|
|
173
|
-
};
|
|
174
|
-
expect(AgentCommandResult.safeParse(result).success).toBe(false);
|
|
175
|
-
expect(() => parseInboundAgentCommandResult(result)).not.toThrow();
|
|
176
|
-
});
|
|
177
|
-
it("unknown field inside the error object: lenient accepts, strict rejects", () => {
|
|
178
|
-
const result = {
|
|
179
|
-
protocol_version: "1.1",
|
|
180
|
-
status: "error",
|
|
181
|
-
error: { code: "internal", message: "boom", retryable: true, trace_id: "t_1" },
|
|
182
|
-
};
|
|
183
|
-
expect(AgentCommandResult.safeParse(result).success).toBe(false);
|
|
184
|
-
expect(() => parseInboundAgentCommandResult(result)).not.toThrow();
|
|
185
|
-
});
|
|
186
|
-
it("deep leniency does not weaken A-003: nested-lenient blocked result still needs a blocked code", () => {
|
|
187
|
-
const result = {
|
|
188
|
-
protocol_version: "1.1",
|
|
189
|
-
status: "blocked",
|
|
190
|
-
error: { code: "internal", message: "boom", retryable: true, trace_id: "t_1" },
|
|
191
|
-
};
|
|
192
|
-
expect(() => parseInboundAgentCommandResult(result)).toThrow();
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe("A-003 / A-006 status<->code mapping", () => {
|
|
196
|
-
it("accepts status ok without an error object", () => {
|
|
197
|
-
expect(AgentCommandResult.safeParse({ protocol_version: "1.0", status: "ok", result: {} }).success).toBe(true);
|
|
198
|
-
});
|
|
199
|
-
it("rejects status error without an error object", () => {
|
|
200
|
-
expect(AgentCommandResult.safeParse({ protocol_version: "1.0", status: "error" }).success).toBe(false);
|
|
201
|
-
});
|
|
202
|
-
it("rejects status blocked with an internal (non-blocked) error code", () => {
|
|
203
|
-
expect(AgentCommandResult.safeParse({
|
|
204
|
-
protocol_version: "1.0",
|
|
205
|
-
status: "blocked",
|
|
206
|
-
error: { code: "internal", message: "boom", retryable: true },
|
|
207
|
-
}).success).toBe(false);
|
|
208
|
-
});
|
|
209
|
-
it("accepts status blocked with policy_denied and budget_exceeded", () => {
|
|
210
|
-
for (const code of ["policy_denied", "budget_exceeded"]) {
|
|
211
|
-
expect(AgentCommandResult.safeParse({
|
|
212
|
-
protocol_version: "1.0",
|
|
213
|
-
status: "blocked",
|
|
214
|
-
error: { code, message: "denied", retryable: false },
|
|
215
|
-
}).success, `blocked+${code} should be accepted`).toBe(true);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
it("rejects status error carrying a blocked-only code (A-006)", () => {
|
|
219
|
-
expect(AgentCommandResult.safeParse({
|
|
220
|
-
protocol_version: "1.0",
|
|
221
|
-
status: "error",
|
|
222
|
-
error: { code: "policy_denied", message: "denied", retryable: false },
|
|
223
|
-
}).success).toBe(false);
|
|
224
|
-
});
|
|
225
|
-
it("rejects status needs_approval with an empty required_approvals", () => {
|
|
226
|
-
expect(AgentCommandResult.safeParse({
|
|
227
|
-
protocol_version: "1.0",
|
|
228
|
-
status: "needs_approval",
|
|
229
|
-
required_approvals: [],
|
|
230
|
-
}).success).toBe(false);
|
|
231
|
-
});
|
|
232
|
-
it("rejects retryable:true on a non-transient code (A-006), strict and lenient", () => {
|
|
233
|
-
const result = {
|
|
234
|
-
protocol_version: "1.0",
|
|
235
|
-
status: "error",
|
|
236
|
-
error: { code: "not_found", message: "no such run", retryable: true },
|
|
237
|
-
};
|
|
238
|
-
expect(AgentCommandResult.safeParse(result).success).toBe(false);
|
|
239
|
-
expect(() => parseInboundAgentCommandResult(result)).toThrow();
|
|
240
|
-
});
|
|
241
|
-
it("accepts retryable:true for the transient codes internal and conflict (A-006)", () => {
|
|
242
|
-
for (const code of ["internal", "conflict"]) {
|
|
243
|
-
expect(AgentCommandResult.safeParse({
|
|
244
|
-
protocol_version: "1.0",
|
|
245
|
-
status: "error",
|
|
246
|
-
error: { code, message: "transient", retryable: true },
|
|
247
|
-
}).success, `error+${code}+retryable should be accepted`).toBe(true);
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
//# sourceMappingURL=protocol.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.test.js","sourceRoot":"","sources":["../src/protocol.test.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AAEzE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,E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AAC,KAAK,CAAC,CAAC;QACjE,MAAM,CAAC,GAAG,EAAE,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;YAC5C,MAAM,CACJ,kBAAkB,CAAC,SAAS,CAAC;gBAC3B,gBAAgB,EAAE,KAAK;gBACvB,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE;aACvD,CAAC,CAAC,OAAO,EACV,SAAS,IAAI,+BAA+B,CAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/schemas.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.test.d.ts","sourceRoot":"","sources":["../src/schemas.test.ts"],"names":[],"mappings":""}
|
package/dist/schemas.test.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Schema-generation drift guard: the committed schemas/*.schema.json MUST equal
|
|
2
|
-
// what the Zod source of truth produces right now. Regenerating produces zero
|
|
3
|
-
// diff — the same generateAll() runs here (against src) and in
|
|
4
|
-
// scripts/generate-schemas.mjs (against dist).
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { describe, expect, it } from "vitest";
|
|
8
|
-
import { generateAll } from "./generate.js";
|
|
9
|
-
const SCHEMAS_DIR = fileURLToPath(new URL("../schemas", import.meta.url));
|
|
10
|
-
describe("generated JSON Schemas are committed and fresh", () => {
|
|
11
|
-
const expected = generateAll();
|
|
12
|
-
const filenames = Object.keys(expected).sort();
|
|
13
|
-
it("emits one schema per public protocol contract", () => {
|
|
14
|
-
expect(filenames).toEqual([
|
|
15
|
-
"agent-command-result.schema.json",
|
|
16
|
-
"agent-command.schema.json",
|
|
17
|
-
"approval-decision.schema.json",
|
|
18
|
-
"approval-request.schema.json",
|
|
19
|
-
"event-envelope.schema.json",
|
|
20
|
-
"evidence-ref.schema.json",
|
|
21
|
-
"policy-decision.schema.json",
|
|
22
|
-
"run-summary.schema.json",
|
|
23
|
-
"task.schema.json",
|
|
24
|
-
].sort());
|
|
25
|
-
});
|
|
26
|
-
for (const filename of filenames) {
|
|
27
|
-
it(`schemas/${filename} matches the Zod source (zero drift)`, () => {
|
|
28
|
-
const path = `${SCHEMAS_DIR}/${filename}`;
|
|
29
|
-
expect(existsSync(path), `schemas/${filename} is not committed — run generate:schemas`).toBe(true);
|
|
30
|
-
expect(readFileSync(path, "utf-8")).toBe(expected[filename]);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=schemas.test.js.map
|
package/dist/schemas.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.test.js","sourceRoot":"","sources":["../src/schemas.test.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,+DAA+D;AAC/D,+CAA+C;AAE/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1E,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,M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