agent-conveyor 0.1.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.
Files changed (85) hide show
  1. package/README.md +1123 -0
  2. package/dist/cli/main.d.ts +2 -0
  3. package/dist/cli/main.js +19 -0
  4. package/dist/cli/main.js.map +1 -0
  5. package/dist/cli/program-name.d.ts +2 -0
  6. package/dist/cli/program-name.js +12 -0
  7. package/dist/cli/program-name.js.map +1 -0
  8. package/dist/cli/typescript-runtime.d.ts +52 -0
  9. package/dist/cli/typescript-runtime.js +18009 -0
  10. package/dist/cli/typescript-runtime.js.map +1 -0
  11. package/dist/index.d.ts +37 -0
  12. package/dist/index.js +20 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/runtime/audit.d.ts +96 -0
  15. package/dist/runtime/audit.js +298 -0
  16. package/dist/runtime/audit.js.map +1 -0
  17. package/dist/runtime/classify.d.ts +8 -0
  18. package/dist/runtime/classify.js +128 -0
  19. package/dist/runtime/classify.js.map +1 -0
  20. package/dist/runtime/codex-session.d.ts +103 -0
  21. package/dist/runtime/codex-session.js +408 -0
  22. package/dist/runtime/codex-session.js.map +1 -0
  23. package/dist/runtime/commands.d.ts +92 -0
  24. package/dist/runtime/commands.js +408 -0
  25. package/dist/runtime/commands.js.map +1 -0
  26. package/dist/runtime/dispatch.d.ts +74 -0
  27. package/dist/runtime/dispatch.js +669 -0
  28. package/dist/runtime/dispatch.js.map +1 -0
  29. package/dist/runtime/export.d.ts +22 -0
  30. package/dist/runtime/export.js +77 -0
  31. package/dist/runtime/export.js.map +1 -0
  32. package/dist/runtime/ingest.d.ts +28 -0
  33. package/dist/runtime/ingest.js +177 -0
  34. package/dist/runtime/ingest.js.map +1 -0
  35. package/dist/runtime/loop-evidence.d.ts +87 -0
  36. package/dist/runtime/loop-evidence.js +448 -0
  37. package/dist/runtime/loop-evidence.js.map +1 -0
  38. package/dist/runtime/manager-config.d.ts +20 -0
  39. package/dist/runtime/manager-config.js +34 -0
  40. package/dist/runtime/manager-config.js.map +1 -0
  41. package/dist/runtime/manager-permissions.d.ts +7 -0
  42. package/dist/runtime/manager-permissions.js +85 -0
  43. package/dist/runtime/manager-permissions.js.map +1 -0
  44. package/dist/runtime/notifications.d.ts +89 -0
  45. package/dist/runtime/notifications.js +208 -0
  46. package/dist/runtime/notifications.js.map +1 -0
  47. package/dist/runtime/replay.d.ts +29 -0
  48. package/dist/runtime/replay.js +331 -0
  49. package/dist/runtime/replay.js.map +1 -0
  50. package/dist/runtime/tasks.d.ts +54 -0
  51. package/dist/runtime/tasks.js +195 -0
  52. package/dist/runtime/tasks.js.map +1 -0
  53. package/dist/runtime/tmux.d.ts +61 -0
  54. package/dist/runtime/tmux.js +189 -0
  55. package/dist/runtime/tmux.js.map +1 -0
  56. package/dist/runtime/visual-diff.d.ts +23 -0
  57. package/dist/runtime/visual-diff.js +234 -0
  58. package/dist/runtime/visual-diff.js.map +1 -0
  59. package/dist/state/database.d.ts +21 -0
  60. package/dist/state/database.js +142 -0
  61. package/dist/state/database.js.map +1 -0
  62. package/dist/state/files.d.ts +38 -0
  63. package/dist/state/files.js +73 -0
  64. package/dist/state/files.js.map +1 -0
  65. package/dist/state/schema-v22.d.ts +1 -0
  66. package/dist/state/schema-v22.js +566 -0
  67. package/dist/state/schema-v22.js.map +1 -0
  68. package/dist/state/sqlite-contract.d.ts +4 -0
  69. package/dist/state/sqlite-contract.js +78 -0
  70. package/dist/state/sqlite-contract.js.map +1 -0
  71. package/dist/state/status.d.ts +12 -0
  72. package/dist/state/status.js +40 -0
  73. package/dist/state/status.js.map +1 -0
  74. package/docs/typescript-migration/cli-contract.md +147 -0
  75. package/docs/typescript-migration/dashboard-contract.md +76 -0
  76. package/docs/typescript-migration/package-install-contract.md +98 -0
  77. package/docs/typescript-migration/qa-gate-matrix.md +103 -0
  78. package/docs/typescript-migration/sqlite-state-contract.md +92 -0
  79. package/docs/typescript-migration/t005-runtime-parity.md +47 -0
  80. package/package.json +88 -0
  81. package/scripts/capture-static-html-screenshot.mjs +88 -0
  82. package/skills/codex-review/SKILL.md +116 -0
  83. package/skills/codex-review/scripts/codex-review +344 -0
  84. package/skills/manage-codex-workers/SKILL.md +696 -0
  85. package/skills/manage-codex-workers/agents/openai.yaml +5 -0
@@ -0,0 +1,40 @@
1
+ import { existsSync } from "node:fs";
2
+ import { DatabaseSync } from "node:sqlite";
3
+ import { defaultDbPath, loadJsonSync, statusPath } from "./files.js";
4
+ export function latestStatusSync(name, options = {}) {
5
+ const fallback = loadJsonSync(statusPath(name, options), {});
6
+ const dbPath = options.dbPath ?? defaultDbPath(options);
7
+ if (!existsSync(dbPath)) {
8
+ return fallback;
9
+ }
10
+ let database;
11
+ try {
12
+ database = new DatabaseSync(dbPath, { readOnly: true });
13
+ const row = database.prepare(`
14
+ select statuses.state, statuses.current_task, statuses.next_action,
15
+ statuses.blocker, statuses.created_at
16
+ from statuses
17
+ join workers on workers.id = statuses.worker_id
18
+ where workers.name = ?
19
+ order by statuses.id desc
20
+ limit 1
21
+ `).get(name);
22
+ if (!row) {
23
+ return fallback;
24
+ }
25
+ return {
26
+ blocker: row.blocker,
27
+ current_task: row.current_task ?? undefined,
28
+ last_update: row.created_at,
29
+ next_action: row.next_action ?? undefined,
30
+ state: row.state,
31
+ };
32
+ }
33
+ catch {
34
+ return fallback;
35
+ }
36
+ finally {
37
+ database?.close();
38
+ }
39
+ }
40
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/state/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAkBrE,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,UAAsE,EAAE;IAExE,MAAM,QAAQ,GAAG,YAAY,CAAe,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,QAAkC,CAAC;IACvC,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC;;;;;;;;KAQ5B,CAAC,CAAC,GAAG,CAAC,IAAI,CAA0B,CAAC;QAEtC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,SAAS;YAC3C,WAAW,EAAE,GAAG,CAAC,UAAU;YAC3B,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,SAAS;YACzC,KAAK,EAAE,GAAG,CAAC,KAAK;SACjB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,KAAK,EAAE,CAAC;IACpB,CAAC;AACH,CAAC"}
@@ -0,0 +1,147 @@
1
+ # TypeScript Migration CLI Contract
2
+
3
+ This contract freezes the current Python CLI surface before TypeScript migration.
4
+ The TypeScript CLI must preserve this surface unless a Judge receipt explicitly
5
+ approves and documents a diff.
6
+
7
+ ## Public Entry Points
8
+
9
+ - `conveyor` package-installed command from `pyproject.toml`.
10
+ - `workerctl` package-installed compatibility command from `pyproject.toml`.
11
+ - `bin/conveyor` local wrapper.
12
+ - `bin/workerctl` local wrapper.
13
+ - `scripts/workerctl` repository-local entry point.
14
+ - `python -m workerctl` until Python compatibility is retired by an explicit
15
+ migration decision.
16
+
17
+ Program name behavior must preserve both `conveyor` and `workerctl`. The Python
18
+ implementation currently selects the name from `CONVEYOR_CLI_PROG`, the
19
+ invoked filename, or defaults to `conveyor`.
20
+
21
+ ## Command Inventory
22
+
23
+ Source of truth: `scripts/workerctl --help` and `workerctl/cli.py`.
24
+
25
+ The top-level command inventory to preserve is:
26
+
27
+ ```text
28
+ create
29
+ start
30
+ start-test
31
+ dashboard
32
+ dispatch
33
+ enqueue-notify-manager
34
+ enqueue-nudge-worker
35
+ enqueue-continue-iteration
36
+ loop-templates
37
+ loop-status
38
+ loop-triggers
39
+ loop-evidence
40
+ ralph-loop-presets
41
+ doctor
42
+ doctor-self
43
+ qa-plan
44
+ qa-run
45
+ create-disposable-binding
46
+ install-skills
47
+ db-doctor
48
+ import-compat
49
+ tasks
50
+ criteria
51
+ criteria-plan
52
+ handoff
53
+ worker-ack
54
+ manager-ack
55
+ runs
56
+ telemetry
57
+ manager-config
58
+ manager-permission
59
+ epilogue
60
+ continuation
61
+ continuation-reviewer
62
+ record-decision
63
+ register-worker
64
+ start-worker
65
+ start-manager
66
+ pair
67
+ register-manager
68
+ deregister
69
+ sessions
70
+ discover
71
+ search
72
+ bind
73
+ unbind
74
+ ingest
75
+ tail
76
+ session-inbox
77
+ manager-inbox
78
+ worker-inbox
79
+ session-nudge
80
+ session-interrupt
81
+ request-worker-compact
82
+ compact-worker
83
+ cycle
84
+ divergences
85
+ commands
86
+ prune
87
+ stop-task
88
+ finish-task
89
+ reconcile
90
+ transcript-capture
91
+ transcript-show
92
+ transcript-prune
93
+ audit
94
+ mutation-audit
95
+ replay
96
+ export-task
97
+ list
98
+ capture
99
+ status
100
+ update-status
101
+ idle-check
102
+ events
103
+ classify
104
+ interrupt
105
+ nudge
106
+ open
107
+ open-worker
108
+ open-manager
109
+ stop
110
+ ```
111
+
112
+ `discover` and `search` are aliases and must remain compatible.
113
+
114
+ ## Behavioral Requirements
115
+
116
+ - Preserve existing exit codes for success, argparse usage errors, and
117
+ `WorkerError`/`CodexSessionError`/`IngestError` failure paths.
118
+ - Preserve JSON output shapes for commands that currently offer `--json`.
119
+ - Preserve plain-text first lines for `conveyor --help` and `workerctl --help`:
120
+ `usage: conveyor` and `usage: workerctl`.
121
+ - Preserve direct argv execution style. Do not route user-provided command text
122
+ through shell interpolation.
123
+ - Preserve local `PATH` installer assumptions that `bin/conveyor` and
124
+ `bin/workerctl` are executable.
125
+ - Preserve `--path` database override semantics on commands that currently
126
+ accept it.
127
+ - Preserve `--dry-run` behavior on mutating or side-effecting commands that
128
+ currently expose dry-run.
129
+ - Preserve no-judgment Dispatch boundary: Dispatch routes mechanical side
130
+ effects and must not decide task success, merge readiness, or acceptance
131
+ criteria truth.
132
+
133
+ ## Contract Drift Disproof Gate
134
+
135
+ Before switching public entry points to TypeScript, run or produce an equivalent
136
+ artifact for:
137
+
138
+ ```bash
139
+ scripts/workerctl --help
140
+ CONVEYOR_CLI_PROG=conveyor scripts/workerctl --help
141
+ CONVEYOR_CLI_PROG=workerctl scripts/workerctl --help
142
+ rg -n "add_parser\\(|set_defaults\\(" workerctl/cli.py
143
+ ```
144
+
145
+ The TypeScript implementation must have an adjudicated command/flag diff against
146
+ the Python surface. Unreviewed missing commands, missing aliases, changed JSON
147
+ shape, or changed help program name block migration completion.
@@ -0,0 +1,76 @@
1
+ # TypeScript Migration Dashboard Contract
2
+
3
+ The dashboard is already TypeScript and must remain green throughout the CLI
4
+ migration.
5
+
6
+ ## Current TS Patterns To Preserve
7
+
8
+ - Root package uses ESM (`"type": "module"`).
9
+ - Dashboard runtime uses `tsx dashboard/server/index.ts`.
10
+ - Dashboard tests use native `node:test` through
11
+ `dashboard/scripts/run-tests.mjs`.
12
+ - Local TS imports use explicit `.ts` extensions.
13
+ - `dashboard/tsconfig.json` is strict, no-emit, and dashboard-scoped.
14
+ - Workerctl dashboard integration builds argv arrays directly and avoids shell
15
+ interpolation.
16
+ - PTY/tmux attach validates unsafe session names before spawning.
17
+ - Dashboard server tolerates optional audit/snapshot telemetry failures where
18
+ current behavior does.
19
+
20
+ ## Current Dashboard Test Coverage
21
+
22
+ `dashboard/server/workerctl.test.ts` currently covers:
23
+
24
+ - workerctl argv builders
25
+ - snapshot/audit/telemetry/task commands
26
+ - bind/create/pair/nudge/interrupt/finish/export args
27
+ - Dispatch correlation chains
28
+ - inbox delivery and consumption evidence
29
+ - blocked loop policy
30
+ - Dispatch heartbeat and health summaries
31
+ - terminal session name safety
32
+ - resize/control message parsing
33
+
34
+ The TS CLI migration must not remove this coverage or make dashboard tests pass
35
+ by stubbing out meaningful CLI behavior.
36
+
37
+ ## Shared Code Boundary
38
+
39
+ Future shared TS CLI code should be introduced in a separate distributable
40
+ boundary, such as `src/**`, and imported by dashboard code only where it remains
41
+ browser/server-safe. Do not import `dashboard/server/index.ts` from CLI code.
42
+ Avoid dragging Vite/React/browser dependencies into the CLI runtime.
43
+
44
+ ## T012 Runtime Boundary
45
+
46
+ T012 moves the dashboard's default workerctl path to the Node CLI command
47
+ `conveyor`. The dashboard may still accept an explicit `--workerctl-path` such
48
+ as `scripts/workerctl` for local compatibility, but default dashboard JSON
49
+ subprocesses should no longer depend on the Python wrapper.
50
+
51
+ The dashboard command builder must construct direct argv arrays for the same
52
+ CLI contracts users can run from `conveyor`: discovery, telemetry snapshots,
53
+ audit, replay, task listing/creation, bind, pair, cycle, session nudge,
54
+ session interrupt, finish, and export. Do not reintroduce dashboard-only
55
+ `--ts-runtime` allowlists; migrated dashboard command targets are owned by the
56
+ default TypeScript runtime.
57
+
58
+ ## Verification
59
+
60
+ Required checks after dashboard-facing changes:
61
+
62
+ ```bash
63
+ npm test -- --runInBand
64
+ npm run build
65
+ ```
66
+
67
+ For frontend/dashboard user-facing changes, add browser inspection or screenshot
68
+ evidence according to `docs/agent-evidence-playbook.md`.
69
+
70
+ ## Contract Drift Disproof Gate
71
+
72
+ The strongest dashboard-specific failure mode is a TS CLI refactor that leaves
73
+ unit tests green but breaks live dashboard command execution or PTY safety.
74
+ Disproof requires both argv/terminal tests and, for dashboard behavior changes,
75
+ an actual dashboard or browser-backed check that the page can still issue safe
76
+ commands through the expected executable.
@@ -0,0 +1,98 @@
1
+ # TypeScript Migration Package And Install Contract
2
+
3
+ The npm package name is `agent-conveyor`.
4
+
5
+ As of the pre-board and T001 checks:
6
+
7
+ - `npm whoami` returned `neonwatty`.
8
+ - `npm view agent-conveyor name version --json` returned npm E404.
9
+ - The pre-migration `package.json` was private dashboard tooling, not a
10
+ publishable CLI package.
11
+ - The pre-migration `pyproject.toml` was the authoritative package metadata for
12
+ the Python package.
13
+
14
+ The package name must be re-checked near final packaging and before any publish
15
+ handoff because registry state can change.
16
+
17
+ ## Historical Python Package Contract
18
+
19
+ Before the TypeScript packaging tranche, install docs used the Python package
20
+ path: `pipx install agent-conveyor`, followed by `conveyor install-skills` and
21
+ `conveyor doctor`. That path is retained here only as historical contract
22
+ context for migration review, not as the current primary install instruction.
23
+
24
+ The historical Python metadata exposed:
25
+
26
+ - package name `agent-conveyor`
27
+ - console script `conveyor`
28
+ - compatibility console script `workerctl`
29
+ - bundled `workerctl/assets/skills/**/*`
30
+
31
+ The historical wheel package smoke proved:
32
+
33
+ - wheel builds
34
+ - installed `conveyor --help` starts with `usage: conveyor`
35
+ - installed `workerctl --help` starts with `usage: workerctl`
36
+ - `install-skills --json` installs expected skills
37
+ - installed `codex-review/scripts/codex-review` is executable
38
+ - installed `manage-codex-workers` skill does not contain stale copyable legacy
39
+ command text
40
+
41
+ ## Current npm Package Contract
42
+
43
+ The TypeScript migration now produces an npm package that:
44
+
45
+ - is named `agent-conveyor`
46
+ - is not `private`
47
+ - declares supported Node engines
48
+ - exposes `bin.conveyor`
49
+ - exposes `bin.workerctl`
50
+ - includes built CLI code
51
+ - includes required dashboard assets if dashboard remains part of the package
52
+ - includes top-level `skills/**` bundled skill assets
53
+ - preserves executable mode for the installed `codex-review` helper
54
+ - excludes `scripts/workerctl`, `workerctl/**/*.py`, and
55
+ `dist/cli/python-bridge.*`
56
+ - avoids automatic npm publish from local scripts or CI unless explicitly
57
+ approved by the operator
58
+
59
+ ## Runtime Cutover Boundary
60
+
61
+ The npm package exposes the Node `conveyor` and `workerctl` bins without the
62
+ Python bridge or packaged Python runtime. The source tree can still retain the
63
+ historical Python implementation and compatibility tests, but normal npm
64
+ package operation must be TypeScript-owned.
65
+
66
+ ## Tarball Smoke Contract
67
+
68
+ Before any public publish, the board must prove a local tarball install:
69
+
70
+ ```bash
71
+ npm pack --json
72
+ tmp_prefix="$(mktemp -d)"
73
+ npm install -g --prefix "$tmp_prefix" ./agent-conveyor-*.tgz
74
+ PATH="$tmp_prefix/bin:$PATH" conveyor --help
75
+ PATH="$tmp_prefix/bin:$PATH" workerctl --help
76
+ CODEX_HOME="$(mktemp -d)" PATH="$tmp_prefix/bin:$PATH" conveyor install-skills --json
77
+ ```
78
+
79
+ The smoke must inspect:
80
+
81
+ - both commands resolve from `PATH`
82
+ - both help first lines are correct
83
+ - installed skill files exist
84
+ - `codex-review/scripts/codex-review` is executable
85
+ - no Python runtime, Python bridge, or `scripts/workerctl` files are packed
86
+ - npm tarball contents include only intended package files
87
+
88
+ ## Docs And CI Contract
89
+
90
+ Docs and CI must use npm as the primary path. Stale Python package publish or
91
+ install commands may remain only as historical migration notes or temporary
92
+ compatibility instructions with explicit labels.
93
+
94
+ ## Publish Constraint
95
+
96
+ Preparing package metadata, tarball, install smoke, CI, and docs is approved.
97
+ Publishing `agent-conveyor` to npm is not approved for autonomous overnight work
98
+ and must remain a blocked/operator-approved final action.
@@ -0,0 +1,103 @@
1
+ # TypeScript Migration QA Gate Matrix
2
+
3
+ The migration must preserve the existing evidence ladder from
4
+ `docs/agent-evidence-playbook.md`: name the strongest realistic failure mode,
5
+ run or inspect evidence that would expose it, and record residual risk.
6
+
7
+ ## Deterministic Local Gates
8
+
9
+ Current baseline before the migration board:
10
+
11
+ | Gate | Command | Current baseline |
12
+ | --- | --- | --- |
13
+ | Python unit tests | `python3 -m unittest discover -s tests -v` | pass, 645 tests |
14
+ | ResourceWarning gate | `scripts/check-resource-warnings` | pass, 645 tests |
15
+ | Python compile gate | `python3 -m py_compile scripts/workerctl scripts/check-resource-warnings workerctl/*.py` | pass |
16
+ | Node/dashboard tests | `npm test -- --runInBand` | pass, 161 tests |
17
+ | Dashboard build | `npm run build` | pass |
18
+ | TypeScript migration audit | `npm run migration:audit:final` | pass after package cutover; npm tarball has no Python runtime/bridge files |
19
+ | Shell syntax | `bash -n scripts/live-smoke scripts/live-smoke-repeat scripts/package-smoke scripts/release-check scripts/rc-check` | pass |
20
+
21
+ While Python remains in the repository, the Python gates remain required. A
22
+ TypeScript replacement may retire them only after equivalent TypeScript gates
23
+ and package smoke prove the migrated command surface no longer imports or
24
+ executes Python for the migrated paths.
25
+
26
+ ## Release-Candidate Gate
27
+
28
+ `scripts/rc-check --skip-live-smoke-repeat` currently runs:
29
+
30
+ - Python unittest.
31
+ - ResourceWarning gate.
32
+ - Python compile gate.
33
+ - TypeScript migration audit.
34
+ - Dashboard tests.
35
+ - Dashboard build.
36
+ - Smoke script syntax checks.
37
+
38
+ The TypeScript migration must keep an equivalent deterministic RC gate. Broad
39
+ CLI, Dispatch, dashboard, or packaging changes should use the RC gate before
40
+ PR/merge claims.
41
+
42
+ ## Package And Release Gates
43
+
44
+ Current gates are Python wheel/sdist based:
45
+
46
+ - `scripts/package-smoke`
47
+ - `scripts/release-check`
48
+ - `.github/workflows/publish.yml`
49
+ - `docs/package-release.md`
50
+
51
+ The migration must replace these with npm tarball semantics while preserving:
52
+
53
+ - `conveyor --help`
54
+ - `workerctl --help`
55
+ - `install-skills --json`
56
+ - bundled `manage-codex-workers` and `codex-review` assets
57
+ - executable `codex-review/scripts/codex-review`
58
+ - stale command text guard for installed skills
59
+ - TypeScript migration audit receipt; Board 13/14 must use
60
+ `npm run migration:audit:final` after Python runtime removal.
61
+
62
+ ## Live And Manual QA Gates
63
+
64
+ Live gates depend on local `tmux`, `codex`, and environment state:
65
+
66
+ - `scripts/live-smoke`
67
+ - `scripts/live-smoke-repeat 3`
68
+ - `scripts/workerctl sessions --state active`
69
+ - `scripts/workerctl reconcile --stale-cycles-seconds 1`
70
+
71
+ Manual and receipt-driven gates include:
72
+
73
+ - `docs/manual-qa-checklist.md`
74
+ - `docs/qa/README.md`
75
+ - `docs/qa/evidence-template.md`
76
+ - `conveyor qa-run ralph-loop-guardrails`
77
+ - `conveyor qa-run generic-loop-template`
78
+ - `conveyor qa-run generic-loop-template-browser`
79
+ - `conveyor qa-run test-coverage-loop`
80
+ - `conveyor qa-run adversarial-triggers`
81
+ - `conveyor qa-run build-clear-loop`
82
+
83
+ If live Codex/tmux is unavailable, record that as a specific blocker for the
84
+ live gate and continue deterministic local work.
85
+
86
+ ## CI Gates
87
+
88
+ Current CI:
89
+
90
+ - `.github/workflows/test.yml` uses macOS, Node 24, `npm ci`,
91
+ `scripts/rc-check --skip-live-smoke-repeat`, and `scripts/package-smoke`.
92
+ - `.github/workflows/live-smoke.yml` runs `scripts/live-smoke` only when Codex
93
+ CLI is available.
94
+ - `.github/workflows/publish.yml` verifies the npm package artifact on manual
95
+ dispatch and must not become an automatic npm publish path during autonomous
96
+ overnight work.
97
+
98
+ ## Strongest QA Failure Mode
99
+
100
+ The migration can appear done while the test suite only proves the dashboard or
101
+ new TS happy path. Completion is blocked until the QA matrix proves CLI,
102
+ database, tmux/Codex ingest, Dispatch, skill install, packaging, dashboard, and
103
+ docs/release contracts are either preserved or explicitly adjudicated.
@@ -0,0 +1,92 @@
1
+ # TypeScript Migration SQLite And State Contract
2
+
3
+ This contract freezes the current Python state model and SQLite compatibility
4
+ surface before TypeScript migration.
5
+
6
+ ## State Root
7
+
8
+ - Default state root is `.codex-workers` under the invocation cwd.
9
+ - `WORKERCTL_STATE_ROOT` overrides the default root.
10
+ - Current Python code captures invocation cwd at import time; any TypeScript
11
+ replacement must preserve the observable default cwd behavior or record a
12
+ Judge-approved intentional diff.
13
+
14
+ ## Compatibility Files
15
+
16
+ The SQLite database is the richer source of truth, but legacy compatibility
17
+ files remain part of the contract:
18
+
19
+ - `config.json`
20
+ - `status.json`
21
+ - `events.jsonl`
22
+ - `transcript.txt`
23
+ - `capture-meta.json`
24
+
25
+ The status read path must preserve the current fallback behavior: prefer SQLite
26
+ status rows when available, but tolerate JSON-only legacy status fixtures.
27
+
28
+ ## SQLite Contract
29
+
30
+ Current schema version: `22`.
31
+
32
+ The TypeScript implementation must preserve:
33
+
34
+ - `PRAGMA foreign_keys = ON`
35
+ - WAL journal mode behavior
36
+ - busy timeout behavior
37
+ - refusal to open a database with a future unsupported schema version
38
+ - migration self-healing behavior covered by the Python test suite
39
+ - required tables, indexes, triggers, check constraints, and foreign keys
40
+
41
+ Required table groups include:
42
+
43
+ - sessions and workers/managers
44
+ - tasks and bindings
45
+ - statuses and terminal/transcript captures
46
+ - prompts, acknowledgements, handoffs, continuations, and configs
47
+ - manager cycles and phase spans
48
+ - runs, telemetry events, and telemetry FTS
49
+ - durable commands, attempts, routed notifications, and command budgets
50
+ - acceptance criteria
51
+ - Codex events and ingest offsets
52
+ - audit/export/replay support tables
53
+
54
+ ## Parity Evidence Required
55
+
56
+ Before TypeScript owns database creation or migration, create a Python-empty DB
57
+ and a TypeScript-empty DB in temp state roots and compare:
58
+
59
+ - `PRAGMA user_version`
60
+ - `.schema`
61
+ - table names
62
+ - index names
63
+ - trigger names
64
+ - critical PRAGMAs
65
+
66
+ Unreviewed diffs block the migration. A schema v23 bump is allowed only as a
67
+ separate Judge-approved migration task with backwards-compatibility tests.
68
+
69
+ ## Fixture Requirements
70
+
71
+ The TypeScript port needs deterministic fixtures for:
72
+
73
+ - JSON-only status fallback.
74
+ - Existing SQLite status preferred over stale JSON status.
75
+ - Future schema version rejection.
76
+ - v4/v5/v6/v21-style migration cases currently covered in Python tests.
77
+ - `WORKERCTL_STATE_ROOT` isolation.
78
+ - Append-only events behavior.
79
+ - Acceptance criteria uniqueness and status/source constraints.
80
+
81
+ ## Contract Drift Disproof Gate
82
+
83
+ Useful commands:
84
+
85
+ ```bash
86
+ WORKERCTL_STATE_ROOT="$(mktemp -d)" scripts/workerctl db-doctor --json
87
+ python3 -m unittest tests.test_workerctl.DatabaseTests tests.test_workerctl.SessionsSchemaTests tests.test_workerctl.CodexEventsSchemaTests -v
88
+ python3 -m py_compile workerctl/*.py
89
+ ```
90
+
91
+ Completion is blocked if the TypeScript-created schema differs from the
92
+ Python-created schema without a recorded Judge decision.
@@ -0,0 +1,47 @@
1
+ # T005 Runtime Parity Audit
2
+
3
+ T005 ports the tmux, Codex rollout discovery, JSONL ingest, and classifier
4
+ runtime layer into TypeScript without switching the public CLI command handlers
5
+ away from the compatibility bridge yet.
6
+
7
+ ## Ported TypeScript Surfaces
8
+
9
+ | Python source | TypeScript source | Proof |
10
+ | --- | --- | --- |
11
+ | `workerctl/tmux.py` command builders, permission text, paste-buffer cleanup, session pane targeting | `src/runtime/tmux.ts` | `src/runtime/runtime.test.ts` covers argument order, liveness checks, permission normalization, cleanup on failure, pane targets, and side-effect audit flags. |
12
+ | `workerctl/codex_session.py` session metadata, native pid selection, lsof rollout lookup, discovery result shape | `src/runtime/codex-session.ts` | `src/runtime/runtime.test.ts` covers metadata parsing, lsof path extraction, pid-to-native-child selection, and end-to-end discovery with fixtures. |
13
+ | `workerctl/ingest.py` JSONL parser and one-session ingest cycle | `src/runtime/ingest.ts` | `src/runtime/runtime.test.ts` covers offsets, malformed complete lines, partial trailing lines, event persistence, heartbeat/offset update, telemetry, idempotent re-ingest, appended partial completion, and shrink refusal. |
14
+ | `workerctl/classify.py` startup and busy-wait classifier | `src/runtime/classify.ts` | `src/runtime/runtime.test.ts` covers Python classifier scenarios: trust, ready, working, empty, error, MCP startup, rate limit, Enter confirmation, trust prompt, plan prompt, active approval, historical approval negative control, fresh status suppression, and recent-event long-running suppression. |
15
+
16
+ ## Bridge Decision
17
+
18
+ Public `conveyor` and `workerctl` command handlers still intentionally route
19
+ through `src/cli/python-bridge.ts` for T005. That preserves the frozen CLI
20
+ contract while the runtime modules move to TypeScript in testable pieces.
21
+
22
+ The remaining command-handler migration belongs to T006/T007:
23
+
24
+ - T006 owns lifecycle, Dispatch, inbox, audit/replay/export, and
25
+ dashboard-facing CLI behavior.
26
+ - T007 owns npm package/install/release/CI/docs conversion and final tarball
27
+ behavior.
28
+
29
+ This means T005 is complete when the TypeScript runtime helpers pass local
30
+ gates and the Python compatibility suite still passes. It does not claim that
31
+ the public CLI no longer executes Python.
32
+
33
+ ## Strongest Failure Mode
34
+
35
+ The strongest realistic T005 failure mode is a false sense of migration
36
+ progress: helper functions pass in TypeScript, but a live/public command path
37
+ silently changes tmux target selection, rollout offsets, classifier decisions,
38
+ or CLI error behavior.
39
+
40
+ Disproof evidence:
41
+
42
+ - Node runtime tests exercise the TypeScript behavior directly.
43
+ - The full Python compatibility suite still passes under an isolated state
44
+ root, proving the bridge-backed public CLI behavior was not regressed.
45
+ - `npm run build` proves the TypeScript helper API compiles into the package.
46
+ - The GoalBuddy board keeps T006/T007 queued for public command-handler and
47
+ package-routing migration before final completion.