gateproof 0.2.1 → 0.2.4
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 +132 -340
- package/dist/act.d.ts +45 -0
- package/dist/act.d.ts.map +1 -1
- package/dist/act.js +22 -0
- package/dist/act.js.map +1 -1
- package/dist/action-executors.d.ts +17 -0
- package/dist/action-executors.d.ts.map +1 -1
- package/dist/action-executors.js +60 -0
- package/dist/action-executors.js.map +1 -1
- package/dist/assert.d.ts +20 -0
- package/dist/assert.d.ts.map +1 -1
- package/dist/assert.js +32 -0
- package/dist/assert.js.map +1 -1
- package/dist/authority.d.ts +34 -0
- package/dist/authority.d.ts.map +1 -0
- package/dist/authority.js +141 -0
- package/dist/authority.js.map +1 -0
- package/dist/cli/gateproof.js +81 -5
- package/dist/cli/gateproof.js.map +1 -1
- package/dist/filepath-backend.d.ts +64 -0
- package/dist/filepath-backend.d.ts.map +1 -0
- package/dist/filepath-backend.js +126 -0
- package/dist/filepath-backend.js.map +1 -0
- package/dist/filepath-protocol.d.ts +214 -0
- package/dist/filepath-protocol.d.ts.map +1 -0
- package/dist/filepath-protocol.js +239 -0
- package/dist/filepath-protocol.js.map +1 -0
- package/dist/filepath-runtime.d.ts +100 -0
- package/dist/filepath-runtime.d.ts.map +1 -0
- package/dist/filepath-runtime.js +190 -0
- package/dist/filepath-runtime.js.map +1 -0
- package/dist/http-backend.d.ts +9 -0
- package/dist/http-backend.d.ts.map +1 -1
- package/dist/http-backend.js +50 -8
- package/dist/http-backend.js.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/prd/index.d.ts +2 -0
- package/dist/prd/index.d.ts.map +1 -1
- package/dist/prd/index.js +4 -0
- package/dist/prd/index.js.map +1 -1
- package/dist/prd/loop.d.ts +160 -0
- package/dist/prd/loop.d.ts.map +1 -0
- package/dist/prd/loop.js +462 -0
- package/dist/prd/loop.js.map +1 -0
- package/dist/prd/runner.d.ts +2 -5
- package/dist/prd/runner.d.ts.map +1 -1
- package/dist/prd/runner.js +154 -122
- package/dist/prd/runner.js.map +1 -1
- package/dist/prd/scope-defaults.d.ts +75 -0
- package/dist/prd/scope-defaults.d.ts.map +1 -0
- package/dist/prd/scope-defaults.js +235 -0
- package/dist/prd/scope-defaults.js.map +1 -0
- package/dist/prd/types.d.ts +80 -0
- package/dist/prd/types.d.ts.map +1 -1
- package/dist/report.d.ts +70 -0
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +183 -0
- package/dist/report.js.map +1 -1
- package/package.json +11 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { Action } from "./act";
|
|
3
3
|
import { GateError } from "./index";
|
|
4
|
+
import type { FilepathRuntime } from "./filepath-backend";
|
|
4
5
|
export interface ActionExecutor {
|
|
5
6
|
execute(action: Action): Effect.Effect<void, GateError>;
|
|
6
7
|
}
|
|
@@ -18,5 +19,21 @@ export declare const DeployExecutor: ActionExecutor;
|
|
|
18
19
|
*/
|
|
19
20
|
export declare const ExecExecutor: ActionExecutor;
|
|
20
21
|
export declare const BrowserExecutor: ActionExecutor;
|
|
22
|
+
/**
|
|
23
|
+
* Executes an AI agent in a Filepath container.
|
|
24
|
+
*
|
|
25
|
+
* The agent runs in an isolated container, communicating via the
|
|
26
|
+
* Filepath Agent Protocol (FAP). NDJSON events on stdout are consumed
|
|
27
|
+
* by the observe layer; this executor just manages the lifecycle.
|
|
28
|
+
*
|
|
29
|
+
* When no FilepathRuntime is configured, the executor fails with a
|
|
30
|
+
* clear error message — it does not silently skip.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createAgentExecutor(runtime?: FilepathRuntime): ActionExecutor;
|
|
33
|
+
/**
|
|
34
|
+
* Set the global FilepathRuntime for agent execution.
|
|
35
|
+
* Call this once at startup if using Act.agent().
|
|
36
|
+
*/
|
|
37
|
+
export declare function setFilepathRuntime(runtime: FilepathRuntime): void;
|
|
21
38
|
export declare function getActionExecutor(action: Action): ActionExecutor;
|
|
22
39
|
//# sourceMappingURL=action-executors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-executors.d.ts","sourceRoot":"","sources":["../src/action-executors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,QAAQ,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"action-executors.d.ts","sourceRoot":"","sources":["../src/action-executors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,QAAQ,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,YAAY,EAAE,cAU1B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cA+B5B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,cA+B1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cA2C7B,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,cAAc,CAwD7E;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAEjE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAehE"}
|
package/dist/action-executors.js
CHANGED
|
@@ -118,6 +118,64 @@ export const BrowserExecutor = {
|
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Executes an AI agent in a Filepath container.
|
|
123
|
+
*
|
|
124
|
+
* The agent runs in an isolated container, communicating via the
|
|
125
|
+
* Filepath Agent Protocol (FAP). NDJSON events on stdout are consumed
|
|
126
|
+
* by the observe layer; this executor just manages the lifecycle.
|
|
127
|
+
*
|
|
128
|
+
* When no FilepathRuntime is configured, the executor fails with a
|
|
129
|
+
* clear error message — it does not silently skip.
|
|
130
|
+
*/
|
|
131
|
+
export function createAgentExecutor(runtime) {
|
|
132
|
+
return {
|
|
133
|
+
execute(action) {
|
|
134
|
+
if (action._tag !== "Agent") {
|
|
135
|
+
return Effect.fail(new GateError({ cause: new Error("Invalid action") }));
|
|
136
|
+
}
|
|
137
|
+
if (!runtime) {
|
|
138
|
+
return Effect.fail(new GateError({
|
|
139
|
+
cause: new Error("Act.agent() requires a FilepathRuntime. " +
|
|
140
|
+
"Provide one via createAgentExecutor(runtime) or use a mock for testing."),
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
const config = action.config;
|
|
144
|
+
const timeoutMs = config.timeoutMs ?? 300_000;
|
|
145
|
+
return Effect.gen(function* () {
|
|
146
|
+
const container = yield* Effect.tryPromise({
|
|
147
|
+
try: () => runtime.spawn(config),
|
|
148
|
+
catch: (e) => new GateError({
|
|
149
|
+
cause: new Error(`Failed to spawn agent "${config.name}": ${e instanceof Error ? e.message : String(e)}`),
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
// Wait for the container to finish (the observe layer reads stdout separately).
|
|
153
|
+
// We just need to ensure the container lifecycle completes within timeout.
|
|
154
|
+
yield* Effect.tryPromise({
|
|
155
|
+
try: async () => {
|
|
156
|
+
for await (const _line of container.stdout) {
|
|
157
|
+
// Drain stdout — the observe resource also reads this stream.
|
|
158
|
+
// In a real implementation, the container's stdout would be tee'd.
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
catch: (e) => new GateError({
|
|
162
|
+
cause: new Error(`Agent "${config.name}" failed: ${e instanceof Error ? e.message : String(e)}`),
|
|
163
|
+
}),
|
|
164
|
+
}).pipe(Effect.timeout(`${timeoutMs} millis`), Effect.catchTag("TimeoutException", (e) => Effect.fail(new GateError({
|
|
165
|
+
cause: new Error(`Agent "${config.name}" timed out after ${timeoutMs}ms`),
|
|
166
|
+
}))));
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
let _agentRuntime;
|
|
172
|
+
/**
|
|
173
|
+
* Set the global FilepathRuntime for agent execution.
|
|
174
|
+
* Call this once at startup if using Act.agent().
|
|
175
|
+
*/
|
|
176
|
+
export function setFilepathRuntime(runtime) {
|
|
177
|
+
_agentRuntime = runtime;
|
|
178
|
+
}
|
|
121
179
|
export function getActionExecutor(action) {
|
|
122
180
|
switch (action._tag) {
|
|
123
181
|
case "Wait":
|
|
@@ -128,6 +186,8 @@ export function getActionExecutor(action) {
|
|
|
128
186
|
return ExecExecutor;
|
|
129
187
|
case "Browser":
|
|
130
188
|
return BrowserExecutor;
|
|
189
|
+
case "Agent":
|
|
190
|
+
return createAgentExecutor(_agentRuntime);
|
|
131
191
|
default:
|
|
132
192
|
throw new Error("Unknown action type");
|
|
133
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-executors.js","sourceRoot":"","sources":["../src/action-executors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"action-executors.js","sourceRoot":"","sources":["../src/action-executors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,M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AAC,CACH,CACF,CACF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED,IAAI,aAA0C,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAwB;IACzD,aAAa,GAAG,OAAO,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC;QACxB,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,SAAS;YACZ,OAAO,eAAe,CAAC;QACzB,KAAK,OAAO;YACV,OAAO,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC5C;YACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
package/dist/assert.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import type { Log } from "./types";
|
|
3
|
+
import type { StoryAuthority } from "./prd/types";
|
|
3
4
|
declare const AssertionFailed_base: Schema.TaggedErrorClass<AssertionFailed, "AssertionFailed", {
|
|
4
5
|
readonly _tag: Schema.tag<"AssertionFailed">;
|
|
5
6
|
} & {
|
|
@@ -33,6 +34,25 @@ export declare namespace Assert {
|
|
|
33
34
|
function hasAction(action: string): Assertion;
|
|
34
35
|
function hasStage(stage: string): Assertion;
|
|
35
36
|
function custom(name: string, fn: (logs: Log[]) => boolean | Promise<boolean>): Assertion;
|
|
37
|
+
/**
|
|
38
|
+
* Assert that agent behavior complied with an authority policy.
|
|
39
|
+
*
|
|
40
|
+
* Checks collected logs against governance rules: tool restrictions,
|
|
41
|
+
* spawn limits, commit permissions, agent/model constraints.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* assert: [
|
|
46
|
+
* Assert.authority({
|
|
47
|
+
* canSpawn: false,
|
|
48
|
+
* canCommit: true,
|
|
49
|
+
* forbiddenTools: ["delete_file"],
|
|
50
|
+
* }),
|
|
51
|
+
* Assert.hasAction("done"),
|
|
52
|
+
* ]
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function authority(policy: StoryAuthority): Assertion;
|
|
36
56
|
function run(assertions: Assertion[], logs: Log[]): Effect.Effect<void, AssertionFailed | AssertionAggregateFailed>;
|
|
37
57
|
}
|
|
38
58
|
export {};
|
package/dist/assert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;;;;;;;
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;;;;;;;AAGlD,qBAAa,eAAgB,SAAQ,oBAMpC;CAAG;;;;;;AAEJ,qBAAa,wBAAyB,SAAQ,6BAK7C;CAAG;AAEJ,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF,yBAAiB,MAAM,CAAC;IACtB,SAAgB,QAAQ,IAAI,SAAS,CAEpC;IAED,SAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAEnD;IAED,SAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEjD;IAED,SAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC9C,SAAS,CAEX;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAW3D;IAED,SAAgB,GAAG,CACjB,UAAU,EAAE,SAAS,EAAE,EACvB,IAAI,EAAE,GAAG,EAAE,GACV,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,wBAAwB,CAAC,CA8DjE;CACF"}
|
package/dist/assert.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
+
import { validateAuthority } from "./authority";
|
|
2
3
|
export class AssertionFailed extends Schema.TaggedError()("AssertionFailed", {
|
|
3
4
|
assertion: Schema.String,
|
|
4
5
|
details: Schema.Unknown
|
|
@@ -26,6 +27,37 @@ export var Assert;
|
|
|
26
27
|
return { _tag: "Custom", fn, name };
|
|
27
28
|
}
|
|
28
29
|
Assert.custom = custom;
|
|
30
|
+
/**
|
|
31
|
+
* Assert that agent behavior complied with an authority policy.
|
|
32
|
+
*
|
|
33
|
+
* Checks collected logs against governance rules: tool restrictions,
|
|
34
|
+
* spawn limits, commit permissions, agent/model constraints.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* assert: [
|
|
39
|
+
* Assert.authority({
|
|
40
|
+
* canSpawn: false,
|
|
41
|
+
* canCommit: true,
|
|
42
|
+
* forbiddenTools: ["delete_file"],
|
|
43
|
+
* }),
|
|
44
|
+
* Assert.hasAction("done"),
|
|
45
|
+
* ]
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function authority(policy) {
|
|
49
|
+
return custom("Authority", (logs) => {
|
|
50
|
+
const violations = validateAuthority(logs, policy);
|
|
51
|
+
if (violations.length > 0) {
|
|
52
|
+
for (const v of violations) {
|
|
53
|
+
console.warn(`[Authority] ${v.rule}: ${v.message}`);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
Assert.authority = authority;
|
|
29
61
|
function run(assertions, logs) {
|
|
30
62
|
return Effect.gen(function* () {
|
|
31
63
|
const failures = [];
|
package/dist/assert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CACxE,iBAAiB,EACjB;IACE,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,OAAO,EAAE,MAAM,CAAC,OAAO;CACxB,CACF;CAAG;AAEJ,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,WAAW,EAA4B,CAC1F,0BAA0B,EAC1B;IACE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;CAC3D,CACF;CAAG;AAQJ,MAAM,KAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAA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E,CAAC;gBACxB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC1B,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,wBAAwB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAjEe,UAAG,MAiElB,CAAA;AACH,CAAC,EArHgB,MAAM,KAAN,MAAM,QAqHtB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authority — Governance validation for agent-executed gates.
|
|
3
|
+
*
|
|
4
|
+
* Validates that agent events (tools used, spawns requested, commits made)
|
|
5
|
+
* comply with the StoryAuthority policy defined on the story.
|
|
6
|
+
*
|
|
7
|
+
* This is the enforcement layer: StoryAuthority defines what's allowed,
|
|
8
|
+
* this module checks whether agent behavior stayed within bounds.
|
|
9
|
+
*/
|
|
10
|
+
import type { Log } from "./types";
|
|
11
|
+
import type { StoryAuthority } from "./prd/types";
|
|
12
|
+
import type { AgentEvent } from "./filepath-protocol";
|
|
13
|
+
export interface AuthorityViolation {
|
|
14
|
+
rule: string;
|
|
15
|
+
message: string;
|
|
16
|
+
event?: AgentEvent;
|
|
17
|
+
log?: Log;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates a stream of logs against a StoryAuthority policy.
|
|
21
|
+
* Returns an array of violations (empty = compliant).
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateAuthority(logs: Log[], authority: StoryAuthority): AuthorityViolation[];
|
|
24
|
+
/**
|
|
25
|
+
* Merges a story's authority with PRD-level defaults.
|
|
26
|
+
* Story-level settings take precedence.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mergeAuthority(storyAuthority?: StoryAuthority, defaultAuthority?: StoryAuthority): StoryAuthority | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Flattens a tree of stories (with children) into a flat array.
|
|
31
|
+
* Assigns parentId to children automatically.
|
|
32
|
+
*/
|
|
33
|
+
export declare function flattenStoryTree<TId extends string>(stories: readonly import("./prd/types").Story<TId>[]): import("./prd/types").Story<TId>[];
|
|
34
|
+
//# sourceMappingURL=authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority.d.ts","sourceRoot":"","sources":["../src/authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,GAAG,EAAE,EACX,SAAS,EAAE,cAAc,GACxB,kBAAkB,EAAE,CAgGtB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,cAAc,CAAC,EAAE,cAAc,EAC/B,gBAAgB,CAAC,EAAE,cAAc,GAChC,cAAc,GAAG,SAAS,CAc5B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,MAAM,EACjD,OAAO,EAAE,SAAS,OAAO,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GACnD,OAAO,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAqBpC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authority — Governance validation for agent-executed gates.
|
|
3
|
+
*
|
|
4
|
+
* Validates that agent events (tools used, spawns requested, commits made)
|
|
5
|
+
* comply with the StoryAuthority policy defined on the story.
|
|
6
|
+
*
|
|
7
|
+
* This is the enforcement layer: StoryAuthority defines what's allowed,
|
|
8
|
+
* this module checks whether agent behavior stayed within bounds.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Validates a stream of logs against a StoryAuthority policy.
|
|
12
|
+
* Returns an array of violations (empty = compliant).
|
|
13
|
+
*/
|
|
14
|
+
export function validateAuthority(logs, authority) {
|
|
15
|
+
const violations = [];
|
|
16
|
+
// Count spawns
|
|
17
|
+
if (authority.canSpawn === false) {
|
|
18
|
+
const spawnLogs = logs.filter((l) => l.action === "spawn");
|
|
19
|
+
if (spawnLogs.length > 0) {
|
|
20
|
+
violations.push({
|
|
21
|
+
rule: "canSpawn",
|
|
22
|
+
message: `Agent spawned ${spawnLogs.length} child agent(s) but canSpawn is false`,
|
|
23
|
+
log: spawnLogs[0],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (authority.maxChildAgents !== undefined) {
|
|
28
|
+
const spawnCount = logs.filter((l) => l.action === "spawn").length;
|
|
29
|
+
if (spawnCount > authority.maxChildAgents) {
|
|
30
|
+
violations.push({
|
|
31
|
+
rule: "maxChildAgents",
|
|
32
|
+
message: `Agent spawned ${spawnCount} children, exceeding limit of ${authority.maxChildAgents}`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Check commits
|
|
37
|
+
if (authority.canCommit === false) {
|
|
38
|
+
const commitLogs = logs.filter((l) => l.action === "commit");
|
|
39
|
+
if (commitLogs.length > 0) {
|
|
40
|
+
violations.push({
|
|
41
|
+
rule: "canCommit",
|
|
42
|
+
message: `Agent made ${commitLogs.length} commit(s) but canCommit is false`,
|
|
43
|
+
log: commitLogs[0],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Check tool restrictions
|
|
48
|
+
if (authority.allowedTools || authority.forbiddenTools) {
|
|
49
|
+
const toolLogs = logs.filter((l) => l.action?.startsWith("tool:"));
|
|
50
|
+
for (const log of toolLogs) {
|
|
51
|
+
const toolName = log.action.replace("tool:", "");
|
|
52
|
+
if (authority.forbiddenTools?.includes(toolName)) {
|
|
53
|
+
violations.push({
|
|
54
|
+
rule: "forbiddenTools",
|
|
55
|
+
message: `Agent used forbidden tool "${toolName}"`,
|
|
56
|
+
log,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (authority.allowedTools &&
|
|
60
|
+
authority.allowedTools.length > 0 &&
|
|
61
|
+
!authority.allowedTools.includes(toolName)) {
|
|
62
|
+
violations.push({
|
|
63
|
+
rule: "allowedTools",
|
|
64
|
+
message: `Agent used tool "${toolName}" which is not in allowedTools`,
|
|
65
|
+
log,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Check agent runtime restrictions
|
|
71
|
+
if (authority.allowedAgents && authority.allowedAgents.length > 0) {
|
|
72
|
+
const spawnLogs = logs.filter((l) => l.action === "spawn");
|
|
73
|
+
for (const log of spawnLogs) {
|
|
74
|
+
const agentType = log.data?.agent;
|
|
75
|
+
if (agentType && !authority.allowedAgents.includes(agentType)) {
|
|
76
|
+
violations.push({
|
|
77
|
+
rule: "allowedAgents",
|
|
78
|
+
message: `Agent spawned child with runtime "${agentType}" which is not in allowedAgents`,
|
|
79
|
+
log,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Check model restrictions
|
|
85
|
+
if (authority.allowedModels && authority.allowedModels.length > 0) {
|
|
86
|
+
const spawnLogs = logs.filter((l) => l.action === "spawn");
|
|
87
|
+
for (const log of spawnLogs) {
|
|
88
|
+
const model = log.data?.model;
|
|
89
|
+
if (model && !authority.allowedModels.includes(model)) {
|
|
90
|
+
violations.push({
|
|
91
|
+
rule: "allowedModels",
|
|
92
|
+
message: `Agent spawned child with model "${model}" which is not in allowedModels`,
|
|
93
|
+
log,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return violations;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Merges a story's authority with PRD-level defaults.
|
|
102
|
+
* Story-level settings take precedence.
|
|
103
|
+
*/
|
|
104
|
+
export function mergeAuthority(storyAuthority, defaultAuthority) {
|
|
105
|
+
if (!storyAuthority && !defaultAuthority)
|
|
106
|
+
return undefined;
|
|
107
|
+
if (!defaultAuthority)
|
|
108
|
+
return storyAuthority;
|
|
109
|
+
if (!storyAuthority)
|
|
110
|
+
return defaultAuthority;
|
|
111
|
+
return {
|
|
112
|
+
...defaultAuthority,
|
|
113
|
+
...storyAuthority,
|
|
114
|
+
// Array fields: story overrides completely (not merged)
|
|
115
|
+
allowedAgents: storyAuthority.allowedAgents ?? defaultAuthority.allowedAgents,
|
|
116
|
+
allowedModels: storyAuthority.allowedModels ?? defaultAuthority.allowedModels,
|
|
117
|
+
allowedTools: storyAuthority.allowedTools ?? defaultAuthority.allowedTools,
|
|
118
|
+
forbiddenTools: storyAuthority.forbiddenTools ?? defaultAuthority.forbiddenTools,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Flattens a tree of stories (with children) into a flat array.
|
|
123
|
+
* Assigns parentId to children automatically.
|
|
124
|
+
*/
|
|
125
|
+
export function flattenStoryTree(stories) {
|
|
126
|
+
const result = [];
|
|
127
|
+
function walk(storyList, parentId) {
|
|
128
|
+
for (const story of storyList) {
|
|
129
|
+
const flat = { ...story, parentId: story.parentId ?? parentId };
|
|
130
|
+
// Remove children from the flat version
|
|
131
|
+
const { children, ...rest } = flat;
|
|
132
|
+
result.push(rest);
|
|
133
|
+
if (children && children.length > 0) {
|
|
134
|
+
walk(children, story.id);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
walk(stories);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority.js","sourceRoot":"","sources":["../src/authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAW,EACX,SAAyB;IAEzB,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,eAAe;IACf,IAAI,SAAS,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;QAC3D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,UAAU,CAAC,IAAI,CAAC;gBACd,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,iBAAiB,SAAS,CAAC,MAAM,uCAAuC;gBACjF,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC;QACnE,IAAI,UAAU,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC;YAC1C,UAAU,CAAC,IAAI,CAAC;gBACd,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,iBAAiB,UAAU,iCAAiC,SAAS,CAAC,cAAc,EAAE;aAChG,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,IAAI,SAAS,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;QAClC,MAAM,UAAU,GAAG,IAAI,CAAC,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/cli/gateproof.js
CHANGED
|
@@ -8,10 +8,12 @@ function printHelp() {
|
|
|
8
8
|
"",
|
|
9
9
|
"Subcommands:",
|
|
10
10
|
" prdts Generate a prd.ts from story descriptions",
|
|
11
|
+
" smoke Run gates once without agent loop (validate setup)",
|
|
11
12
|
"",
|
|
12
13
|
"Usage:",
|
|
13
14
|
" npx gateproof prdts --in stories.txt --out prd.ts",
|
|
14
15
|
" echo \"User can sign up\" | npx gateproof prdts --stdout",
|
|
16
|
+
" npx gateproof smoke ./prd.ts",
|
|
15
17
|
"",
|
|
16
18
|
"Options (prdts):",
|
|
17
19
|
" -i, --in <path> Input file with one story per line",
|
|
@@ -21,6 +23,13 @@ function printHelp() {
|
|
|
21
23
|
" --model <id> Model id (default: big-pickle)",
|
|
22
24
|
" --api-key <key> API key (or set OPENCODE_ZEN_API_KEY)",
|
|
23
25
|
" --overwrite Overwrite output file if it exists",
|
|
26
|
+
"",
|
|
27
|
+
"Options (smoke):",
|
|
28
|
+
" --report <path> Write JSON report to path",
|
|
29
|
+
" --check-scope Validate scope constraints against git diff",
|
|
30
|
+
" --base-ref <ref> Git ref for scope checking (default: HEAD)",
|
|
31
|
+
" --json Output results as JSON",
|
|
32
|
+
"",
|
|
24
33
|
" -h, --help Show help",
|
|
25
34
|
].join("\n");
|
|
26
35
|
stdout.write(`${text}\n`);
|
|
@@ -31,10 +40,14 @@ function parseArgs(argv) {
|
|
|
31
40
|
model: "big-pickle",
|
|
32
41
|
stdout: false,
|
|
33
42
|
overwrite: false,
|
|
43
|
+
checkScope: false,
|
|
44
|
+
json: false,
|
|
34
45
|
};
|
|
35
46
|
if (argv.length > 0 && !argv[0].startsWith("-")) {
|
|
36
47
|
args.subcommand = argv.shift();
|
|
37
48
|
}
|
|
49
|
+
// For smoke command, first non-flag arg is prd path
|
|
50
|
+
let foundPrdPath = false;
|
|
38
51
|
for (let i = 0; i < argv.length; i++) {
|
|
39
52
|
const arg = argv[i];
|
|
40
53
|
switch (arg) {
|
|
@@ -61,6 +74,18 @@ function parseArgs(argv) {
|
|
|
61
74
|
case "--overwrite":
|
|
62
75
|
args.overwrite = true;
|
|
63
76
|
break;
|
|
77
|
+
case "--report":
|
|
78
|
+
args.reportPath = argv[++i];
|
|
79
|
+
break;
|
|
80
|
+
case "--check-scope":
|
|
81
|
+
args.checkScope = true;
|
|
82
|
+
break;
|
|
83
|
+
case "--base-ref":
|
|
84
|
+
args.baseRef = argv[++i];
|
|
85
|
+
break;
|
|
86
|
+
case "--json":
|
|
87
|
+
args.json = true;
|
|
88
|
+
break;
|
|
64
89
|
case "--help":
|
|
65
90
|
case "-h":
|
|
66
91
|
printHelp();
|
|
@@ -69,6 +94,11 @@ function parseArgs(argv) {
|
|
|
69
94
|
if (arg && arg.startsWith("-")) {
|
|
70
95
|
throw new Error(`Unknown flag: ${arg}`);
|
|
71
96
|
}
|
|
97
|
+
// Positional argument - treat as prd path for smoke command
|
|
98
|
+
if (!foundPrdPath && args.subcommand === "smoke") {
|
|
99
|
+
args.prdPath = arg;
|
|
100
|
+
foundPrdPath = true;
|
|
101
|
+
}
|
|
72
102
|
}
|
|
73
103
|
}
|
|
74
104
|
return args;
|
|
@@ -207,11 +237,11 @@ function coercePrd(input) {
|
|
|
207
237
|
});
|
|
208
238
|
return { stories };
|
|
209
239
|
}
|
|
210
|
-
function buildPrompt(
|
|
211
|
-
return `Transform the following
|
|
240
|
+
function buildPrompt(promptText) {
|
|
241
|
+
return `Transform the following product prompt into a structured PRD object with inline gate implementations.
|
|
212
242
|
|
|
213
|
-
|
|
214
|
-
${
|
|
243
|
+
Prompt:
|
|
244
|
+
${promptText}
|
|
215
245
|
|
|
216
246
|
Requirements:
|
|
217
247
|
1. Generate kebab-case IDs for each story (e.g., "user-signup", "email-verification")
|
|
@@ -223,7 +253,7 @@ Requirements:
|
|
|
223
253
|
- Include Assert.custom or Assert.noErrors assertions
|
|
224
254
|
- Be self-contained and runnable
|
|
225
255
|
- Match the story's intent (e.g., if story is about API health, gate should check API endpoint)
|
|
226
|
-
5. Infer dependencies from
|
|
256
|
+
5. Infer dependencies from the prompt (e.g., if a story mentions "depends on signup", add "user-signup" to dependsOn)
|
|
227
257
|
6. If dependencies are mentioned in natural language, map them to the appropriate story IDs
|
|
228
258
|
|
|
229
259
|
For gate implementations, use this EXACT pattern (return the gate spec directly):
|
|
@@ -447,6 +477,49 @@ async function runPrdts(args) {
|
|
|
447
477
|
await writeFile(outputPath, prdFile, "utf8");
|
|
448
478
|
stdout.write(`✅ Wrote ${outputPath}\n`);
|
|
449
479
|
}
|
|
480
|
+
async function runSmoke(args) {
|
|
481
|
+
const prdPath = args.prdPath ?? "prd.ts";
|
|
482
|
+
if (!existsSync(prdPath)) {
|
|
483
|
+
throw new Error(`PRD file not found: ${prdPath}`);
|
|
484
|
+
}
|
|
485
|
+
// Dynamic import the prd module
|
|
486
|
+
const { runPrd } = await import("../prd/runner");
|
|
487
|
+
const { resolve } = await import("node:path");
|
|
488
|
+
// Load the PRD file
|
|
489
|
+
const absolutePath = resolve(process.cwd(), prdPath);
|
|
490
|
+
const mod = await import(`file://${absolutePath}`);
|
|
491
|
+
let prd;
|
|
492
|
+
if (mod.default && typeof mod.default === "object" && "stories" in mod.default) {
|
|
493
|
+
prd = mod.default;
|
|
494
|
+
}
|
|
495
|
+
else if (mod.prd && typeof mod.prd === "object" && "stories" in mod.prd) {
|
|
496
|
+
prd = mod.prd;
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
throw new Error(`PRD file must export 'prd' or a default object with 'stories': ${prdPath}`);
|
|
500
|
+
}
|
|
501
|
+
stdout.write(`\n🔥 Smoke test: ${prdPath}\n`);
|
|
502
|
+
stdout.write(` Stories: ${prd.stories.length}\n`);
|
|
503
|
+
stdout.write(` Scope check: ${args.checkScope ? "enabled" : "disabled"}\n\n`);
|
|
504
|
+
const result = await runPrd(prd, process.cwd(), {
|
|
505
|
+
reportPath: args.reportPath,
|
|
506
|
+
checkScope: args.checkScope,
|
|
507
|
+
baseRef: args.baseRef,
|
|
508
|
+
});
|
|
509
|
+
if (args.json) {
|
|
510
|
+
stdout.write(JSON.stringify(result.report ?? { success: result.success }, null, 2) + "\n");
|
|
511
|
+
}
|
|
512
|
+
else if (result.success) {
|
|
513
|
+
stdout.write(`\n✅ Smoke test passed! All ${prd.stories.length} gates green.\n`);
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
stdout.write(`\n❌ Smoke test failed at: ${result.failedStory?.id ?? "unknown"}\n`);
|
|
517
|
+
if (result.error) {
|
|
518
|
+
stdout.write(` Error: ${result.error.message}\n`);
|
|
519
|
+
}
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
450
523
|
async function main() {
|
|
451
524
|
try {
|
|
452
525
|
const args = parseArgs(process.argv.slice(2));
|
|
@@ -458,6 +531,9 @@ async function main() {
|
|
|
458
531
|
case "prdts":
|
|
459
532
|
await runPrdts(args);
|
|
460
533
|
break;
|
|
534
|
+
case "smoke":
|
|
535
|
+
await runSmoke(args);
|
|
536
|
+
break;
|
|
461
537
|
default:
|
|
462
538
|
throw new Error(`Unknown subcommand: ${args.subcommand}`);
|
|
463
539
|
}
|