diff --git a/.github/scripts/pr-quality.test.cjs b/.github/scripts/pr-quality.test.cjs index fa0fc6414c4..55c948d65af 100644 --- a/.github/scripts/pr-quality.test.cjs +++ b/.github/scripts/pr-quality.test.cjs @@ -644,7 +644,7 @@ describe("assessPrDescription with the readiness section", () => { "", "## Test plan", "", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"); it("never counts the injected checklist as description substance", () => { @@ -670,7 +670,7 @@ describe("collectPrQualityFailures", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"); it("reports wrong_base without requiring ancestry inputs", () => { @@ -905,7 +905,7 @@ describe("collectPrQualityFailures", () => { "No gui changes in this PR; proxy routing only.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, @@ -925,7 +925,7 @@ describe("collectPrQualityFailures", () => { "This change adjusts gui/ spacing tokens used by the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, @@ -945,7 +945,7 @@ describe("collectPrQualityFailures", () => { "This change adjusts gui/ spacing tokens used by the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, @@ -968,7 +968,7 @@ describe("collectPrQualityFailures", () => { "This change adjusts gui/ spacing tokens used by the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, @@ -993,7 +993,7 @@ describe("collectPrQualityFailures", () => { "![after](https://example.com/after.png)", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, @@ -1017,7 +1017,7 @@ describe("collectPrQualityFailures", () => { "[shot]: https://example.com/after.png", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, @@ -1041,7 +1041,7 @@ describe("collectPrQualityFailures", () => { "```", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), behindMain: 0, behindBase: 0, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6b5dde70e5..d15e696000e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,7 +273,7 @@ jobs: # between jobs, so leaving a usable token in .git/config is avoidable # residue. Matches the convention already used by the other workflows. persist-credentials: false - # tests/release-version-line.test.ts compares package.json against the + # tests/ci-workflows/release-version-line.test.ts compares package.json against the # newest release tag. actions/checkout fetches no tags by default, so # without this the check reads an empty tag set and passes on anything - # the exact regression it exists to catch would ride through CI green. @@ -347,12 +347,12 @@ jobs: - name: Test storage policy API run: | bun test --isolate \ - ./tests/api-storage-policy-already-running.test.ts \ - ./tests/api-storage-policy-mutation-busy.test.ts \ - ./tests/api-storage-policy-put-race.test.ts \ - ./tests/api-storage-policy-run.test.ts \ - ./tests/api-storage-policy.test.ts \ - ./tests/api-storage.test.ts + ./tests/storage/api-storage-policy-already-running.test.ts \ + ./tests/storage/api-storage-policy-mutation-busy.test.ts \ + ./tests/storage/api-storage-policy-put-race.test.ts \ + ./tests/storage/api-storage-policy-run.test.ts \ + ./tests/storage/api-storage-policy.test.ts \ + ./tests/storage/api-storage.test.ts # Bun 1.3.14 has shown a Linux isolate wedge around startServer() plus the user # cost overlay reconciler. Keep api-usage in one fresh process so a runtime @@ -384,7 +384,7 @@ jobs: bun run build - name: Test api usage API - run: bun test --isolate ./tests/api-usage.test.ts + run: bun test --isolate ./tests/server/api-usage.test.ts # Everything that is not the suite: type safety, privacy, lint, build, smoke. # One runner, once per push. Splitting these across the shards would repeat a @@ -431,7 +431,7 @@ jobs: run: bun run privacy:scan # The ocx skill ships a capability -> route map generated from src/cli/capabilities.ts. - # `bun run test` already covers this via tests/skill-ocx.test.ts; this step exists so the + # `bun run test` already covers this via tests/ci-workflows/skill-ocx.test.ts; this step exists so the # failure names the fix instead of surfacing as a byte-comparison diff in a test log. - name: Check the generated ocx skill surface is current run: bun run skill:surface:check @@ -471,7 +471,7 @@ jobs: # between jobs, so leaving a usable token in .git/config is avoidable # residue. Matches the convention already used by the other workflows. persist-credentials: false - # tests/release-version-line.test.ts compares package.json against the + # tests/ci-workflows/release-version-line.test.ts compares package.json against the # newest release tag. actions/checkout fetches no tags by default, so # without this the check reads an empty tag set and passes on anything - # the exact regression it exists to catch would ride through CI green. @@ -564,7 +564,7 @@ jobs: # between jobs, so leaving a usable token in .git/config is avoidable # residue. Matches the convention already used by the other workflows. persist-credentials: false - # tests/release-version-line.test.ts compares package.json against the + # tests/ci-workflows/release-version-line.test.ts compares package.json against the # newest release tag. actions/checkout fetches no tags by default, so # without this the check reads an empty tag set and passes on anything - # the exact regression it exists to catch would ride through CI green. @@ -709,7 +709,7 @@ jobs: # residue. Matches the convention already used by the other workflows. persist-credentials: false # Same reason as the Linux shards and the macOS control: this leg runs the - # whole suite, and tests/release-version-line.test.ts reads release tags. + # whole suite, and tests/ci-workflows/release-version-line.test.ts reads release tags. # Without tags the check sees an empty set and cannot fail. fetch-tags: true diff --git a/.github/workflows/dev-version-bump.yml b/.github/workflows/dev-version-bump.yml index a29b29d067d..b730658e49f 100644 --- a/.github/workflows/dev-version-bump.yml +++ b/.github/workflows/dev-version-bump.yml @@ -2,7 +2,7 @@ name: Dev version bump # When a release publishes, open a pull request that moves `dev` past the published # version. Without this, `dev` keeps carrying a version that is at or behind a released -# one, and `tests/release-version-line.test.ts` fails on `dev` and on every pull request +# one, and `tests/ci-workflows/release-version-line.test.ts` fails on `dev` and on every pull request # opened against it - inherited red a contributor cannot fix from their own diff. # # That has been repaired by hand four times: 32529c2b2, e4a85d134, 076ad3036, befcac3e1. @@ -98,7 +98,7 @@ jobs: # of the tag set, so it is settled here by the detector that already owns the # question. If this fails, no pull request is opened and the job goes red asking # for a human decision - which is the correct outcome, not a fallback. - run: bun test tests/release-version-line.test.ts + run: bun test tests/ci-workflows/release-version-line.test.ts - name: Open the bump pull request if: ${{ steps.decide.outputs.changed == 'true' }} @@ -174,7 +174,7 @@ jobs: ## Summary \`${RELEASED_VERSION}\` published, so \`dev\` would otherwise keep a version at or - behind a released one and \`tests/release-version-line.test.ts\` would fail on + behind a released one and \`tests/ci-workflows/release-version-line.test.ts\` would fail on \`dev\` and on every pull request opened against it. This moves \`dev\` to \`${NEXT_VERSION}\`. @@ -184,7 +184,7 @@ jobs: ## Verification - \`bun test tests/release-version-line.test.ts\` ran against this exact tree + \`bun test tests/ci-workflows/release-version-line.test.ts\` ran against this exact tree before the pull request was opened; the workflow refuses to open one if the chosen version collides with a published release. diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index 39ef2523364..d8ac13ab366 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -4,7 +4,7 @@ # Gating and least-privilege: findings fail the job (`blocking: warning`). # Write-scoped outputs (sticky PR comments, inline review comments, commit # statuses) stay disabled so the workflow needs no write permissions. Do not -# re-add write scopes without revisiting tests/ci-workflows.test.ts, which +# re-add write scopes without revisiting tests/ci-workflows/ci-workflows.test.ts, which # pins this contract. # # Docs: https://www.react.doctor/docs/ci-and-prs/github-actions-setup diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0535742950..9aff178dd28 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: # still bumps it, which is the point. # # It is declared FIRST in this file, ahead of the jobs it depends on, because - # tests/ci-workflows.test.ts splits the workflow on `- name:` and reads each `run:` + # tests/ci-workflows/ci-workflows.test.ts splits the workflow on `- name:` and reads each `run:` # block to the start of the next one when it checks that dispatch inputs never # interpolate into shell source. A job declared between two steps lands inside that # window and reads as shell. Job order in YAML carries no execution meaning - `needs` diff --git a/.gitignore b/.gitignore index 19ab5348b85..ce10233dccd 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ devlog/**/security-advisory-draft* # Local agent/session artifacts # These are per-machine agent state (goalplans, ledgers, evidence scratch). # They are never part of the product and must not be committed, not even with -# `git add -f` — see tests/repo-hygiene.test.ts, which fails if any path here +# `git add -f` — see tests/ci-workflows/repo-hygiene.test.ts, which fails if any path here # becomes tracked again. .codexclaw/ **/.codexclaw/ @@ -57,11 +57,12 @@ devlog/**/security-advisory-draft* # blocks the release preflight's clean-tree check for work that has nothing to do # with it, so ignore both shapes. tests/.tmp-* +tests/**/.tmp-* .claude/ # Retired Go native-runtime experiment. `go/` is not part of the build, the # typecheck, or the test path, and nothing in `src/` imports it. A single file # from it (go/internal/cli/config_parity.go) has now been committed by a broad # `git add` three separate times and reached `dev` once — see -# tests/repo-hygiene.test.ts, which fails if any path here becomes tracked again. +# tests/ci-workflows/repo-hygiene.test.ts, which fails if any path here becomes tracked again. go/ diff --git a/AGENTS.md b/AGENTS.md index d011af129bb..beed354ba52 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,7 +17,7 @@ Bun-native TypeScript with no separate server compile step. `scripts/test-layout/layout.json`; a domain's files move together with `scripts/test-layout/move.ts` and `layout.migrated` records which domains have moved, so until a domain is listed there its files are still at the - root. `tests/test-layout.test.ts` enforces the map. Shared helpers in + root. `tests/ci-workflows/test-layout.test.ts` enforces the map. Shared helpers in `tests/helpers/`, fixtures in `tests/fixtures/`, broader scenarios in `tests/e2e-style/`. Source-oracle tests resolve the repository through `tests/helpers/repo-root.ts`, never `import.meta.dir + "/.."`. A new test @@ -103,7 +103,7 @@ contributor who ignores it entirely still passes every gate. `privacy:scan` does read it — that is deliberate, and it is what makes a public devlog safe rather than merely visible. -Two mechanical guards in `tests/repo-hygiene.test.ts` back this up: no `160000` +Two mechanical guards in `tests/ci-workflows/repo-hygiene.test.ts` back this up: no `160000` gitlink may be tracked anywhere, and neither the vendored reference clones nor the security triage excised before publication may reappear in the index. Both were driven red once to prove they are not vacuous. The gitlink assertion exists @@ -161,8 +161,8 @@ What matters for development work: the enforcement is code, not prose — [`src/cli/agent-driven.ts`](./src/cli/agent-driven.ts), [`src/cli/star-prompt.ts`](./src/cli/star-prompt.ts), and [`src/server/management/sidebar-routes.ts`](./src/server/management/sidebar-routes.ts), -covered by `tests/startup-prompt.test.ts`, `tests/cli/agent-driven.test.ts`, and -`tests/sidebar-routes.test.ts`. If you add another action that spends the user's +covered by `tests/server/startup-prompt.test.ts`, `tests/cli/agent-driven.test.ts`, and +`tests/server/sidebar-routes.test.ts`. If you add another action that spends the user's identity, credits, or reputation, gate it the same way rather than relying on a prompt an agent can answer, and document it in `AGENTS_INSTALL.md`. @@ -197,7 +197,7 @@ bun run skill:surface # regenerate after adding a capability bun run skill:surface:check # what CI asserts ``` -`tests/skill-ocx.test.ts` fails if the committed map drifts from `src/cli/capabilities.ts`, and +`tests/ci-workflows/skill-ocx.test.ts` fails if the committed map drifts from `src/cli/capabilities.ts`, and also if the hand-written pages name a command the registry does not have. That second check is not hypothetical: it caught a documented `ocx request-history` that never existed. diff --git a/AGENTS_INSTALL.md b/AGENTS_INSTALL.md index ac630b2a02b..404d5ec420d 100644 --- a/AGENTS_INSTALL.md +++ b/AGENTS_INSTALL.md @@ -69,8 +69,8 @@ agent-driven callers regardless: - [`src/server/management/sidebar-routes.ts`](./src/server/management/sidebar-routes.ts) — the `403 agent_consent_required` refusal. -Regression coverage: `tests/startup-prompt.test.ts`, -`tests/cli/agent-driven.test.ts`, `tests/sidebar-routes.test.ts`. +Regression coverage: `tests/server/startup-prompt.test.ts`, +`tests/cli/agent-driven.test.ts`, `tests/server/sidebar-routes.test.ts`. If a future action spends the user's identity, credits, or reputation, gate it the same way rather than relying on a prompt an agent can answer, and document diff --git a/MAINTAINERS.md b/MAINTAINERS.md index f7183db6efa..77836596fc8 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -75,7 +75,7 @@ when a maintainer steps down. - Promotion from `dev` to `main` and npm releases is maintainer-controlled. - **Closing out a release includes moving `dev`'s version line forward.** A published release leaves `dev` carrying a version at or behind it, and - `tests/release-version-line.test.ts` then fails on `dev` and on every pull request + `tests/ci-workflows/release-version-line.test.ts` then fails on `dev` and on every pull request opened against it — red that contributors inherit and cannot fix from their own diff. This was repaired by hand four times (`32529c2b2`, `e4a85d134`, `076ad3036`, `befcac3e1`) before it was automated. diff --git a/docs/superpowers/plans/2026-07-26-oauth-reliability-integrity.md b/docs/superpowers/plans/2026-07-26-oauth-reliability-integrity.md index 15bc508f210..28873044944 100644 --- a/docs/superpowers/plans/2026-07-26-oauth-reliability-integrity.md +++ b/docs/superpowers/plans/2026-07-26-oauth-reliability-integrity.md @@ -609,7 +609,7 @@ EOF **Files:** - Test: `tests/codex-integration/codex-metadata-integrity.test.ts` (new) - Modify only if a real gap is found: `src/codex/auth-context.ts`, `src/adapters/openai-responses.ts` -- Confirm existing: `tests/server-xai-oauth-401-replay.test.ts`, `tests/server-kiro-oauth-401-replay.test.ts`, `tests/codex-integration/codex-routing.test.ts` (policy A) +- Confirm existing: `tests/server/server-xai-oauth-401-replay.test.ts`, `tests/server/server-kiro-oauth-401-replay.test.ts`, `tests/codex-integration/codex-routing.test.ts` (policy A) **Interfaces:** - Consumes: `headersForCodexAuthContext`, `FORWARD_HEADERS` @@ -655,7 +655,7 @@ If fabrication or account-id mismatch is found, fix the minimal header path. Do - [ ] **Step 4: Run related suite** ```bash -bun test tests/codex-integration/codex-metadata-integrity.test.ts tests/codex-integration/codex-auth-context.test.ts tests/codex-integration/codex-routing.test.ts tests/session-affinity.test.ts tests/server-xai-oauth-401-replay.test.ts tests/server-kiro-oauth-401-replay.test.ts +bun test tests/codex-integration/codex-metadata-integrity.test.ts tests/codex-integration/codex-auth-context.test.ts tests/codex-integration/codex-routing.test.ts tests/server/session-affinity.test.ts tests/server/server-xai-oauth-401-replay.test.ts tests/server/server-kiro-oauth-401-replay.test.ts ``` Expected: PASS @@ -714,7 +714,7 @@ EOF ```bash bun test tests/lib/privacy-mask-account.test.ts tests/oauth/oauth-log.test.ts tests/oauth/oauth-refresh-generic-lock.test.ts tests/oauth/oauth-health.test.ts tests/cli/cli-status-oauth-health.test.ts tests/service/doctor-oauth.test.ts tests/oauth/oauth-accounts-api.test.ts tests/codex-integration/codex-metadata-integrity.test.ts -bun test tests/oauth/oauth-refresh.test.ts tests/providers/xai/xai-refresh-lock.test.ts tests/codex-integration/codex-routing.test.ts tests/session-affinity.test.ts tests/codex-integration/codex-auth-context.test.ts +bun test tests/oauth/oauth-refresh.test.ts tests/providers/xai/xai-refresh-lock.test.ts tests/codex-integration/codex-routing.test.ts tests/server/session-affinity.test.ts tests/codex-integration/codex-auth-context.test.ts bun run test bun run typecheck bun run lint:gui diff --git a/docs/superpowers/plans/2026-07-28-pr-quality-gates.md b/docs/superpowers/plans/2026-07-28-pr-quality-gates.md index fe04ac5aaf1..0c7a9010032 100644 --- a/docs/superpowers/plans/2026-07-28-pr-quality-gates.md +++ b/docs/superpowers/plans/2026-07-28-pr-quality-gates.md @@ -6,7 +6,7 @@ **Architecture:** Pure validators live in `.github/scripts/pr-quality.cjs` (reusing `issue-quality` helpers for placeholders / structured sections). The workflow checks out **trusted** scripts from the repository default branch (sparse, no PR head), then the existing `github-script` step requires that module, evaluates base + ancestry + description, and drafts/`setFailed`s when any gate fails. -**Tech Stack:** Node CommonJS (Actions scripts), `node:test` for script unit tests, Bun/`tests/ci-workflows.test.ts` + `enforce-pr-target-harness.ts` for workflow behavioral coverage, Astro docs-site for contributing copy. +**Tech Stack:** Node CommonJS (Actions scripts), `node:test` for script unit tests, Bun/`tests/ci-workflows/ci-workflows.test.ts` + `enforce-pr-target-harness.ts` for workflow behavioral coverage, Astro docs-site for contributing copy. **Spec:** `docs/superpowers/specs/2026-07-28-pr-quality-gates-design.md` @@ -33,7 +33,7 @@ | `.github/workflows/enforce-pr-target.yml` | Checkout + require + multi-gate orchestration | | `.github/scripts/enforce-pr-target.test.cjs` | Static workflow assertions (checkout safety, synchronize, paths) | | `tests/helpers/enforce-pr-target-harness.ts` | Allow `require` of scripts; mock compare + permission; PR `body` | -| `tests/ci-workflows.test.ts` | Structural allowlist + behavioral scenarios | +| `tests/ci-workflows/ci-workflows.test.ts` | Structural allowlist + behavioral scenarios | | `.github/workflows/issue-quality-tests.yml` | Path filters for new script/tests | | `docs-site/src/content/docs/contributing.md` | User-facing branch + description rules | | `AGENTS.md` / `MAINTAINERS.md` | One-line CI policy note | @@ -490,7 +490,7 @@ git commit -m "feat(ci): enforce PR ancestry and description in target gate" **Files:** - Modify: `tests/helpers/enforce-pr-target-harness.ts` -- Modify: `tests/ci-workflows.test.ts` +- Modify: `tests/ci-workflows/ci-workflows.test.ts` **Interfaces:** - Consumes: workflow script that `require`s `pr-quality.cjs` and calls compare/permission APIs @@ -529,7 +529,7 @@ function scopedRequire(id: string) { 5. Record `repos.getCollaboratorPermissionLevel` and `repos.compareCommitsWithBasehead` on the fake github client. -- [ ] **Step 2: Update structural allowlist in `tests/ci-workflows.test.ts`** +- [ ] **Step 2: Update structural allowlist in `tests/ci-workflows/ci-workflows.test.ts`** - Steps length **2**: checkout then github-script - Pin checkout SHA `11bd71901bbe5b1630ceea73d27597364c9af683`, default_branch ref, `persist-credentials: false`, sparse `.github/scripts`, no PR head ref @@ -550,7 +550,7 @@ function scopedRequire(id: string) { ```bash node --test .github/scripts/pr-quality.test.cjs .github/scripts/enforce-pr-target.test.cjs -bun test tests/ci-workflows.test.ts +bun test tests/ci-workflows/ci-workflows.test.ts ``` Expected: PASS. @@ -558,7 +558,7 @@ Expected: PASS. - [ ] **Step 5: Commit** ```bash -git add tests/helpers/enforce-pr-target-harness.ts tests/ci-workflows.test.ts +git add tests/helpers/enforce-pr-target-harness.ts tests/ci-workflows/ci-workflows.test.ts git commit -m "test(ci): cover PR ancestry and description enforcement paths" ``` @@ -601,7 +601,7 @@ git commit -m "docs: document PR ancestry and description quality gates" ```bash node --test .github/scripts/pr-quality.test.cjs .github/scripts/enforce-pr-target.test.cjs -bun test tests/ci-workflows.test.ts +bun test tests/ci-workflows/ci-workflows.test.ts bun run typecheck bun run privacy:scan ``` diff --git a/docs/superpowers/plans/2026-08-06-deepseek-responses-streaming-terminal-repair.md b/docs/superpowers/plans/2026-08-06-deepseek-responses-streaming-terminal-repair.md index 4720749b10a..3940fdcc2eb 100644 --- a/docs/superpowers/plans/2026-08-06-deepseek-responses-streaming-terminal-repair.md +++ b/docs/superpowers/plans/2026-08-06-deepseek-responses-streaming-terminal-repair.md @@ -366,7 +366,7 @@ abort/cancel, taint, and candidate completeness immediately before enqueueing. Run: ```bash -bun test tests/responses/responses-terminal-repair.test.ts tests/responses/sse-failed-tail.test.ts tests/relay-eager.test.ts +bun test tests/responses/responses-terminal-repair.test.ts tests/responses/sse-failed-tail.test.ts tests/server/relay-eager.test.ts ``` Expected: all tests pass with no duplicate terminal, timer leak, or retained @@ -560,7 +560,7 @@ git commit -m "docs(deepseek): describe streaming terminal repair" Run: ```bash -bun test tests/responses/responses-terminal-repair.test.ts tests/providers/deepseek-inbound-wire.test.ts tests/responses/ws-endpoint.test.ts tests/responses/sse-failed-tail.test.ts tests/relay-eager.test.ts tests/responses/responses-item-id-repair.test.ts tests/providers/deepseek-responses-item-id-repair.test.ts tests/providers/deepseek-reasoning-replay.test.ts tests/responses/responses-state.test.ts +bun test tests/responses/responses-terminal-repair.test.ts tests/providers/deepseek-inbound-wire.test.ts tests/responses/ws-endpoint.test.ts tests/responses/sse-failed-tail.test.ts tests/server/relay-eager.test.ts tests/responses/responses-item-id-repair.test.ts tests/providers/deepseek-responses-item-id-repair.test.ts tests/providers/deepseek-reasoning-replay.test.ts tests/responses/responses-state.test.ts ``` Expected: 0 failures. diff --git a/docs/superpowers/plans/2026-08-13-cl10-deep-review-hardening.md b/docs/superpowers/plans/2026-08-13-cl10-deep-review-hardening.md index ce8233cbf38..f3006eecf00 100644 --- a/docs/superpowers/plans/2026-08-13-cl10-deep-review-hardening.md +++ b/docs/superpowers/plans/2026-08-13-cl10-deep-review-hardening.md @@ -27,7 +27,7 @@ **Files:** - Create: `tests/lab/lab-public-deep-review-regressions.test.ts` -- Modify: `tests/ci-workflows.test.ts` +- Modify: `tests/ci-workflows/ci-workflows.test.ts` **Interfaces:** - Consumes: current CL-10 public module APIs. diff --git a/docs/superpowers/specs/2026-07-28-pr-quality-gates-design.md b/docs/superpowers/specs/2026-07-28-pr-quality-gates-design.md index a5f00449b2a..5dec2f38cbe 100644 --- a/docs/superpowers/specs/2026-07-28-pr-quality-gates-design.md +++ b/docs/superpowers/specs/2026-07-28-pr-quality-gates-design.md @@ -139,7 +139,7 @@ Unchanged from #631: `contents: write` + `pull-requests: write` for draft GraphQ | --- | --- | | `.github/scripts/pr-quality.test.cjs` | Pure rules: #644-like compare fixture fails ancestry; behind_main>0 passes; maintainer skip N/A at pure layer; empty / comment-only / escaped `\n` / thin / good structured / good unstructured bodies | | `enforce-pr-target.test.cjs` / harness | Workflow wires `synchronize`; calls quality module; `setFailed` when ancestry or description fails; soft-fail draft still; no checkout | -| `tests/ci-workflows.test.ts` | Permissions + trigger types stay in sync | +| `tests/ci-workflows/ci-workflows.test.ts` | Permissions + trigger types stay in sync | Offline fixtures only — no live GitHub in unit tests. diff --git a/gui/src/api-targets.ts b/gui/src/api-targets.ts index 83eed5e9a14..7d6dc12109c 100644 --- a/gui/src/api-targets.ts +++ b/gui/src/api-targets.ts @@ -33,7 +33,7 @@ export function isConnectedRuntime(): boolean { * * The role is the wrong predicate, and it was tried first: `standalone` + `hostname: * "0.0.0.0"` is an operator who deliberately exposed the dashboard and MUST type the admin - * token (tests/server-management-auth.test.ts, "a non-loopback binding never issues a GUI + * token (tests/server/server-management-auth.test.ts, "a non-loopback binding never issues a GUI * session from a forged loopback Host"), while a `hub` on loopback still mints its own * session. Gating on `role === "hub"` would have hidden the prompt from exactly the * operator who needs it. diff --git a/scripts/bump-dev-version.ts b/scripts/bump-dev-version.ts index e57d02e0325..53c41815a00 100644 --- a/scripts/bump-dev-version.ts +++ b/scripts/bump-dev-version.ts @@ -8,7 +8,7 @@ * `package.json` there, and pushes that branch. `release.yml` ends at "Create GitHub * release". Nothing advances `dev`. So the moment a release publishes, `dev` carries a * version that is at or behind a published one, and - * `tests/release-version-line.test.ts` fails on `dev` and on every pull request opened + * `tests/ci-workflows/release-version-line.test.ts` fails on `dev` and on every pull request opened * against it — inherited red that a contributor cannot fix from their own diff. * * That has been repaired by hand four times: `32529c2b2`, `e4a85d134`, `076ad3036`, @@ -45,7 +45,7 @@ * stable release means that core is consumed, so `dev` moves to the next minor. * * Freeness is then checked where the tag set IS visible: the workflow runs - * `tests/release-version-line.test.ts` in the `dev` checkout after the rewrite. If the + * `tests/ci-workflows/release-version-line.test.ts` in the `dev` checkout after the rewrite. If the * candidate collides with something published, that test fails, no pull request is * opened, and the job goes red asking for a human decision. This file only enforces * what it can prove without I/O — that the candidate ranks strictly ahead of both @@ -108,7 +108,7 @@ export function decideDevVersion(released: string, current: string): BumpDecisio : `${rel.major}.${rel.minor}.${rel.patch}`; // Nothing to do when dev is already clear of the RELEASED version. That is the real - // question — the detector in tests/release-version-line.test.ts compares dev against + // question — the detector in tests/ci-workflows/release-version-line.test.ts compares dev against // published tags, not against this candidate. // // Comparing against the candidate instead is wrong, and a test caught it: dev at diff --git a/scripts/generate-ocx-skill-surface.ts b/scripts/generate-ocx-skill-surface.ts index c6a0d71c274..b0ede70217e 100644 --- a/scripts/generate-ocx-skill-surface.ts +++ b/scripts/generate-ocx-skill-surface.ts @@ -3,7 +3,7 @@ * * Generated rather than written, because a hand-maintained surface map is a SECOND description * of the CLI that is free to drift from the first -- the same defect class this unit removed from - * the help text. `tests/skill-ocx.test.ts` asserts the committed file matches this output, so a + * the help text. `tests/ci-workflows/skill-ocx.test.ts` asserts the committed file matches this output, so a * capability added without regenerating fails CI instead of silently shipping a stale skill. * * Usage: diff --git a/scripts/openai-provider-option-final-gates.ts b/scripts/openai-provider-option-final-gates.ts index a6cf3f9bd4f..e157179c420 100644 --- a/scripts/openai-provider-option-final-gates.ts +++ b/scripts/openai-provider-option-final-gates.ts @@ -52,12 +52,12 @@ const focusedTests = [ "tests/gui/codex-account-mode-state.test.ts", "tests/routing/router.test.ts", "tests/codex-integration/codex-routing.test.ts", - "tests/server-auth.test.ts", + "tests/server/server-auth.test.ts", "tests/codex-integration/codex-catalog.test.ts", "tests/codex-integration/codex-quota-prime.test.ts", "tests/providers/provider-quota.test.ts", - "tests/server-images.test.ts", - "tests/server-search.test.ts", + "tests/server/server-images.test.ts", + "tests/server/server-search.test.ts", ]; const staleContractPattern = [ ["openai", "multi"].join("-"), diff --git a/scripts/release.ts b/scripts/release.ts index c9939e09d45..fa4416bc0a2 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -536,13 +536,13 @@ console.log("→ test suite"); // without executing them; a `bash` step would miss that shim, escape into the // real suite, and fail the helper tests with exit 127. const ISOLATED_TEST_FILES = [ - "./tests/api-storage-policy-already-running.test.ts", - "./tests/api-storage-policy-mutation-busy.test.ts", - "./tests/api-storage-policy-put-race.test.ts", - "./tests/api-storage-policy-run.test.ts", - "./tests/api-storage-policy.test.ts", - "./tests/api-storage.test.ts", - "./tests/api-usage.test.ts", + "./tests/storage/api-storage-policy-already-running.test.ts", + "./tests/storage/api-storage-policy-mutation-busy.test.ts", + "./tests/storage/api-storage-policy-put-race.test.ts", + "./tests/storage/api-storage-policy-run.test.ts", + "./tests/storage/api-storage-policy.test.ts", + "./tests/storage/api-storage.test.ts", + "./tests/server/api-usage.test.ts", ]; await runLoud([ "bun", "test", "--isolate", "tests", diff --git a/scripts/test-layout/layout.json b/scripts/test-layout/layout.json index ab49a9ddfd8..0f8610c1393 100644 --- a/scripts/test-layout/layout.json +++ b/scripts/test-layout/layout.json @@ -1230,6 +1230,7 @@ }, "migrated": [ "adapters", + "ci-workflows", "claude-integration", "cli", "clients", @@ -1242,7 +1243,9 @@ "providers", "responses", "routing", + "server", "service", + "storage", "update", "usage", "vision", diff --git a/scripts/test.ts b/scripts/test.ts index d69549a8249..a7840757f90 100644 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -329,7 +329,7 @@ export const SERIAL_FULL_SUITE_FILES = [ "providers/cursor/cursor-native-exec-shell.test.ts", "codex-integration/issue-452-empty-503.test.ts", "adapters/openai/openai-provider-option-e2e.test.ts", - "release-helper.test.ts", + "ci-workflows/release-helper.test.ts", "update/update-stop-first.test.ts", ] as const; diff --git a/src/server/auth-cors.ts b/src/server/auth-cors.ts index 8da10d5f44f..cc8f342943b 100644 --- a/src/server/auth-cors.ts +++ b/src/server/auth-cors.ts @@ -62,7 +62,7 @@ export function isLoopbackRequestHost(value: string | null): boolean { // Scope of that guarantee: it holds for Hosts `parseHttpHost` can parse. An unparseable // Host still returns true above — pre-existing behavior, not browser-reachable (a browser // composes Host from its own connection), and pinned by a characterization test in - // tests/server-loopback-host-gate.test.ts. Tightening it is separate work. + // tests/server/server-loopback-host-gate.test.ts. Tightening it is separate work. return isLoopbackHostname(parsed.hostname); } diff --git a/src/server/index.ts b/src/server/index.ts index ff71c73ddb1..80461161119 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -1280,7 +1280,7 @@ export function startServer(port?: number, deps: StartServerDeps = {}): Server char.repeat(40); diff --git a/tests/bump-dev-version.test.ts b/tests/ci-workflows/bump-dev-version.test.ts similarity index 97% rename from tests/bump-dev-version.test.ts rename to tests/ci-workflows/bump-dev-version.test.ts index 87c42daf7aa..814a7165e9d 100644 --- a/tests/bump-dev-version.test.ts +++ b/tests/ci-workflows/bump-dev-version.test.ts @@ -3,7 +3,7 @@ import { chmodSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; -import { decideDevVersion } from "../scripts/bump-dev-version"; +import { decideDevVersion } from "../../scripts/bump-dev-version"; /** * The bump rule that keeps dev off an already-published version. @@ -16,8 +16,8 @@ import { decideDevVersion } from "../scripts/bump-dev-version"; // fileURLToPath, not .pathname: on Windows the pathname is "/D:/a/.../bump-dev-version.ts", // which bun cannot open, so every CLI case exited 1 before reaching the code under test — // and the malformed-input case read that same load failure as a correct rejection. -const CLI = fileURLToPath(new URL("../scripts/bump-dev-version.ts", import.meta.url)); -const WORKFLOW = fileURLToPath(new URL("../.github/workflows/dev-version-bump.yml", import.meta.url)); +const CLI = fileURLToPath(new URL("../../scripts/bump-dev-version.ts", import.meta.url)); +const WORKFLOW = fileURLToPath(new URL("../../.github/workflows/dev-version-bump.yml", import.meta.url)); function runCli(...args: string[]) { const proc = Bun.spawnSync([process.execPath, CLI, ...args]); diff --git a/tests/bun-runtime.test.ts b/tests/ci-workflows/bun-runtime.test.ts similarity index 98% rename from tests/bun-runtime.test.ts rename to tests/ci-workflows/bun-runtime.test.ts index bfc1c333caa..7e80816fe76 100644 --- a/tests/bun-runtime.test.ts +++ b/tests/ci-workflows/bun-runtime.test.ts @@ -2,9 +2,9 @@ import { describe, it, expect, afterAll, afterEach } from "bun:test"; import { mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { BUN_RUNTIME_PATH_ENV, BUN_RUNTIME_SOURCE_ENV, isRealBunBinary, bundledBunPath, durableBunPath, durableBunRuntime, reportedBunRuntimeSource, withProcessRuntimeProvenance } from "../src/lib/bun-runtime"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; -import { repoPath } from "./helpers/repo-root"; +import { BUN_RUNTIME_PATH_ENV, BUN_RUNTIME_SOURCE_ENV, isRealBunBinary, bundledBunPath, durableBunPath, durableBunRuntime, reportedBunRuntimeSource, withProcessRuntimeProvenance } from "../../src/lib/bun-runtime"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoPath } from "../helpers/repo-root"; // realpath the temp root: on macOS /var is a symlink to /private/var, so a path built // from mkdtemp compares unequal to the same path resolved through process.cwd(). diff --git a/tests/ci-workflows.test.ts b/tests/ci-workflows/ci-workflows.test.ts similarity index 99% rename from tests/ci-workflows.test.ts rename to tests/ci-workflows/ci-workflows.test.ts index e2f8ab0b5ee..7418e89a278 100644 --- a/tests/ci-workflows.test.ts +++ b/tests/ci-workflows/ci-workflows.test.ts @@ -6,7 +6,9 @@ import { methodsOf, runEnforcePrTarget, type HarnessResult, -} from "./helpers/enforce-pr-target-harness"; +} from "../helpers/enforce-pr-target-harness"; +import { pathToFileURL } from "node:url"; +import { repoRoot } from "../helpers/repo-root"; /** Final consolidated gate comment body (the single bot message). */ function lastGateCommentBody(result: HarnessResult): string { @@ -27,9 +29,9 @@ const lastReadinessCommentBody = lastGateCommentBody; /** Alias kept for scenarios that named the pre-consolidation enforcer comment. */ const lastEnforcerCommentBody = lastGateCommentBody; -const root = new URL("../", import.meta.url); -const doctorGuiIfChangedScript = fileURLToPath(new URL("../scripts/doctor-gui-if-changed.ts", import.meta.url)); -const lintGuiIfChangedScript = fileURLToPath(new URL("../scripts/lint-gui-if-changed.ts", import.meta.url)); +const root = pathToFileURL(repoRoot() + "/"); +const doctorGuiIfChangedScript = fileURLToPath(new URL("../../scripts/doctor-gui-if-changed.ts", import.meta.url)); +const lintGuiIfChangedScript = fileURLToPath(new URL("../../scripts/lint-gui-if-changed.ts", import.meta.url)); async function readText(path: string): Promise { return await Bun.file(new URL(path, root)).text(); @@ -172,7 +174,7 @@ describe("GitHub Actions hardening", () => { expect(workflow).toContain(`--shard=\${{ matrix.shard }}/${linuxShards.length}`); // Every job that runs tests/ must fetch tags, because one of those tests reads - // them. tests/release-version-line.test.ts compares package.json against the + // them. tests/ci-workflows/release-version-line.test.ts compares package.json against the // newest release tag, and actions/checkout brings no tags by default: git is // present, `git tag --list` exits 0, and stdout is empty. The check then has an // empty set, cannot fail, and a version regression rides through green. That is @@ -1514,7 +1516,7 @@ describe("GitHub Actions hardening", () => { "", "## Test plan", "", - "- Run `bun test tests/ci-workflows.test.ts`", + "- Run `bun test tests/ci-workflows/ci-workflows.test.ts`", ].join("\n"); /** * Fixture for the trusted `MAINTAINERS.md`: the current-maintainers table @@ -2890,7 +2892,7 @@ describe("GitHub Actions hardening", () => { "", "## Test plan", "", - "- Ran \`bun test tests/ci-workflows.test.ts\`", + "- Ran \`bun test tests/ci-workflows/ci-workflows.test.ts\`", ].join("\n"), }, authorPermission: "write", @@ -2925,7 +2927,7 @@ describe("GitHub Actions hardening", () => { "This change adjusts gui/ spacing tokens used by the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, files: GUI_CHANGED_FILES, @@ -2945,7 +2947,7 @@ describe("GitHub Actions hardening", () => { "This change adjusts gui/ spacing tokens used by the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, comments: [ @@ -2971,7 +2973,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, comments: [ @@ -2995,7 +2997,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, labels: ["gui-screenshot-waived"], @@ -3058,7 +3060,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, labels: ["gui-screenshot-waived"], @@ -3248,7 +3250,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, eventName: "issue_comment", @@ -3280,7 +3282,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, eventName: "issue_comment", @@ -3311,7 +3313,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, eventName: "issue_comment", @@ -3382,7 +3384,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, comments: [ @@ -3406,7 +3408,7 @@ describe("GitHub Actions hardening", () => { "This change fixes the provider list spacing in the dashboard.", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, comments: [ @@ -3431,7 +3433,7 @@ describe("GitHub Actions hardening", () => { "![after](https://example.com/after.png)", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, authorPermission: "write", @@ -3456,7 +3458,7 @@ describe("GitHub Actions hardening", () => { "[shot]: https://example.com/after.png", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, authorPermission: "write", @@ -3481,7 +3483,7 @@ describe("GitHub Actions hardening", () => { "```", "", "## Test plan", - "- Ran bun test tests/ci-workflows.test.ts", + "- Ran bun test tests/ci-workflows/ci-workflows.test.ts", ].join("\n"), }, files: GUI_CHANGED_FILES, @@ -5118,7 +5120,7 @@ describe("GitHub Actions hardening", () => { describe("doctor-gui-if-changed", () => { test("guiPathsChanged is a slash-guarded gui/ prefix predicate", async () => { - const { guiPathsChanged } = await import("../scripts/doctor-gui-if-changed"); + const { guiPathsChanged } = await import("../../scripts/doctor-gui-if-changed"); expect(guiPathsChanged(["gui/src/App.tsx"])).toBe(true); expect(guiPathsChanged(["gui"])).toBe(true); @@ -5129,7 +5131,7 @@ describe("doctor-gui-if-changed", () => { }); test("looksLikeDoctorInfraFailure detects registry/network outages", async () => { - const { looksLikeDoctorInfraFailure } = await import("../scripts/doctor-gui-if-changed"); + const { looksLikeDoctorInfraFailure } = await import("../../scripts/doctor-gui-if-changed"); expect(looksLikeDoctorInfraFailure("npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org")).toBe(true); expect(looksLikeDoctorInfraFailure("npm ERR! code ECONNRESET")).toBe(true); expect(looksLikeDoctorInfraFailure("npm ERR! network timeout")).toBe(true); @@ -5191,7 +5193,7 @@ describe("doctor-gui-if-changed", () => { }); test("isDoctorBufferOverflow recognizes ENOBUFS / maxBuffer errors", async () => { - const { isDoctorBufferOverflow } = await import("../scripts/doctor-gui-if-changed"); + const { isDoctorBufferOverflow } = await import("../../scripts/doctor-gui-if-changed"); expect(isDoctorBufferOverflow("ENOBUFS")).toBe(true); expect(isDoctorBufferOverflow("ERR_CHILD_PROCESS_STDIO_MAXBUFFER")).toBe(true); expect(isDoctorBufferOverflow("ENOENT")).toBe(false); diff --git a/tests/cleanup-orphaned-workflows.test.ts b/tests/ci-workflows/cleanup-orphaned-workflows.test.ts similarity index 98% rename from tests/cleanup-orphaned-workflows.test.ts rename to tests/ci-workflows/cleanup-orphaned-workflows.test.ts index 665606a0f9f..c530d841cd1 100644 --- a/tests/cleanup-orphaned-workflows.test.ts +++ b/tests/ci-workflows/cleanup-orphaned-workflows.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { cleanupOrphanedWorkflowRuns } from "../scripts/ci/cleanup-orphaned-workflows.mjs"; +import { cleanupOrphanedWorkflowRuns } from "../../scripts/ci/cleanup-orphaned-workflows.mjs"; interface MockRoute { method?: string; @@ -45,7 +45,7 @@ function baseRoutes(extra: MockRoute[]): MockRoute[] { describe("orphaned GitHub Actions cleanup", () => { test("workflow is default-branch-only, least-privilege, bounded, and pinned", async () => { const text = await Bun.file( - new URL("../.github/workflows/cleanup-orphaned-workflows.yml", import.meta.url), + new URL("../../.github/workflows/cleanup-orphaned-workflows.yml", import.meta.url), ).text(); const workflow = Bun.YAML.parse(text) as { on?: Record; diff --git a/tests/closed-pr-branch-cleanup.test.ts b/tests/ci-workflows/closed-pr-branch-cleanup.test.ts similarity index 98% rename from tests/closed-pr-branch-cleanup.test.ts rename to tests/ci-workflows/closed-pr-branch-cleanup.test.ts index 4fb0f3261ad..d1cbc4bdf6a 100644 --- a/tests/closed-pr-branch-cleanup.test.ts +++ b/tests/ci-workflows/closed-pr-branch-cleanup.test.ts @@ -28,7 +28,7 @@ interface CleanupModule { }) => { deletions: { branch: string; pullRequests: number[] }[]; keeps: { branch: string; reason: string }[] }; } -const cleanup = await import("../.github/scripts/closed-pr-branch-cleanup.cjs") as unknown as CleanupModule & { default?: CleanupModule }; +const cleanup = await import("../../.github/scripts/closed-pr-branch-cleanup.cjs") as unknown as CleanupModule & { default?: CleanupModule }; // A .cjs module reached through ESM interop may arrive under `default`; taking whichever // carries the planner keeps the test honest about what it is calling. const api: CleanupModule = typeof cleanup.planClosedPrBranchDeletions === "function" diff --git a/tests/compatibility-version.test.ts b/tests/ci-workflows/compatibility-version.test.ts similarity index 91% rename from tests/compatibility-version.test.ts rename to tests/ci-workflows/compatibility-version.test.ts index e4c81cd3a87..d89a511dc5f 100644 --- a/tests/compatibility-version.test.ts +++ b/tests/ci-workflows/compatibility-version.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { buildCompatibilityVersionManifest } from "../scripts/generate-compatibility-version"; +import { buildCompatibilityVersionManifest } from "../../scripts/generate-compatibility-version"; describe("Compatibility Lab generated implementation identity", () => { test("manifest covers exact tracked source authority without self-reference", () => { diff --git a/tests/docs-429-failover-claims.test.ts b/tests/ci-workflows/docs-429-failover-claims.test.ts similarity index 100% rename from tests/docs-429-failover-claims.test.ts rename to tests/ci-workflows/docs-429-failover-claims.test.ts diff --git a/tests/docs-bun-source-requirement.test.ts b/tests/ci-workflows/docs-bun-source-requirement.test.ts similarity index 91% rename from tests/docs-bun-source-requirement.test.ts rename to tests/ci-workflows/docs-bun-source-requirement.test.ts index a1b968894b7..a0891e50048 100644 --- a/tests/docs-bun-source-requirement.test.ts +++ b/tests/ci-workflows/docs-bun-source-requirement.test.ts @@ -1,4 +1,5 @@ import { expect, test } from "bun:test"; +import { repoPath } from "../helpers/repo-root"; /** * Every contributor entry point must say that building from source needs a local `bun`, and @@ -15,20 +16,20 @@ const PARAGRAPH_START = "Source development requires the `bun` CLI on your `PATH const CASES = [ { - path: "../CONTRIBUTING.md", + path: "CONTRIBUTING.md", paragraph: "Source development requires the `bun` CLI on your `PATH`. The published npm package bundles its own" + " Bun runtime for end users, but contributor commands such as `bun install`, `bun run test`, and" + " `bun run prepush` run from your local Bun installation.", }, { - path: "../README.md", + path: "README.md", paragraph: "Source development requires the `bun` CLI on your `PATH`. This is separate from the published npm" + " package's bundled Bun runtime, which is used only by installed `ocx` commands.", }, { - path: "../docs-site/src/content/docs/contributing.md", + path: "docs-site/src/content/docs/contributing.md", paragraph: "Source development requires the `bun` CLI on your `PATH`. The published npm package bundles its own" + " Bun runtime for users, but this checkout's scripts run through your local Bun installation.", @@ -47,7 +48,7 @@ function normalizedRequirementParagraph(text: string): string | undefined { test("source development docs require a local Bun CLI while preserving the bundled-runtime distinction", async () => { for (const entry of CASES) { - const text = await Bun.file(new URL(entry.path, import.meta.url)).text(); + const text = await Bun.file(repoPath(entry.path)).text(); expect(normalizedRequirementParagraph(text)).toBe(entry.paragraph); } }); diff --git a/tests/dsh-path-contract.test.ts b/tests/ci-workflows/dsh-path-contract.test.ts similarity index 92% rename from tests/dsh-path-contract.test.ts rename to tests/ci-workflows/dsh-path-contract.test.ts index 546a332339c..07ae53629a1 100644 --- a/tests/dsh-path-contract.test.ts +++ b/tests/ci-workflows/dsh-path-contract.test.ts @@ -7,8 +7,8 @@ import { EXPORT_CLIENTS, dshConfigPath, dshHomeDir, -} from "../src/clients/config-export"; -import { INTEGRATION_CLIENTS } from "../src/integrations/registry"; +} from "../../src/clients/config-export"; +import { INTEGRATION_CLIENTS } from "../../src/integrations/registry"; const HOME = join(tmpdir(), "ocx-dsh-path-home"); @@ -53,7 +53,7 @@ describe("DSH 0.1.0-rc.6 path contract", () => { }); test("checked-in fixture is a secret-free parseable rc.6 settings namespace", () => { - const text = readFileSync(new URL("./fixtures/dsh-settings-0.1.0-rc.6.yaml", import.meta.url), "utf8"); + const text = readFileSync(new URL("../fixtures/dsh-settings-0.1.0-rc.6.yaml", import.meta.url), "utf8"); const parsed = Bun.YAML.parse(text) as Record; expect(parsed).toHaveProperty("llm-pi-ai.providers.acme-gateway.api", "openai-completions"); expect(parsed).toHaveProperty("llm-pi-ai.providers.acme-gateway.models.1.reasoningEfforts.max", "ultra"); diff --git a/tests/dsh-rc6-compat-script.test.ts b/tests/ci-workflows/dsh-rc6-compat-script.test.ts similarity index 98% rename from tests/dsh-rc6-compat-script.test.ts rename to tests/ci-workflows/dsh-rc6-compat-script.test.ts index 61fbe6d9d9e..305900af6ff 100644 --- a/tests/dsh-rc6-compat-script.test.ts +++ b/tests/ci-workflows/dsh-rc6-compat-script.test.ts @@ -6,7 +6,7 @@ import { buildDshChildEnv, hasExpectedDshToolOutputs, renderDshSettings, -} from "../scripts/dsh-rc6-compat-e2e"; +} from "../../scripts/dsh-rc6-compat-e2e"; describe("optional DSH rc.6 compatibility E2E helpers", () => { test("pins the exact developer-preview version", () => { diff --git a/tests/dsh-writer-lock.test.ts b/tests/ci-workflows/dsh-writer-lock.test.ts similarity index 96% rename from tests/dsh-writer-lock.test.ts rename to tests/ci-workflows/dsh-writer-lock.test.ts index 5c6ab58f495..22e1b36f4e7 100644 --- a/tests/dsh-writer-lock.test.ts +++ b/tests/ci-workflows/dsh-writer-lock.test.ts @@ -3,23 +3,23 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, statSync, writeFileSy import { rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { ExportModel } from "../src/clients/config-export"; -import { INTEGRATION_CLIENTS } from "../src/integrations/registry"; -import { createIntegrationStateStore, type IntegrationStateStore } from "../src/integrations/store"; +import type { ExportModel } from "../../src/clients/config-export"; +import { INTEGRATION_CLIENTS } from "../../src/integrations/registry"; +import { createIntegrationStateStore, type IntegrationStateStore } from "../../src/integrations/store"; import { applyIntegrationCoordinated, disableIntegrationCoordinated, restoreIntegrationCoordinated, type IntegrationWriteInput, -} from "../src/integrations/writer"; +} from "../../src/integrations/writer"; import { IntegrationWriterLockBusyError, IntegrationWriterLockIOError, withIntegrationWriterLock, type IntegrationWriterLockSeams, -} from "../src/integrations/writer-lock"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/integrations/writer-lock"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function eexist(): Error & { code: string } { return Object.assign(new Error("exists"), { code: "EEXIST" }); diff --git a/tests/fixture-dir-uniqueness.test.ts b/tests/ci-workflows/fixture-dir-uniqueness.test.ts similarity index 97% rename from tests/fixture-dir-uniqueness.test.ts rename to tests/ci-workflows/fixture-dir-uniqueness.test.ts index a9cb7cc01b5..da572621e00 100644 --- a/tests/fixture-dir-uniqueness.test.ts +++ b/tests/ci-workflows/fixture-dir-uniqueness.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; import { readdirSync, readFileSync } from "node:fs"; import { join, relative, sep } from "node:path"; -import { repoPath } from "./helpers/repo-root"; -import { currentPath, loadLayout } from "../scripts/test-layout/schema"; +import { repoPath } from "../helpers/repo-root"; +import { currentPath, loadLayout } from "../../scripts/test-layout/schema"; /** * A fixed fixture directory shared by two test files is a silent flake factory. diff --git a/tests/install-scripts.test.ts b/tests/ci-workflows/install-scripts.test.ts similarity index 97% rename from tests/install-scripts.test.ts rename to tests/ci-workflows/install-scripts.test.ts index e75cece86f7..38ab13eac66 100644 --- a/tests/install-scripts.test.ts +++ b/tests/ci-workflows/install-scripts.test.ts @@ -11,16 +11,17 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { fileURLToPath } from "node:url"; -import { normalizePackageModes } from "../scripts/prepare-package"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { normalizePackageModes } from "../../scripts/prepare-package"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoRoot as resolveRepoRoot } from "../helpers/repo-root"; // Windows CI runners spawn Node/Bun child processes slowly ("Slow filesystem detected"); // the package-main import test measured 9.4s there vs bun's 5s default. Same remedy as // codex-history-provider / cursor-mcp-stdio. setDefaultTimeout(30_000); -const root = new URL("../", import.meta.url); +const root = pathToFileURL(resolveRepoRoot() + "/"); const repoRoot = fileURLToPath(root); function mode(path: string): number { diff --git a/tests/keyring-smoke.test.ts b/tests/ci-workflows/keyring-smoke.test.ts similarity index 98% rename from tests/keyring-smoke.test.ts rename to tests/ci-workflows/keyring-smoke.test.ts index 5f2cf7b5ae3..9cc9657bb8d 100644 --- a/tests/keyring-smoke.test.ts +++ b/tests/ci-workflows/keyring-smoke.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { runKeyringSmoke, type KeyringSmokeEntry } from "../scripts/keyring-smoke"; +import { runKeyringSmoke, type KeyringSmokeEntry } from "../../scripts/keyring-smoke"; class MemoryKeyringEntry implements KeyringSmokeEntry { secret: Buffer | null = null; diff --git a/tests/package-tree-integrity.test.ts b/tests/ci-workflows/package-tree-integrity.test.ts similarity index 97% rename from tests/package-tree-integrity.test.ts rename to tests/ci-workflows/package-tree-integrity.test.ts index 16817f89c0d..13da9e02e7c 100644 --- a/tests/package-tree-integrity.test.ts +++ b/tests/ci-workflows/package-tree-integrity.test.ts @@ -1,16 +1,16 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { chmodSync, existsSync, mkdirSync, renameSync, statSync, writeFileSync } from "node:fs"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; +import { saveConfig } from "../../src/config"; import { createPackageTreeIntegrityGuard, createRuntimePackageTreeIntegrityGuard, type PackageTreeObservation, -} from "../src/lib/package-tree-integrity"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lib/package-tree-integrity"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const TEST_DIR = join(import.meta.dir, ".tmp-package-tree-integrity"); const previousOpencodexHome = process.env.OPENCODEX_HOME; diff --git a/tests/privacy-scan-meta-key.test.ts b/tests/ci-workflows/privacy-scan-meta-key.test.ts similarity index 97% rename from tests/privacy-scan-meta-key.test.ts rename to tests/ci-workflows/privacy-scan-meta-key.test.ts index c8259e966f8..f21f3a75d9d 100644 --- a/tests/privacy-scan-meta-key.test.ts +++ b/tests/ci-workflows/privacy-scan-meta-key.test.ts @@ -11,7 +11,7 @@ * detector was deleted. */ import { describe, expect, test } from "bun:test"; -import { scanText } from "../scripts/privacy-scan"; +import { scanText } from "../../scripts/privacy-scan"; /** Assembled at runtime so this file contains no secret-shaped literal of its own. */ const canary = ["LLM", "1".repeat(16), "c".repeat(27)].join("|"); diff --git a/tests/release-helper.test.ts b/tests/ci-workflows/release-helper.test.ts similarity index 98% rename from tests/release-helper.test.ts rename to tests/ci-workflows/release-helper.test.ts index c692a80f585..4a21bab794c 100644 --- a/tests/release-helper.test.ts +++ b/tests/ci-workflows/release-helper.test.ts @@ -3,12 +3,12 @@ import { chmodSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; -import { commandInvocation } from "../src/lib/win-exec"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { commandInvocation } from "../../src/lib/win-exec"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; setDefaultTimeout(30_000); -const repoRoot = dirname(fileURLToPath(new URL("../package.json", import.meta.url))); +const repoRoot = dirname(fileURLToPath(new URL("../../package.json", import.meta.url))); const releaseScriptPath = join(repoRoot, "scripts", "release.ts"); interface LoggedCall { @@ -371,10 +371,10 @@ describe("release helper", () => { && call.args.some(arg => arg.startsWith("--path-ignore-patterns=") && arg.includes("api-usage")), ); const isolatedUsageIndex = findCallIndex(calls, "bun", call => - call.args.join(" ") === "test --isolate ./tests/api-usage.test.ts", + call.args.join(" ") === "test --isolate ./tests/server/api-usage.test.ts", ); const isolatedStorageIndex = findCallIndex(calls, "bun", call => - call.args.join(" ") === "test --isolate ./tests/api-storage.test.ts", + call.args.join(" ") === "test --isolate ./tests/storage/api-storage.test.ts", ); const privacyIndex = findCallIndex(calls, "bun", call => call.args.join(" ") === "run privacy:scan"); const versionIndex = findCallIndex(calls, "npm", call => call.args.join(" ") === "version 9.9.9 --no-git-tag-version"); diff --git a/tests/release-notes.test.ts b/tests/ci-workflows/release-notes.test.ts similarity index 99% rename from tests/release-notes.test.ts rename to tests/ci-workflows/release-notes.test.ts index 25c28926fdb..11196108d73 100644 --- a/tests/release-notes.test.ts +++ b/tests/ci-workflows/release-notes.test.ts @@ -24,7 +24,7 @@ import { splitPolishInput, stripCarriedReleaseNotes, validatePolishedSections, -} from "../scripts/release-notes"; +} from "../../scripts/release-notes"; describe("matchingPreviewTag", () => { test("picks the newest matching preview tag for a stable version", () => { diff --git a/tests/release-version-line.test.ts b/tests/ci-workflows/release-version-line.test.ts similarity index 97% rename from tests/release-version-line.test.ts rename to tests/ci-workflows/release-version-line.test.ts index 7b52e2d1473..c683885a2f6 100644 --- a/tests/release-version-line.test.ts +++ b/tests/ci-workflows/release-version-line.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; import { readFileSync } from "node:fs"; -import { compareReleaseTags } from "../scripts/release-notes"; -import { repoPath, repoRoot as resolveRepoRoot } from "./helpers/repo-root"; +import { compareReleaseTags } from "../../scripts/release-notes"; +import { repoPath, repoRoot as resolveRepoRoot } from "../helpers/repo-root"; const repoRoot = resolveRepoRoot(); diff --git a/tests/repo-hygiene.test.ts b/tests/ci-workflows/repo-hygiene.test.ts similarity index 99% rename from tests/repo-hygiene.test.ts rename to tests/ci-workflows/repo-hygiene.test.ts index 10ed2e3ae15..6e1733384d0 100644 --- a/tests/repo-hygiene.test.ts +++ b/tests/ci-workflows/repo-hygiene.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; import { existsSync, statSync } from "node:fs"; import { join } from "node:path"; -import { repoRoot as resolveRepoRoot } from "./helpers/repo-root"; +import { repoRoot as resolveRepoRoot } from "../helpers/repo-root"; const repoRoot = resolveRepoRoot(); diff --git a/tests/skill-ocx.test.ts b/tests/ci-workflows/skill-ocx.test.ts similarity index 96% rename from tests/skill-ocx.test.ts rename to tests/ci-workflows/skill-ocx.test.ts index 6c452086091..9293dd080a2 100644 --- a/tests/skill-ocx.test.ts +++ b/tests/ci-workflows/skill-ocx.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "bun:test"; import { readFileSync, existsSync } from "node:fs"; import { join } from "node:path"; -import { renderManagementSurface } from "../scripts/generate-ocx-skill-surface"; -import { CAPABILITIES, HEAD_CAPABILITIES, capabilityInvocation } from "../src/cli/capabilities"; -import { CLI_COMMANDS } from "../src/cli/registry"; -import { repoPath } from "./helpers/repo-root"; +import { renderManagementSurface } from "../../scripts/generate-ocx-skill-surface"; +import { CAPABILITIES, HEAD_CAPABILITIES, capabilityInvocation } from "../../src/cli/capabilities"; +import { CLI_COMMANDS } from "../../src/cli/registry"; +import { repoPath } from "../helpers/repo-root"; /** * wp8: the repo-owned `ocx` skill. diff --git a/tests/test-home-guard.test.ts b/tests/ci-workflows/test-home-guard.test.ts similarity index 97% rename from tests/test-home-guard.test.ts rename to tests/ci-workflows/test-home-guard.test.ts index a99b98d7f6d..398e6a20994 100644 --- a/tests/test-home-guard.test.ts +++ b/tests/ci-workflows/test-home-guard.test.ts @@ -13,10 +13,11 @@ import { describe, expect, test } from "bun:test"; import { mkdtempSync, mkdirSync, readFileSync, statSync, symlinkSync, writeFileSync } from "node:fs"; import { homedir, tmpdir } from "node:os"; import { join } from "node:path"; -import { fileURLToPath } from "node:url"; -import { assertNotRealHomeUnderTest, isTestHomeGuardArmed, protectedHomeForTests } from "../src/lib/test-home-guard"; -import { getConfigDir } from "../src/config"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { assertNotRealHomeUnderTest, isTestHomeGuardArmed, protectedHomeForTests } from "../../src/lib/test-home-guard"; +import { getConfigDir } from "../../src/config"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoRoot } from "../helpers/repo-root"; /** * Two different things are needed from the repo root, and conflating them is @@ -29,13 +30,13 @@ import { removeTreeWithRetry } from "./helpers/remove-tree"; * though Bun sits exactly where setup-bun left it. That misdirection is why * this read as a missing-Bun problem for four CI runs. */ -const REPO_ROOT = fileURLToPath(new URL("..", import.meta.url)); +const REPO_ROOT = repoRoot(); /** * The probe source needs a module SPECIFIER, not a path. A Windows path * (`D:\a\...`) embedded in an import string would have its backslashes eaten as * escapes, so keep the `file://` URL form for anything interpolated into code. */ -const REPO_ROOT_URL = new URL("..", import.meta.url).href; +const REPO_ROOT_URL = pathToFileURL(repoRoot() + "/").href; /** * Run a probe in a child process so we control OCX_REAL_HOME at STARTUP — the guard @@ -303,7 +304,7 @@ const canSymlink = (() => { * to succeed", and the failure only reproduces when the lock throws. */ test("the preload arms the guard before it can throw on the run lock", async () => { - const source = await Bun.file(new URL("./preload.ts", import.meta.url)).text(); + const source = await Bun.file(new URL("../preload.ts", import.meta.url)).text(); const armAt = source.indexOf('process.env.OCX_TEST_HOME_GUARD = "1"'); const assertAt = source.indexOf("test home guard failed to arm"); diff --git a/tests/test-runner.test.ts b/tests/ci-workflows/test-runner.test.ts similarity index 99% rename from tests/test-runner.test.ts rename to tests/ci-workflows/test-runner.test.ts index 28b8328c445..798c7e67d86 100644 --- a/tests/test-runner.test.ts +++ b/tests/ci-workflows/test-runner.test.ts @@ -11,7 +11,8 @@ import { resolveBunTestPlan, selectChangedComparisonRef, SERIAL_FULL_SUITE_FILES, -} from "../scripts/test"; +} from "../../scripts/test"; +import { repoPath, repoRoot } from "../helpers/repo-root"; import { acquireTestRunLock, resolveBareTestRunIdentity, @@ -22,13 +23,13 @@ import { TEST_RUN_LOCK_TOKEN_ENV, TEST_RUN_NO_QUEUE_ENV, type TestRunRuntimeFileSystem, -} from "../scripts/test-run-lock"; +} from "../../scripts/test-run-lock"; import { decodeWindowsIdentityPowerShellOutputForTests, windowsIdentityPowerShellCommandForTests, windowsIdentityPowerShellSpawnOptionsForTests, -} from "../src/codex/user-identity"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/codex/user-identity"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function runGit(cwd: string, ...args: string[]): string { @@ -377,10 +378,10 @@ describe("bun test argv", () => { try { const result = Bun.spawnSync([ process.execPath, - join(import.meta.dir, "../scripts/test.ts"), + repoPath("scripts", "test.ts"), fixturePath, ], { - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), env: { ...process.env, OCX_TEST_NO_QUEUE: "1" }, stdout: "pipe", stderr: "pipe", diff --git a/tests/zz-ci-api-usage-isolation.test.ts b/tests/ci-workflows/zz-ci-api-usage-isolation.test.ts similarity index 84% rename from tests/zz-ci-api-usage-isolation.test.ts rename to tests/ci-workflows/zz-ci-api-usage-isolation.test.ts index 7529bd66384..d5c2b1e29df 100644 --- a/tests/zz-ci-api-usage-isolation.test.ts +++ b/tests/ci-workflows/zz-ci-api-usage-isolation.test.ts @@ -14,7 +14,7 @@ type Job = { test("Linux shards isolate api-usage into its own gated job", async () => { const text = await Bun.file( - new URL("../.github/workflows/ci.yml", import.meta.url), + new URL("../../.github/workflows/ci.yml", import.meta.url), ).text(); const workflow = Bun.YAML.parse(text) as { jobs?: Record; @@ -26,7 +26,7 @@ test("Linux shards isolate api-usage into its own gated job", async () => { expect(shardRun).toContain("scripts/ci/run-bun-test-batches.sh"); const batchHelper = await Bun.file( - new URL("../scripts/ci/run-bun-test-batches.sh", import.meta.url), + new URL("../../scripts/ci/run-bun-test-batches.sh", import.meta.url), ).text(); // Basename-anchored so the exclusion follows the file into tests/usage/. expect(batchHelper).toContain("*/api-usage.test.ts)"); @@ -38,7 +38,7 @@ test("Linux shards isolate api-usage into its own gated job", async () => { const apiUsageRun = apiUsageJob?.steps?.find( step => step.name === "Test api usage API", )?.run ?? ""; - expect(apiUsageRun).toBe("bun test --isolate ./tests/api-usage.test.ts"); + expect(apiUsageRun).toBe("bun test --isolate ./tests/server/api-usage.test.ts"); expect(apiUsageRun).not.toContain("--shard"); expect(workflow.jobs?.ci?.needs).toContain("api-usage"); diff --git a/tests/zz-ci-storage-policy-isolation.test.ts b/tests/ci-workflows/zz-ci-storage-policy-isolation.test.ts similarity index 78% rename from tests/zz-ci-storage-policy-isolation.test.ts rename to tests/ci-workflows/zz-ci-storage-policy-isolation.test.ts index e4a12b5e564..7e49737b478 100644 --- a/tests/zz-ci-storage-policy-isolation.test.ts +++ b/tests/ci-workflows/zz-ci-storage-policy-isolation.test.ts @@ -14,7 +14,7 @@ type Job = { test("Linux shards isolate the storage API runtime family into its own gated job", async () => { const text = await Bun.file( - new URL("../.github/workflows/ci.yml", import.meta.url), + new URL("../../.github/workflows/ci.yml", import.meta.url), ).text(); const workflow = Bun.YAML.parse(text) as { jobs?: Record; @@ -26,7 +26,7 @@ test("Linux shards isolate the storage API runtime family into its own gated job expect(shardRun).toContain("scripts/ci/run-bun-test-batches.sh"); const batchHelper = await Bun.file( - new URL("../scripts/ci/run-bun-test-batches.sh", import.meta.url), + new URL("../../scripts/ci/run-bun-test-batches.sh", import.meta.url), ).text(); // Basename-anchored so the exclusion follows the files into tests/storage/. expect(batchHelper).toContain("*/api-storage-policy*.test.ts"); @@ -40,12 +40,12 @@ test("Linux shards isolate the storage API runtime family into its own gated job step => step.name === "Test storage policy API", )?.run ?? ""; const dedicatedFiles = [ - "tests/api-storage-policy-already-running.test.ts", - "tests/api-storage-policy-mutation-busy.test.ts", - "tests/api-storage-policy-put-race.test.ts", - "tests/api-storage-policy-run.test.ts", - "tests/api-storage-policy.test.ts", - "tests/api-storage.test.ts", + "tests/storage/api-storage-policy-already-running.test.ts", + "tests/storage/api-storage-policy-mutation-busy.test.ts", + "tests/storage/api-storage-policy-put-race.test.ts", + "tests/storage/api-storage-policy-run.test.ts", + "tests/storage/api-storage-policy.test.ts", + "tests/storage/api-storage.test.ts", ]; // Extract all test file paths from the run command diff --git a/tests/zz-pr-coderabbit-readiness-revalidation.test.ts b/tests/ci-workflows/zz-pr-coderabbit-readiness-revalidation.test.ts similarity index 96% rename from tests/zz-pr-coderabbit-readiness-revalidation.test.ts rename to tests/ci-workflows/zz-pr-coderabbit-readiness-revalidation.test.ts index d4db288ba5a..cc2e2cfb273 100644 --- a/tests/zz-pr-coderabbit-readiness-revalidation.test.ts +++ b/tests/ci-workflows/zz-pr-coderabbit-readiness-revalidation.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; import { callsTo, runEnforcePrTarget, -} from "./helpers/enforce-pr-target-harness"; +} from "../helpers/enforce-pr-target-harness"; type WorkflowJob = { if?: string; @@ -69,7 +69,7 @@ function completedChecklistBody(): string { async function readGateScript(): Promise { const text = await Bun.file( - new URL("../.github/workflows/enforce-pr-target.yml", import.meta.url), + new URL("../../.github/workflows/enforce-pr-target.yml", import.meta.url), ).text(); const workflow = Bun.YAML.parse(text) as Workflow; const script = workflow.jobs?.["enforce-target"]?.steps?.find( @@ -96,7 +96,7 @@ function gateBodyFrom( describe("workflow comment-spam hardening", () => { test("PR gate consumes CodeRabbit commit status from the trusted default branch", async () => { const text = await Bun.file( - new URL("../.github/workflows/enforce-pr-target.yml", import.meta.url), + new URL("../../.github/workflows/enforce-pr-target.yml", import.meta.url), ).text(); const workflow = Bun.YAML.parse(text) as Workflow; @@ -259,7 +259,7 @@ describe("workflow comment-spam hardening", () => { test("issue-comment translation rejects PR and bot comments before runner allocation", async () => { const text = await Bun.file( - new URL("../.github/workflows/enforce-issue-quality.yml", import.meta.url), + new URL("../../.github/workflows/enforce-issue-quality.yml", import.meta.url), ).text(); const workflow = Bun.YAML.parse(text) as Workflow; const jobIf = workflow.jobs?.["translate-comment"]?.if ?? ""; @@ -271,7 +271,7 @@ describe("workflow comment-spam hardening", () => { test("contributor docs describe the label waiver and commit-status trust boundary", async () => { const docs = await Bun.file( - new URL("../docs-site/src/content/docs/contributing/pr-quality.md", import.meta.url), + new URL("../../docs-site/src/content/docs/contributing/pr-quality.md", import.meta.url), ).text(); expect(docs).toContain("gui-screenshot-waived"); diff --git a/tests/claude-integration/claude-cli.test.ts b/tests/claude-integration/claude-cli.test.ts index e4922aaccde..2e94faca5ce 100644 --- a/tests/claude-integration/claude-cli.test.ts +++ b/tests/claude-integration/claude-cli.test.ts @@ -31,7 +31,7 @@ describe("ocx claude proxy liveness", () => { const seen: (number | undefined)[] = []; const findLiveProxy = async (io?: LivenessIo): Promise => { seen.push(io?.attempts); - // retry semantics are covered by tests/proxy-liveness.test.ts:102-119; this pins that the launcher hands the stop-path budget down. + // retry semantics are covered by tests/server/proxy-liveness.test.ts:102-119; this pins that the launcher hands the stop-path budget down. return { pid: 4242, port: 10100, source: "runtime" }; }; diff --git a/tests/helpers/enforce-pr-target-harness.ts b/tests/helpers/enforce-pr-target-harness.ts index af295cb678f..59236b47ab9 100644 --- a/tests/helpers/enforce-pr-target-harness.ts +++ b/tests/helpers/enforce-pr-target-harness.ts @@ -283,7 +283,7 @@ const DEFAULT_BODY = [ "", "## Test plan", "", - "- [x] Run `bun test tests/ci-workflows.test.ts`", + "- [x] Run `bun test tests/ci-workflows/ci-workflows.test.ts`", "- [x] Confirm enforce-pr-target behaviour locally", ].join("\n"); diff --git a/tests/providers/aside-client.test.ts b/tests/providers/aside-client.test.ts index abf4146ba8c..0f47a99109b 100644 --- a/tests/providers/aside-client.test.ts +++ b/tests/providers/aside-client.test.ts @@ -106,7 +106,7 @@ describe("Aside client config", () => { * * This is the SERIALIZER half of the contract. It starts from a hand-built ExportModel, so * it would stay green if enrichment or the catalog dropped the ladder upstream; the - * end-to-end guard for that seam lives in tests/management-client-config-route.test.ts. + * end-to-end guard for that seam lives in tests/server/management-client-config-route.test.ts. */ test("an Anthropic row with a ladder gets an effort control, one without stays bare", () => { const withLadder = buildClientConfig("aside", { diff --git a/tests/account-import.test.ts b/tests/server/account-import.test.ts similarity index 97% rename from tests/account-import.test.ts rename to tests/server/account-import.test.ts index e8bb1c5f851..51732607396 100644 --- a/tests/account-import.test.ts +++ b/tests/server/account-import.test.ts @@ -2,9 +2,9 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { createAntigravityAccountImportAdapter } from "../src/oauth/account-import/google-antigravity-adapter"; -import { parseCockpitAccountDocument } from "../src/oauth/account-import/parser"; -import { importAccounts } from "../src/oauth/account-import/service"; +import { createAntigravityAccountImportAdapter } from "../../src/oauth/account-import/google-antigravity-adapter"; +import { parseCockpitAccountDocument } from "../../src/oauth/account-import/parser"; +import { importAccounts } from "../../src/oauth/account-import/service"; import { ACCOUNT_IMPORT_FORMAT, ACCOUNT_IMPORT_MAX_RECORDS, @@ -12,9 +12,9 @@ import { AccountImportAbortError, type AccountImportAdapter, type ValidatedAntigravityCredential, -} from "../src/oauth/account-import/types"; -import { getAccountSet, upsertCredentialByIdentity } from "../src/oauth/store"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/oauth/account-import/types"; +import { getAccountSet, upsertCredentialByIdentity } from "../../src/oauth/store"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const CANARY = "cockpit-canary-refresh-token-DO-NOT-LEAK"; const originalHome = process.env.OPENCODEX_HOME; diff --git a/tests/account-pool-management-api.test.ts b/tests/server/account-pool-management-api.test.ts similarity index 98% rename from tests/account-pool-management-api.test.ts rename to tests/server/account-pool-management-api.test.ts index 30accf7285b..e8eed3c05d1 100644 --- a/tests/account-pool-management-api.test.ts +++ b/tests/server/account-pool-management-api.test.ts @@ -1,14 +1,14 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleCodexAuthAPI } from "../src/codex/auth-api"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { handleCodexAuthAPI } from "../../src/codex/auth-api"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function makeCodexConfig(overrides: Partial = {}): OcxConfig { return { diff --git a/tests/adapter-resolve.test.ts b/tests/server/adapter-resolve.test.ts similarity index 98% rename from tests/adapter-resolve.test.ts rename to tests/server/adapter-resolve.test.ts index 927864eb9ff..26ed9fb1410 100644 --- a/tests/adapter-resolve.test.ts +++ b/tests/server/adapter-resolve.test.ts @@ -5,8 +5,8 @@ * provider-wide adapter wins and the hosted tool is dropped on the way out. */ import { describe, expect, test } from "bun:test"; -import { resolveWireProtocolOverride } from "../src/server/adapter-resolve"; -import type { OcxProviderConfig } from "../src/types"; +import { resolveWireProtocolOverride } from "../../src/server/adapter-resolve"; +import type { OcxProviderConfig } from "../../src/types"; function gateway(overrides: Partial = {}): OcxProviderConfig { return { diff --git a/tests/agent-task-recovery-cache.test.ts b/tests/server/agent-task-recovery-cache.test.ts similarity index 98% rename from tests/agent-task-recovery-cache.test.ts rename to tests/server/agent-task-recovery-cache.test.ts index 4c255c8a018..3107bff1a15 100644 --- a/tests/agent-task-recovery-cache.test.ts +++ b/tests/server/agent-task-recovery-cache.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { resetAgentTaskRecoveryCache, resolveCachedAgentTaskRecovery, -} from "../src/server/responses/agent-task-recovery-cache"; +} from "../../src/server/responses/agent-task-recovery-cache"; const realDateNow = Date.now; diff --git a/tests/agent-task-recovery-combo.test.ts b/tests/server/agent-task-recovery-combo.test.ts similarity index 94% rename from tests/agent-task-recovery-combo.test.ts rename to tests/server/agent-task-recovery-combo.test.ts index 2408b8d99b9..19a2f63317d 100644 --- a/tests/agent-task-recovery-combo.test.ts +++ b/tests/server/agent-task-recovery-combo.test.ts @@ -7,9 +7,9 @@ import { clearResponseStateMemoryForTests, responseContinuationRetainedStoreSnapshot, runPendingResponseStatePersistForTests, -} from "../src/responses/state"; -import { resetAgentTaskRecoveryState } from "../src/server/responses/agent-task-recovery"; -import { agentTaskRecoveryCacheSnapshotForTests } from "../src/server/responses/agent-task-recovery-cache"; +} from "../../src/responses/state"; +import { resetAgentTaskRecoveryState } from "../../src/server/responses/agent-task-recovery"; +import { agentTaskRecoveryCacheSnapshotForTests } from "../../src/server/responses/agent-task-recovery-cache"; import { codexHeaders, encryptedInput, @@ -19,8 +19,8 @@ import { providerResponse, recoverySse, routedConfig, -} from "./helpers/agent-task-recovery"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../helpers/agent-task-recovery"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function providerCompletion(): Response { return Response.json({ diff --git a/tests/agent-task-recovery-fallback.test.ts b/tests/server/agent-task-recovery-fallback.test.ts similarity index 91% rename from tests/agent-task-recovery-fallback.test.ts rename to tests/server/agent-task-recovery-fallback.test.ts index 62b7053c2a5..19495add896 100644 --- a/tests/agent-task-recovery-fallback.test.ts +++ b/tests/server/agent-task-recovery-fallback.test.ts @@ -2,8 +2,8 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { noteSubagentModelFailure, resetSubagentModelFallbackStateForTests, -} from "../src/codex/subagent-model-fallback"; -import { resetAgentTaskRecoveryState } from "../src/server/responses/agent-task-recovery"; +} from "../../src/codex/subagent-model-fallback"; +import { resetAgentTaskRecoveryState } from "../../src/server/responses/agent-task-recovery"; import { codexHeaders, encryptedInput, @@ -12,7 +12,7 @@ import { providerResponse, recoverySse, routedConfig, -} from "./helpers/agent-task-recovery"; +} from "../helpers/agent-task-recovery"; describe("agent task recovery fallback routing", () => { beforeEach(() => { diff --git a/tests/agent-task-recovery-security.test.ts b/tests/server/agent-task-recovery-security.test.ts similarity index 99% rename from tests/agent-task-recovery-security.test.ts rename to tests/server/agent-task-recovery-security.test.ts index ab6ddb2f9ed..8fd42dae0e9 100644 --- a/tests/agent-task-recovery-security.test.ts +++ b/tests/server/agent-task-recovery-security.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { resetAgentTaskRecoveryState } from "../src/server/responses/agent-task-recovery"; +import { resetAgentTaskRecoveryState } from "../../src/server/responses/agent-task-recovery"; import { codexHeaders, encryptedInput, @@ -11,7 +11,7 @@ import { recoverySse, routedConfig, ROUTING_ENVELOPE, -} from "./helpers/agent-task-recovery"; +} from "../helpers/agent-task-recovery"; const realDateNow = Date.now; diff --git a/tests/agent-task-recovery.test.ts b/tests/server/agent-task-recovery.test.ts similarity index 98% rename from tests/agent-task-recovery.test.ts rename to tests/server/agent-task-recovery.test.ts index fe6200b01af..e90b2bf9885 100644 --- a/tests/agent-task-recovery.test.ts +++ b/tests/server/agent-task-recovery.test.ts @@ -1,8 +1,8 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { createTranslatorBudget } from "../src/lib/translator-budget"; -import { warnAgentTaskRecoveryStartup } from "../src/server"; -import { resetAgentTaskRecoveryState } from "../src/server/responses/agent-task-recovery"; -import { agentTaskRecoveryWaiterCountForTests } from "../src/server/responses/agent-task-recovery-cache"; +import { createTranslatorBudget } from "../../src/lib/translator-budget"; +import { warnAgentTaskRecoveryStartup } from "../../src/server"; +import { resetAgentTaskRecoveryState } from "../../src/server/responses/agent-task-recovery"; +import { agentTaskRecoveryWaiterCountForTests } from "../../src/server/responses/agent-task-recovery-cache"; import { agentMessage, codexHeaders, @@ -17,7 +17,7 @@ import { routedConfig, ROUTING_ENVELOPE, SECOND_FERNET_TASK, -} from "./helpers/agent-task-recovery"; +} from "../helpers/agent-task-recovery"; describe("agent task recovery (opt-in, default off)", () => { beforeEach(() => { diff --git a/tests/alias-management-api.test.ts b/tests/server/alias-management-api.test.ts similarity index 91% rename from tests/alias-management-api.test.ts rename to tests/server/alias-management-api.test.ts index 512f1aea589..3f25e7bde6e 100644 --- a/tests/alias-management-api.test.ts +++ b/tests/server/alias-management-api.test.ts @@ -1,7 +1,7 @@ import { expect, test } from "bun:test"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { OcxConfig } from "../src/types"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; function config(): OcxConfig { return { port: 10100, defaultProvider: "alpha", apiKeys: [{ id: "test", name: "test", key: "test-key", createdAt: new Date(0).toISOString() }], providers: { diff --git a/tests/api-access-endpoints.test.ts b/tests/server/api-access-endpoints.test.ts similarity index 98% rename from tests/api-access-endpoints.test.ts rename to tests/server/api-access-endpoints.test.ts index a34e3698856..820aa2c6585 100644 --- a/tests/api-access-endpoints.test.ts +++ b/tests/server/api-access-endpoints.test.ts @@ -3,7 +3,7 @@ import { buildApiAccessEndpoints, formatAuthorityHost, resolveApiAccessBaseUrl, -} from "../src/server/management/api-access"; +} from "../../src/server/management/api-access"; describe("buildApiAccessEndpoints", () => { test("builds the external gateway URLs from hostname and port", () => { diff --git a/tests/api-catalog-route.test.ts b/tests/server/api-catalog-route.test.ts similarity index 94% rename from tests/api-catalog-route.test.ts rename to tests/server/api-catalog-route.test.ts index d51cfb8c7a3..f05dcb1febd 100644 --- a/tests/api-catalog-route.test.ts +++ b/tests/server/api-catalog-route.test.ts @@ -1,12 +1,12 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; -import { handleManagementAPI } from "../src/server/management-api"; -import { loadConfig, saveConfig } from "../src/config"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { ManagementRequest, managementHeaders } from "./helpers/management-auth"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { loadConfig, saveConfig } from "../../src/config"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { ManagementRequest, managementHeaders } from "../helpers/management-auth"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const TEST_DIR = join(import.meta.dir, `.tmp-api-catalog-route-${process.pid}`); const previousOpencodexHome = process.env.OPENCODEX_HOME; @@ -145,7 +145,7 @@ describe("GET|HEAD /v1/catalog least-privilege data-plane route (#809)", () => { writeFileSync(join(isolatedCodexHome.path, "opencodex-catalog.json"), JSON.stringify(catalogFixture)); saveConfig(dataPlaneConfig()); - const { startServer } = await import("../src/server"); + const { startServer } = await import("../../src/server"); const server = startServer(0); try { const res = await fetch(new URL("/v1/catalog", server.url), { @@ -201,7 +201,7 @@ describe("GET|HEAD /v1/catalog least-privilege data-plane route (#809)", () => { writeFileSync(join(isolatedCodexHome.path, "opencodex-catalog.json"), JSON.stringify(catalogFixture)); saveConfig(dataPlaneConfig()); - const { startServer } = await import("../src/server"); + const { startServer } = await import("../../src/server"); const server = startServer(0); try { const anonymous = await fetch(new URL("/v1/catalog", server.url)); @@ -254,7 +254,7 @@ describe("GET|HEAD /v1/catalog least-privilege data-plane route (#809)", () => { writeFileSync(join(isolatedCodexHome.path, "opencodex-catalog.json"), JSON.stringify(big)); saveConfig(dataPlaneConfig()); - const { serializePersistedCatalog, MAX_REMOTE_CATALOG_BYTES } = await import("../src/server/catalog-download"); + const { serializePersistedCatalog, MAX_REMOTE_CATALOG_BYTES } = await import("../../src/server/catalog-download"); const serialized = await serializePersistedCatalog(); expect(serialized.body).not.toBeNull(); expect(serialized.bytes!).toBeGreaterThan(32 * 1024 * 1024); @@ -274,7 +274,7 @@ describe("GET|HEAD /v1/catalog least-privilege data-plane route (#809)", () => { isolatedCodexHome = installIsolatedCodexHome("ocx-v1-catalog-missing-"); saveConfig(dataPlaneConfig()); - const { startServer } = await import("../src/server"); + const { startServer } = await import("../../src/server"); const server = startServer(0); try { const res = await fetch(new URL("/v1/catalog", server.url), { @@ -283,7 +283,7 @@ describe("GET|HEAD /v1/catalog least-privilege data-plane route (#809)", () => { expect(res.status).toBe(404); // catalog_not_found rather than the generic not_found: this is what distinguishes // "route exists, no catalog" from "route is gone", so a deleted route cannot pass - // the AUTH_MATRIX check in tests/api-key-attribution.test.ts vacuously. + // the AUTH_MATRIX check in tests/server/api-key-attribution.test.ts vacuously. const body = await res.json() as { error?: { code?: string } }; expect(body.error?.code).toBe("catalog_not_found"); } finally { diff --git a/tests/api-codex-log-guard-compact.test.ts b/tests/server/api-codex-log-guard-compact.test.ts similarity index 92% rename from tests/api-codex-log-guard-compact.test.ts rename to tests/server/api-codex-log-guard-compact.test.ts index d0fb68771b6..5c0aa7adfa8 100644 --- a/tests/api-codex-log-guard-compact.test.ts +++ b/tests/server/api-codex-log-guard-compact.test.ts @@ -4,11 +4,11 @@ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { CodexLogGuardMaintenanceDeps } from "../src/codex/log-guard/maintenance"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { OcxConfig } from "../src/types"; -import { ManagementRequest } from "./helpers/management-auth"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import type { CodexLogGuardMaintenanceDeps } from "../../src/codex/log-guard/maintenance"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; +import { ManagementRequest } from "../helpers/management-auth"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; const originalCodexHome = process.env.CODEX_HOME; diff --git a/tests/api-codex-log-guard-protection.test.ts b/tests/server/api-codex-log-guard-protection.test.ts similarity index 95% rename from tests/api-codex-log-guard-protection.test.ts rename to tests/server/api-codex-log-guard-protection.test.ts index 55d7e268e4d..e2d4e119b57 100644 --- a/tests/api-codex-log-guard-protection.test.ts +++ b/tests/server/api-codex-log-guard-protection.test.ts @@ -4,11 +4,11 @@ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { CodexLogGuardMode, CodexLogGuardProtectionDeps } from "../src/codex/log-guard/protection"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { OcxConfig } from "../src/types"; -import { ManagementRequest } from "./helpers/management-auth"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import type { CodexLogGuardMode, CodexLogGuardProtectionDeps } from "../../src/codex/log-guard/protection"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; +import { ManagementRequest } from "../helpers/management-auth"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; const originalCodexHome = process.env.CODEX_HOME; diff --git a/tests/api-codex-log-guard.test.ts b/tests/server/api-codex-log-guard.test.ts similarity index 95% rename from tests/api-codex-log-guard.test.ts rename to tests/server/api-codex-log-guard.test.ts index 4c78576855a..17ec172cad3 100644 --- a/tests/api-codex-log-guard.test.ts +++ b/tests/server/api-codex-log-guard.test.ts @@ -4,10 +4,10 @@ import { mkdirSync, mkdtempSync, unlinkSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { OcxConfig } from "../src/types"; -import { ManagementRequest } from "./helpers/management-auth"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; +import { ManagementRequest } from "../helpers/management-auth"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; const originalCodexHome = process.env.CODEX_HOME; diff --git a/tests/api-debug.test.ts b/tests/server/api-debug.test.ts similarity index 94% rename from tests/api-debug.test.ts rename to tests/server/api-debug.test.ts index a5dda168abf..736a0ac084d 100644 --- a/tests/api-debug.test.ts +++ b/tests/server/api-debug.test.ts @@ -1,19 +1,19 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { appendDebugLogLine, getDebugLogEntries, resetDebugLogBufferForTests } from "../src/lib/debug-log-buffer"; -import { clearDebugSettings, setDebugSettings } from "../src/lib/debug-settings"; -import { debugProviderDiagnostic } from "../src/lib/debug"; -import { getInjectionDebugLogEntries, injectionDebugLog, resetInjectionDebugLogBufferForTests } from "../src/lib/injection-debug-log"; -import { startServer } from "../src/server"; -import { appendUsageDebug } from "../src/usage/debug"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { RETAINED_TRUNCATION_MARKER, retainedUtf8Bytes } from "../src/lib/admission"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { appendDebugLogLine, getDebugLogEntries, resetDebugLogBufferForTests } from "../../src/lib/debug-log-buffer"; +import { clearDebugSettings, setDebugSettings } from "../../src/lib/debug-settings"; +import { debugProviderDiagnostic } from "../../src/lib/debug"; +import { getInjectionDebugLogEntries, injectionDebugLog, resetInjectionDebugLogBufferForTests } from "../../src/lib/injection-debug-log"; +import { startServer } from "../../src/server"; +import { appendUsageDebug } from "../../src/usage/debug"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { RETAINED_TRUNCATION_MARKER, retainedUtf8Bytes } from "../../src/lib/admission"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/api-key-attribution.test.ts b/tests/server/api-key-attribution.test.ts similarity index 98% rename from tests/api-key-attribution.test.ts rename to tests/server/api-key-attribution.test.ts index 4630e21f0f5..66c0a247595 100644 --- a/tests/api-key-attribution.test.ts +++ b/tests/server/api-key-attribution.test.ts @@ -2,15 +2,15 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { AUTH_MATRIX } from "../src/server/auth-cors"; -import { clearApiKeyUsageCacheForTests, readApiKeyUsageRollup, rollupApiKeyUsage } from "../src/server/management/api-key-usage"; -import { resetUsageAggregateCacheForTests } from "../src/server/management/usage-aggregate-cache"; -import * as usageLedgerScannerModule from "../src/usage/ledger-scanner"; -import { normalizeUsageEntryForTest, usageLogPath, type PersistedUsageEntry } from "../src/usage/log"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { AUTH_MATRIX } from "../../src/server/auth-cors"; +import { clearApiKeyUsageCacheForTests, readApiKeyUsageRollup, rollupApiKeyUsage } from "../../src/server/management/api-key-usage"; +import { resetUsageAggregateCacheForTests } from "../../src/server/management/usage-aggregate-cache"; +import * as usageLedgerScannerModule from "../../src/usage/ledger-scanner"; +import { normalizeUsageEntryForTest, usageLogPath, type PersistedUsageEntry } from "../../src/usage/log"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const ADMIN_TOKEN = "admin-secret-for-attribution"; const previousHome = process.env.OPENCODEX_HOME; diff --git a/tests/api-keys-routes.test.ts b/tests/server/api-keys-routes.test.ts similarity index 98% rename from tests/api-keys-routes.test.ts rename to tests/server/api-keys-routes.test.ts index 745f7c5a435..8ee35dae78e 100644 --- a/tests/api-keys-routes.test.ts +++ b/tests/server/api-keys-routes.test.ts @@ -2,13 +2,13 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { loadConfig, readConfigDiagnostics, saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { isDataPlaneAdmissionSecret } from "../src/server/auth-cors"; -import { ownAdmissionTokens } from "../src/claude/auth-detect"; -import { commitClientKeyRotation, startClientKeyRotation } from "../src/client/hub-client"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { loadConfig, readConfigDiagnostics, saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { isDataPlaneAdmissionSecret } from "../../src/server/auth-cors"; +import { ownAdmissionTokens } from "../../src/claude/auth-detect"; +import { commitClientKeyRotation, startClientKeyRotation } from "../../src/client/hub-client"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // The /api/keys handlers had no direct test before this file: GET masking, POST // persistence and DELETE semantics were only ever exercised through a CLI fixture @@ -259,7 +259,7 @@ describe("POST /api/keys", () => { }); test("the POST handler no longer reads provider API keys", async () => { - const source = readFileSync(new URL("../src/server/management/oauth-account-routes.ts", import.meta.url), "utf-8"); + const source = readFileSync(new URL("../../src/server/management/oauth-account-routes.ts", import.meta.url), "utf-8"); const start = source.indexOf('url.pathname === "/api/keys" && req.method === "POST"'); const end = source.indexOf('url.pathname === "/api/keys" && req.method === "PATCH"'); expect(start).toBeGreaterThan(-1); diff --git a/tests/api-usage.test.ts b/tests/server/api-usage.test.ts similarity index 97% rename from tests/api-usage.test.ts rename to tests/server/api-usage.test.ts index e379e529265..a86836a0dee 100644 --- a/tests/api-usage.test.ts +++ b/tests/server/api-usage.test.ts @@ -1,20 +1,20 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { appendFileSync, closeSync, mkdirSync, mkdtempSync, openSync, writeFileSync, writeSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { refreshUserCostOverlays, resetPreservedDiskOnlyProvidersForTests, userCostOverlayVersion } from "../src/usage/user-cost-overlays"; -import { stopUserCostOverlayReconciler } from "../src/usage/user-cost-overlay-reconciler"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; -import { resetUsageReadCacheForTests, setManagementUsageMaxEntriesForTests, usageReadCacheStatsForTests } from "../src/usage/log"; -import * as usageLogModule from "../src/usage/log"; -import * as usageLedgerScannerModule from "../src/usage/ledger-scanner"; -import { getUsageSummaryCacheEntry, resetUsageSummaryCacheForTests } from "../src/server/management/usage-summary-cache"; -import * as usageAggregateCacheModule from "../src/server/management/usage-aggregate-cache"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { refreshUserCostOverlays, resetPreservedDiskOnlyProvidersForTests, userCostOverlayVersion } from "../../src/usage/user-cost-overlays"; +import { stopUserCostOverlayReconciler } from "../../src/usage/user-cost-overlay-reconciler"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { resetUsageReadCacheForTests, setManagementUsageMaxEntriesForTests, usageReadCacheStatsForTests } from "../../src/usage/log"; +import * as usageLogModule from "../../src/usage/log"; +import * as usageLedgerScannerModule from "../../src/usage/ledger-scanner"; +import { getUsageSummaryCacheEntry, resetUsageSummaryCacheForTests } from "../../src/server/management/usage-summary-cache"; +import * as usageAggregateCacheModule from "../../src/server/management/usage-aggregate-cache"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/bounded-body.test.ts b/tests/server/bounded-body.test.ts similarity index 98% rename from tests/bounded-body.test.ts rename to tests/server/bounded-body.test.ts index bf75d86f923..f5223d34a4b 100644 --- a/tests/bounded-body.test.ts +++ b/tests/server/bounded-body.test.ts @@ -4,9 +4,9 @@ import { boundedBodyBufferGrowthsForTests, readBoundedResponseBytes, readBoundedResponseBody, -} from "../src/lib/bounded-body"; -import { UPSTREAM_JSON_BODY_READ_OPTIONS } from "../src/server/responses/core"; -import { readBoundedJsonRequestBody } from "../src/server/request-decompress"; +} from "../../src/lib/bounded-body"; +import { UPSTREAM_JSON_BODY_READ_OPTIONS } from "../../src/server/responses/core"; +import { readBoundedJsonRequestBody } from "../../src/server/request-decompress"; const encoder = new TextEncoder(); @@ -281,7 +281,7 @@ describe("readBoundedResponseBody", () => { // past the payload ceiling. It also never increments the growth counter above, // so that test alone cannot catch it. Pin the shape, the same instrument this // repository uses for the relay retention rule and the star-consent guard. - const source = (await Bun.file(new URL("../src/lib/bounded-body.ts", import.meta.url)).text()) + const source = (await Bun.file(new URL("../../src/lib/bounded-body.ts", import.meta.url)).text()) .replace(/\/\*[\s\S]*?\*\//g, "") .replace(/(^|[^:])\/\/.*$/gm, "$1"); diff --git a/tests/bridge-live-delivery.test.ts b/tests/server/bridge-live-delivery.test.ts similarity index 94% rename from tests/bridge-live-delivery.test.ts rename to tests/server/bridge-live-delivery.test.ts index 50a1c058a99..e2ba0f038e4 100644 --- a/tests/bridge-live-delivery.test.ts +++ b/tests/server/bridge-live-delivery.test.ts @@ -1,10 +1,10 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import type { ServerWebSocket } from "bun"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import { responsesSseToAnthropicSse } from "../src/claude/outbound"; -import { pumpResponsesSseToWebSocket, type WsData } from "../src/server/ws-bridge"; -import type { AdapterEvent } from "../src/types"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +import { bridgeToResponsesSSE } from "../../src/bridge"; +import { responsesSseToAnthropicSse } from "../../src/claude/outbound"; +import { pumpResponsesSseToWebSocket, type WsData } from "../../src/server/ws-bridge"; +import type { AdapterEvent } from "../../src/types"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; async function* burstGenerator(count: number): AsyncGenerator { for (let i = 0; i < count; i++) { diff --git a/tests/cancel-body-on-abort.test.ts b/tests/server/cancel-body-on-abort.test.ts similarity index 93% rename from tests/cancel-body-on-abort.test.ts rename to tests/server/cancel-body-on-abort.test.ts index ba30d003d4e..23dbb3e394a 100644 --- a/tests/cancel-body-on-abort.test.ts +++ b/tests/server/cancel-body-on-abort.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { cancelBodyOnAbort } from "../src/lib/abort"; -import { readBodyCapped } from "../src/server/live"; +import { cancelBodyOnAbort } from "../../src/lib/abort"; +import { readBodyCapped } from "../../src/server/live"; function bodyWithCancelSpy(): { body: ReadableStream; cancelled: () => boolean } { let cancelled = false; @@ -70,7 +70,7 @@ describe("readBodyCapped settles the stream when a read throws", () => { // no test noticed. Asserting the call site is crude but it is the thing that was actually // missing. test("the live relay attaches the body guard before consuming the upstream body", async () => { - const source = await Bun.file(new URL("../src/server/live.ts", import.meta.url)).text(); + const source = await Bun.file(new URL("../../src/server/live.ts", import.meta.url)).text(); const guardAt = source.indexOf("cancelBodyOnAbort(upstreamResponse.body"); const readAt = source.indexOf("payload = await readBodyCapped("); @@ -83,7 +83,7 @@ describe("readBodyCapped settles the stream when a read throws", () => { }); test("the bounded reader exclusively owns all non-combo Responses error bodies", async () => { - const source = await Bun.file(new URL("../src/server/responses/core.ts", import.meta.url)).text(); + const source = await Bun.file(new URL("../../src/server/responses/core.ts", import.meta.url)).text(); expect(source.match(/\breadDisplaySafeErrorText\(/g)).toHaveLength(4); expect(source).not.toContain("detachPassthroughErrorGuard"); @@ -98,10 +98,10 @@ describe("readBodyCapped settles the stream when a read throws", () => { // readBoundedResponseBody reads `response.body` itself with the abort signal threaded // through, and the combo contract is that the getter is touched exactly once (pinned by // "captures passthrough failed usage from its original bounded body exactly once" in - // tests/server-combo-failover-e2e.test.ts). An earlier revision guarded them anyway and + // tests/server/server-combo-failover-e2e.test.ts). An earlier revision guarded them anyway and // broke that test by adding a second `.body` read. test("the combo failure branches do not add a second body read", async () => { - const source = await Bun.file(new URL("../src/server/responses/core.ts", import.meta.url)).text(); + const source = await Bun.file(new URL("../../src/server/responses/core.ts", import.meta.url)).text(); for (const marker of ["const failure = await consumeComboFailure("]) { let from = 0; diff --git a/tests/config.test.ts b/tests/server/config.test.ts similarity index 99% rename from tests/config.test.ts rename to tests/server/config.test.ts index 67b9afe54ea..6f4bc436b68 100644 --- a/tests/config.test.ts +++ b/tests/server/config.test.ts @@ -30,15 +30,15 @@ import { validateConfigCandidate, writeRuntimePort, writePid, -} from "../src/config"; - -import * as windowsAcl from "../src/lib/windows-secret-acl"; -import { setTrustedWindowsSystemDirectoryResolverForTests } from "../src/lib/windows-elevation"; -import { AtomicWriteResidualTempError, atomicWriteFile, atomicWriteFileAsync, hardenConfigDir, hardenExistingSecret, renameAtomicFile, saveConfig } from "../src/config"; -import { nextAtomicTempSequence } from "../src/config/atomic-write"; -import { flushConfigDirHardeningForTests } from "../src/config/paths"; -import { providerManagementConfigError } from "../src/server/auth-cors"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/config"; + +import * as windowsAcl from "../../src/lib/windows-secret-acl"; +import { setTrustedWindowsSystemDirectoryResolverForTests } from "../../src/lib/windows-elevation"; +import { AtomicWriteResidualTempError, atomicWriteFile, atomicWriteFileAsync, hardenConfigDir, hardenExistingSecret, renameAtomicFile, saveConfig } from "../../src/config"; +import { nextAtomicTempSequence } from "../../src/config/atomic-write"; +import { flushConfigDirHardeningForTests } from "../../src/config/paths"; +import { providerManagementConfigError } from "../../src/server/auth-cors"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; /** @@ -2582,7 +2582,7 @@ describe("opencodex config defaults", () => { expect(isOcxStartCommandLine("opencodex start")).toBe(true); expect(isOcxStartCommandLine("bun run src/cli.ts status")).toBe(false); - expect(isOcxStartCommandLine("bun test C:/work/opencodex/tests/config.test.ts")).toBe(false); + expect(isOcxStartCommandLine("bun test C:/work/opencodex/tests/server/config.test.ts")).toBe(false); expect(isOcxStartCommandLine("notepad.exe")).toBe(false); }); diff --git a/tests/consume-for-inspection-cancel.test.ts b/tests/server/consume-for-inspection-cancel.test.ts similarity index 98% rename from tests/consume-for-inspection-cancel.test.ts rename to tests/server/consume-for-inspection-cancel.test.ts index 96632374e5d..166642d4fcf 100644 --- a/tests/consume-for-inspection-cancel.test.ts +++ b/tests/server/consume-for-inspection-cancel.test.ts @@ -5,8 +5,8 @@ import { getInspectionCounters, resetInspectionCountersForTest, type SseInspector, -} from "../src/server/relay"; -import type { RequestLogContext } from "../src/server/request-log"; +} from "../../src/server/relay"; +import type { RequestLogContext } from "../../src/server/request-log"; // Regression for issue #44: native-passthrough turns are inspected on a teed background stream. // Codex disconnects the instant it finishes reading, so the inspection stream is frequently diff --git a/tests/data-plane-admission-identity.test.ts b/tests/server/data-plane-admission-identity.test.ts similarity index 97% rename from tests/data-plane-admission-identity.test.ts rename to tests/server/data-plane-admission-identity.test.ts index ba6f97f3a6f..474ed0658a7 100644 --- a/tests/data-plane-admission-identity.test.ts +++ b/tests/server/data-plane-admission-identity.test.ts @@ -7,15 +7,15 @@ import { resolveApiAuth, resolveDataPlaneAdmissionSecret, resolveResponsesApiAuth, -} from "../src/server/auth-cors"; +} from "../../src/server/auth-cors"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { buildResponsesWsData } from "../src/server/ws-bridge"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { buildResponsesWsData } from "../../src/server/ws-bridge"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // The admission path already knew WHICH key matched and threw it away. These // tests pin two things at once: the id now survives, and no admission decision diff --git a/tests/debug-settings.test.ts b/tests/server/debug-settings.test.ts similarity index 98% rename from tests/debug-settings.test.ts rename to tests/server/debug-settings.test.ts index ab598ca7fae..e7b240fad9a 100644 --- a/tests/debug-settings.test.ts +++ b/tests/server/debug-settings.test.ts @@ -8,7 +8,7 @@ import { isUsageDebugEnabled, resetDebugSettingsForTests, setDebugSettings, -} from "../src/lib/debug-settings"; +} from "../../src/lib/debug-settings"; describe("debug settings", () => { const prevFrames = process.env.OCX_DEBUG_FRAMES; diff --git a/tests/error-fidelity.test.ts b/tests/server/error-fidelity.test.ts similarity index 96% rename from tests/error-fidelity.test.ts rename to tests/server/error-fidelity.test.ts index 5bcd58a0429..c3044aaa4e0 100644 --- a/tests/error-fidelity.test.ts +++ b/tests/server/error-fidelity.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, formatErrorResponse } from "../src/bridge"; -import { classifyError } from "../src/lib/errors"; -import { sanitizePassthroughHeaders } from "../src/server"; -import type { AdapterEvent } from "../src/types"; +import { bridgeToResponsesSSE, formatErrorResponse } from "../../src/bridge"; +import { classifyError } from "../../src/lib/errors"; +import { sanitizePassthroughHeaders } from "../../src/server"; +import type { AdapterEvent } from "../../src/types"; async function* replay(events: AdapterEvent[]): AsyncGenerator { for (const event of events) yield event; diff --git a/tests/errors-adapter-failure.test.ts b/tests/server/errors-adapter-failure.test.ts similarity index 98% rename from tests/errors-adapter-failure.test.ts rename to tests/server/errors-adapter-failure.test.ts index 62cc5425196..b712ce3def8 100644 --- a/tests/errors-adapter-failure.test.ts +++ b/tests/server/errors-adapter-failure.test.ts @@ -3,8 +3,8 @@ import { adapterFailureFromMessage, classifyError, parseRetryAfterFromMessage, -} from "../src/lib/errors"; -import { bufferCompactResponse } from "../src/server/responses"; +} from "../../src/lib/errors"; +import { bufferCompactResponse } from "../../src/server/responses"; describe("adapterFailureFromMessage", () => { test("maps resource_exhausted to 429 rate_limit_error", () => { diff --git a/tests/fetch-header-timeout.test.ts b/tests/server/fetch-header-timeout.test.ts similarity index 96% rename from tests/fetch-header-timeout.test.ts rename to tests/server/fetch-header-timeout.test.ts index 7fb549ba775..1ce097def08 100644 --- a/tests/fetch-header-timeout.test.ts +++ b/tests/server/fetch-header-timeout.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { fetchWithHeaderTimeout } from "../src/server/responses"; +import { fetchWithHeaderTimeout } from "../../src/server/responses"; const servers: Array> = []; @@ -127,7 +127,7 @@ describe("#2567 the upstream fetch disables Bun's per-request idle timeout", () } test("providerFetch passes timeout: 0 to the underlying fetch", async () => { - const { providerFetch } = await import("../src/server/responses/fetch-helpers"); + const { providerFetch } = await import("../../src/server/responses/fetch-helpers"); const { calls, fetch } = recordingFetch(); const provider = { adapter: "openai-chat", @@ -170,7 +170,7 @@ describe("#2567 the upstream fetch disables Bun's per-request idle timeout", () }); test("fetchWithHeaderDeadline passes timeout: 0 to its injected fetch", async () => { - const { fetchWithHeaderDeadline } = await import("../src/server/claude-messages"); + const { fetchWithHeaderDeadline } = await import("../../src/server/claude-messages"); const { calls, fetch } = recordingFetch(); const result = await fetchWithHeaderDeadline( diff --git a/tests/health-scoring.test.ts b/tests/server/health-scoring.test.ts similarity index 95% rename from tests/health-scoring.test.ts rename to tests/server/health-scoring.test.ts index a23484c1d69..b54436cc15c 100644 --- a/tests/health-scoring.test.ts +++ b/tests/server/health-scoring.test.ts @@ -2,19 +2,19 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { appendUsageEntry, resetUsageReadCacheForTests, type PersistedUsageEntry } from "../src/usage/log"; -import { closeRequestHistoryIndex } from "../src/routing/history/indexer"; +import { appendUsageEntry, resetUsageReadCacheForTests, type PersistedUsageEntry } from "../../src/usage/log"; +import { closeRequestHistoryIndex } from "../../src/routing/history/indexer"; import { clearHealthHistoryCacheForTests, codexPoolHealthEvidence, healthEvidenceForCandidate, healthScore, HEALTH_SCORE_CONSTANTS, -} from "../src/routing/health"; -import { evaluatePolicyProfile } from "../src/routing/evaluator"; -import { NoEligiblePolicyCandidateError, routeModel } from "../src/router"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/routing/health"; +import { evaluatePolicyProfile } from "../../src/routing/evaluator"; +import { NoEligiblePolicyCandidateError, routeModel } from "../../src/router"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; @@ -118,7 +118,7 @@ describe("health-aware scoring (RI-06)", () => { }); test("hard cooldown is authoritative: score 0 and evaluator exclusion", async () => { - const { clearCodexUpstreamHealth } = await import("../src/codex/routing"); + const { clearCodexUpstreamHealth } = await import("../../src/codex/routing"); clearCodexUpstreamHealth(); const now = Date.now(); const evidence = { @@ -248,7 +248,7 @@ describe("health-aware scoring (RI-06)", () => { }); test("execution path applies live codex account cooldown to openai candidates", async () => { - const { clearCodexUpstreamHealth, recordCodexUpstreamOutcome } = await import("../src/codex/routing"); + const { clearCodexUpstreamHealth, recordCodexUpstreamOutcome } = await import("../../src/codex/routing"); clearCodexUpstreamHealth(); const now = Date.now(); const cfg = config({ @@ -276,7 +276,7 @@ describe("health-aware scoring (RI-06)", () => { }); test("mixed pool cooldown/soft-avoid states degrade to soft-avoid", async () => { - const { clearCodexUpstreamHealth, recordCodexUpstreamOutcome } = await import("../src/codex/routing"); + const { clearCodexUpstreamHealth, recordCodexUpstreamOutcome } = await import("../../src/codex/routing"); clearCodexUpstreamHealth(); const now = Date.now(); const cfg = config({ diff --git a/tests/input-admission.test.ts b/tests/server/input-admission.test.ts similarity index 98% rename from tests/input-admission.test.ts rename to tests/server/input-admission.test.ts index d97e0fe82ef..9b8ac9c978d 100644 --- a/tests/input-admission.test.ts +++ b/tests/server/input-admission.test.ts @@ -4,9 +4,9 @@ import { checkInputAdmission, estimateInputTokens, resolveInputCeiling, -} from "../src/server/responses/input-admission"; -import { modelRecordValue } from "../src/reasoning-effort"; -import type { OcxMessage, OcxParsedRequest, OcxProviderConfig, OcxTool } from "../src/types"; +} from "../../src/server/responses/input-admission"; +import { modelRecordValue } from "../../src/reasoning-effort"; +import type { OcxMessage, OcxParsedRequest, OcxProviderConfig, OcxTool } from "../../src/types"; const CANONICAL_NATIVE: OcxProviderConfig = { adapter: "openai-responses", diff --git a/tests/local-management-attestation.test.ts b/tests/server/local-management-attestation.test.ts similarity index 96% rename from tests/local-management-attestation.test.ts rename to tests/server/local-management-attestation.test.ts index 0df59a8601f..b80261dbb4e 100644 --- a/tests/local-management-attestation.test.ts +++ b/tests/server/local-management-attestation.test.ts @@ -4,7 +4,7 @@ import { createLocalAttestationProof, createLocalAttestationSecret, verifyLocalAttestationProof, -} from "../src/lib/local-management-attestation"; +} from "../../src/lib/local-management-attestation"; describe("local management listener attestation", () => { test("a proof authenticates one challenge, pid, and port", () => { diff --git a/tests/local-management-capability.test.ts b/tests/server/local-management-capability.test.ts similarity index 97% rename from tests/local-management-capability.test.ts rename to tests/server/local-management-capability.test.ts index 88976fee869..41bf78c5912 100644 --- a/tests/local-management-capability.test.ts +++ b/tests/server/local-management-capability.test.ts @@ -4,13 +4,13 @@ import { LOCAL_MANAGEMENT_READ_PATHS, createLocalManagementReadCapability, verifyLocalManagementReadCapability, -} from "../src/lib/local-management-capability"; +} from "../../src/lib/local-management-capability"; import { SYSTEM_RESTART_METHOD, SYSTEM_RESTART_PATH, createSystemRestartCapability, verifySystemRestartCapability, -} from "../src/lib/system-restart-contract"; +} from "../../src/lib/system-restart-contract"; describe("local management read capability", () => { const secret = "A".repeat(43); diff --git a/tests/local-management-direct-transport.test.ts b/tests/server/local-management-direct-transport.test.ts similarity index 96% rename from tests/local-management-direct-transport.test.ts rename to tests/server/local-management-direct-transport.test.ts index 8a6b36062b3..2fda9cbcb37 100644 --- a/tests/local-management-direct-transport.test.ts +++ b/tests/server/local-management-direct-transport.test.ts @@ -4,7 +4,8 @@ import { createServer } from "node:http"; import { createConnection, createServer as createTcpServer, type Server, type Socket } from "node:net"; import { join } from "node:path"; import { pathToFileURL } from "node:url"; -import { directLocalHttpFetch } from "../src/server/direct-local-http"; +import { directLocalHttpFetch } from "../../src/server/direct-local-http"; +import { repoPath, repoRoot } from "../helpers/repo-root"; const PID = 4242; const SECRET = "A".repeat(43); @@ -294,9 +295,9 @@ describe("local management direct transport", () => { targetPort = await listen(target); proxyPort = await listen(proxy); - const proxyLivenessUrl = pathToFileURL(join(import.meta.dir, "..", "src", "server", "proxy-liveness.ts")).href; - const localClientUrl = pathToFileURL(join(import.meta.dir, "..", "src", "server", "local-management-read-client.ts")).href; - const capabilityUrl = pathToFileURL(join(import.meta.dir, "..", "src", "lib", "local-management-capability.ts")).href; + const proxyLivenessUrl = pathToFileURL(repoPath("src", "server", "proxy-liveness.ts")).href; + const localClientUrl = pathToFileURL(repoPath("src", "server", "local-management-read-client.ts")).href; + const capabilityUrl = pathToFileURL(repoPath("src", "lib", "local-management-capability.ts")).href; const childSource = ` const liveness = await import(${JSON.stringify(proxyLivenessUrl)}); const client = await import(${JSON.stringify(localClientUrl)}); @@ -331,7 +332,7 @@ describe("local management direct transport", () => { } const child = Bun.spawn([process.execPath, "--eval", childSource], { - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), env: childEnv, stdout: "pipe", stderr: "pipe", diff --git a/tests/local-provider-reload-client.test.ts b/tests/server/local-provider-reload-client.test.ts similarity index 94% rename from tests/local-provider-reload-client.test.ts rename to tests/server/local-provider-reload-client.test.ts index 192e987b21f..bc17839fd22 100644 --- a/tests/local-provider-reload-client.test.ts +++ b/tests/server/local-provider-reload-client.test.ts @@ -3,16 +3,16 @@ import { LOCAL_ATTESTATION_CHALLENGE_HEADER, LOCAL_ATTESTATION_PROOF_HEADER, createLocalAttestationProof, -} from "../src/lib/local-management-attestation"; +} from "../../src/lib/local-management-attestation"; import { LOCAL_PROVIDER_RELOAD_CAPABILITY_HEADER, LOCAL_PROVIDER_RELOAD_CAPABILITY_VERSION, LOCAL_PROVIDER_RELOAD_NAME_HEADER, LOCAL_PROVIDER_RELOAD_PATH, verifyLocalProviderReloadCapability, -} from "../src/lib/local-provider-reload-contract"; -import { requestBoundLocalProviderReload } from "../src/server/local-provider-reload-client"; -import type { LiveProxy } from "../src/server/proxy-liveness"; +} from "../../src/lib/local-provider-reload-contract"; +import { requestBoundLocalProviderReload } from "../../src/server/local-provider-reload-client"; +import type { LiveProxy } from "../../src/server/proxy-liveness"; const secret = "A".repeat(43); const nonce = "B".repeat(43); diff --git a/tests/logs-timezone.test.ts b/tests/server/logs-timezone.test.ts similarity index 94% rename from tests/logs-timezone.test.ts rename to tests/server/logs-timezone.test.ts index d31edfc0884..9372b6a0c11 100644 --- a/tests/logs-timezone.test.ts +++ b/tests/server/logs-timezone.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { handleManagementAPI } from "../src/server/management-api"; -import { ManagementRequest as Request } from "./helpers/management-auth"; -import type { OcxConfig } from "../src/types"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { ManagementRequest as Request } from "../helpers/management-auth"; +import type { OcxConfig } from "../../src/types"; const config = { providers: [] } as unknown as OcxConfig; diff --git a/tests/loopback-listener-admission.test.ts b/tests/server/loopback-listener-admission.test.ts similarity index 97% rename from tests/loopback-listener-admission.test.ts rename to tests/server/loopback-listener-admission.test.ts index ca7907b5da0..e0cf1f27cda 100644 --- a/tests/loopback-listener-admission.test.ts +++ b/tests/server/loopback-listener-admission.test.ts @@ -17,10 +17,10 @@ import { isAllowedRequestOrigin, requestPolicyView, resolveResponsesApiAuth, -} from "../src/server/auth-cors"; -import { buildProviderTableBlock, shouldInjectApiAuthHeader } from "../src/codex/inject"; -import { validateConfigCandidate } from "../src/config"; -import type { OcxConfig } from "../src/types"; +} from "../../src/server/auth-cors"; +import { buildProviderTableBlock, shouldInjectApiAuthHeader } from "../../src/codex/inject"; +import { validateConfigCandidate } from "../../src/config"; +import type { OcxConfig } from "../../src/types"; const wildcardConfig = { hostname: "0.0.0.0", @@ -60,7 +60,7 @@ describe("loopback listener policy view", () => { }); test("both Anthropic routes finish CORS with the listener-effective policy", () => { - const source = readFileSync(new URL("../src/server/index.ts", import.meta.url), "utf8"); + const source = readFileSync(new URL("../../src/server/index.ts", import.meta.url), "utf8"); const countTokensStart = source.indexOf('url.pathname === "/v1/messages/count_tokens"'); const messagesStart = source.indexOf('url.pathname === "/v1/messages"', countTokensStart + 1); const chatStart = source.indexOf('url.pathname === "/v1/chat/completions"', messagesStart); diff --git a/tests/loopback-listener-integration.test.ts b/tests/server/loopback-listener-integration.test.ts similarity index 99% rename from tests/loopback-listener-integration.test.ts rename to tests/server/loopback-listener-integration.test.ts index e98b7e18d31..46fb44e2136 100644 --- a/tests/loopback-listener-integration.test.ts +++ b/tests/server/loopback-listener-integration.test.ts @@ -13,17 +13,17 @@ import { spawnSync } from "node:child_process"; import { connect } from "node:net"; import { networkInterfaces, tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { runListenerShutdown } from "../src/server/lifecycle"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { runListenerShutdown } from "../../src/server/lifecycle"; import { findAvailablePort, PortUnavailableError, setEphemeralPortAllocatorForTests, -} from "../src/server/ports"; -import type { OcxConfig } from "../src/types"; -import { SERVER_BUDGET_MS } from "./helpers/test-budget"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/ports"; +import type { OcxConfig } from "../../src/types"; +import { SERVER_BUDGET_MS } from "../helpers/test-budget"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const previousApiToken = process.env.OPENCODEX_API_AUTH_TOKEN; const previousAdminToken = process.env.OPENCODEX_ADMIN_AUTH_TOKEN; diff --git a/tests/management-api-logs-metrics.test.ts b/tests/server/management-api-logs-metrics.test.ts similarity index 96% rename from tests/management-api-logs-metrics.test.ts rename to tests/server/management-api-logs-metrics.test.ts index 1f09fdd2322..a9fa2821b8e 100644 --- a/tests/management-api-logs-metrics.test.ts +++ b/tests/server/management-api-logs-metrics.test.ts @@ -2,16 +2,16 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { existsSync, mkdtempSync, readFileSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleManagementAPI } from "../src/server/management-api"; -import { usageLogPath } from "../src/usage/log"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { usageLogPath } from "../../src/usage/log"; import { addRequestLog, clearRequestLogsForTests, getRequestLogEntries, type RequestLogEntry, -} from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const config = { providers: [] } as unknown as OcxConfig; @@ -230,4 +230,4 @@ describe("GET /api/logs display metrics", () => { } }); }); -import { ManagementRequest as Request } from "./helpers/management-auth"; +import { ManagementRequest as Request } from "../helpers/management-auth"; diff --git a/tests/management-client-config-route.test.ts b/tests/server/management-client-config-route.test.ts similarity index 98% rename from tests/management-client-config-route.test.ts rename to tests/server/management-client-config-route.test.ts index 2d65323b4c9..93c3e79cdb7 100644 --- a/tests/management-client-config-route.test.ts +++ b/tests/server/management-client-config-route.test.ts @@ -6,9 +6,9 @@ import { GATED_MODEL_CLIENT_VERSION_FLOOR, resetCodexModelEntitlementCacheForTests, seedCodexModelEntitlementsForTests, -} from "../src/codex/model-entitlements"; -import { handleManagementAPI } from "../src/server/management-api"; -import { loadExportModels } from "../src/server/management/model-rows"; +} from "../../src/codex/model-entitlements"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { loadExportModels } from "../../src/server/management/model-rows"; import { OPENCODE_API_KEY_ENV, OPENCODE_CONFIG_SCHEMA, @@ -23,10 +23,10 @@ import { type McodeGeneratedConfig, type OpencodeGeneratedConfig, type PiGeneratedConfig, -} from "../src/clients/config-export"; -import type { OcxConfig } from "../src/types"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/clients/config-export"; +import type { OcxConfig } from "../../src/types"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** * A key that looks exactly like a real one. Every assertion about `ocx_` absence is diff --git a/tests/management-integration-journal-delete.test.ts b/tests/server/management-integration-journal-delete.test.ts similarity index 96% rename from tests/management-integration-journal-delete.test.ts rename to tests/server/management-integration-journal-delete.test.ts index 0ab66f0712a..613e48566a0 100644 --- a/tests/management-integration-journal-delete.test.ts +++ b/tests/server/management-integration-journal-delete.test.ts @@ -2,17 +2,17 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { ExportModel } from "../src/clients/config-export"; -import { INTEGRATION_CLIENTS } from "../src/integrations/registry"; -import { createIntegrationStateStore, type IntegrationStateStore } from "../src/integrations/store"; -import { handleManagementAPI } from "../src/server/management-api"; +import type { ExportModel } from "../../src/clients/config-export"; +import { INTEGRATION_CLIENTS } from "../../src/integrations/registry"; +import { createIntegrationStateStore, type IntegrationStateStore } from "../../src/integrations/store"; +import { handleManagementAPI } from "../../src/server/management-api"; import { setIntegrationMutationFlightTestHooks, setIntegrationPathTestHooks, -} from "../src/server/management/integration-routes"; -import type { OcxConfig } from "../src/types"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/management/integration-routes"; +import type { OcxConfig } from "../../src/types"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** * DELETE /api/client-integrations/journal -- the branches of diff --git a/tests/management-integration-routes.test.ts b/tests/server/management-integration-routes.test.ts similarity index 97% rename from tests/management-integration-routes.test.ts rename to tests/server/management-integration-routes.test.ts index 9f620e32451..70d4ff39939 100644 --- a/tests/management-integration-routes.test.ts +++ b/tests/server/management-integration-routes.test.ts @@ -3,21 +3,22 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, import { tmpdir } from "node:os"; import { fileURLToPath } from "node:url"; import { dirname, join } from "node:path"; -import type { ExportModel } from "../src/clients/config-export"; -import { fileIO, type IntegrationIO } from "../src/integrations/config-io"; -import { INTEGRATION_CLIENTS, INTEGRATION_CLIENT_IDS } from "../src/integrations/registry"; -import { readIntegrationState } from "../src/integrations/state"; -import { createIntegrationStateStore, type IntegrationStateStore } from "../src/integrations/store"; -import { applyIntegration } from "../src/integrations/writer"; -import type { IntegrationWriterLockSeams } from "../src/integrations/writer-lock"; -import { handleManagementAPI } from "../src/server/management-api"; +import type { ExportModel } from "../../src/clients/config-export"; +import { fileIO, type IntegrationIO } from "../../src/integrations/config-io"; +import { INTEGRATION_CLIENTS, INTEGRATION_CLIENT_IDS } from "../../src/integrations/registry"; +import { readIntegrationState } from "../../src/integrations/state"; +import { createIntegrationStateStore, type IntegrationStateStore } from "../../src/integrations/store"; +import { applyIntegration } from "../../src/integrations/writer"; +import type { IntegrationWriterLockSeams } from "../../src/integrations/writer-lock"; +import { handleManagementAPI } from "../../src/server/management-api"; import { setIntegrationMutationFlightTestHooks, setIntegrationPathTestHooks, -} from "../src/server/management/integration-routes"; -import type { OcxConfig } from "../src/types"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/management/integration-routes"; +import type { OcxConfig } from "../../src/types"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoPath, repoRoot } from "../helpers/repo-root"; /** * Route contract for devlog/_fin/260802_client_toggle_api/040 §6-§7. @@ -38,10 +39,10 @@ let store: IntegrationStateStore; * fall back to the JSON root payload (which silently voids the wire test). */ { - if (!existsSync(join(import.meta.dir, "..", "gui", "dist", "index.html"))) { + if (!existsSync(repoPath("gui", "dist", "index.html"))) { const build = Bun.spawnSync({ cmd: ["bun", "run", "build:gui"], - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), stdout: "inherit", stderr: "inherit", }); @@ -270,7 +271,7 @@ describe("GET /api/client-integrations", () => { /** The models the route itself derives, so expectations cannot drift from it. */ async function exportModels(): Promise { - const { loadExportModels } = await import("../src/server/management/model-rows"); + const { loadExportModels } = await import("../../src/server/management/model-rows"); return loadExportModels(config); } @@ -981,8 +982,8 @@ describe("admission", () => { process.env.OPENCODEX_ADMIN_AUTH_TOKEN = ["admission", "secret", "fixture"].join("-"); installHermes(); - const { saveConfig } = await import("../src/config"); - const { startServer } = await import("../src/server"); + const { saveConfig } = await import("../../src/config"); + const { startServer } = await import("../../src/server"); saveConfig(config); const server = startServer(0); try { @@ -1105,8 +1106,8 @@ describe("admission", () => { delete process.env.OPENCODEX_ADMIN_AUTH_TOKEN; installHermes(); - const { saveConfig } = await import("../src/config"); - const { startServer } = await import("../src/server"); + const { saveConfig } = await import("../../src/config"); + const { startServer } = await import("../../src/server"); saveConfig(config); const server = startServer(0); try { @@ -1140,7 +1141,7 @@ describe("admission", () => { // `fileURLToPath`, not `.pathname`: a Windows URL pathname is // `/D:/a/...`, which never exists as a filesystem path and would make // this guard vacuously true. - expect(existsSync(fileURLToPath(new URL("../gui/dist/index.html", import.meta.url)))).toBe(false); + expect(existsSync(fileURLToPath(new URL("../../gui/dist/index.html", import.meta.url)))).toBe(false); return; } diff --git a/tests/management-origin-tls.test.ts b/tests/server/management-origin-tls.test.ts similarity index 96% rename from tests/management-origin-tls.test.ts rename to tests/server/management-origin-tls.test.ts index ede00e3ef47..385cb408a4b 100644 --- a/tests/management-origin-tls.test.ts +++ b/tests/server/management-origin-tls.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { isAllowedManagementOrigin } from "../src/server/auth-cors"; -import type { OcxConfig } from "../src/types"; +import { isAllowedManagementOrigin } from "../../src/server/auth-cors"; +import type { OcxConfig } from "../../src/types"; function config(partial: Partial = {}): OcxConfig { return { diff --git a/tests/management-provider-validation.test.ts b/tests/server/management-provider-validation.test.ts similarity index 99% rename from tests/management-provider-validation.test.ts rename to tests/server/management-provider-validation.test.ts index 6f0db824f23..35a7924ebeb 100644 --- a/tests/management-provider-validation.test.ts +++ b/tests/server/management-provider-validation.test.ts @@ -1,21 +1,21 @@ import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test"; -import { managementFetch as fetch, ManagementRequest as Request } from "./helpers/management-auth"; +import { managementFetch as fetch, ManagementRequest as Request } from "../helpers/management-auth"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { readCodexAccountRecord, saveCodexAccountCredential } from "../src/codex/account-store"; -import { getTrackedCodexWebSocketCountForAccount } from "../src/codex/websocket-registry"; -import { clearAccountNeedsReauth, clearAccountQuota, getAccountQuota, isAccountNeedsReauth, markAccountNeedsReauth, updateAccountQuota } from "../src/codex/auth-api"; +import { readCodexAccountRecord, saveCodexAccountCredential } from "../../src/codex/account-store"; +import { getTrackedCodexWebSocketCountForAccount } from "../../src/codex/websocket-registry"; +import { clearAccountNeedsReauth, clearAccountQuota, getAccountQuota, isAccountNeedsReauth, markAccountNeedsReauth, updateAccountQuota } from "../../src/codex/auth-api"; import { CODEX_THREAD_AFFINITY_IDLE_TTL_MS, clearCodexUpstreamHealth, clearThreadAccountMap, getCodexUpstreamHealth, recordCodexUpstreamOutcome, -} from "../src/codex/routing"; -import { loadConfig, saveConfig } from "../src/config"; -import { deriveProviderPresets } from "../src/providers/derive"; -import { MAIN_CODEX_ACCOUNT_ID } from "../src/codex/main-account"; +} from "../../src/codex/routing"; +import { loadConfig, saveConfig } from "../../src/config"; +import { deriveProviderPresets } from "../../src/providers/derive"; +import { MAIN_CODEX_ACCOUNT_ID } from "../../src/codex/main-account"; import { assertServerAuthConfig, corsHeaders, @@ -27,27 +27,27 @@ import { rootFallbackPayload, safeConfigDTO, startServer, -} from "../src/server"; -import { handleManagementAPI } from "../src/server/management-api"; -import { providerManagementConfigError } from "../src/server/auth-cors"; -import { providerEmptyToolOutputConfigError } from "../src/config/provider-validation"; -import { providerServiceTierConfigError, withProviderServiceTierDTO } from "../src/server/management/provider-capability-config"; -import { clearModelCache, markProviderDiscoveryFailed, markProviderDiscoveryOk } from "../src/codex/model-cache"; +} from "../../src/server"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { providerManagementConfigError } from "../../src/server/auth-cors"; +import { providerEmptyToolOutputConfigError } from "../../src/config/provider-validation"; +import { providerServiceTierConfigError, withProviderServiceTierDTO } from "../../src/server/management/provider-capability-config"; +import { clearModelCache, markProviderDiscoveryFailed, markProviderDiscoveryOk } from "../../src/codex/model-cache"; import { resetCodexModelEntitlementCacheForTests, resolveCodexModelEntitlements, type CodexModelEntitlementCredentialSnapshot, -} from "../src/codex/model-entitlements"; -import type { OcxConfig } from "../src/types"; -import { fakeChatGptJwt } from "./helpers/fake-chatgpt-jwt"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import * as destinationPolicy from "../src/lib/destination-policy"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; -import { LOCAL_PROVIDER_RELOAD_NAME_HEADER, LOCAL_PROVIDER_RELOAD_PATH } from "../src/lib/local-provider-reload-contract"; -import { getAccountSet, saveCredential } from "../src/oauth/store"; -import { fastPolicyForModel } from "../src/providers/service-tier"; -import { resolveWireProtocolOverride } from "../src/server/adapter-resolve"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/codex/model-entitlements"; +import type { OcxConfig } from "../../src/types"; +import { fakeChatGptJwt } from "../helpers/fake-chatgpt-jwt"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import * as destinationPolicy from "../../src/lib/destination-policy"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; +import { LOCAL_PROVIDER_RELOAD_NAME_HEADER, LOCAL_PROVIDER_RELOAD_PATH } from "../../src/lib/local-provider-reload-contract"; +import { getAccountSet, saveCredential } from "../../src/oauth/store"; +import { fastPolicyForModel } from "../../src/providers/service-tier"; +import { resolveWireProtocolOverride } from "../../src/server/adapter-resolve"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // Full-suite Windows load: startServer + multi-step provider PATCH/GET flows exceed the // default 5s per-test budget (same flake class as 810fa115 / claude-management-api). @@ -1386,7 +1386,7 @@ describe("provider management validation", () => { // The stored value is only half the contract — assert the RUNTIME resolution too, since // router.ts backfills the registry default beneath user entries at resolve time. - const { routedProviderConfig } = await import("../src/router"); + const { routedProviderConfig } = await import("../../src/router"); const stored = loadConfig().providers.deepseek; expect(stored).toBeDefined(); expect(routedProviderConfig("deepseek", stored!).annotateEmptyToolOutputs).toBe(false); diff --git a/tests/management-route-registry.test.ts b/tests/server/management-route-registry.test.ts similarity index 97% rename from tests/management-route-registry.test.ts rename to tests/server/management-route-registry.test.ts index d5ccab6efee..497ead58c87 100644 --- a/tests/management-route-registry.test.ts +++ b/tests/server/management-route-registry.test.ts @@ -2,8 +2,9 @@ import { describe, expect, test } from "bun:test"; import { existsSync, readFileSync, readdirSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; -import { MANAGEMENT_ROUTES } from "../src/server/management/route-registry"; -import { scanRoutes, distinctRoutes } from "./helpers/management-route-scan"; +import { MANAGEMENT_ROUTES } from "../../src/server/management/route-registry"; +import { scanRoutes, distinctRoutes } from "../helpers/management-route-scan"; +import { repoRoot as resolveRepoRoot } from "../helpers/repo-root"; /** * Reconciles the declared route registry against source, in three directions. @@ -32,7 +33,7 @@ import { scanRoutes, distinctRoutes } from "./helpers/management-route-scan"; * The scanner fails loud: a path guard whose method it cannot resolve comes back with * `method: null` and test 4 fails on it. It never assumes GET. */ -const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const repoRoot = resolveRepoRoot(); /** Files that carry management routes. Kept explicit: two live outside `management/`. */ function routeCarryingFiles(): string[] { diff --git a/tests/memory-watchdog.test.ts b/tests/server/memory-watchdog.test.ts similarity index 96% rename from tests/memory-watchdog.test.ts rename to tests/server/memory-watchdog.test.ts index edc9cc757ad..e5c91705f91 100644 --- a/tests/memory-watchdog.test.ts +++ b/tests/server/memory-watchdog.test.ts @@ -8,18 +8,18 @@ import { observedMemoryCounter, startMemoryWatchdog, type MemorySampleBase, -} from "../src/server/memory-watchdog"; -import { handleManagementAPI } from "../src/server/management-api"; -import { selectEagerPath } from "../src/lib/bun-stream-caps"; -import type { OcxConfig } from "../src/types"; +} from "../../src/server/memory-watchdog"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { selectEagerPath } from "../../src/lib/bun-stream-caps"; +import type { OcxConfig } from "../../src/types"; import { appOwnedBytesSnapshot, registerRetainedStore, resetAppOwnedMemoryForTests, -} from "../src/lib/app-owned-memory"; -import { registerDefaultAppOwnedMemoryStores } from "../src/lib/app-owned-memory-stores"; -import { appendDebugLogLine, resetDebugLogBufferForTests } from "../src/lib/debug-log-buffer"; -import { resetUsageAggregateCacheForTests } from "../src/server/management/usage-aggregate-cache"; +} from "../../src/lib/app-owned-memory"; +import { registerDefaultAppOwnedMemoryStores } from "../../src/lib/app-owned-memory-stores"; +import { appendDebugLogLine, resetDebugLogBufferForTests } from "../../src/lib/debug-log-buffer"; +import { resetUsageAggregateCacheForTests } from "../../src/server/management/usage-aggregate-cache"; function config(): OcxConfig { return { @@ -351,4 +351,4 @@ describe("GET /api/system/memory", () => { expect(wire).not.toContain("model/provider-id"); }); }); -import { ManagementRequest as Request } from "./helpers/management-auth"; +import { ManagementRequest as Request } from "../helpers/management-auth"; diff --git a/tests/model-discovery-management-api.test.ts b/tests/server/model-discovery-management-api.test.ts similarity index 91% rename from tests/model-discovery-management-api.test.ts rename to tests/server/model-discovery-management-api.test.ts index ff512c0568d..ad132847bb7 100644 --- a/tests/model-discovery-management-api.test.ts +++ b/tests/server/model-discovery-management-api.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { OcxConfig } from "../src/types"; -import { ManagementRequest as Request } from "./helpers/management-auth"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; +import { ManagementRequest as Request } from "../helpers/management-auth"; function config(): OcxConfig { return { port: 10100, defaultProvider: "vendor", providers: { vendor: { liveModels: false, models: ["known"] } }, disabledModels: ["vendor/new"] }; diff --git a/tests/outbound-body-guard.test.ts b/tests/server/outbound-body-guard.test.ts similarity index 98% rename from tests/outbound-body-guard.test.ts rename to tests/server/outbound-body-guard.test.ts index 45b832e6374..56abb3f9990 100644 --- a/tests/outbound-body-guard.test.ts +++ b/tests/server/outbound-body-guard.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; import { checkOutboundBodySize, describeOutboundBodyRefusal, -} from "../src/server/responses/outbound-body-guard"; +} from "../../src/server/responses/outbound-body-guard"; describe("outbound body guard", () => { test("an unconfigured limit admits without measuring", () => { diff --git a/tests/owned-service-home.test.ts b/tests/server/owned-service-home.test.ts similarity index 94% rename from tests/owned-service-home.test.ts rename to tests/server/owned-service-home.test.ts index 721c5dbcf48..6822aeadcee 100644 --- a/tests/owned-service-home.test.ts +++ b/tests/server/owned-service-home.test.ts @@ -3,10 +3,11 @@ import { copyFileSync, mkdirSync, mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; -import { claimOwnedServiceHome, withOwnedServiceHomePreload } from "./helpers/owned-service-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { claimOwnedServiceHome, withOwnedServiceHomePreload } from "../helpers/owned-service-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { helperPath, repoRoot as resolveRepoRoot } from "../helpers/repo-root"; -const repoRoot = resolve(import.meta.dir, ".."); +const repoRoot = resolveRepoRoot(); test("Windows owned-service-home fixture masks manager queries in a real child", async () => { const root = mkdtempSync(join(tmpdir(), "ocx-owned-service-home-seam-")); @@ -25,7 +26,7 @@ test("Windows owned-service-home fixture masks manager queries in a real child", const spacedCheckout = join(root, "checkout with spaces"); mkdirSync(spacedCheckout, { recursive: true }); const spacedPreload = join(spacedCheckout, "owned-service-home-preload.ts"); - copyFileSync(join(import.meta.dir, "helpers", "owned-service-home-preload.ts"), spacedPreload); + copyFileSync(helperPath("owned-service-home-preload.ts"), spacedPreload); const child = Bun.spawn([process.execPath, ...withOwnedServiceHomePreload(["--eval", ` import { join } from "node:path"; diff --git a/tests/passive-route-linker.test.ts b/tests/server/passive-route-linker.test.ts similarity index 90% rename from tests/passive-route-linker.test.ts rename to tests/server/passive-route-linker.test.ts index d3185fc3137..a8c6dec2033 100644 --- a/tests/passive-route-linker.test.ts +++ b/tests/server/passive-route-linker.test.ts @@ -4,8 +4,8 @@ import { resolvePassiveRouteSubjectId, hasPassiveRouteLinker, resetPassiveRouteLinkerForTests, -} from "../src/server/passive-route-linker"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; +} from "../../src/server/passive-route-linker"; +import type { OcxConfig, OcxProviderConfig } from "../../src/types"; const config = {} as OcxConfig; const routed = { baseUrl: "https://example.test" } as OcxProviderConfig; @@ -65,7 +65,7 @@ describe("core request path boundary", () => { // Guard 1 for this phase: the per-request module must not name Lab or the // compatibility layer at all. Driven red by restoring the old import. test("responses/core.ts does not import lab or routing/compatibility", async () => { - const source = await Bun.file(new URL("../src/server/responses/core.ts", import.meta.url)).text(); + const source = await Bun.file(new URL("../../src/server/responses/core.ts", import.meta.url)).text(); expect(source).not.toContain("routing/compatibility"); expect(source).not.toContain('from "../../lab/'); expect(source).not.toContain("resolveProductionRouteSubject"); @@ -74,7 +74,7 @@ describe("core request path boundary", () => { }); test("the Lab-side registration owns the subject construction", async () => { - const source = await Bun.file(new URL("../src/lib/lab-passive-linker-registration.ts", import.meta.url)).text(); + const source = await Bun.file(new URL("../../src/lib/lab-passive-linker-registration.ts", import.meta.url)).text(); expect(source).toContain("resolveProductionRouteSubject"); expect(source).toContain("setPassiveRouteLinker"); }); diff --git a/tests/port-reclaim.test.ts b/tests/server/port-reclaim.test.ts similarity index 99% rename from tests/port-reclaim.test.ts rename to tests/server/port-reclaim.test.ts index 5402e71a86d..56833cf4906 100644 --- a/tests/port-reclaim.test.ts +++ b/tests/server/port-reclaim.test.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from "bun:test"; -import { reclaimListenPort } from "../src/server/port-reclaim"; +import { reclaimListenPort } from "../../src/server/port-reclaim"; import { isBareIpv6Address, parseTcpQuadsForLocalPort, dropWindowsTcpRowsForLocalPort, -} from "../src/server/windows-tcp-drop"; -import { parseListenPidsFromNetstat } from "../src/server/port-reclaim"; +} from "../../src/server/windows-tcp-drop"; +import { parseListenPidsFromNetstat } from "../../src/server/port-reclaim"; describe("parseListenPidsFromNetstat", () => { test("extracts Windows LISTENING owners for the local port", () => { diff --git a/tests/ports.test.ts b/tests/server/ports.test.ts similarity index 99% rename from tests/ports.test.ts rename to tests/server/ports.test.ts index c6c36883a3f..6d573ad7525 100644 --- a/tests/ports.test.ts +++ b/tests/server/ports.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, test } from "bun:test"; import { createServer, type Server } from "node:net"; -import { findAvailablePort, isAddrInUse, isPortAvailable, PortUnavailableError, shouldPersistSelectedPort, waitForPortAvailable } from "../src/server/ports"; +import { findAvailablePort, isAddrInUse, isPortAvailable, PortUnavailableError, shouldPersistSelectedPort, waitForPortAvailable } from "../../src/server/ports"; const servers: Server[] = []; diff --git a/tests/proxy-env.test.ts b/tests/server/proxy-env.test.ts similarity index 97% rename from tests/proxy-env.test.ts rename to tests/server/proxy-env.test.ts index 1439013162c..e43ad2d9be3 100644 --- a/tests/proxy-env.test.ts +++ b/tests/server/proxy-env.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { applyProxyEnv } from "../src/config"; -import type { OcxConfig } from "../src/types"; +import { applyProxyEnv } from "../../src/config"; +import type { OcxConfig } from "../../src/types"; const PROXY_ENV_KEYS = ["HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "no_proxy", "OCX_TEST_PROXY_REF", "OCX_TEST_NO_PROXY_REF"] as const; let saved: Record; @@ -153,8 +153,8 @@ describe("applyProxyEnv", () => { }); describe("applyProxyEnv with proxy: \"auto\" (#1525)", () => { - const { applyProxyEnvWith } = require("../src/config") as typeof import("../src/config"); - const { parseWindowsProxyServer, readWindowsSystemProxy } = require("../src/lib/windows-system-proxy") as typeof import("../src/lib/windows-system-proxy"); + const { applyProxyEnvWith } = require("../../src/config") as typeof import("../../src/config"); + const { parseWindowsProxyServer, readWindowsSystemProxy } = require("../../src/lib/windows-system-proxy") as typeof import("../../src/lib/windows-system-proxy"); function capture(run: () => void): string[] { const lines: string[] = []; diff --git a/tests/proxy-liveness.test.ts b/tests/server/proxy-liveness.test.ts similarity index 99% rename from tests/proxy-liveness.test.ts rename to tests/server/proxy-liveness.test.ts index e590a8be487..ec24c75eaf9 100644 --- a/tests/proxy-liveness.test.ts +++ b/tests/server/proxy-liveness.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; import { createReadinessGate, runStartupReadinessSync, -} from "../src/server/readiness"; +} from "../../src/server/readiness"; import { findLiveProxy, isOpencodexHealthz, @@ -10,13 +10,13 @@ import { probeReadiness, proxyIdentityAt, validateReadyzBody, -} from "../src/server/proxy-liveness"; +} from "../../src/server/proxy-liveness"; import { checkRemoteProtocolCompatibility, parseRemoteReadyMetadata, readyProtocolMetadata, -} from "../src/remote/protocol"; -import { getDefaultConfig } from "../src/config"; +} from "../../src/remote/protocol"; +import { getDefaultConfig } from "../../src/config"; function healthz(body: unknown, status = 200): Response { return new Response(JSON.stringify(body), { status }); diff --git a/tests/relay-eager.test.ts b/tests/server/relay-eager.test.ts similarity index 99% rename from tests/relay-eager.test.ts rename to tests/server/relay-eager.test.ts index f3cfbd91c7e..f8086c1f2bf 100644 --- a/tests/relay-eager.test.ts +++ b/tests/server/relay-eager.test.ts @@ -10,13 +10,13 @@ import { createSseInspector, doneFrame, MAX_TAIL_ERROR_MESSAGE_CHARS, -} from "../src/server/relay"; -import { relaySseEagerBounded, type EagerRelayHooks } from "../src/server/relay-eager"; -import { createTranslatorBudget } from "../src/lib/translator-budget"; -import type { RequestLogContext } from "../src/server/request-log"; -import { MAX_CLIENT_SSE_FRAME_BYTES } from "../src/server/sse-frame-buffer"; +} from "../../src/server/relay"; +import { relaySseEagerBounded, type EagerRelayHooks } from "../../src/server/relay-eager"; +import { createTranslatorBudget } from "../../src/lib/translator-budget"; +import type { RequestLogContext } from "../../src/server/request-log"; +import { MAX_CLIENT_SSE_FRAME_BYTES } from "../../src/server/sse-frame-buffer"; -import { watchdogMs } from "./helpers/ci-watchdog"; +import { watchdogMs } from "../helpers/ci-watchdog"; const enc = new TextEncoder(); function sse(event: string): Uint8Array { @@ -129,8 +129,8 @@ describe("relaySseEagerBounded — inline payload rewrite (#864)", () => { // either way, which is exactly why no behavioral assertion catches a regression // here — relay.ts already states the rule in prose at its own drain, and this // pins it for both files. The sanctioned shape is: cancel the reader on abort. - const eager = await Bun.file(new URL("../src/server/relay-eager.ts", import.meta.url)).text(); - const relay = await Bun.file(new URL("../src/server/relay.ts", import.meta.url)).text(); + const eager = await Bun.file(new URL("../../src/server/relay-eager.ts", import.meta.url)).text(); + const relay = await Bun.file(new URL("../../src/server/relay.ts", import.meta.url)).text(); // Strip comments first: both files DESCRIBE the banned shape in prose, and the // rule is about the code, not the explanation of why the code avoids it. diff --git a/tests/response-model-identity.test.ts b/tests/server/response-model-identity.test.ts similarity index 96% rename from tests/response-model-identity.test.ts rename to tests/server/response-model-identity.test.ts index 9f5a5eb0425..11d021563d8 100644 --- a/tests/response-model-identity.test.ts +++ b/tests/server/response-model-identity.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { handleResponses } from "../src/server/responses/core"; -import type { RequestLogContext } from "../src/server/request-log"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; +import { handleResponses } from "../../src/server/responses/core"; +import type { RequestLogContext } from "../../src/server/request-log"; +import type { OcxConfig, OcxProviderConfig } from "../../src/types"; const originalFetch = globalThis.fetch; diff --git a/tests/retry-after-429.test.ts b/tests/server/retry-after-429.test.ts similarity index 97% rename from tests/retry-after-429.test.ts rename to tests/server/retry-after-429.test.ts index 1820d267542..168fe06b6a4 100644 --- a/tests/retry-after-429.test.ts +++ b/tests/server/retry-after-429.test.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from "bun:test"; -import { formatErrorResponse } from "../src/bridge"; +import { formatErrorResponse } from "../../src/bridge"; import { DEFAULT_RETRYABLE_429_RETRY_AFTER_SEC, resolveClientRetryAfter, -} from "../src/lib/retry-after"; -import { formatPassthroughUpstreamError } from "../src/server/responses/passthrough-error"; -import { consumeComboFailure } from "../src/server/responses/core"; +} from "../../src/lib/retry-after"; +import { formatPassthroughUpstreamError } from "../../src/server/responses/passthrough-error"; +import { consumeComboFailure } from "../../src/server/responses/core"; describe("resolveClientRetryAfter (#507)", () => { test("prefers a validated upstream Retry-After header", () => { diff --git a/tests/route-decision-trace.test.ts b/tests/server/route-decision-trace.test.ts similarity index 98% rename from tests/route-decision-trace.test.ts rename to tests/server/route-decision-trace.test.ts index 132acf67fb7..6918a9f77b9 100644 --- a/tests/route-decision-trace.test.ts +++ b/tests/server/route-decision-trace.test.ts @@ -2,8 +2,8 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { routeModel } from "../src/router"; -import { requestLogEntryFromPersistedUsage } from "../src/server/request-log"; +import { routeModel } from "../../src/router"; +import { requestLogEntryFromPersistedUsage } from "../../src/server/request-log"; import { appendUsageEntry, normalizeUsageEntryForTest, @@ -11,7 +11,7 @@ import { readUsageEntries, resetUsageReadCacheForTests, type PersistedUsageEntry, -} from "../src/usage/log"; +} from "../../src/usage/log"; import { MAX_EXCLUSIONS_PER_CANDIDATE, MAX_TRACE_CANDIDATES, @@ -21,9 +21,9 @@ import { buildRouteDecisionTrace, normalizeRouteDecisionTrace, type RouteDecisionTraceV1, -} from "../src/routing/trace"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/routing/trace"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** Near-budget trace: 8 candidates x 16 exclusions with max-length strings. */ function oversizedTrace(): RouteDecisionTraceV1 { diff --git a/tests/server-403-permission-e2e.test.ts b/tests/server/server-403-permission-e2e.test.ts similarity index 89% rename from tests/server-403-permission-e2e.test.ts rename to tests/server/server-403-permission-e2e.test.ts index cc964291b7e..4cf61d88241 100644 --- a/tests/server-403-permission-e2e.test.ts +++ b/tests/server/server-403-permission-e2e.test.ts @@ -1,16 +1,16 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { logsFromApiBody } from "./helpers/logs-api"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { logsFromApiBody } from "../helpers/logs-api"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { classifyError } from "../src/lib/errors"; -import { startServer } from "../src/server"; -import { clearRequestLogsForTests } from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { classifyError } from "../../src/lib/errors"; +import { startServer } from "../../src/server"; +import { clearRequestLogsForTests } from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const SUBSCRIPTION_MESSAGE = "this model requires a subscription, upgrade for access: https://ollama.com/upgrade"; diff --git a/tests/server-auth.test.ts b/tests/server/server-auth.test.ts similarity index 98% rename from tests/server-auth.test.ts rename to tests/server/server-auth.test.ts index 6fd98e29c86..f75ec368b0e 100644 --- a/tests/server-auth.test.ts +++ b/tests/server/server-auth.test.ts @@ -1,15 +1,15 @@ -import { waitForNativeMainStartupGate } from "../src/codex/native-profile-startup"; +import { waitForNativeMainStartupGate } from "../../src/codex/native-profile-startup"; import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; import { createHash } from "node:crypto"; -import { logsFromApiBody } from "./helpers/logs-api"; +import { logsFromApiBody } from "../helpers/logs-api"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { request as httpRequest } from "node:http"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import { clearCodexWebSocketRegistry, getTrackedCodexWebSocketCountForAccount } from "../src/codex/websocket-registry"; -import { INTERNAL_DEADLINE_MS, SERVER_BUDGET_MS } from "./helpers/test-budget"; -import { clearAccountNeedsReauth, clearAccountQuota, getAccountQuota, isAccountNeedsReauth, markAccountNeedsReauth, updateAccountQuota } from "../src/codex/auth-api"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import { clearCodexWebSocketRegistry, getTrackedCodexWebSocketCountForAccount } from "../../src/codex/websocket-registry"; +import { INTERNAL_DEADLINE_MS, SERVER_BUDGET_MS } from "../helpers/test-budget"; +import { clearAccountNeedsReauth, clearAccountQuota, getAccountQuota, isAccountNeedsReauth, markAccountNeedsReauth, updateAccountQuota } from "../../src/codex/auth-api"; import { CODEX_THREAD_AFFINITY_IDLE_TTL_MS, clearCodexUpstreamHealth, @@ -18,11 +18,11 @@ import { getCodexUpstreamHealth, isCodexAccountSoftAvoided, recordCodexUpstreamOutcome, -} from "../src/codex/routing"; -import { loadConfig, saveConfig } from "../src/config"; -import { clearUpstreamHostHealth, getUpstreamHostHealth, recordUpstreamHostFailure, upstreamHostHealthKey } from "../src/codex/upstream-host-health"; -import { deriveProviderPresets } from "../src/providers/derive"; -import { MAIN_CODEX_ACCOUNT_ID } from "../src/codex/main-account"; +} from "../../src/codex/routing"; +import { loadConfig, saveConfig } from "../../src/config"; +import { clearUpstreamHostHealth, getUpstreamHostHealth, recordUpstreamHostFailure, upstreamHostHealthKey } from "../../src/codex/upstream-host-health"; +import { deriveProviderPresets } from "../../src/providers/derive"; +import { MAIN_CODEX_ACCOUNT_ID } from "../../src/codex/main-account"; import { assertServerAuthConfig, corsHeaders, @@ -34,24 +34,24 @@ import { rootFallbackPayload, safeConfigDTO, startServer, -} from "../src/server"; -import { clearRequestLogsForTests, getRequestLogEntries } from "../src/server/request-log"; -import { readUsageEntries } from "../src/usage/log"; -import { handleManagementAPI } from "../src/server/management-api"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; -import { fakeChatGptJwt } from "./helpers/fake-chatgpt-jwt"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { ownedServiceHomeInspection } from "./helpers/owned-service-home-inspection"; -import { configuredAdminToken } from "../src/lib/admin-secrets"; -import { SYSTEM_RESTART_CAPABILITY_VERSION } from "../src/lib/system-restart-contract"; -import { LOCAL_PROVIDER_RELOAD_CAPABILITY_VERSION } from "../src/lib/local-provider-reload-contract"; -import { GUI_PAIR_CAPABILITY_VERSION } from "../src/lib/gui-pair-capability"; -import { resetCodexModelEntitlementCacheForTests } from "../src/codex/model-entitlements"; -import { getDebugLogEntries, resetDebugLogBufferForTests } from "../src/lib/debug-log-buffer"; -import { resetDebugSettingsForTests, setDebugSettings } from "../src/lib/debug-settings"; -import { watchdogMs } from "./helpers/ci-watchdog"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server"; +import { clearRequestLogsForTests, getRequestLogEntries } from "../../src/server/request-log"; +import { readUsageEntries } from "../../src/usage/log"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; +import { fakeChatGptJwt } from "../helpers/fake-chatgpt-jwt"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { ownedServiceHomeInspection } from "../helpers/owned-service-home-inspection"; +import { configuredAdminToken } from "../../src/lib/admin-secrets"; +import { SYSTEM_RESTART_CAPABILITY_VERSION } from "../../src/lib/system-restart-contract"; +import { LOCAL_PROVIDER_RELOAD_CAPABILITY_VERSION } from "../../src/lib/local-provider-reload-contract"; +import { GUI_PAIR_CAPABILITY_VERSION } from "../../src/lib/gui-pair-capability"; +import { resetCodexModelEntitlementCacheForTests } from "../../src/codex/model-entitlements"; +import { getDebugLogEntries, resetDebugLogBufferForTests } from "../../src/lib/debug-log-buffer"; +import { resetDebugSettingsForTests, setDebugSettings } from "../../src/lib/debug-settings"; +import { watchdogMs } from "../helpers/ci-watchdog"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const previousApiToken = process.env.OPENCODEX_API_AUTH_TOKEN; const previousOpencodexHome = process.env.OPENCODEX_HOME; const originalGlobalFetch = globalThis.fetch; @@ -1006,7 +1006,7 @@ describe("server local API auth", () => { }, 15_000); test("safeConfigDTO exposes the freeTier badge flag (WP040)", async () => { - const { safeConfigDTO } = await import("../src/server/auth-cors"); + const { safeConfigDTO } = await import("../../src/server/auth-cors"); const dto = safeConfigDTO({ port: 0, defaultProvider: "nvidia", diff --git a/tests/server-background-lifecycle.test.ts b/tests/server/server-background-lifecycle.test.ts similarity index 95% rename from tests/server-background-lifecycle.test.ts rename to tests/server/server-background-lifecycle.test.ts index 88d1d52f7e4..faa0f9949c6 100644 --- a/tests/server-background-lifecycle.test.ts +++ b/tests/server/server-background-lifecycle.test.ts @@ -14,32 +14,32 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { getActiveMemoryWatchdog } from "../src/server/memory-watchdog"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { getActiveMemoryWatchdog } from "../../src/server/memory-watchdog"; import { getStorageCleanupPolicyJobState, requestStorageCleanupPolicyRun, resetStorageCleanupPolicyJobForTestsAsync, setStorageCleanupPolicyJobTestHooks, -} from "../src/storage/policy-job"; +} from "../../src/storage/policy-job"; import { normalizeStorageCleanupPolicy, writeStorageCleanupPolicyToConfig, -} from "../src/storage/policy"; -import { stopStorageCleanupScheduler } from "../src/storage/policy-scheduler"; +} from "../../src/storage/policy"; +import { stopStorageCleanupScheduler } from "../../src/storage/policy-scheduler"; import { drainStorageWorkers, liveStorageWorkerCount, -} from "../src/storage/worker-lifecycle"; -import type { OcxConfig } from "../src/types"; -import { SERVER_BUDGET_MS } from "./helpers/test-budget"; -import { managementFetch } from "./helpers/management-auth"; +} from "../../src/storage/worker-lifecycle"; +import type { OcxConfig } from "../../src/types"; +import { SERVER_BUDGET_MS } from "../helpers/test-budget"; +import { managementFetch } from "../helpers/management-auth"; import { installIsolatedCodexHome, type IsolatedCodexHome, -} from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; type StartedServer = ReturnType; type IntervalTimer = ReturnType; diff --git a/tests/server-clickjacking-headers.test.ts b/tests/server/server-clickjacking-headers.test.ts similarity index 84% rename from tests/server-clickjacking-headers.test.ts rename to tests/server/server-clickjacking-headers.test.ts index fc74000150c..39df82478e0 100644 --- a/tests/server-clickjacking-headers.test.ts +++ b/tests/server/server-clickjacking-headers.test.ts @@ -2,9 +2,9 @@ import { describe, expect, test } from "bun:test"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { browserSecurityHeaders, corsHeaders } from "../src/server/auth-cors"; -import { serveGuiFile } from "../src/server/gui-static"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { browserSecurityHeaders, corsHeaders } from "../../src/server/auth-cors"; +import { serveGuiFile } from "../../src/server/gui-static"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const EXPECTED = { "X-Frame-Options": "DENY", diff --git a/tests/server-combo-failover-e2e.test.ts b/tests/server/server-combo-failover-e2e.test.ts similarity index 97% rename from tests/server-combo-failover-e2e.test.ts rename to tests/server/server-combo-failover-e2e.test.ts index 1c3f69b778c..6c84ccab308 100644 --- a/tests/server-combo-failover-e2e.test.ts +++ b/tests/server/server-combo-failover-e2e.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, mock, setDefaultTimeout, test } from "bun:test"; -import { logsFromApiBody } from "./helpers/logs-api"; -import { managementFetch as fetch, ManagementRequest as Request } from "./helpers/management-auth"; +import { logsFromApiBody } from "../helpers/logs-api"; +import { managementFetch as fetch, ManagementRequest as Request } from "../helpers/management-auth"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; @@ -8,53 +8,53 @@ import { clearComboSelectionState, clearComboTargetCooldowns, isComboTargetInCooldown, -} from "../src/combos"; -import { readConfigDiagnostics, saveConfig } from "../src/config"; -import type { ProviderAdapter } from "../src/adapters/base"; -import { handleManagementAPI } from "../src/server/management-api"; -import { saveCredential } from "../src/oauth/store"; -import { XAI_OAUTH_DISCOVERY_URL } from "../src/oauth/xai"; -import { XAI_GROK_CLI_BASE_URL } from "../src/providers/xai-transport"; -import type { AdapterEvent, OcxConfig, OcxProviderConfig, OcxProviderContinuationState } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { clearRequestLogsForTests, hydrateRequestLogsFromDisk, type RequestLogContext } from "../src/server/request-log"; -import { responseWithDeferredRequestLog } from "../src/server/relay"; -import { readUsageEntries } from "../src/usage/log"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; +} from "../../src/combos"; +import { readConfigDiagnostics, saveConfig } from "../../src/config"; +import type { ProviderAdapter } from "../../src/adapters/base"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { saveCredential } from "../../src/oauth/store"; +import { XAI_OAUTH_DISCOVERY_URL } from "../../src/oauth/xai"; +import { XAI_GROK_CLI_BASE_URL } from "../../src/providers/xai-transport"; +import type { AdapterEvent, OcxConfig, OcxProviderConfig, OcxProviderContinuationState } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { clearRequestLogsForTests, hydrateRequestLogsFromDisk, type RequestLogContext } from "../../src/server/request-log"; +import { responseWithDeferredRequestLog } from "../../src/server/relay"; +import { readUsageEntries } from "../../src/usage/log"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; import { clearCodexUpstreamHealth, formatCodexProviderForLog, getCodexUpstreamHealth, -} from "../src/codex/routing"; -import { startServer } from "../src/server"; -import { fakeChatGptJwt } from "./helpers/fake-chatgpt-jwt"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/codex/routing"; +import { startServer } from "../../src/server"; +import { fakeChatGptJwt } from "../helpers/fake-chatgpt-jwt"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; import { clearResponseStateForTests, flushResponseState, responseStatePersistPendingForTests, -} from "../src/responses/state"; -import { clearCursorThreadContinuityForTests } from "../src/adapters/cursor/thread-continuity"; -import { COMPACT_PROMPT, encodeCompactionSummary } from "../src/responses/compaction"; +} from "../../src/responses/state"; +import { clearCursorThreadContinuityForTests } from "../../src/adapters/cursor/thread-continuity"; +import { COMPACT_PROMPT, encodeCompactionSummary } from "../../src/responses/compaction"; // Full-suite Windows load: startServer + combo rename/delete management flows exceed the // default 5s per-test budget (same flake class as 810fa115 / claude-management-api). setDefaultTimeout(30_000); -const actualResolver = await import("../src/server/adapter-resolve"); +const actualResolver = await import("../../src/server/adapter-resolve"); const actualResolveAdapter = actualResolver.resolveAdapter; -const actualRetry = await import("../src/lib/upstream-retry"); +const actualRetry = await import("../../src/lib/upstream-retry"); const actualFetchWithTransientRetry = actualRetry.fetchWithTransientRetry; -const { createCursorAdapter } = await import("../src/adapters/cursor"); -import type { CursorTransportFactory } from "../src/adapters/cursor/transport"; +const { createCursorAdapter } = await import("../../src/adapters/cursor"); +import type { CursorTransportFactory } from "../../src/adapters/cursor/transport"; let customRunTurn: NonNullable | undefined; let customFetchResponse: NonNullable | undefined; let customTransientResponse: (() => Promise) | undefined; let customUsageEstimate: ((model: string) => number | undefined) | undefined; let customCursorTransportFactory: CursorTransportFactory | undefined; -mock.module("../src/server/adapter-resolve", () => ({ +mock.module("../../src/server/adapter-resolve", () => ({ ...actualResolver, resolveAdapter(provider: OcxProviderConfig, cacheRetention?: "none" | "short" | "long") { if (provider.adapter === "cursor" && customCursorTransportFactory) { @@ -102,7 +102,7 @@ mock.module("../src/server/adapter-resolve", () => ({ }, })); -mock.module("../src/lib/upstream-retry", () => ({ +mock.module("../../src/lib/upstream-retry", () => ({ ...actualRetry, fetchWithTransientRetry( ...args: Parameters @@ -112,8 +112,8 @@ mock.module("../src/lib/upstream-retry", () => ({ }, })); -const { handleResponses } = await import("../src/server/responses"); -const { handleResponsesCompact } = await import("../src/server/responses/compact"); +const { handleResponses } = await import("../../src/server/responses"); +const { handleResponsesCompact } = await import("../../src/server/responses/compact"); type HandleOptions = NonNullable[3]>; const TOKEN_ENDPOINT = "https://auth.x.ai/oauth/token"; @@ -1670,7 +1670,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("disabled image input expands text-only previous_response_id exactly once before child dispatch", async () => { - const { rememberResponseState } = await import("../src/responses/state"); + const { rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "combo/free", input: [{ role: "user", content: "earlier text" }] }, { @@ -1702,7 +1702,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo continuation expansion respects the client task scope", async () => { - const { rememberResponseState } = await import("../src/responses/state"); + const { rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "combo/free", input: "legacy private history" }, { @@ -1748,8 +1748,8 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo child preserves replay provenance for compaction and generated guidance", async () => { - const { rememberResponseState } = await import("../src/responses/state"); - const { multiAgentGuidanceText, PROACTIVE_MULTI_AGENT_MODE_TEXT } = await import("../src/server/responses/collaboration"); + const { rememberResponseState } = await import("../../src/responses/state"); + const { multiAgentGuidanceText, PROACTIVE_MULTI_AGENT_MODE_TEXT } = await import("../../src/server/responses/collaboration"); const guidance = `${PROACTIVE_MULTI_AGENT_MODE_TEXT}`; const tools = ["spawn_agent", "send_input"].map(name => ({ type: "function", @@ -1841,7 +1841,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo failover dispatches the one parent-validated continuation snapshot", async () => { - const { clearResponseStateForTests, rememberResponseState } = await import("../src/responses/state"); + const { clearResponseStateForTests, rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "combo/free", input: [{ role: "user", content: "stable prior history" }] }, { @@ -1889,7 +1889,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo keeps an explicitly empty provider-state snapshot across failover", async () => { - const { previousResponseProviderState, rememberResponseState } = await import("../src/responses/state"); + const { previousResponseProviderState, rememberResponseState } = await import("../../src/responses/state"); customRunTurn = async (_parsed, _incoming, emit) => { emit({ type: "text_delta", text: "seed" }); emit({ type: "done", providerState: { kiro: { conversationId: "late-owned-state" } } }); @@ -1939,7 +1939,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo response state deep-merges provider-private payloads generically", async () => { - const { previousResponseProviderState } = await import("../src/responses/state"); + const { previousResponseProviderState } = await import("../../src/responses/state"); let turn = 0; customRunTurn = async (_parsed, _incoming, emit) => { turn += 1; @@ -2003,7 +2003,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo child retains the local id without inheriting unbound provider state", async () => { - const { rememberResponseState } = await import("../src/responses/state"); + const { rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "combo/free", input: "prior target turn" }, { @@ -2046,7 +2046,7 @@ describe("server combo failover 030 activation matrix", () => { }); test("combo rejects malformed provider-continuation owner metadata", async () => { - const { rememberResponseState } = await import("../src/responses/state"); + const { rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "combo/free", input: "prior target turn" }, { @@ -2260,7 +2260,7 @@ describe("server combo failover 030 activation matrix", () => { ); test("disabled image input rejects an image restored from previous_response_id before dispatch", async () => { - const { rememberResponseState } = await import("../src/responses/state"); + const { rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "combo/free", @@ -2909,7 +2909,7 @@ describe("cursor conversation continuity across store:false chains", () => { } test("ownerless legacy Cursor state fails closed before adapter dispatch", async () => { - const { rememberResponseState } = await import("../src/responses/state"); + const { rememberResponseState } = await import("../../src/responses/state"); rememberResponseState( { model: "cursortest/composer-2", input: "legacy" }, { @@ -2977,7 +2977,7 @@ describe("cursor conversation continuity across store:false chains", () => { expect(seen[1]).toBe(seen[0]); const secondJson = await second.json() as { id: string }; - const { previousResponseProviderState } = await import("../src/responses/state"); + const { previousResponseProviderState } = await import("../../src/responses/state"); expect(previousResponseProviderState(secondJson.id)?.cursor?.conversationId).toBe(seen[1]); }); diff --git a/tests/server-images-bodyless-content-length.test.ts b/tests/server/server-images-bodyless-content-length.test.ts similarity index 94% rename from tests/server-images-bodyless-content-length.test.ts rename to tests/server/server-images-bodyless-content-length.test.ts index cb2e8d9dd94..cff24a0e6b4 100644 --- a/tests/server-images-bodyless-content-length.test.ts +++ b/tests/server/server-images-bodyless-content-length.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { IMAGES_RESPONSE_MAX_BYTES, readImageResponseBytes } from "../src/server/images"; +import { IMAGES_RESPONSE_MAX_BYTES, readImageResponseBytes } from "../../src/server/images"; test("bodyless 304 ignores representation Content-Length when enforcing image response size", async () => { const response = new Response(null, { diff --git a/tests/server-images.test.ts b/tests/server/server-images.test.ts similarity index 98% rename from tests/server-images.test.ts rename to tests/server/server-images.test.ts index 3f7c98d2245..a6b78da18cf 100644 --- a/tests/server-images.test.ts +++ b/tests/server/server-images.test.ts @@ -6,20 +6,20 @@ import { afterEach, beforeEach, expect, test } from "bun:test"; import { existsSync, mkdirSync} from "node:fs"; import { join } from "node:path"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import { clearAccountNeedsReauth, clearAccountQuota } from "../src/codex/auth-api"; -import { clearCodexUpstreamHealth, clearThreadAccountMap, getCodexUpstreamHealth } from "../src/codex/routing"; -import { saveConfig } from "../src/config"; -import { selectImagesProvider } from "../src/providers/openai-sidecar"; -import { startServer } from "../src/server"; -import { handleImages, IMAGES_RESPONSE_MAX_BYTES, readImageResponseBytes, setXaiResultPinnedDownloadForTests } from "../src/server/images"; -import { MAX_ENCODED_BYTES_PER_IMAGE } from "../src/images/artifacts"; -import { saveCredential } from "../src/oauth/store"; -import type { OcxConfig } from "../src/types"; -import { ANTIGRAVITY_REQUEST_UA } from "../src/adapters/google-antigravity-wire"; -import { fakeChatGptJwt } from "./helpers/fake-chatgpt-jwt"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import { clearAccountNeedsReauth, clearAccountQuota } from "../../src/codex/auth-api"; +import { clearCodexUpstreamHealth, clearThreadAccountMap, getCodexUpstreamHealth } from "../../src/codex/routing"; +import { saveConfig } from "../../src/config"; +import { selectImagesProvider } from "../../src/providers/openai-sidecar"; +import { startServer } from "../../src/server"; +import { handleImages, IMAGES_RESPONSE_MAX_BYTES, readImageResponseBytes, setXaiResultPinnedDownloadForTests } from "../../src/server/images"; +import { MAX_ENCODED_BYTES_PER_IMAGE } from "../../src/images/artifacts"; +import { saveCredential } from "../../src/oauth/store"; +import type { OcxConfig } from "../../src/types"; +import { ANTIGRAVITY_REQUEST_UA } from "../../src/adapters/google-antigravity-wire"; +import { fakeChatGptJwt } from "../helpers/fake-chatgpt-jwt"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const previousApiToken = process.env.OPENCODEX_API_AUTH_TOKEN; const previousOpencodexHome = process.env.OPENCODEX_HOME; @@ -1945,7 +1945,7 @@ test("CCA body-read client cancellation returns 499, not 504", async () => { // // We call handleImages directly (not via server fetch) because a client-side // fetch abort tears down the connection before the server response can be read. - const { handleImages } = await import("../src/server/images"); + const { handleImages } = await import("../../src/server/images"); globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { const requestUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url; const url = new URL(requestUrl); @@ -2165,7 +2165,7 @@ test("CCA client abort during OAuth preflight returns 499, not a hung response", // Regression for finding2-oauth-signal: when the client disconnects while // getValidAccessToken is refreshing the token, the request must return 499 // promptly, not hang waiting for the refresh HTTP call to complete. - const { handleImages } = await import("../src/server/images"); + const { handleImages } = await import("../../src/server/images"); hungOauthFetchMock(); // Long timeout so the deadline does NOT fire — only the client abort triggers. @@ -2196,7 +2196,7 @@ test("CCA deadline expiry during OAuth preflight returns 504, not a hung respons // Regression for finding2-oauth-signal: when the deadline fires while // getValidAccessToken is refreshing the token, the request must return 504 // promptly, not hang waiting for the refresh HTTP call to complete. - const { handleImages } = await import("../src/server/images"); + const { handleImages } = await import("../../src/server/images"); hungOauthFetchMock(); // Short timeout so the deadline fires during the hung OAuth refresh. @@ -2538,7 +2538,7 @@ test("CCA rejects invalid base64 and non-image bytes instead of returning b64_js test("GET /v1/opencodex/artifacts/:id serves opaque artifacts with API auth", async () => { process.env.OPENCODEX_API_AUTH_TOKEN = "proxy-admission-secret"; - const { materializeInlineImage, createImageBudget, artifactHttpUrl } = await import("../src/images/artifacts"); + const { materializeInlineImage, createImageBudget, artifactHttpUrl } = await import("../../src/images/artifacts"); const filePath = await materializeInlineImage(CCA_TINY_PNG, createImageBudget()); const urlPath = artifactHttpUrl(filePath); diff --git a/tests/server-key-failover-e2e.test.ts b/tests/server/server-key-failover-e2e.test.ts similarity index 97% rename from tests/server-key-failover-e2e.test.ts rename to tests/server/server-key-failover-e2e.test.ts index ab6fca75828..57ab87b2cba 100644 --- a/tests/server-key-failover-e2e.test.ts +++ b/tests/server/server-key-failover-e2e.test.ts @@ -2,14 +2,14 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { clearKeyCooldowns } from "../src/providers/key-failover"; -import { deriveXaiConvId } from "../src/providers/xai-transport"; -import { clearReasoningReplayCacheForTests } from "../src/responses/reasoning-replay-cache"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { clearKeyCooldowns } from "../../src/providers/key-failover"; +import { deriveXaiConvId } from "../../src/providers/xai-transport"; +import { clearReasoningReplayCacheForTests } from "../../src/responses/reasoning-replay-cache"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/server-kiro-completion-e2e.test.ts b/tests/server/server-kiro-completion-e2e.test.ts similarity index 98% rename from tests/server-kiro-completion-e2e.test.ts rename to tests/server/server-kiro-completion-e2e.test.ts index 99f1d9b6ebf..01327b482c8 100644 --- a/tests/server-kiro-completion-e2e.test.ts +++ b/tests/server/server-kiro-completion-e2e.test.ts @@ -2,14 +2,14 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { KIRO_COMPLETION_TOOL_NAME } from "../src/adapters/kiro-constants"; -import { saveConfig } from "../src/config"; -import { encodeMessage } from "../src/lib/eventstream-decoder"; -import { startServer } from "../src/server"; -import { clearRequestLogsForTests, getRequestLogEntries } from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { KIRO_COMPLETION_TOOL_NAME } from "../../src/adapters/kiro-constants"; +import { saveConfig } from "../../src/config"; +import { encodeMessage } from "../../src/lib/eventstream-decoder"; +import { startServer } from "../../src/server"; +import { clearRequestLogsForTests, getRequestLogEntries } from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const enc = new TextEncoder(); const originalFetch = globalThis.fetch; diff --git a/tests/server-kiro-oauth-401-replay.test.ts b/tests/server/server-kiro-oauth-401-replay.test.ts similarity index 96% rename from tests/server-kiro-oauth-401-replay.test.ts rename to tests/server/server-kiro-oauth-401-replay.test.ts index b26ce466d49..80c39e6f3c0 100644 --- a/tests/server-kiro-oauth-401-replay.test.ts +++ b/tests/server/server-kiro-oauth-401-replay.test.ts @@ -2,14 +2,14 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { KIRO_COMPLETION_TOOL_NAME } from "../src/adapters/kiro-constants"; -import { encodeMessage } from "../src/lib/eventstream-decoder"; -import { saveConfig } from "../src/config"; -import { saveCredential } from "../src/oauth/store"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { KIRO_COMPLETION_TOOL_NAME } from "../../src/adapters/kiro-constants"; +import { encodeMessage } from "../../src/lib/eventstream-decoder"; +import { saveConfig } from "../../src/config"; +import { saveCredential } from "../../src/oauth/store"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const enc = new TextEncoder(); const CHAT_ENDPOINT = "https://runtime.us-east-1.kiro.dev/"; diff --git a/tests/server-live.test.ts b/tests/server/server-live.test.ts similarity index 98% rename from tests/server-live.test.ts rename to tests/server/server-live.test.ts index 8e97b156a1f..16ee4c79463 100644 --- a/tests/server-live.test.ts +++ b/tests/server/server-live.test.ts @@ -5,27 +5,27 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync, readFileSync } from "node:fs"; import { join } from "node:path"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import { clearAccountNeedsReauth, clearAccountQuota } from "../src/codex/auth-api"; -import { clearCodexUpstreamHealth, clearThreadAccountMap } from "../src/codex/routing"; -import { saveConfig } from "../src/config"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import { clearAccountNeedsReauth, clearAccountQuota } from "../../src/codex/auth-api"; +import { clearCodexUpstreamHealth, clearThreadAccountMap } from "../../src/codex/routing"; +import { saveConfig } from "../../src/config"; import { createReadinessGate, runStartupReadinessSync, type ReadinessGate, -} from "../src/server/readiness"; +} from "../../src/server/readiness"; import { enqueueLiveSidebandPendingFrame, exceedsLiveSidebandFrameByteLimit, exceedsLiveSidebandPendingByteLimit, MAX_WS_FRAME_BYTES, startServer, -} from "../src/server"; -import { beginShutdownDrain, isDraining, resetLifecycleDrainStateForTests } from "../src/server/lifecycle"; -import type { OcxConfig } from "../src/types"; -import { fakeChatGptJwt } from "./helpers/fake-chatgpt-jwt"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server"; +import { beginShutdownDrain, isDraining, resetLifecycleDrainStateForTests } from "../../src/server/lifecycle"; +import type { OcxConfig } from "../../src/types"; +import { fakeChatGptJwt } from "../helpers/fake-chatgpt-jwt"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const previousApiToken = process.env.OPENCODEX_API_AUTH_TOKEN; const previousOpencodexHome = process.env.OPENCODEX_HOME; @@ -914,7 +914,7 @@ test("sideband queue enforces aggregate bytes and frame count without retaining test("buildLiveSidebandUpstreamWsUrl maps Frameless and Realtime join shapes", async () => { const { buildLiveSidebandUpstreamWsUrl, forwardLiveUrl, keyedLiveUrl, parseLiveSidebandTarget } = - await import("../src/server/live"); + await import("../../src/server/live"); expect(forwardLiveUrl("https://chatgpt.com/backend-api/codex", true)).toBe( "https://chatgpt.com/backend-api/codex/realtime/calls?intent=quicksilver&architecture=avas", @@ -968,7 +968,7 @@ test("buildLiveSidebandUpstreamWsUrl maps Frameless and Realtime join shapes", a }); test("parseLiveSidebandTarget recognizes standalone realtime sessions", async () => { - const { parseLiveSidebandTarget } = await import("../src/server/live"); + const { parseLiveSidebandTarget } = await import("../../src/server/live"); // Desktop voice since codex 0.147.x: standalone WebSocket transport, no call_id. expect( @@ -1021,7 +1021,7 @@ test("parseLiveSidebandTarget recognizes standalone realtime sessions", async () }); test("standalone realtime query relay drops credential-shaped keys and keeps raw bytes", async () => { - const { parseLiveSidebandTarget, sanitizeStandaloneRealtimeQuery } = await import("../src/server/live"); + const { parseLiveSidebandTarget, sanitizeStandaloneRealtimeQuery } = await import("../../src/server/live"); // Noncanonical encodings and bare keys survive byte-for-byte. expect(sanitizeStandaloneRealtimeQuery("model=a%2fb&flag&x=%20~")).toBe("model=a%2fb&flag&x=%20~"); @@ -1050,7 +1050,7 @@ test("standalone realtime query relay drops credential-shaped keys and keeps raw }); test("buildLiveSidebandUpstreamWsUrl maps standalone realtime session shapes", async () => { - const { buildLiveSidebandUpstreamWsUrl } = await import("../src/server/live"); + const { buildLiveSidebandUpstreamWsUrl } = await import("../../src/server/live"); expect( buildLiveSidebandUpstreamWsUrl({ @@ -1083,7 +1083,7 @@ test("buildLiveSidebandUpstreamWsUrl maps standalone realtime session shapes", a }); test("sideband URL policy: override precedence, normalization, and fail-closed bounds", async () => { - const { buildLiveSidebandUpstreamWsUrl } = await import("../src/server/live"); + const { buildLiveSidebandUpstreamWsUrl } = await import("../../src/server/live"); const frameless = { style: "frameless-path", callId: "rtc_1" } as const; const realtime = { style: "realtime-query", callId: "rtc 2" } as const; diff --git a/tests/server-loopback-host-gate.test.ts b/tests/server/server-loopback-host-gate.test.ts similarity index 98% rename from tests/server-loopback-host-gate.test.ts rename to tests/server/server-loopback-host-gate.test.ts index e5937eeb16e..254b8684127 100644 --- a/tests/server-loopback-host-gate.test.ts +++ b/tests/server/server-loopback-host-gate.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { isAllowedRequestOrigin, isLoopbackRequestHost } from "../src/server/auth-cors"; -import type { OcxConfig } from "../src/types"; +import { isAllowedRequestOrigin, isLoopbackRequestHost } from "../../src/server/auth-cors"; +import type { OcxConfig } from "../../src/types"; // A loopback bind: isApiAuthRequired() is false, so admission runs through the // Host/Origin branch these tests exercise. diff --git a/tests/server-management-auth.test.ts b/tests/server/server-management-auth.test.ts similarity index 98% rename from tests/server-management-auth.test.ts rename to tests/server/server-management-auth.test.ts index 9b8e4046abb..aece9bc93a4 100644 --- a/tests/server-management-auth.test.ts +++ b/tests/server/server-management-auth.test.ts @@ -1,21 +1,21 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; -import { SERVER_BUDGET_MS } from "./helpers/test-budget"; +import { SERVER_BUDGET_MS } from "../helpers/test-budget"; import { mkdtempSync, readFileSync, unlinkSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { getConfigPath, saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { findAvailablePort } from "../src/server/ports"; -import type { OcxConfig } from "../src/types"; -import { serveGuiFile, serveSessionBootstrap } from "../src/server/gui-static"; -import { isProxyAdmissionSecret } from "../src/server/auth-cors"; +import { getConfigPath, saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { findAvailablePort } from "../../src/server/ports"; +import type { OcxConfig } from "../../src/types"; +import { serveGuiFile, serveSessionBootstrap } from "../../src/server/gui-static"; +import { isProxyAdmissionSecret } from "../../src/server/auth-cors"; import { initializeManagementAuthState, issueGuiSession, managementPrincipal, removeManagementTokenPathBestEffort, requireManagementAuth, -} from "../src/server/management-auth"; +} from "../../src/server/management-auth"; import { hardenSecretPath, hardenedSecretPathCountForTests, @@ -24,12 +24,12 @@ import { setPlatformForTests, timedOutSecretPathCountForTests, hardenSecretDir, -} from "../src/lib/windows-secret-acl"; +} from "../../src/lib/windows-secret-acl"; import { LOCAL_ATTESTATION_CHALLENGE_HEADER, LOCAL_ATTESTATION_PROOF_HEADER, verifyLocalAttestationProof, -} from "../src/lib/local-management-attestation"; +} from "../../src/lib/local-management-attestation"; import { LOCAL_MANAGEMENT_CAPABILITY_HEADER, LOCAL_MANAGEMENT_CAPABILITY_EXPIRES_AT_HEADER, @@ -38,11 +38,11 @@ import { LOCAL_MANAGEMENT_NONCE_HEADER, LOCAL_MANAGEMENT_READ_PATHS, createLocalManagementReadCapability, -} from "../src/lib/local-management-capability"; +} from "../../src/lib/local-management-capability"; import { CODEX_APP_SERVER_STATE_PATH, CODEX_RESTART_PATH, -} from "../src/lib/codex-restart-contract"; +} from "../../src/lib/codex-restart-contract"; import { SYSTEM_RESTART_CAPABILITY_HEADER, SYSTEM_RESTART_EXPECTED_PID_HEADER, @@ -50,7 +50,7 @@ import { SYSTEM_RESTART_NONCE_HEADER, SYSTEM_RESTART_PATH, createSystemRestartCapability, -} from "../src/lib/system-restart-contract"; +} from "../../src/lib/system-restart-contract"; import { LOCAL_PROVIDER_RELOAD_CAPABILITY_HEADER, LOCAL_PROVIDER_RELOAD_CAPABILITY_TTL_MS, @@ -62,7 +62,7 @@ import { LOCAL_PROVIDER_RELOAD_PATH, createLocalProviderReloadCapability, verifyLocalProviderReloadCapability, -} from "../src/lib/local-provider-reload-contract"; +} from "../../src/lib/local-provider-reload-contract"; import { GUI_PAIR_BROWSER_ORIGIN_HEADER, GUI_PAIR_CAPABILITY_HEADER, @@ -73,7 +73,7 @@ import { GUI_PAIR_NONCE_HEADER, GUI_PAIR_PATH, createGuiPairCapability, -} from "../src/lib/gui-pair-capability"; +} from "../../src/lib/gui-pair-capability"; import { GUI_PAIRING_GRANT_TTL_MS, LOOPBACK_GUI_SESSION_TTL_MS, @@ -81,9 +81,9 @@ import { authorizeGuiSessionRequest, consumeGuiPairingGrant, createGuiPairingGrant, -} from "../src/server/gui-session"; -import { setSystemRestartIoForTests } from "../src/server/management/system-restart"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/gui-session"; +import { setSystemRestartIoForTests } from "../../src/server/management/system-restart"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const previousHome = process.env.OPENCODEX_HOME; const previousDataToken = process.env.OPENCODEX_API_AUTH_TOKEN; diff --git a/tests/server-opencode-go-goal-streaming.test.ts b/tests/server/server-opencode-go-goal-streaming.test.ts similarity index 96% rename from tests/server-opencode-go-goal-streaming.test.ts rename to tests/server/server-opencode-go-goal-streaming.test.ts index c9defa4bf13..cc01247a74e 100644 --- a/tests/server-opencode-go-goal-streaming.test.ts +++ b/tests/server/server-opencode-go-goal-streaming.test.ts @@ -2,11 +2,11 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const CHAT_ENDPOINT = "https://opencode.ai/zen/go/v1/chat/completions"; diff --git a/tests/server-rate-limit-retry-e2e.test.ts b/tests/server/server-rate-limit-retry-e2e.test.ts similarity index 97% rename from tests/server-rate-limit-retry-e2e.test.ts rename to tests/server/server-rate-limit-retry-e2e.test.ts index 7284acdbaf0..92afec7efea 100644 --- a/tests/server-rate-limit-retry-e2e.test.ts +++ b/tests/server/server-rate-limit-retry-e2e.test.ts @@ -2,12 +2,12 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { clearKeyCooldowns } from "../src/providers/key-failover"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { clearKeyCooldowns } from "../../src/providers/key-failover"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/server-request-body-size.test.ts b/tests/server/server-request-body-size.test.ts similarity index 89% rename from tests/server-request-body-size.test.ts rename to tests/server/server-request-body-size.test.ts index 0f312e978a5..14b37c0f478 100644 --- a/tests/server-request-body-size.test.ts +++ b/tests/server/server-request-body-size.test.ts @@ -1,10 +1,10 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync} from "node:fs"; import { join } from "node:path"; -import { startServer } from "../src/server"; -import { MAX_DECOMPRESSED_BODY_BYTES } from "../src/server/request-decompress"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { startServer } from "../../src/server"; +import { MAX_DECOMPRESSED_BODY_BYTES } from "../../src/server/request-decompress"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const TEST_DIR = join(import.meta.dir, ".tmp-server-request-body-size-test"); let isolatedCodexHome: IsolatedCodexHome | null = null; diff --git a/tests/server-search.test.ts b/tests/server/server-search.test.ts similarity index 97% rename from tests/server-search.test.ts rename to tests/server/server-search.test.ts index 9ba2e4d4f1f..fffd663279f 100644 --- a/tests/server-search.test.ts +++ b/tests/server/server-search.test.ts @@ -6,23 +6,23 @@ import { afterEach, beforeEach, expect, test } from "bun:test"; import { existsSync, mkdirSync} from "node:fs"; import { join } from "node:path"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import { clearAccountNeedsReauth, clearAccountQuota } from "../src/codex/auth-api"; -import { setCodexAccountPaused } from "../src/codex/account-pause"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import { clearAccountNeedsReauth, clearAccountQuota } from "../../src/codex/auth-api"; +import { setCodexAccountPaused } from "../../src/codex/account-pause"; import { clearCodexUpstreamHealth, clearThreadAccountMap, getCodexUpstreamHealth, recordCodexUpstreamOutcome, -} from "../src/codex/routing"; -import { loadConfig, saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { clearRequestLogsForTests, getRequestLogEntries } from "../src/server/request-log"; -import { handleSearch, SEARCH_RESPONSE_MAX_BYTES } from "../src/server/search"; -import type { OcxConfig } from "../src/types"; -import { fakeChatGptJwt } from "./helpers/fake-chatgpt-jwt"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/codex/routing"; +import { loadConfig, saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { clearRequestLogsForTests, getRequestLogEntries } from "../../src/server/request-log"; +import { handleSearch, SEARCH_RESPONSE_MAX_BYTES } from "../../src/server/search"; +import type { OcxConfig } from "../../src/types"; +import { fakeChatGptJwt } from "../helpers/fake-chatgpt-jwt"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const previousApiToken = process.env.OPENCODEX_API_AUTH_TOKEN; const previousOpencodexHome = process.env.OPENCODEX_HOME; diff --git a/tests/server-stop-config-hardening.test.ts b/tests/server/server-stop-config-hardening.test.ts similarity index 93% rename from tests/server-stop-config-hardening.test.ts rename to tests/server/server-stop-config-hardening.test.ts index 3c0f203ebfa..102292cc615 100644 --- a/tests/server-stop-config-hardening.test.ts +++ b/tests/server/server-stop-config-hardening.test.ts @@ -2,14 +2,14 @@ import { afterEach, beforeEach, expect, spyOn, test } from "bun:test"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { flushConfigDirHardening, flushConfigDirHardeningForTests, hardenConfigDir } from "../src/config/paths"; -import * as windowsAcl from "../src/lib/windows-secret-acl"; -import * as nativeStartup from "../src/codex/native-profile-startup"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { flushConfigDirHardening, flushConfigDirHardeningForTests, hardenConfigDir } from "../../src/config/paths"; +import * as windowsAcl from "../../src/lib/windows-secret-acl"; +import * as nativeStartup from "../../src/codex/native-profile-startup"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** * On Windows, `hardenConfigDir()` starts an `icacls.exe` child that holds the config directory diff --git a/tests/server-xai-chat-reasoning-streaming.test.ts b/tests/server/server-xai-chat-reasoning-streaming.test.ts similarity index 95% rename from tests/server-xai-chat-reasoning-streaming.test.ts rename to tests/server/server-xai-chat-reasoning-streaming.test.ts index ed2d0f28127..861a40098bb 100644 --- a/tests/server-xai-chat-reasoning-streaming.test.ts +++ b/tests/server/server-xai-chat-reasoning-streaming.test.ts @@ -2,16 +2,16 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { saveCredential } from "../src/oauth/store"; +import { saveConfig } from "../../src/config"; +import { saveCredential } from "../../src/oauth/store"; import { XAI_GROK_CLI_BASE_URL, XAI_GROK_CLIENT_VERSION, -} from "../src/providers/xai-transport"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/providers/xai-transport"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const CHAT_ENDPOINT = `${XAI_GROK_CLI_BASE_URL}/chat/completions`; const encoder = new TextEncoder(); diff --git a/tests/server-xai-header-parity.test.ts b/tests/server/server-xai-header-parity.test.ts similarity index 93% rename from tests/server-xai-header-parity.test.ts rename to tests/server/server-xai-header-parity.test.ts index b4b4db6a618..584b7c0eead 100644 --- a/tests/server-xai-header-parity.test.ts +++ b/tests/server/server-xai-header-parity.test.ts @@ -2,12 +2,12 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { deriveXaiConvId } from "../src/providers/xai-transport"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { deriveXaiConvId } from "../../src/providers/xai-transport"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; const CONV_KEY = "server-parity-conversation"; diff --git a/tests/server-xai-oauth-401-replay.test.ts b/tests/server/server-xai-oauth-401-replay.test.ts similarity index 96% rename from tests/server-xai-oauth-401-replay.test.ts rename to tests/server/server-xai-oauth-401-replay.test.ts index 3fe3d165530..6ad96b59d2d 100644 --- a/tests/server-xai-oauth-401-replay.test.ts +++ b/tests/server/server-xai-oauth-401-replay.test.ts @@ -2,14 +2,14 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { XAI_OAUTH_DISCOVERY_URL } from "../src/oauth/xai"; -import { saveCredential } from "../src/oauth/store"; -import { XAI_GROK_CLI_BASE_URL } from "../src/providers/xai-transport"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { XAI_OAUTH_DISCOVERY_URL } from "../../src/oauth/xai"; +import { saveCredential } from "../../src/oauth/store"; +import { XAI_GROK_CLI_BASE_URL } from "../../src/providers/xai-transport"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const TOKEN_ENDPOINT = "https://auth.x.ai/oauth/token"; const OAUTH_RESPONSES_ENDPOINT = `${XAI_GROK_CLI_BASE_URL}/responses`; diff --git a/tests/server-xai-responses-streaming.test.ts b/tests/server/server-xai-responses-streaming.test.ts similarity index 97% rename from tests/server-xai-responses-streaming.test.ts rename to tests/server/server-xai-responses-streaming.test.ts index 2925a47f00d..ef0f1e53134 100644 --- a/tests/server-xai-responses-streaming.test.ts +++ b/tests/server/server-xai-responses-streaming.test.ts @@ -2,16 +2,16 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { saveCredential } from "../src/oauth/store"; +import { saveConfig } from "../../src/config"; +import { saveCredential } from "../../src/oauth/store"; import { XAI_GROK_CLI_BASE_URL, XAI_GROK_CLIENT_VERSION, -} from "../src/providers/xai-transport"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/providers/xai-transport"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const RESPONSES_ENDPOINT = `${XAI_GROK_CLI_BASE_URL}/responses`; const encoder = new TextEncoder(); diff --git a/tests/session-affinity.test.ts b/tests/server/session-affinity.test.ts similarity index 95% rename from tests/session-affinity.test.ts rename to tests/server/session-affinity.test.ts index d3ff5b20b34..2a34a854851 100644 --- a/tests/session-affinity.test.ts +++ b/tests/server/session-affinity.test.ts @@ -1,12 +1,12 @@ import { describe, expect, test, beforeEach, afterEach } from "bun:test"; import { existsSync, mkdirSync} from "node:fs"; import { join } from "node:path"; -import { resolveCodexAccountForThread, clearThreadAccountMap, formatCodexProviderForLog } from "../src/codex/routing"; -import { CODEX_ACCOUNT_LOG_LABEL_RE, fallbackCodexAccountLogLabel } from "../src/codex/account-label"; -import { updateAccountQuota, clearAccountQuota } from "../src/codex/auth-api"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { resolveCodexAccountForThread, clearThreadAccountMap, formatCodexProviderForLog } from "../../src/codex/routing"; +import { CODEX_ACCOUNT_LOG_LABEL_RE, fallbackCodexAccountLogLabel } from "../../src/codex/account-label"; +import { updateAccountQuota, clearAccountQuota } from "../../src/codex/auth-api"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const TEST_DIR = join(import.meta.dir, ".tmp-session-affinity-test"); let previousOpencodexHome: string | undefined; diff --git a/tests/session-lane-recall-harness.test.ts b/tests/server/session-lane-recall-harness.test.ts similarity index 96% rename from tests/session-lane-recall-harness.test.ts rename to tests/server/session-lane-recall-harness.test.ts index 5e06136ec12..4feaa6a3dcb 100644 --- a/tests/session-lane-recall-harness.test.ts +++ b/tests/server/session-lane-recall-harness.test.ts @@ -2,8 +2,8 @@ import { describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { saveConfig } from "../src/config"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../src/adapters/openai-chat"; +import { saveConfig } from "../../src/config"; import { MAX_ACTIVE_TURNS, MAX_ACTIVE_SESSION_LANES, @@ -12,12 +12,12 @@ import { sessionLaneMetrics, tryAdmitTurn, type ActiveTurnLease, -} from "../src/server/lifecycle"; -import { sessionLaneIdFromRequest } from "../src/server/request-log-conversation"; -import { startServer } from "../src/server"; -import type { AdapterEvent, OcxConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/lifecycle"; +import { sessionLaneIdFromRequest } from "../../src/server/request-log-conversation"; +import { startServer } from "../../src/server"; +import type { AdapterEvent, OcxConfig } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const provider = { adapter: "openai-chat", baseUrl: "https://example.test/v1", apiKey: "key" }; diff --git a/tests/sidebar-routes.test.ts b/tests/server/sidebar-routes.test.ts similarity index 98% rename from tests/sidebar-routes.test.ts rename to tests/server/sidebar-routes.test.ts index 8a84f822542..cb484c4a355 100644 --- a/tests/sidebar-routes.test.ts +++ b/tests/server/sidebar-routes.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { handleManagementAPI } from "../src/server/management-api"; -import { invalidateStarStatusCache, setStarDepsForTests, type StarDeps } from "../src/github/star-state"; -import type { OcxConfig } from "../src/types"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { invalidateStarStatusCache, setStarDepsForTests, type StarDeps } from "../../src/github/star-state"; +import type { OcxConfig } from "../../src/types"; /** * Route-level proof for the two sidebar endpoints. The unit tests cover the state diff --git a/tests/sidebar-star-state.test.ts b/tests/server/sidebar-star-state.test.ts similarity index 99% rename from tests/sidebar-star-state.test.ts rename to tests/server/sidebar-star-state.test.ts index bcb29542f6d..f6a67894dec 100644 --- a/tests/sidebar-star-state.test.ts +++ b/tests/server/sidebar-star-state.test.ts @@ -6,7 +6,7 @@ import { starRepository, STAR_REPO, type StarDeps, -} from "../src/github/star-state"; +} from "../../src/github/star-state"; type GhCall = { args: string[]; timeoutMs: number }; diff --git a/tests/startup-action-control-elevation.test.ts b/tests/server/startup-action-control-elevation.test.ts similarity index 99% rename from tests/startup-action-control-elevation.test.ts rename to tests/server/startup-action-control-elevation.test.ts index cb249cb7e5e..66fdbff3e4d 100644 --- a/tests/startup-action-control-elevation.test.ts +++ b/tests/server/startup-action-control-elevation.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test"; import * as childProcess from "node:child_process"; -import { WINDOWS_SCHTASKS_CREATE_ACCESS_DENIED_MARKER } from "../src/lib/windows-elevation"; +import { WINDOWS_SCHTASKS_CREATE_ACCESS_DENIED_MARKER } from "../../src/lib/windows-elevation"; const execFileMock = mock(( _file: string, @@ -26,7 +26,7 @@ const { resetStartupInstallStateForTests, runStartupInstallAction, setStartupInstallFinalizeForTests, -} = await import("../src/server/startup-action-control"); +} = await import("../../src/server/startup-action-control"); describe("startup install elevation retry", () => { const originalPlatform = process.platform; diff --git a/tests/startup-action-control.test.ts b/tests/server/startup-action-control.test.ts similarity index 92% rename from tests/startup-action-control.test.ts rename to tests/server/startup-action-control.test.ts index 6dc037a9d20..42840fd5194 100644 --- a/tests/startup-action-control.test.ts +++ b/tests/server/startup-action-control.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { startupInstallArgv, type StartupInstallAction } from "../src/server/startup-action-control"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { OcxConfig } from "../src/types"; +import { startupInstallArgv, type StartupInstallAction } from "../../src/server/startup-action-control"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; const config = { port: 10100, providers: {}, defaultProvider: "openai", codexAutoStart: true } as OcxConfig; @@ -66,4 +66,4 @@ describe("startup install actions", () => { expect(called).toBe(false); }); }); -import { ManagementRequest as Request } from "./helpers/management-auth"; +import { ManagementRequest as Request } from "../helpers/management-auth"; diff --git a/tests/startup-prompt.test.ts b/tests/server/startup-prompt.test.ts similarity index 98% rename from tests/startup-prompt.test.ts rename to tests/server/startup-prompt.test.ts index 4b61304f549..46a8d2a830f 100644 --- a/tests/startup-prompt.test.ts +++ b/tests/server/startup-prompt.test.ts @@ -1,6 +1,8 @@ import { describe, expect, test } from "bun:test"; +import { pathToFileURL } from "node:url"; +import { repoRoot } from "../helpers/repo-root"; -const root = new URL("../", import.meta.url); +const root = pathToFileURL(repoRoot() + "/"); async function readText(path: string): Promise { return await Bun.file(new URL(path, root)).text(); diff --git a/tests/stream-aborted-marker.test.ts b/tests/server/stream-aborted-marker.test.ts similarity index 97% rename from tests/stream-aborted-marker.test.ts rename to tests/server/stream-aborted-marker.test.ts index 6d1a74a57a4..5e142a34293 100644 --- a/tests/stream-aborted-marker.test.ts +++ b/tests/server/stream-aborted-marker.test.ts @@ -2,20 +2,20 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { consumeForInspection, trackSseForRequestLog } from "../src/server/relay"; +import { consumeForInspection, trackSseForRequestLog } from "../../src/server/relay"; import { addFinalRequestLog, addRequestLog, beginRequestAttempt, httpStatusForRequestLogTerminal, type RequestLogContext, -} from "../src/server/request-log"; +} from "../../src/server/request-log"; import { readUsageEntries, resetUsageReadCacheForTests, type PersistedUsageAttempt, -} from "../src/usage/log"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/usage/log"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // Port of codex-router #139's streamAborted metering marker: an upstream stream // that dies after its 200 head was committed must meter as a truncated turn diff --git a/tests/system-env.test.ts b/tests/server/system-env.test.ts similarity index 99% rename from tests/system-env.test.ts rename to tests/server/system-env.test.ts index 776df8da944..e44ca7b43eb 100644 --- a/tests/system-env.test.ts +++ b/tests/server/system-env.test.ts @@ -1,12 +1,12 @@ import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from "bun:test"; import * as childProcess from "node:child_process"; import * as fs from "node:fs"; -import type { OcxConfig } from "../src/types"; +import type { OcxConfig } from "../../src/types"; import { cleanStaleSystemEnv, injectSystemEnv, revertSystemEnv, -} from "../src/server/system-env"; +} from "../../src/server/system-env"; const originalFetch = globalThis.fetch; const originalPlatform = process.platform; diff --git a/tests/system-restart.test.ts b/tests/server/system-restart.test.ts similarity index 98% rename from tests/system-restart.test.ts rename to tests/server/system-restart.test.ts index cd62c87dd34..951f95fdeee 100644 --- a/tests/system-restart.test.ts +++ b/tests/server/system-restart.test.ts @@ -2,8 +2,8 @@ * #563 — memory-card drain-and-restart acceptance + respawn policy. */ import { afterEach, describe, expect, test } from "bun:test"; -import { handleManagementAPI } from "../src/server/management-api"; -import { resetLifecycleDrainStateForTests, setDraining } from "../src/server/lifecycle"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { resetLifecycleDrainStateForTests, setDraining } from "../../src/server/lifecycle"; import { DEADLINE_LISTENER_STOP_TIMEOUT_MS, MEMORY_DRAIN_RESTART_MS, @@ -11,9 +11,9 @@ import { acceptSystemRestart, setSystemRestartIoForTests, waitForReplacementReady, -} from "../src/server/management/system-restart"; -import { SYSTEM_RESTART_EXPECTED_PID_HEADER } from "../src/lib/system-restart-contract"; -import type { OcxConfig } from "../src/types"; +} from "../../src/server/management/system-restart"; +import { SYSTEM_RESTART_EXPECTED_PID_HEADER } from "../../src/lib/system-restart-contract"; +import type { OcxConfig } from "../../src/types"; function config(): OcxConfig { return { @@ -856,4 +856,4 @@ describe("POST /api/system/restart", () => { expect(scheduled).toBe(1); }); }); -import { ManagementRequest as Request } from "./helpers/management-auth"; +import { ManagementRequest as Request } from "../helpers/management-auth"; diff --git a/tests/system-routes.test.ts b/tests/server/system-routes.test.ts similarity index 97% rename from tests/system-routes.test.ts rename to tests/server/system-routes.test.ts index 81fd36b5d77..45907fb6abd 100644 --- a/tests/system-routes.test.ts +++ b/tests/server/system-routes.test.ts @@ -13,14 +13,14 @@ */ import { afterEach, describe, expect, test } from "bun:test"; -import { handleManagementAPI } from "../src/server/management-api"; +import { handleManagementAPI } from "../../src/server/management-api"; import { readWindowsReplaceRetryCounters, renameAtomicFile, resetWindowsReplaceRetryCountersForTests, type ReplacePublisher, -} from "../src/lib/windows-atomic-replace"; -import type { OcxConfig } from "../src/types"; +} from "../../src/lib/windows-atomic-replace"; +import type { OcxConfig } from "../../src/types"; function config(): OcxConfig { return { diff --git a/tests/terminal-guard-server.test.ts b/tests/server/terminal-guard-server.test.ts similarity index 99% rename from tests/terminal-guard-server.test.ts rename to tests/server/terminal-guard-server.test.ts index 39a1393e09e..96a82b05d84 100644 --- a/tests/terminal-guard-server.test.ts +++ b/tests/server/terminal-guard-server.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; const config = { port: 0, diff --git a/tests/terminal-guard.test.ts b/tests/server/terminal-guard.test.ts similarity index 98% rename from tests/terminal-guard.test.ts rename to tests/server/terminal-guard.test.ts index 4ceac1f02db..c8d60d1ce67 100644 --- a/tests/terminal-guard.test.ts +++ b/tests/server/terminal-guard.test.ts @@ -4,9 +4,9 @@ import { buildContinuationRequest, guardTerminalEventStream, isTerminalGuardPassthroughOnly, -} from "../src/server/responses/terminal-guard"; -import { buildResponseJSON } from "../src/bridge"; -import type { AdapterEvent, OcxParsedRequest } from "../src/types"; +} from "../../src/server/responses/terminal-guard"; +import { buildResponseJSON } from "../../src/bridge"; +import type { AdapterEvent, OcxParsedRequest } from "../../src/types"; function parsed(userText: string, withTools = true): OcxParsedRequest { return { diff --git a/tests/upstream-connect-error.test.ts b/tests/server/upstream-connect-error.test.ts similarity index 97% rename from tests/upstream-connect-error.test.ts rename to tests/server/upstream-connect-error.test.ts index e7376e5a289..9f1d50ec11d 100644 --- a/tests/upstream-connect-error.test.ts +++ b/tests/server/upstream-connect-error.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { describeUpstreamConnectFailure } from "../src/server/responses/upstream-error"; +import { describeUpstreamConnectFailure } from "../../src/server/responses/upstream-error"; function tlsAltnameError(url: string): Error { // Shape of what Bun's fetch actually rejects with on a certificate/hostname mismatch. diff --git a/tests/upstream-http-version.test.ts b/tests/server/upstream-http-version.test.ts similarity index 96% rename from tests/upstream-http-version.test.ts rename to tests/server/upstream-http-version.test.ts index 7acb7837890..365424f9f44 100644 --- a/tests/upstream-http-version.test.ts +++ b/tests/server/upstream-http-version.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { providerFetch, withUpstreamHttpVersion } from "../src/server/responses/fetch-helpers"; -import { UpstreamHttpVersionTargetError } from "../src/lib/upstream-http-version"; -import type { OcxProviderConfig } from "../src/types"; +import { providerFetch, withUpstreamHttpVersion } from "../../src/server/responses/fetch-helpers"; +import { UpstreamHttpVersionTargetError } from "../../src/lib/upstream-http-version"; +import type { OcxProviderConfig } from "../../src/types"; const HTTPS_URL = "https://opencode.ai/zen/go/v1/chat/completions"; const HTTP_URL = "http://127.0.0.1:10900/zen/go/v1/chat/completions"; diff --git a/tests/v2-agent-message-failfast.test.ts b/tests/server/v2-agent-message-failfast.test.ts similarity index 99% rename from tests/v2-agent-message-failfast.test.ts rename to tests/server/v2-agent-message-failfast.test.ts index 9e218dec115..0dec3b40715 100644 --- a/tests/v2-agent-message-failfast.test.ts +++ b/tests/server/v2-agent-message-failfast.test.ts @@ -2,8 +2,8 @@ import { afterEach, describe, expect, test } from "bun:test"; import { handleResponses, hasUnreadableEncryptedAgentTask, -} from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; +} from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; const originalFetch = globalThis.fetch; diff --git a/tests/service/process-state.test.ts b/tests/service/process-state.test.ts index 21d27a1e3a6..8df957011bd 100644 --- a/tests/service/process-state.test.ts +++ b/tests/service/process-state.test.ts @@ -72,7 +72,7 @@ describe("proxy process-state ownership", () => { )).toBe(true); expect(isOcxStartCommandLine("opencodex start")).toBe(true); expect(isOcxStartCommandLine("bun run src/cli.ts status")).toBe(false); - expect(isOcxStartCommandLine("bun test C:/work/opencodex/tests/config.test.ts")).toBe(false); + expect(isOcxStartCommandLine("bun test C:/work/opencodex/tests/server/config.test.ts")).toBe(false); expect(isOcxStartCommandLine("notepad.exe")).toBe(false); }); diff --git a/tests/api-storage-cleanup.test.ts b/tests/storage/api-storage-cleanup.test.ts similarity index 98% rename from tests/api-storage-cleanup.test.ts rename to tests/storage/api-storage-cleanup.test.ts index 0455b77c529..08a5000675d 100644 --- a/tests/api-storage-cleanup.test.ts +++ b/tests/storage/api-storage-cleanup.test.ts @@ -1,14 +1,14 @@ import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { Database } from "bun:sqlite"; import { existsSync, mkdirSync, mkdtempSync, utimesSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // Windows CI under load can spend >5s just binding the proxy + previewing cleanup; // Bun's default test budget then fails the suite before the assertion runs. diff --git a/tests/api-storage-policy-already-running.test.ts b/tests/storage/api-storage-policy-already-running.test.ts similarity index 98% rename from tests/api-storage-policy-already-running.test.ts rename to tests/storage/api-storage-policy-already-running.test.ts index bba29163c18..815a7e92aea 100644 --- a/tests/api-storage-policy-already-running.test.ts +++ b/tests/storage/api-storage-policy-already-running.test.ts @@ -14,7 +14,7 @@ import { waitForJobIdle, type PolicyApiHarness, resetStorageCleanupPolicyJobForTestsAsync, -} from "./helpers/storage-policy-api"; +} from "../helpers/storage-policy-api"; let harness: PolicyApiHarness; diff --git a/tests/api-storage-policy-mutation-busy.test.ts b/tests/storage/api-storage-policy-mutation-busy.test.ts similarity index 98% rename from tests/api-storage-policy-mutation-busy.test.ts rename to tests/storage/api-storage-policy-mutation-busy.test.ts index 05167d9d50d..e8e1298337a 100644 --- a/tests/api-storage-policy-mutation-busy.test.ts +++ b/tests/storage/api-storage-policy-mutation-busy.test.ts @@ -14,7 +14,7 @@ import { waitForJobIdle, type PolicyApiHarness, resetStorageCleanupPolicyJobForTestsAsync, -} from "./helpers/storage-policy-api"; +} from "../helpers/storage-policy-api"; let harness: PolicyApiHarness; diff --git a/tests/api-storage-policy-put-race.test.ts b/tests/storage/api-storage-policy-put-race.test.ts similarity index 99% rename from tests/api-storage-policy-put-race.test.ts rename to tests/storage/api-storage-policy-put-race.test.ts index a544d52e817..b425e449ce8 100644 --- a/tests/api-storage-policy-put-race.test.ts +++ b/tests/storage/api-storage-policy-put-race.test.ts @@ -14,7 +14,7 @@ import { waitForJobIdle, type PolicyApiHarness, resetStorageCleanupPolicyJobForTestsAsync, -} from "./helpers/storage-policy-api"; +} from "../helpers/storage-policy-api"; let harness: PolicyApiHarness; diff --git a/tests/api-storage-policy-run.test.ts b/tests/storage/api-storage-policy-run.test.ts similarity index 98% rename from tests/api-storage-policy-run.test.ts rename to tests/storage/api-storage-policy-run.test.ts index 8e353c09ba4..5db21920235 100644 --- a/tests/api-storage-policy-run.test.ts +++ b/tests/storage/api-storage-policy-run.test.ts @@ -13,7 +13,7 @@ import { waitForJobIdle, type PolicyApiHarness, resetStorageCleanupPolicyJobForTestsAsync, -} from "./helpers/storage-policy-api"; +} from "../helpers/storage-policy-api"; let harness: PolicyApiHarness; diff --git a/tests/api-storage-policy.test.ts b/tests/storage/api-storage-policy.test.ts similarity index 98% rename from tests/api-storage-policy.test.ts rename to tests/storage/api-storage-policy.test.ts index f9682606771..f28f12e7457 100644 --- a/tests/api-storage-policy.test.ts +++ b/tests/storage/api-storage-policy.test.ts @@ -11,7 +11,7 @@ import { uninstallPolicyApiHarness, type PolicyApiHarness, resetStorageCleanupPolicyJobForTestsAsync, -} from "./helpers/storage-policy-api"; +} from "../helpers/storage-policy-api"; let harness: PolicyApiHarness; diff --git a/tests/api-storage.test.ts b/tests/storage/api-storage.test.ts similarity index 94% rename from tests/api-storage.test.ts rename to tests/storage/api-storage.test.ts index 7f88886696a..b5ca548e3d0 100644 --- a/tests/api-storage.test.ts +++ b/tests/storage/api-storage.test.ts @@ -1,13 +1,13 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { mkdirSync, mkdtempSync, readdirSync, statSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/storage-cleanup.test.ts b/tests/storage/storage-cleanup.test.ts similarity index 99% rename from tests/storage-cleanup.test.ts rename to tests/storage/storage-cleanup.test.ts index d34ea93cd22..421950368c8 100644 --- a/tests/storage-cleanup.test.ts +++ b/tests/storage/storage-cleanup.test.ts @@ -25,9 +25,9 @@ import { restoreTrashEntry, selectOldestPercent, type ExecuteCleanupOptions, -} from "../src/storage/cleanup"; -import { STORE_BUDGET_MS } from "./helpers/test-budget"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/cleanup"; +import { STORE_BUDGET_MS } from "../helpers/test-budget"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const OLD = new Date("2026-01-01T00:00:00Z"); const MID = new Date("2026-02-01T00:00:00Z"); diff --git a/tests/storage-mutation-race.test.ts b/tests/storage/storage-mutation-race.test.ts similarity index 96% rename from tests/storage-mutation-race.test.ts rename to tests/storage/storage-mutation-race.test.ts index 3f7a95382fd..d4a85925d5b 100644 --- a/tests/storage-mutation-race.test.ts +++ b/tests/storage/storage-mutation-race.test.ts @@ -2,7 +2,7 @@ * Regression: cleanup and restore must not mutate CODEX_HOME concurrently. */ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { Database } from "bun:sqlite"; import { existsSync, @@ -16,33 +16,33 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { drainAndShutdown } from "../src/server/lifecycle"; -import type { OcxConfig } from "../src/types"; -import { endStorageMutation, getActiveStorageMutation, tryBeginStorageMutation } from "../src/storage/storage-mutation-coordinator"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { drainAndShutdown } from "../../src/server/lifecycle"; +import type { OcxConfig } from "../../src/types"; +import { endStorageMutation, getActiveStorageMutation, tryBeginStorageMutation } from "../../src/storage/storage-mutation-coordinator"; import { resetArchivedCleanupJobForTests, setArchivedCleanupJobTestHooks, -} from "../src/storage/cleanup-job"; +} from "../../src/storage/cleanup-job"; import { resetStorageCleanupPolicyJobForTestsAsync, setStorageCleanupPolicyJobTestHooks, -} from "../src/storage/policy-job"; -import { stopStorageCleanupScheduler } from "../src/storage/policy-scheduler"; +} from "../../src/storage/policy-job"; +import { stopStorageCleanupScheduler } from "../../src/storage/policy-scheduler"; import { resetRestoreTrashJobForTestsAsync, runRestoreTrashEntryJob, setRestoreTrashJobTestHooks, -} from "../src/storage/restore-job"; +} from "../../src/storage/restore-job"; import { resetStorageMutationCoordinatorForTests, -} from "../src/storage/storage-mutation-coordinator"; +} from "../../src/storage/storage-mutation-coordinator"; import { cancelQueuedStorageWorkerSpawns, drainStorageWorkers, -} from "../src/storage/worker-lifecycle"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; +} from "../../src/storage/worker-lifecycle"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/storage-policy-config-race.test.ts b/tests/storage/storage-policy-config-race.test.ts similarity index 94% rename from tests/storage-policy-config-race.test.ts rename to tests/storage/storage-policy-config-race.test.ts index cd9aa5efd5a..7f43f6ba6da 100644 --- a/tests/storage-policy-config-race.test.ts +++ b/tests/storage/storage-policy-config-race.test.ts @@ -7,16 +7,16 @@ import { loadConfig, saveConfig, setPersistedConfigMutationBeforeCommitForTests, -} from "../src/config"; -import { computeNextRun, runStorageCleanupPolicy } from "../src/storage/policy"; +} from "../../src/config"; +import { computeNextRun, runStorageCleanupPolicy } from "../../src/storage/policy"; import { getStorageCleanupPolicyJobState, requestStorageCleanupPolicyRun, resetStorageCleanupPolicyJobForTestsAsync, setStorageCleanupPolicyJobTestHooks, -} from "../src/storage/policy-job"; -import type { OcxConfig, StorageCleanupPolicy } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/policy-job"; +import type { OcxConfig, StorageCleanupPolicy } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let configHome = ""; let previousHome: string | undefined; diff --git a/tests/storage-policy-job-responsive.test.ts b/tests/storage/storage-policy-job-responsive.test.ts similarity index 90% rename from tests/storage-policy-job-responsive.test.ts rename to tests/storage/storage-policy-job-responsive.test.ts index a9558ab11eb..b93552a9d03 100644 --- a/tests/storage-policy-job-responsive.test.ts +++ b/tests/storage/storage-policy-job-responsive.test.ts @@ -3,23 +3,23 @@ * streaming response on the proxy event loop. */ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { Database } from "bun:sqlite"; import { mkdirSync, mkdtempSync, utimesSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { drainAndShutdown } from "../src/server/lifecycle"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { drainAndShutdown } from "../../src/server/lifecycle"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; import { resetStorageCleanupPolicyJobForTestsAsync, setStorageCleanupPolicyJobTestHooks, -} from "../src/storage/policy-job"; -import { stopStorageCleanupScheduler } from "../src/storage/policy-scheduler"; -import { drainStorageWorkers } from "../src/storage/worker-lifecycle"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/policy-job"; +import { stopStorageCleanupScheduler } from "../../src/storage/policy-scheduler"; +import { drainStorageWorkers } from "../../src/storage/worker-lifecycle"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/storage-policy.test.ts b/tests/storage/storage-policy.test.ts similarity index 99% rename from tests/storage-policy.test.ts rename to tests/storage/storage-policy.test.ts index a9368edf46d..1b0f226edc7 100644 --- a/tests/storage-policy.test.ts +++ b/tests/storage/storage-policy.test.ts @@ -9,7 +9,7 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { StorageCleanupPolicy } from "../src/types"; +import type { StorageCleanupPolicy } from "../../src/types"; import { BUSY_DEFER_MS, computeNextRun, @@ -21,15 +21,15 @@ import { runStorageCleanupPolicy, selectReduceToBytes, selectPolicyPreview, -} from "../src/storage/policy"; +} from "../../src/storage/policy"; import { listArchivedCandidates, selectOldestPercent, type ArchivedCandidate, type CleanupResult, type ExecuteCleanupOptions, -} from "../src/storage/cleanup"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/cleanup"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // seedHome() writes real files plus a sqlite fixture for every case it backs. // On a slow windows-latest runner those cases land at 6-8s against bun's 5s diff --git a/tests/storage-restore-job-errors.test.ts b/tests/storage/storage-restore-job-errors.test.ts similarity index 93% rename from tests/storage-restore-job-errors.test.ts rename to tests/storage/storage-restore-job-errors.test.ts index eb45d7b992b..0f6c1f6e14c 100644 --- a/tests/storage-restore-job-errors.test.ts +++ b/tests/storage/storage-restore-job-errors.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { restoreResultFromWorkerRejection } from "../src/storage/restore-job"; +import { restoreResultFromWorkerRejection } from "../../src/storage/restore-job"; describe("restoreResultFromWorkerRejection", () => { test("maps worker timeout to restore_worker_timeout", () => { diff --git a/tests/storage-restore-job-responsive.test.ts b/tests/storage/storage-restore-job-responsive.test.ts similarity index 93% rename from tests/storage-restore-job-responsive.test.ts rename to tests/storage/storage-restore-job-responsive.test.ts index 1b44945dbc9..088877696c6 100644 --- a/tests/storage-restore-job-responsive.test.ts +++ b/tests/storage/storage-restore-job-responsive.test.ts @@ -3,23 +3,23 @@ * streaming response on the proxy event loop. */ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../helpers/management-auth"; import { Database } from "bun:sqlite"; import { existsSync, mkdirSync, mkdtempSync, utimesSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { drainAndShutdown } from "../src/server/lifecycle"; -import type { OcxConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { stopStorageCleanupScheduler } from "../src/storage/policy-scheduler"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { drainAndShutdown } from "../../src/server/lifecycle"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { stopStorageCleanupScheduler } from "../../src/storage/policy-scheduler"; import { resetRestoreTrashJobForTestsAsync, setRestoreTrashJobTestHooks, -} from "../src/storage/restore-job"; -import { drainStorageWorkers } from "../src/storage/worker-lifecycle"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/restore-job"; +import { drainStorageWorkers } from "../../src/storage/worker-lifecycle"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousHome: string | undefined; diff --git a/tests/storage-scanner.test.ts b/tests/storage/storage-scanner.test.ts similarity index 99% rename from tests/storage-scanner.test.ts rename to tests/storage/storage-scanner.test.ts index 78c9cc152bd..67f21d6ec03 100644 --- a/tests/storage-scanner.test.ts +++ b/tests/storage/storage-scanner.test.ts @@ -3,8 +3,8 @@ import { Database } from "bun:sqlite"; import { mkdirSync, mkdtempSync, readdirSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { scanStorage, type StorageBucket, type StorageReport } from "../src/storage/scanner"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { scanStorage, type StorageBucket, type StorageReport } from "../../src/storage/scanner"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const OLD_MTIME = new Date("2026-01-02T03:04:05Z"); const MID_MTIME = new Date("2026-03-04T05:06:07Z"); diff --git a/tests/storage-worker-lifecycle.test.ts b/tests/storage/storage-worker-lifecycle.test.ts similarity index 96% rename from tests/storage-worker-lifecycle.test.ts rename to tests/storage/storage-worker-lifecycle.test.ts index 1462b67335d..9f92227678c 100644 --- a/tests/storage-worker-lifecycle.test.ts +++ b/tests/storage/storage-worker-lifecycle.test.ts @@ -23,7 +23,7 @@ import { getStorageCleanupPolicyJobState, resetStorageCleanupPolicyJobForTestsAsync, setStorageCleanupPolicyJobTestHooks, -} from "../src/storage/policy-job"; +} from "../../src/storage/policy-job"; import { drainStorageWorkers, liveStorageWorkerCount, @@ -31,9 +31,9 @@ import { terminateStorageWorker, tryReserveStorageWorker, withStorageWorkerSpawnGate, -} from "../src/storage/worker-lifecycle"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/worker-lifecycle"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let isolatedCodexHome: IsolatedCodexHome | null = null; let testDir = ""; diff --git a/tests/storage-worker-os-join-settle.test.ts b/tests/storage/storage-worker-os-join-settle.test.ts similarity index 81% rename from tests/storage-worker-os-join-settle.test.ts rename to tests/storage/storage-worker-os-join-settle.test.ts index 6bd92a0aa71..68c32d5cc0e 100644 --- a/tests/storage-worker-os-join-settle.test.ts +++ b/tests/storage/storage-worker-os-join-settle.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { storageWorkerOsJoinSettleMs } from "../src/storage/worker-lifecycle"; +import { storageWorkerOsJoinSettleMs } from "../../src/storage/worker-lifecycle"; test("storage worker OS-join settle covers every Bun 1.3.14 isolate platform", () => { expect(storageWorkerOsJoinSettleMs("win32")).toBe(1_500); diff --git a/tests/storage-worker-teardown-isolate.test.ts b/tests/storage/storage-worker-teardown-isolate.test.ts similarity index 97% rename from tests/storage-worker-teardown-isolate.test.ts rename to tests/storage/storage-worker-teardown-isolate.test.ts index a516c6442c5..fa8c244a7d4 100644 --- a/tests/storage-worker-teardown-isolate.test.ts +++ b/tests/storage/storage-worker-teardown-isolate.test.ts @@ -28,14 +28,14 @@ import { resetStorageCleanupPolicyJobForTests, resetStorageCleanupPolicyJobForTestsAsync, setStorageCleanupPolicyJobTestHooks, -} from "../src/storage/policy-job"; +} from "../../src/storage/policy-job"; import { drainStorageWorkers, liveStorageWorkerCount, terminateStorageWorker, -} from "../src/storage/worker-lifecycle"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/storage/worker-lifecycle"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let isolatedCodexHome: IsolatedCodexHome | null = null; let testDir = ""; diff --git a/tests/test-layout-tooling.test.ts b/tests/test-layout-tooling.test.ts index 6a9066aa298..cb3e0036c55 100644 --- a/tests/test-layout-tooling.test.ts +++ b/tests/test-layout-tooling.test.ts @@ -286,8 +286,8 @@ describe("membership oracle", () => { // incorrectly on the day it is added. const pinnedOverrides = new Set([ "openai-responses-passthrough.test.ts", - // Placed under routing/ by its author in #3523 (it exercises the oauth routing quorum, - // not the Anthropic adapter); the anthropic- seed would say otherwise. + // Placed under routing/ by its author (#3523, restored by #3530): it exercises the oauth + // routing quorum, not the Anthropic adapter, so the anthropic- seed is wrong for it. "anthropic-quorum-cache.test.ts", ]); const mismatches: string[] = [];