@ftrdotdev/pi-delegates 0.1.0 → 0.2.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/CHANGELOG.md +51 -0
- package/OPERATIONS.md +79 -6
- package/README.md +25 -17
- package/ROADMAP.md +21 -0
- package/TESTING.md +153 -318
- package/package.json +4 -3
- package/skills/pi-delegates/SKILL.md +29 -0
- package/skills/pi-delegates/references/launch.md +28 -0
- package/src/docs-contract.test.ts +106 -0
- package/src/domain/definitions.ts +3 -1
- package/src/domain/failure.ts +33 -0
- package/src/domain/model-source.ts +30 -0
- package/src/domain/orchestration/control.test.ts +69 -35
- package/src/domain/orchestration/control.ts +110 -89
- package/src/domain/orchestration/fanout.test.ts +125 -20
- package/src/domain/orchestration/fanout.ts +60 -22
- package/src/domain/orchestration/gates.test.ts +14 -15
- package/src/domain/orchestration/launch.test.ts +210 -11
- package/src/domain/orchestration/launch.ts +142 -32
- package/src/domain/orchestration/requests.test.ts +11 -16
- package/src/domain/orchestration/requests.ts +14 -1
- package/src/domain/orchestration/review.test.ts +89 -11
- package/src/domain/orchestration/run-wait.test.ts +4 -1
- package/src/domain/orchestration/run-wait.ts +1 -1
- package/src/domain/orchestration/workflow.test.ts +157 -16
- package/src/domain/orchestration/workflow.ts +269 -196
- package/src/domain/run-records.ts +214 -52
- package/src/domain/settlement.test.ts +186 -0
- package/src/domain/settlement.ts +137 -0
- package/src/domain/shapes.test.ts +20 -0
- package/src/domain/skills.test.ts +31 -20
- package/src/domain/skills.ts +36 -19
- package/src/domain/toolkit.test.ts +15 -1
- package/src/domain/toolkit.ts +8 -13
- package/src/domain/turn-budget.test.ts +37 -0
- package/src/domain/turn-budget.ts +23 -0
- package/src/domain/view.test.ts +78 -14
- package/src/domain/view.ts +67 -35
- package/src/extension/commands.test.ts +27 -23
- package/src/extension/commands.ts +10 -7
- package/src/extension/entry.test.ts +214 -56
- package/src/extension/entry.ts +78 -40
- package/src/extension/gate-alerts.test.ts +10 -8
- package/src/extension/inspector-command.test.ts +173 -21
- package/src/extension/inspector-command.ts +100 -53
- package/src/extension/prompt.test.ts +2 -4
- package/src/extension/retry-observer.test.ts +292 -0
- package/src/extension/retry-observer.ts +150 -0
- package/src/extension/settle-alerts.test.ts +579 -0
- package/src/extension/settle-alerts.ts +175 -0
- package/src/extension/shortcut.test.ts +6 -8
- package/src/extension/tools.test.ts +325 -24
- package/src/extension/tools.ts +61 -13
- package/src/extension/version.test.ts +21 -29
- package/src/goldens.test.ts +294 -0
- package/src/harness-policy.test.ts +13 -11
- package/src/layers.test.ts +309 -0
- package/src/layers.ts +405 -0
- package/src/package-manifest.test.ts +32 -19
- package/src/presentation/actions.test.ts +8 -8
- package/src/presentation/activity.test.ts +7 -8
- package/src/presentation/close.test.ts +14 -16
- package/src/presentation/inspector.test.ts +14 -11
- package/src/presentation/inspector.ts +27 -25
- package/src/presentation/overlay.test.ts +1 -3
- package/src/presentation/repaint.test.ts +226 -190
- package/src/presentation/snapshot.test.ts +5 -0
- package/src/presentation/status.test.ts +43 -0
- package/src/presentation/status.ts +30 -0
- package/src/presentation/strip.test.ts +13 -6
- package/src/presentation/strip.ts +7 -14
- package/src/presentation/wording.test.ts +153 -3
- package/src/presentation/wording.ts +78 -6
- package/src/runtime/bridge.ts +38 -44
- package/src/runtime/{timers.test.ts → clock.test.ts} +1 -1
- package/src/runtime/clock.ts +31 -0
- package/src/runtime/config.test.ts +26 -7
- package/src/runtime/config.ts +6 -1
- package/src/runtime/execution-env.test.ts +6 -8
- package/src/runtime/extensions.test.ts +4 -4
- package/src/runtime/extensions.ts +23 -11
- package/src/runtime/handle.ts +54 -0
- package/src/runtime/log.test.ts +19 -7
- package/src/runtime/log.ts +23 -0
- package/src/runtime/mcp.test.ts +29 -32
- package/src/runtime/mcp.ts +70 -3
- package/src/runtime/runtime-state.test.ts +25 -0
- package/src/runtime/runtime-state.ts +36 -0
- package/src/runtime/session-tag.ts +11 -0
- package/src/runtime/session.test.ts +24 -31
- package/src/runtime/session.ts +99 -261
- package/src/runtime/storage.ts +29 -0
- package/src/test-hygiene.test.ts +97 -0
- package/src/runtime/timers.ts +0 -10
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { assert, it } from "@effect/vitest";
|
|
2
|
+
import { describeViolations, scanHygiene, type HygieneViolation } from "../test-support/hygiene.ts";
|
|
3
|
+
import { dirEntries, join, readText } from "../test-support/platform.ts";
|
|
4
|
+
|
|
5
|
+
/** Test files allowed to import a `node:` module. Empty: the suite needs none. */
|
|
6
|
+
const allowList: readonly string[] = [];
|
|
7
|
+
|
|
8
|
+
/** Paths the tree scan never reads: a Node-only script tree and this guard's own bad examples. */
|
|
9
|
+
const exemptFromTreeScan: readonly string[] = ["scripts/**", "test-support/fixtures/**"];
|
|
10
|
+
|
|
11
|
+
const PACKAGE_ROOT = join(import.meta.dirname, "..");
|
|
12
|
+
|
|
13
|
+
interface Source {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly source: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Every file under `dir`, as paths relative to the package root. */
|
|
19
|
+
const collect = async (dir: string, found: Source[] = []): Promise<Source[]> => {
|
|
20
|
+
for (const entry of await dirEntries(join(PACKAGE_ROOT, dir))) {
|
|
21
|
+
const path = join(dir, entry.name);
|
|
22
|
+
if (entry.directory) await collect(path, found);
|
|
23
|
+
else found.push({ path, source: await readText(join(PACKAGE_ROOT, path)) });
|
|
24
|
+
}
|
|
25
|
+
return found;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The tree as the guard reads it: the source tree and the shims, never the exemptions. */
|
|
29
|
+
const tree = async (): Promise<readonly Source[]> =>
|
|
30
|
+
[...(await collect("src")), ...(await collect("test-support"))].filter(
|
|
31
|
+
(source) => !source.path.startsWith("test-support/fixtures/"),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const kinds = (violations: readonly HygieneViolation[]): string[] =>
|
|
35
|
+
violations.map((violation) => violation.kind).sort();
|
|
36
|
+
|
|
37
|
+
it("the scanner reports a node import when a fixture test file imports one", async () => {
|
|
38
|
+
const source = await readText(
|
|
39
|
+
join(PACKAGE_ROOT, "test-support/fixtures/hygiene/node-import.fixture.ts"),
|
|
40
|
+
);
|
|
41
|
+
const violations = scanHygiene([{ path: "src/fixtures/node-import.test.ts", source }]);
|
|
42
|
+
|
|
43
|
+
assert.strictEqual(violations.length, 1, describeViolations(violations));
|
|
44
|
+
assert.strictEqual(violations[0]?.kind, "node-import");
|
|
45
|
+
assert.strictEqual(violations[0]?.path, "src/fixtures/node-import.test.ts");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("the scanner reports a hand-built provider when a fixture shapes a runtime object", async () => {
|
|
49
|
+
const source = await readText(
|
|
50
|
+
join(PACKAGE_ROOT, "test-support/fixtures/hygiene/hand-built-provider.fixture.ts"),
|
|
51
|
+
);
|
|
52
|
+
const violations = scanHygiene([{ path: "src/fixtures/hand-built-provider.ts", source }]);
|
|
53
|
+
|
|
54
|
+
assert.deepStrictEqual(
|
|
55
|
+
kinds(violations),
|
|
56
|
+
["hand-built-provider", "layer-build", "layer-call"],
|
|
57
|
+
describeViolations(violations),
|
|
58
|
+
);
|
|
59
|
+
assert.ok(
|
|
60
|
+
violations.every((violation) => violation.path === "src/fixtures/hand-built-provider.ts"),
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("the scanner ignores a pattern that appears only in a comment", () => {
|
|
65
|
+
const violations = scanHygiene([
|
|
66
|
+
{
|
|
67
|
+
path: "src/extension/example.ts",
|
|
68
|
+
source:
|
|
69
|
+
"// a call site would do `Thing.layer(1)`, and this comment is not code\nconst a = 1;\n",
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
assert.deepStrictEqual(violations, [], describeViolations(violations));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("the tree has no node imports in test files and builds layers in one place when the scanner reads src", async () => {
|
|
77
|
+
assert.deepStrictEqual(allowList, [], "a test file needed a node: import");
|
|
78
|
+
assert.deepStrictEqual(
|
|
79
|
+
exemptFromTreeScan,
|
|
80
|
+
["scripts/**", "test-support/fixtures/**"],
|
|
81
|
+
"a path joined the exemption list",
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const violations = scanHygiene(await tree());
|
|
85
|
+
const nodeImports = violations.filter(
|
|
86
|
+
(violation) => violation.kind === "node-import" && !allowList.includes(violation.path),
|
|
87
|
+
);
|
|
88
|
+
const builders = violations.filter(
|
|
89
|
+
(violation) =>
|
|
90
|
+
violation.kind !== "node-import" &&
|
|
91
|
+
violation.path !== "src/layers.ts" &&
|
|
92
|
+
!allowList.includes(violation.path),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
assert.deepStrictEqual(nodeImports, [], describeViolations(nodeImports));
|
|
96
|
+
assert.deepStrictEqual(builders, [], describeViolations(builders));
|
|
97
|
+
});
|
package/src/runtime/timers.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** Injectable timers, so orchestration tests never sleep on wall-clock time. */
|
|
2
|
-
export interface Timers {
|
|
3
|
-
setTimeout(callback: () => void, ms: number): unknown;
|
|
4
|
-
clearTimeout(handle: unknown): void;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const systemTimers: Timers = {
|
|
8
|
-
setTimeout: (callback, ms) => setTimeout(callback, ms),
|
|
9
|
-
clearTimeout: (handle) => clearTimeout(handle as ReturnType<typeof setTimeout>),
|
|
10
|
-
};
|