Skip to content

test(server): pin the queen export route and bundle helper - createQueenExportRoute (Closes #1676) - #1934

Merged
dmitrii-f-t27 merged 1 commit into
queenfrom
zcode/tests-1676-queen-export
Oct 13, 2026
Merged

dmitrii-f-t27 merged 1 commit into
queenfrom
zcode/tests-1676-queen-export

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Collaborator

Closes #1676

What changed

One new file: trios/agent-server/apps/server/tests/api/queen-export.test.ts (the path the issue's Success Criteria names). The subject queen-export.ts is untouched.

The single exported route factory and the exported bundleOfBranch helper are exercised (7 it( blocks) against a real throwaway git repository steered through the WORKSPACE_DIR / TRIOS_REPO_URL / TRIOS_REPO_REF environment overrides (restored in an afterAll):

  • bundleOfBranch (3 tests): 404 for a branch this checkout does not hold (pinned error text); 409 for a branch level with the base; and the ok case - branch, base, the commit list (sha, author, date, subject), the file list, and bytes that are a REAL bundle proven by git bundle verify against the same checkout (the singular wording measured on this git).
  • The route (4 tests): GET / lists only the branches ahead of the base (the level branch and the foreign name excluded), sorted by issue; GET /:issue serves the branch as JSON with the commit list, file list and base64 bundle bytes (measured: the base64 decodes to a bundle whose header starts with # v); GET /abc answers 400 with the pinned message; GET /999 answers 404 (the stored-bundle fallback is inert without DATABASE_URL - measured).

The suite registers no mock.module at all and touches nothing outside its mkdtempSync tree, so it cannot affect sibling suites. No network, no database, no container.

How it was verified (FR-004)

  • Passing run against the unmodified subject: 7 pass / 0 fail / 30 expect() calls, Ran 7 tests across 1 file (~0.5 s).
  • Deliberately broken copy (the no-commits check widened to -1; the 404 error reworded; the listing sort reversed; the issue validation loosened to allow 0): 4 fail out of 7, quoted raw above. The subject was restored byte-identical (git checkout) and the suite passes again.
  • Three draft corrections came from measurement, not guessing: this git's bundle-verify wording (The bundle contains this ref:), the branch topology (a branch cut from another work branch counts both commits), and a subarray length. The file is biome ci-clean and contributes no typecheck error (local monorepo typecheck: base set, 0 mentions of the new file).

Not verified

  • Nothing beyond the quoted local runs; the CI Tests / server-api job re-runs the suite on this SHA.

Dmitrii Fedorov (@dmitrii-f-t27)

…eenExportRoute

The first suite for queen-export.ts: the route and the exported
bundleOfBranch helper exercised (7 tests) against a real throwaway
git repository steered through the WORKSPACE_DIR / TRIOS_REPO_URL /
TRIOS_REPO_REF overrides - real git, real bundles verified by
git bundle verify, no mock.module, no database (the stored-bundle
fallback is measured inert without DATABASE_URL), no network, no
container; the subject is untouched.

Closes #1676
@tri-claw

tri-claw Bot commented Oct 13, 2026

Copy link
Copy Markdown

Summary by t27-bees

This PR adds a test suite that pins the behavior of createQueenExportRoute and its bundleOfBranch helper by exercising them against a real throwaway git repository. The tests verify bundle creation, route listing, and error responses without mocks, databases, or network.

Worth a look

  • Global process.env mutation (lines 54–59, 61–67): The test overwrites WORKSPACE_DIR, TRIOS_REPO_URL, TRIOS_REPO_REF and deletes DATABASE_URL/RAILWAY_SSOT_URL at module level, restoring them only in afterAll. If the test crashes or is interrupted, these leak into other suites running in the same process.

  • Temp directory cleanup only in afterAll (lines 44, 61–67): mkdtempSync creates parent; rmSync(parent, …) runs only in afterAll. A test failure before afterAll leaves the temp tree on disk.

  • Git output string matching (line 118): The test asserts verified.includes('The bundle contains this ref:'), which the description notes was "measured on this git". Different git versions or locales may phrase this differently, causing false failures.

  • Shell interpolation in git helper (line 48): execSync(git -C "${repo}" ${args}) interpolates args directly into the shell command. While current calls use hardcoded strings, the pattern invites injection if reused with dynamic input.

  • Branch sorting assumption (line 146): The test expects body.branches.map(b => b.issue) to equal [45, 123], relying on the implementation sorting by issue number. If the sort order changes (e.g., by date), the test fails even though the contract ("sorted by issue") is unchanged.


Read: 1 files, +192 -0, the whole diff. Head dcf2cc1. Model: openai-compatible/nvidia/nemotron-3-ultra-550b-a55b. Commands: @t27-bees review | summary | help | pause | resume. Free for every repository.

@github-actions

Copy link
Copy Markdown

βœ… Tests passed β€” 3560/3630

Suite Passed Failed Skipped
βœ… agent 188/188 0 0
βœ… build 9/9 0 0
βœ… cdp-protocol 5/5 0 0
βœ… eval 93/93 0 0
βœ… server-agent 280/280 0 0
βœ… server-api 2159/2228 0 69
βœ… server-browser 6/6 0 0
βœ… server-integration 10/11 0 1
βœ… server-lib 279/279 0 0
βœ… server-pglive 166/166 0 0
βœ… server-root 68/68 0 0
βœ… server-sim 8/8 0 0
βœ… server-skills 31/31 0 0
βœ… server-tools 244/244 0 0
βœ… shared 14/14 0 0

View workflow run

@dmitrii-f-t27

Copy link
Copy Markdown
Collaborator Author

Checks note, before merge:

  • runner / Biome and runner / Typecheck are red on the base branch queen with pre-existing failures (reference base run https://github.com/gHashTag/trios/actions/runs/38087839871 on dfb6d97). On this PR's SHA: the Typecheck log has the 19 base error TS lines and 0 mentions of the new queen-export.test.ts; the Biome log has 0 diagnostics for the new file. All Tests / * suites including server-pglive are green on this SHA, and the suite registers no mock.module at all (a real throwaway git repository steered by environment overrides), so it cannot affect sibling suites.

Dmitrii Fedorov (@dmitrii-f-t27)

@dmitrii-f-t27
dmitrii-f-t27 merged commit f134f33 into queen Oct 13, 2026
17 of 19 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.

1 participant