Skip to content

S09: the Queen's task lifecycle, measured from the supervisor that runs (Closes #4828) - #5360

Merged
dmitrii-f-t27 merged 1 commit into
masterfrom
spec/trinity-s09-queen
Oct 1, 2026
Merged

dmitrii-f-t27 merged 1 commit into
masterfrom
spec/trinity-s09-queen

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Collaborator

Closes #4828 (S09 of gHashTag/trinity#988, re-filed from #3571)

The decision

The family of repositories describes at least five "Queen cycles":

  • the six phases in trinity AGENTS.md;
  • the six phases in specs/queen/lotus.t27;
  • the five stages of lotus_cycle.zig;
  • AEL v2.0;
  • the PHI LOOP.

Only one cycle moves work: the round of the trios supervisor (gHashTag/BrowserOS trios/agent-server, feat/queen-supervisor at c25e1b02). It is the only one that chooses, leases, reviews and releases. specs/queen/dispatch.t27 (QueenDispatch, "queen-dispatch") makes that lifecycle the canonical state machine and names the other cycles as adapters, each with a phase map:

  • lotus-policy: a resource-policy loop that holds no task;
  • agents-md-phases: implemented nowhere;
  • ael-v2: an agent session's loop;
  • phi-loop: the workflow for making a change.

Evidence: the supervisor's own code, run

tools/trinity_queen_dispatch.py keeps five kinds of evidence apart:

  • ts: its TypeScript under bun. stateOfDispatch over 2112 inputs, composeCards (public board columns), createRoundGate under concurrent requests.
  • queend: its Swift policy binary, built at the pin. choose over all 120 orders of five candidates, capacity at 0..5 running, review over a grid, retry over every sequence of failure kinds.
  • pg: PostgreSQL 16 with its own runPgMigrations and ensureQueenColumns:
    • the singleton lease under 32 contenders × 20 rounds, plus expiry, renewal, release and fencing;
    • recordDispatch, finishDispatch and both reapers on real rows;
    • releaseStaleContracts;
    • takeBackRefusedAcceptances with injected CI answers;
    • the round's and the board's own SELECT, extracted from the pinned source.
  • lotus: the Zig cycle of gHashTag/trinity at afc9d384, 29/29 tests in Debug and ReleaseFast.
  • live: one snapshot of the public /queen/status and /queen/public-board.

run replays the spec through the generated C on 2488 cases drawn from these records. --self-check plants 16 faults and catches each one, including a priority sort that returns its input.

Measured (each tagged with its evidence in the spec)

  • No priority and no dependencies. The first eligible issue in GitHub's listing order wins, in every one of the 120 orders.
  • Retry-ceiling defect. The one-release bound of a spent retry ceiling never applies, because the round and the board don't select ceiling_releases. A stored 1 reads as 0, the row is "failed" instead of "rejected", and the issue is handed back every hour. Shown with the supervisor's own SQL.
  • Board "done" is not acceptance. The public board draws a closed issue as done whatever its verdict: escalate, send-back, wait or none.
  • What accept requires. Accept needs criteria, a commit and a reviewer, but no PR, CI or merge. Without an open PR, a red check can't take it back.
  • One Queen at a time holds. One owner per term and a strictly rising fence. But only recordTick is fenced, and the dispatch writer replaced a row still awaiting review.
  • No heartbeat, no cancel. A bee is reaped only by age (121 minutes yes, 119 no) or at boot, and nothing cancels one.
  • Idempotency. Duplicate and late endings, a second criteria release and a second CI take-back are all no-ops. There are no event IDs.
  • Agents are not workers. The 27 named agents are documentation; no code maps an issue to a letter.

Fixed in place

  • specs/queen/task_analysis.t27 sorted by returning its input, counted 27 workers because there are 27 letters, and did not compile in C. It now orders by its own score with tests on deliberately unsorted input (7/7 in C and Zig) and states that no runtime applies it.
  • specs/queen/lotus.t27 now carries its status as the lotus-policy design.
  • Cards queen.lib and agent.phi-loop, the specs/OWNERS.md (queen/) row, the README S09 section, and docs/now are updated.
  • The card seals left stale by my own S07 and S08 PRs (agent.tri-api, state.trinity-dir) are refreshed here.

Not measured

GitHub itself, a real provider or bee, the Mac app's own loop, and the revision Railway actually deploys. The live snapshot (2026-10-01 02:44Z: working, 7 of 20 workers, 930 public cards) says what was served at that minute and nothing more.

Checks run locally

All pass: trinity_queen_dispatch.py check and --self-check, S07/S08 check, parse ratchet, now-shape, documented commands, damage negatives, validate-conformance (all valid), seal verify for every touched spec, and no new dupe_scan or assertionless findings.

🤖 Generated with Claude Code

specs/queen/dispatch.t27 states the canonical task state machine of the
trios supervisor round and names lotus-policy, the AGENTS.md phases, AEL
v2.0 and the PHI LOOP as adapters, held to the supervisor's TypeScript, its
queend binary, a PostgreSQL run of its writers, the Zig lotus cycle and a
live snapshot. task_analysis.t27 now compiles and really orders.

Closes #4828

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-01 02:58:29 UTC

Summary

Status Count
Total Open PRs 45
PRs with Failing Checks 42
PRs with All Checks Green 3
READY 3
FAILING 42
PENDING 0
NO CHECKS YET 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=403499176a5d != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@dmitrii-f-t27
dmitrii-f-t27 merged commit 20fe650 into master Oct 1, 2026
26 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[spec][Trinity S09] Reconcile Queen phases and specify task leases, retries and evidence

1 participant