Skip to content

feat(queen): bees record a tri cast, read a tool index, name missing tools - #531

Merged
gHashTag merged 1 commit into
feat/queen-supervisorfrom
feat/bee-cast
Oct 3, 2026
Merged

gHashTag merged 1 commit into
feat/queen-supervisorfrom
feat/bee-cast

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 3, 2026

Copy link
Copy Markdown
Owner

What this changes

Each bee job now ends with a check that can be rerun. Bees also see the tools that already exist.

1. Each job ends with a tri cast recording

  • Recorder. queen-cast.ts is a Bun recorder that writes the tri cast format: asciicast v2, plus an x event that carries each command's exit code and the commands/redacted header fields. It follows termgif.py closely enough that tri cast check accepts its files. The bee runs it as the last step of the job:
    bun agent-server/apps/server/src/api/services/queen-cast.ts record /workspace/casts/queen-N.cast -- "bun test tests/api/x.test.ts" "git diff --stat"
    
    How it differs from termgif.py:
    • It uses pipes, not a pty, with stderr merged into stdout. Colour depends on whether each tool turns colour on without a tty.
    • Typing is shown in stages: the command appears, then its output follows.
    • The home path is replaced with ~ in the output and in the header.
    • Each command has a timeout. A command that times out is recorded with exit code 124.
  • Where the file goes. The recording is written to the Railway volume at /workspace/casts/queen-N.cast, outside every worktree, so it can never be committed.
  • Brief and system prompt. The brief has a new ## Recording your work section, and the VERDICT template has a cast: <path> line. The worker system prompt repeats the rule.
  • Verdict parser.
    • parseVerdictCast reads the cast: line.
    • The line is not counted as a criterion and does not end the block.
    • A criterion that is literally named cast (- cast: met) is still a criterion.

2. The review warns but never fails on the recording

The review reads the file and checks it the way tri cast check does:

  • every exit code is present and is 0;
  • no home path appears;
  • no secret appears, matched by shape or by the value of a secret environment variable;
  • the recording is not older than this attempt.

The result is one sentence near the top of the review note, plus a cast field (ok/missing/fail) in the log. It never changes the decision.

This is deliberate. A missing or failing recording would otherwise send back work that meets every criterion. Here is how the rule could tighten later:

  1. Watch how often bees produce a clean recording.
  2. Then make it a criterion.

3. From the Mac to the blog

To publish a bee's recording by hand:

tri cast check queen-N.cast && tri cast publish queen-N.cast queen-N --title "..." --desc "..."

There is also an opt-in automatic chain, because harvest (land.mjs) runs on the Mac:

  • With TRI_CAST_SHIP=1 (off by default), land.mjs calls cast-ship.mjs for each issue it lands.
  • cast-ship.mjs fetches the recording through the existing container channel. The bytes travel as hex, because channel.clean() drops lines containing "Existing" or "Migrate".
  • It runs tri cast check on the recording. Only if the check is clean does it run tri cast ship <cast> queen-N --title ... --desc ....
  • It never passes --confirm and never passes --repo. That makes it a dry run: it renders local files and drafts, and sends nothing. Publishing is still the owner's tap.
  • The result goes to the landing log and to the casts field of the land record.

4. Bees get a tool index and a missing-tool: line

  • The index.
    • queen-tool-index.json is generated from the tool catalog of gHashTag/trinity, not written by hand. The catalog is the cards under apps/website/public/t27/files/specs/tools/, read through the site's own readToolCatalog(). That joins spec-tools.json with the spec-tools-trios.json part file and checks the hash and count.
    • It has one line per command (name - purpose, merging aliases that share a purpose) and covers trios tri, trinity tri, t27 tri and MCP: 360 lines.
    • It records the source commit and content sha256. Regenerate it with:
      bun agent-server/apps/server/src/api/services/queen-tools.ts generate --site <trinity>/apps/website
      
      This does nothing when the commit and hash are unchanged.
    • The generator refuses to write output that looks like a token.
    • Source: trinity PR feat: restore per-window side panel conversation on reopen browseros-ai/BrowserOS#1282 head a1b44cbc3025. Regenerate it once that PR merges.
  • In the brief. Bees read the committed file at spawn, so there are no network calls. The index sits in a ## Tools you already have section just before ## Finishing, and costs about 7k tokens per brief.
  • The rule. Look a job up in the index before writing a script or doing a multi-step job by hand. If no tool exists and the job will come up again, add missing-tool: <what> to the verdict block. The worker system prompt repeats the rule. parseVerdictMissingTools reads these lines, which are not criteria and do not end the block.
  • The efficiency signal.
    • The review counts the bee's tool calls from its transcript tool rows and notes which indexed commands it ran.
    • This goes into the review note as one sentence, and into the round log as tools and missingTools.
    • The Queen's report lists the missing tools.
    • The Queen does not open issues on its own: that would be a new network call, and the owner decides.
  • Who sees the index. The Queen is code, not a model, so the index goes into the bees' context and the Queen uses it to count. The adversarial reviewer judges criteria and does not get the index.

Tests

Only targeted files were run; the full suite is left to CI.

  • New: tests/api/queen-cast.test.ts (19) and tests/api/queen-tools.test.ts (13). All pass.
  • These existing suites pass:
    • verdict-block, queen-verdict-template, queen-verdict-position
    • queen-review-unjudged, queen-criteria, queen-criteria-run
    • queen-round, queen-witness, queen-adversarial-review
    • queen-brief-shape, queen-salvage, queen-tick-sweep
    • sql-template-literals, queen-public-status
  • queen-salvage-guards fails one test at the 5s default timeout: a git-heavy rename test. It passes with --timeout 60000 and does not touch this change.
  • selftest.mjs: the 4 new cast-ship cases pass when run on their own. The full selftest timed out locally.
  • Not run locally: tsc. Left to CI.

🤖 Generated with Claude Code

…tools

Every bee job now ends with a terminal recording in the tri cast format
(asciicast v2 with exit-code events), written by queen-cast.ts to
/workspace/casts/queen-N.cast and named on a `cast:` line of the VERDICT.
The review checks it the way `tri cast check` does and says what it found
in the note; it warns and never sends work back on it.

Bees also get a generated index of the commands that already exist (one
line per command, from the gHashTag/trinity tool catalog, cached with its
commit), a rule to use it before writing a script, and a `missing-tool:`
verdict line for a repeated job with no tool. The review counts tool calls
per job, the indexed commands used and the missing tools, and logs and
reports them.

On the Mac, land.mjs can hand a landed bee's recording to `tri cast ship`
as a dry run (cast-ship.mjs), opt-in with TRI_CAST_SHIP=1, never --confirm.

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

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

⚠️ No test results were produced

View workflow run

@gHashTag
gHashTag merged commit 2da4043 into feat/queen-supervisor Oct 3, 2026
3 of 18 checks passed
@github-actions
github-actions Bot deleted the feat/bee-cast branch October 4, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant