You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit be34a95
Browse filesBrowse the repository at this point in the historyBrowse files
test(chain): wait on states with short timings and 100 ms polling
The chain starts its hub with every Triage wait short and polls every
100 ms. No scenario sleeps for a fixed time or asserts a duration: woken
waits for its manager to poll again, unset reads the hub's answer to the
delivery, unrouted keeps the reconcile pass out of reach instead of
timing the retry, and local-sidecars asserts each cause in its own test.
A lint rule under tests/chain fails on a literal real sleep of a second
or more, and AGENTS.md says a failed chain shard is read, never rerun.
Copy file name to clipboardExpand all lines: AGENTS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,7 @@ Check these for a stock route or primitive before touching the hub, sidecars or
57
57
- Tests beside the code are fast and offline; anything that runs real services lives in `e2e/`.
58
58
- The one exception is `tests/chain/`: it starts the real hub and local sidecars but reaches no outside service (a fake GitHub and a stub decision model), and CI runs it as its own job, `bun run test:chain`.
59
59
- Never read `process.env` in tests.
60
+
- A failed chain shard is read, never rerun.
60
61
- A change to how a workflow judges or reviews states its package's eval result before and after.
Copy file name to clipboardExpand all lines: docs/DEV.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,8 @@ Hub tests connect to `postgres://postgres:postgres@localhost:5432/interchange` a
89
89
90
90
`bun run test:chain` (`tests/chain/`) runs its files two at a time, one scenario each, each isolated from the others. Each file starts a hub on a database of its own, serving a portal build, sets up a workspace through the portal's routes, waits for the hub to start its listener, and sends GitHub's webhooks to it. GitHub and the decision model are local stand-ins, so it needs no account or key; each hub's sidecars are local processes, and it installs the workflows' native modules from the npm registry as a deploy does. Code review needs an isolated sidecar, which a local process is not, so it is not part of the chain test.
91
91
92
+
The chain starts its hub with every Triage wait short (`TIMINGS` in `tests/chain/stack.ts`, set through the `TRIAGE_*_MS` variables in [SELF_HOST.md](SELF_HOST.md#triage-tuning)); the hub publishes the listener's and manager's share in their release, since a workflow's process gets none of the hub's environment. A scenario polls every 100 ms for the state it names and never sleeps for a fixed time, which `bun run lint` enforces under `tests/chain/`. The one real wait left is stock's one-minute ping timeout in the scenarios that freeze a listener's sidecar. A failed chain shard is read, never rerun.
93
+
92
94
In CI the chain runs in five shards, each with its own list of files in `.github/workflows/ci.yml`; a new chain file must be added to one. A pull request that changes none of `apps/hub`, `apps/sidecar`, `apps/web/scripts`, `apps/web/src/lib`, `tooling/`, `packages/`, `tests/chain/`, `vendor/`, the lockfile, the root `package.json` or the CI workflow and setup actions skips the chain, so a change limited to the portal's pages and components, docs, e2e or research does not run it; every push to `main` runs it.
93
95
94
96
Scripts are listed in [IMPLEMENTATION.md](IMPLEMENTATION.md#scripts).
thrownewError(`Timed out waiting for ${what}.\nRuns:\n${awaitrunEvents()}\nGitHub misses: ${github.misses.join(", ")}\nHub:\n${hub.logs.slice(-80).join("\n")}`);
test("the listener and two live managers each run in a sidecar of their own, and a released manager's sidecar is gone",async()=>{
99
+
constmanaged=once(asyncfunctionmanaged(){
99
100
constreleaseFirst=github.hold(FIRST,1);
100
101
constreleaseSecond=github.hold(SECOND,1);
101
102
awaitpushed(FIRST,sha("first-1"));
@@ -108,12 +109,8 @@ test("the listener and two live managers each run in a sidecar of their own, and
108
109
constclaim=awaitclaimOf(SECOND);
109
110
returnclaim?.status==="live" ? claim : undefined;
110
111
});
111
-
expect(first.runId).not.toBe(second.runId);
112
-
113
112
constlive=awaitrows(`select a.id, a.sidecar_id, r.status, coalesce(s.frozen_approval_bundle -> 'projection' ->> 'id', d.name) as workflow from sidecar_allocation a join workflow_run r on r.id = a.anchor_run_id join workflow_definition d on d.id = r.definition_id left join workflow_run_launch_spec s on s.anchor_run_id = r.id where a.status = 'allocated'`);
constlistener=awaitrows(`select a.status, r.status as run from sidecar_allocation a join workflow_run r on r.id = a.anchor_run_id where a.id = '${listenerId}'`);
constlistener=awaitrows(`select a.status, r.status as run from sidecar_allocation a join workflow_run r on r.id = a.anchor_run_id where a.id = '${String(listenerRow["id"])}'`);
0 commit comments