@gtrabanco/agentic-workflow 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.
@@ -1,103 +0,0 @@
1
- // Engine suite for packages/agentic-workflow/bin/turn-contract.mjs.
2
- //
3
- // Per-box pass/fail/n-a over the shared throwaway-repo matrix (fixtures.mjs),
4
- // plus the CLI contract, subdirectory invocation, the read-only assertion, and
5
- // the engine-only phase-lint clause of box2 (ED-52-3).
6
-
7
- import test from "node:test";
8
- import assert from "node:assert/strict";
9
- import { chmodSync, mkdirSync, readFileSync, utimesSync, writeFileSync } from "node:fs";
10
- import path from "node:path";
11
-
12
- import { makeContext, receiptCases, engineOnlyCases, git, newRepo, commitFile } from "./fixtures.mjs";
13
-
14
- const ctx = makeContext();
15
- test.after(() => ctx.cleanup());
16
-
17
- for (const c of [...receiptCases(ctx), ...engineOnlyCases(ctx)]) {
18
- test(c.name, () => {
19
- const r = ctx.runEngine(c.dir, c.args ?? [], c.env ?? {});
20
- assert.equal(r.stdout, `${c.line}\n`, `stdout for "${c.name}"`);
21
- assert.equal(r.code, c.code, `exit code for "${c.name}"`);
22
- });
23
- }
24
-
25
- test("empty repo fails without a stack trace", () => {
26
- const r = ctx.runEngine(ctx.fx.empty);
27
- assert.equal(r.code, 1);
28
- assert.equal(r.stderr, "", "no diagnostics on a fail path");
29
- });
30
-
31
- test("--help names both flags and exits 0", () => {
32
- for (const args of [["--help"], ["--finished", "--help"]]) {
33
- const r = ctx.runEngine(ctx.fx.ok, args);
34
- assert.equal(r.code, 0, `exit for ${args.join(" ")}`);
35
- assert.match(r.stdout, /--finished/);
36
- assert.match(r.stdout, /--help/);
37
- }
38
- });
39
-
40
- test("unknown flag prints usage on stderr and exits 2", () => {
41
- const r = ctx.runEngine(ctx.fx.ok, ["--nope"]);
42
- assert.equal(r.code, 2);
43
- assert.equal(r.stdout, "", "usage errors never print a receipt on stdout");
44
- assert.match(r.stderr, /unknown argument: --nope/);
45
- });
46
-
47
- test("works from a subdirectory of the repository", () => {
48
- const sub = path.join(ctx.fx.ok, "subdir");
49
- mkdirSync(sub, { recursive: true });
50
- const r = ctx.runEngine(sub);
51
- assert.equal(r.code, 0);
52
- assert.equal(r.stdout, "TURN-CONTRACT ok\n");
53
- });
54
-
55
- test("the verifier is read-only", () => {
56
- const before = git(ctx.fx.ok, "status", "--porcelain", "--untracked-files=all");
57
- const r = ctx.runEngine(ctx.fx.ok);
58
- const after = git(ctx.fx.ok, "status", "--porcelain", "--untracked-files=all");
59
- assert.equal(r.stdout, "TURN-CONTRACT ok\n");
60
- assert.equal(after, before, "the verifier must not mutate tree or index");
61
- });
62
-
63
- test("the status read does not rewrite .git/index", () => {
64
- const dir = newRepo(ctx.root, "readonlyindex", "feat/readonlyindex");
65
- commitFile(dir, "docs/features/readonlyindex/SPEC.md", "unit doc\n");
66
- // A stale mtime on a tracked file makes `git status` want to refresh the
67
- // index; the read must not write it (F10, fold cycle 3 — a porcelain-only
68
- // before/after comparison cannot observe that write).
69
- const stale = new Date("2020-01-01T00:00:00.000Z");
70
- utimesSync(path.join(dir, "README.md"), stale, stale);
71
- const index = path.join(dir, ".git", "index");
72
- const before = readFileSync(index);
73
- const r = ctx.runEngine(dir);
74
- assert.equal(r.stdout, "TURN-CONTRACT ok\n");
75
- assert.equal(r.code, 0);
76
- assert.deepEqual(readFileSync(index), before, "git status must not refresh (rewrite) .git/index");
77
- });
78
-
79
- test("the box2 phase-lint clause is read-only", () => {
80
- const before = git(ctx.fx.lintpass, "status", "--porcelain", "--untracked-files=all");
81
- const r = ctx.runEngine(ctx.fx.lintpass);
82
- const after = git(ctx.fx.lintpass, "status", "--porcelain", "--untracked-files=all");
83
- assert.equal(r.stdout, "TURN-CONTRACT ok\n");
84
- assert.equal(after, before, "the phase-lint spawn must not mutate tree or index");
85
- });
86
-
87
- test("unreadable .git fails closed with a fail line", (t) => {
88
- if (typeof process.getuid === "function" && process.getuid() === 0) {
89
- t.skip("running as root: permission bits are not enforced");
90
- return;
91
- }
92
- const dir = newRepo(ctx.root, "plumbing", "feat/plumbing");
93
- commitFile(dir, "docs/features/plumbing/ACCEPTANCE.md", "frozen\n");
94
- const dotgit = path.join(dir, ".git");
95
- chmodSync(dotgit, 0o000);
96
- try {
97
- const r = ctx.runEngine(dir);
98
- assert.equal(r.code, 1, "never a fake ok when plumbing is denied");
99
- assert.equal(r.stdout, "TURN-CONTRACT fail box1: not-a-repo\n");
100
- } finally {
101
- chmodSync(dotgit, 0o755);
102
- }
103
- });
@@ -1,20 +0,0 @@
1
- // Two-engine parity suite: the same fixture-repo matrix through the crate
2
- // engine and the scaffold shim must produce byte-identical stdout and exit
3
- // codes (AC7). This is the drift gate between the two implementations.
4
-
5
- import test from "node:test";
6
- import assert from "node:assert/strict";
7
-
8
- import { makeContext, receiptCases } from "./fixtures.mjs";
9
-
10
- const ctx = makeContext();
11
- test.after(() => ctx.cleanup());
12
-
13
- for (const c of receiptCases(ctx)) {
14
- test(`parity: ${c.name}`, () => {
15
- const engine = ctx.runEngine(c.dir, c.args ?? [], c.env ?? {});
16
- const shim = ctx.runShim(c.dir, c.args ?? [], c.env ?? {});
17
- assert.equal(engine.code, shim.code, `exit parity for "${c.name}"`);
18
- assert.equal(engine.stdout, shim.stdout, `stdout parity for "${c.name}"`);
19
- });
20
- }