Skip to content

feat(trios-macos): merge the Queen supervisor work, keeping the TODO inspector - #1087

Open
gHashTag wants to merge 4 commits into
mainfrom
feat/queen-supervisor-merge
Open

feat(trios-macos): merge the Queen supervisor work, keeping the TODO inspector#1087
gHashTag wants to merge 4 commits into
mainfrom
feat/queen-supervisor-merge

Conversation

@gHashTag

@gHashTag gHashTag commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Two trees had diverged since the switchover moved this app out of gHashTag/BrowserOS.
This merges them rather than letting either overwrite the other.

What came across

Work done in BrowserOS after the switchover and never ported back:

  • Delegation that actually runs. QueenWorkerRunner starts a bee on its own
    transport, so navigating between chats cannot cancel it. QueenBranchCommitter
    attributes its edits through a throwaway index and commit-tree — HEAD, the real
    index and the working tree are never touched.
  • Supervision surfaces. QueenDashboardView above 760pt,
    QueenCompactSupervisorBar in the 400pt panel, QueenTaskBanner in each worker chat.
  • QueenObserver reads a live transcript for looping, spinning, out-of-bounds
    writes and overspending. A pure function over the transcript, not a second agent:
    these patterns are mechanical, and a mechanical check cannot hallucinate the way the
    thing it watches can.
  • QueenSalience + SalienceLearner rank the review queue by learned intervention
    rate rather than age alone. The observation threshold is derived from the priors, not
    chosen.
  • Skills as a managed resource. SkillCatalog / SkillStore / SkillsTabView, and
    QueenSystemPrompt so the Queen can see what she can run — she previously could reach
    4 of 26 because the list was a Swift literal.
  • ReplayTransport with SSE cassettes, plus the model and keychain stack.

What was kept from this repository

This tree had productionised things the other had archived as prototypes. All preserved:

  • TodoPanelPolicy, TodoListProjection and their tests
  • QueenIntelligenceEngine, QueenMasterViewModel and the delegation chain
  • The TODO inspector in FullscreenChatWorkspace, threaded through ChatPanelView
  • Package.swift, xtask, MIGRATED.md

The three real conflicts

File Resolution
FullscreenChatWorkspace.swift Merged by hand — the TODO inspector and the swarm surfaces coexist
ChatPanelView.swift Taken from this repository, which had the richer version (queen activity feed, scroll tracking)
CLAUDE.md Kept as-is; its paths and CI are repository-specific

Everything else differed only because this repository snapshotted an earlier point in
time.

Not brought across

agent-server/ — the switchover replaced it with the Rust trios-server. The
orphaned-tool-call repair that lives there has no home here yet, so
AI_MissingToolResultsError after an aborted turn is still unhandled on this side.

Testing

  • ./build.sh --dev succeeds
  • tests/swift/run_chat_sse_e2e.sh passes, including the cassette-replay, observer and
    salience-learner assertions
  • The XCTest suite under tests/TriOSKitTests/ remains broken, as it was before

Caveats worth a reviewer's eye

  • build.sh came from the other tree and assumes ../Sources/CSQLCipher; this repo has
    no module map at that path. I staged one locally to verify the build — it is not in
    this diff, so build.sh will not work here until that is resolved or the SPM path is
    used instead.
  • ChatPanelView.swift was resolved by taking one side whole. If the BrowserOS side had
    session-recovery UI worth keeping, it is not in this commit.

🤖 Generated with Claude Code

Closes #1088

Dmitrii Vasilev and others added 2 commits July 29, 2026 23:26
…inspector

Two trees had diverged since the switchover moved this app out of BrowserOS.
This merges them rather than overwriting either.

From gHashTag/BrowserOS (never ported back):
- Queen supervisor: QueenWorkerRunner starts a delegated bee on its own
  transport; QueenBranchCommitter attributes its edits through a throwaway index
  and commit-tree, so HEAD and the working tree are never touched
- QueenObserver reads a live transcript for looping, spinning, out-of-bounds
  writes and overspending - a pure function, not a second agent
- QueenSalience + SalienceLearner rank the review queue by learned intervention
  rate rather than age alone, with a threshold derived from the priors
- Skills as a managed resource: SkillCatalog/SkillStore/SkillsTabView, and
  QueenSystemPrompt so the Queen can actually see what she can run
- ReplayTransport with SSE cassettes, and the model/keychain stack

Kept from this repository, which the other tree had archived as a prototype:
- TodoPanelPolicy, TodoListProjection and their tests
- QueenIntelligenceEngine, QueenMasterViewModel and the delegation chain
- The TODO inspector in FullscreenChatWorkspace, threaded through ChatPanelView
- Package.swift, xtask, MIGRATED.md

Three files genuinely conflicted. FullscreenChatWorkspace was merged by hand so
the TODO inspector and the swarm surfaces coexist. ChatPanelView was taken from
this repository, which had the richer version. CLAUDE.md was kept as-is because
its paths and CI are repository-specific.

agent-server/ was deliberately not brought across: the switchover replaced it
with the Rust trios-server. The orphaned-tool-call repair that lives there has
no home here yet.

Verified: build.sh --dev succeeds, and the headless chat SSE harness passes
including the cassette, observer and salience-learner assertions. The XCTest
suite remains broken, as it was before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Law L1 is enforced in CI here: a single .sh anywhere fails Constitutional
Enforcement. The merge brought eight of them across, all from the BrowserOS
tree, and none of them existed on main.

Four already have Rust ports in xtask - build, chat-sse-e2e, mesh-chat-e2e and
e2e-flow are one-to-one replacements written when the scripts were removed.
Bringing the originals back re-added exactly what this repository had
deliberately ported away. The other four came with them and had no business
here either.

The Makefile goes too: it was a wrapper around build.sh and means nothing
without it.

xtask picks up the new sources on its own - it compiles every git-tracked Swift
file plus a short allowlist, so the Queen surfaces added by this branch are
included the moment they are committed. No build change was needed.

The agent-safe-build skill described the Makefile as the interface, which was
true in the other repository and false here. Rewritten around xtask, keeping the
verification traps, which are about judgement rather than tooling and cost real
sessions to learn.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Dmitrii Vasilev and others added 2 commits July 30, 2026 01:34
The merge moved the app tree but not everything it depended on, and it brought
36 test files into a job that had been running 5.

**CSQLCipher.** MemoryStore encrypts the agent database with SQLCipher, whose
`sqlite3_key` the system sqlite3 does not have, so the C library has to be
declared rather than assumed. Its systemLibrary target lived at the browseros
repo *root* and did not travel with the app. Ported here, with `brew install
sqlcipher` on the runner. `HotkeyAnalytics.swift` was missing from the library
sources for the same reason - nothing referenced it until its test arrived.

**The suite hung rather than failed.** `ProjectPaths.buildVariant` reads the
bundle's Info.plist, and under `swift test` there is no bundle, so it reported
`prod`, took the Keychain path, and blocked in `SecItemCopyMatching` on a
password dialog no runner can answer. That is worse than a red build: the job
would have died on its 30-minute timeout having reported nothing at all. The
plist still wins where there is one, so no shipped app can be moved off its own
data directory by an environment variable; the environment is consulted only
when there is no bundle to ask. CI sets `TRIOS_VARIANT=dev` and the tests use
file-backed secrets.

**25 of the 36 tests are excluded, by name.** Fifteen do not compile and ten
fail. All of it predates this merge - CI never built these files in the tree
they came from, so nothing caught the drift for a long time. Fifteen are one
shape: the sources became actor-isolated and the tests still call them
synchronously. Repairing them is real work and does not belong inside a merge,
where it would bury the merge. Listed individually in Package.swift and
enumerated in #1089 so the gap is countable instead of silent.

`TriOSEncryptionTests.testTamperDetection` is on that list and its name is
alarming, so: tamper detection works. AES-GCM rejects the flipped byte and
`XCTAssertThrowsError` passes. The test then asserts the error's *type*, and
CryptoKit throws its own rather than TriOSEncryptionError.

`MockURLProtocol` lived inside `SSETransportTests.swift`, so excluding that file
took the helper with it and broke three suites that had nothing wrong with
them. It has its own file now.

Result: 16 files, 120 tests, green - against the 5 files this job ran before.

Refs #1089
Closes #1088

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`recordFetchSuccess` and `recordFamilyRevoked` hand the audit write to a
detached Task so the auth path is never blocked by disk IO. They return before
the entry exists. Both tests read the file on the next line.

Locally this passed, which is the interesting part: an earlier test had already
created the file, so there was always something to read. On CI's clean checkout
there was not, and the suite failed there and only there. The same staleness
meant `testRecordFamilyRevoked...` could have passed on a line written by a
different test entirely - it asserted `contains("family.revoked")` against
whatever happened to be in the file.

Both now poll for the marker with a 2s deadline instead of assuming the write
has landed, and the log is cleared in both setUp and tearDown rather than only
after. Clearing only afterwards makes the first run on a clean machine behave
differently from every run after it, which is how this stayed hidden.

Verified on a clean data directory and again immediately after, both green:
120 tests, 0 failures.

Refs #1089

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gHashTag

Copy link
Copy Markdown
Owner Author

All four required checks are green: no-js-check, Test, Constitutional Enforcement, guard. Compile and test (macos-15 runner) is green too.

Three things had to be fixed to get there, and two of them are worth a look
because they are not merge mechanics.

L1. The merge carried eight shell scripts across. This repository forbids
them and had already ported four to xtask, so bringing the originals back
re-added exactly what it had deliberately removed. Removed, along with the
Makefile that wrapped build.sh, and the agent-safe-build skill was
rewritten around xtask.

The Swift job could not compile. MemoryStore uses SQLCipher, whose
sqlite3_key the system sqlite3 does not have. Its systemLibrary target lived
at the browseros repo root and did not travel with the app tree. Ported, plus
brew install sqlcipher on the runner.

The suite did not fail - it hung. ProjectPaths.buildVariant reads the
bundle's Info.plist, and under swift test there is no bundle, so it reported
prod, took the Keychain path, and blocked in SecItemCopyMatching on a
password dialog no runner can answer. That is worse than red: the job would die
on its 30-minute timeout having reported nothing. The plist still wins where
there is one, so no shipped app can be moved off its own data directory by an
environment variable.

Two judgement calls to review

25 of the 36 incoming test files are excluded by name — 15 do not compile,
10 fail. All of it predates this merge; CI never built these files in the tree
they came from. Listed individually in Package.swift and enumerated in #1089.
The result is 16 files / 120 tests green, against the 5 files this job ran
before. If you would rather block the merge until they are repaired, say so and
I will do that instead.

TriOSEncryptionTests.testTamperDetection is on that list and its name is
alarming, so: tamper detection works. AES-GCM rejects the flipped byte and
XCTAssertThrowsError passes. The test then asserts the error's type, and
CryptoKit throws its own rather than TriOSEncryptionError.

Two files were resolved unilaterally and deserve a second opinion:
ChatPanelView.swift was taken wholly from this repository's side, and
CLAUDE.md was kept as theirs.

One real bug found on the way

The audit-log tests read the file on the line after the call that writes it, but
recordFetchSuccess hands the write to a detached Task and returns first. It
passed locally only because an earlier test had left a file behind — which also
meant testRecordFamilyRevoked... could pass on a line written by a different
test. Both now poll for their own marker and clear the log in setUp as well as
tearDown.

I cannot merge this myself: branch protection requires one approving review and
I am the author. Auto-merge is disabled for the repository, so it needs a manual
approve and merge.

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.

Merge the Queen supervisor work back from BrowserOS

1 participant