From 7109a0646649b8785683d7f34e4aa6a30f99c92b Mon Sep 17 00:00:00 2001 From: jun Date: Sat, 5 Sep 2026 04:28:49 +0900 Subject: [PATCH 1/2] test(layout): move adapters, responses, lab, gui into tests// (#3497) --- .github/CODEOWNERS | 2 +- AGENTS.md | 2 +- ...eek-responses-streaming-terminal-repair.md | 30 +++--- .../2026-08-09-routed-computer-use-browser.md | 8 +- ...-12-cl10-public-evidence-implementation.md | 16 ++-- .../2026-08-13-cl10-deep-review-hardening.md | 4 +- ...ponses-streaming-terminal-repair-design.md | 2 +- gui/src/pages/claude-manual-env.ts | 2 +- gui/src/pages/dashboard-shared.ts | 2 +- .../pages/integrations/integration-tabs.ts | 2 +- gui/tests/integrations-tab-coverage.test.ts | 2 +- gui/tests/models-workspace-panels.test.tsx | 2 +- scripts/openai-provider-option-final-gates.ts | 20 ++-- scripts/test-layout/layout.json | 4 + scripts/test.ts | 2 +- src/adapters/openai-responses.ts | 2 +- src/adapters/xai-web-search.ts | 2 +- src/providers/label.ts | 2 +- src/server/index.ts | 2 +- src/server/management/route-registry.ts | 2 +- structure/04_transports-and-sidecars.md | 2 +- tests/{ => adapters}/abort-race.test.ts | 10 +- .../adapter-buffered-tool-conformance.test.ts | 14 +-- .../adapter-error-inline.test.ts | 10 +- .../adapter-registry-authority.test.ts | 8 +- .../adapter-tool-conformance.test.ts | 18 ++-- tests/{ => adapters}/adapter-usage.test.ts | 10 +- .../anthropic}/anthropic-account-pool.test.ts | 16 ++-- ...ropic-agentrouter-language-framing.test.ts | 6 +- .../anthropic-baseurl-override.test.ts | 6 +- .../anthropic-compatible-stream.test.ts | 10 +- .../anthropic-empty-content.test.ts | 4 +- .../anthropic-eof-tolerance.test.ts | 8 +- .../anthropic}/anthropic-error-body.test.ts | 14 +-- .../anthropic-error-stop-reason.test.ts | 8 +- .../anthropic}/anthropic-hardening.test.ts | 8 +- .../anthropic}/anthropic-image-guard.test.ts | 2 +- .../anthropic-image-normalize.test.ts | 4 +- .../anthropic-image-retry-e2e.test.ts | 16 ++-- .../anthropic}/anthropic-image-retry.test.ts | 10 +- .../anthropic-pool-toggle-copy.test.ts | 0 .../anthropic}/anthropic-reasoning.test.ts | 12 +-- .../anthropic-stream-hardening.test.ts | 6 +- .../anthropic}/anthropic-tail-guard.test.ts | 4 +- .../anthropic-thinking-signature.test.ts | 14 +-- .../anthropic}/anthropic-tool-call-id.test.ts | 2 +- .../anthropic}/anthropic-tool-schema.test.ts | 4 +- .../bridge-legacy-shell-normalization.test.ts | 4 +- tests/{ => adapters}/bridge-lifecycle.test.ts | 6 +- .../bridge-nonstreaming-terminal.test.ts | 6 +- .../bridge-raw-reasoning-hidden.test.ts | 12 +-- .../bridge-reasoning-replay-batch.test.ts | 6 +- .../bridge-terminal-singleness.test.ts | 4 +- tests/{ => adapters}/bridge.test.ts | 6 +- .../buffered-response-shape-guards.test.ts | 14 +-- .../empty-tool-output-annotation.test.ts | 12 +-- .../antigravity-baseurl-override.test.ts | 6 +- .../antigravity-static-catalog.test.ts | 10 +- tests/{ => adapters/google}/gcp-adc.test.ts | 12 +-- .../google}/gemini-37-flash-migration.test.ts | 16 ++-- .../google}/gemini-web-search.test.ts | 28 +++--- .../google}/google-adapter.test.ts | 8 +- .../google}/google-antigravity-oauth.test.ts | 8 +- .../google}/google-antigravity-replay.test.ts | 10 +- .../google}/google-antigravity-wire.test.ts | 16 ++-- .../google-buffered-stop-reason.test.ts | 8 +- .../google-claude-prefill-guard.test.ts | 6 +- .../google}/google-empty-content.test.ts | 4 +- .../google}/google-errors.test.ts | 2 +- .../google}/google-hardening.test.ts | 12 +-- .../google}/google-models-listing.test.ts | 14 +-- .../google}/google-output-clamp.test.ts | 2 +- ...google-provider-metadata-roundtrip.test.ts | 4 +- ...google-signature-history-roundtrip.test.ts | 18 ++-- .../google-tool-result-adjacency.test.ts | 4 +- .../google}/google-tool-schema.test.ts | 2 +- .../google}/google-vertex-http.test.ts | 10 +- .../google}/google-vertex-stream.test.ts | 12 +-- .../google-vertex-thought-signature.test.ts | 10 +- .../google}/google-wire-compiler.test.ts | 8 +- .../google}/vertex-catalog.test.ts | 8 +- .../identity-neutralize.test.ts | 14 +-- tests/{ => adapters}/key-failover.test.ts | 14 +-- .../openai}/openai-api-virtual-models.test.ts | 22 ++--- .../openai-chat-dangling-toolcalls.test.ts | 4 +- .../openai}/openai-chat-eof.test.ts | 8 +- .../openai}/openai-chat-hardening.test.ts | 14 +-- ...chat-invalid-tool-call-diagnostics.test.ts | 10 +- .../openai}/openai-chat-model-suffix.test.ts | 8 +- .../openai}/openai-chat-native-policy.test.ts | 14 +-- .../openai-chat-parallel-stream.test.ts | 6 +- .../openai}/openai-chat-system-order.test.ts | 4 +- .../openai-chat-tool-result-images.test.ts | 4 +- .../openai}/openai-chat-url.test.ts | 6 +- .../openai-provider-option-e2e.test.ts | 41 +++++---- .../openai-provider-option-migration.test.ts | 4 +- .../openai-provider-option-startup.test.ts | 12 +-- .../openai-provider-option-tooling.test.ts | 12 +-- .../openai}/openai-provider-option.test.ts | 10 +- .../reasoning-replay-identity.test.ts | 6 +- .../reasoning-replay-robustness.test.ts | 11 ++- tests/{ => adapters}/run-turn-queue.test.ts | 4 +- ...rminal-continuation-owner-rotation.test.ts | 20 ++-- .../tool-argument-integers.test.ts | 6 +- .../{ => adapters}/tool-catalog-nudge.test.ts | 6 +- .../tool-choice-performance.test.ts | 4 +- .../{ => adapters}/translator-budget.test.ts | 14 +-- .../upstream-http-error.test.ts | 2 +- .../{ => gui}/alibaba-intl-token-plan.test.ts | 8 +- tests/{ => gui}/claude-manual-env.test.ts | 2 +- .../codex-account-mode-state.test.ts | 2 +- .../{ => gui}/codex-auth-modal-status.test.ts | 0 tests/{ => gui}/combo-workspace-data.test.ts | 4 +- tests/{ => gui}/dashboard-uptime.test.ts | 2 +- tests/{ => gui}/gui-api-error.test.ts | 2 +- .../{ => gui}/gui-management-session.test.ts | 2 +- tests/{ => gui}/gui-pair-capability.test.ts | 2 +- tests/{ => gui}/gui-pair-client.test.ts | 8 +- tests/{ => gui}/gui-static.test.ts | 4 +- .../{ => gui}/integrations-invariants.test.ts | 24 ++--- .../logs-model-tier-confirmation.test.ts | 5 +- tests/{ => gui}/models-page-groups.test.ts | 2 +- tests/{ => gui}/models-workspace-tabs.test.ts | 4 +- tests/{ => gui}/oauth-first-add-hint.test.ts | 2 +- tests/{ => gui}/oauth-tos-warning.test.ts | 2 +- tests/{ => gui}/provider-payload.test.ts | 14 +-- .../{ => gui}/provider-workspace-auth.test.ts | 6 +- .../{ => gui}/provider-workspace-data.test.ts | 14 +-- .../{ => gui}/provider-workspace-rail.test.ts | 8 +- .../provider-workspace-state.test.ts | 2 +- tests/{ => gui}/quota-bars-rows.test.ts | 6 +- tests/{ => gui}/qwen-cloud-endpoints.test.ts | 8 +- .../rate-limit-reset-credits.test.ts | 6 +- .../{ => gui}/routing-intelligence-ui.test.ts | 7 +- .../routing-profile-editor-data.test.ts | 2 +- tests/{ => gui}/startup-health-ui.test.ts | 2 +- .../tencent-siliconflow-providers.test.ts | 16 ++-- .../vision-sidecar-timeout-bounds.test.ts | 4 +- tests/{ => gui}/volcengine-providers.test.ts | 28 +++--- tests/helpers/dead-pid.ts | 2 +- tests/{ => lab}/core-lab-boundary.test.ts | 3 +- tests/{ => lab}/lab-activation.test.ts | 24 ++--- ...-automation-coderabbit-regressions.test.ts | 36 ++++---- ...ation-final-coderabbit-regressions.test.ts | 35 +++---- ...ab-automation-ingwannu-regressions.test.ts | 17 ++-- .../lab-automation-management-http.test.ts | 14 +-- ...utomation-persisted-cap-regression.test.ts | 8 +- .../lab-automation-review-regressions.test.ts | 32 +++---- tests/{ => lab}/lab-automation.test.ts | 42 ++++----- .../{ => lab}/lab-community-evidence.test.ts | 8 +- .../lab-community-filename-contract.test.ts | 8 +- .../lab-community-mutation-lock.test.ts | 10 +- ...lab-community-publisher-continuity.test.ts | 6 +- .../{ => lab}/lab-conformance-harness.test.ts | 22 ++--- .../lab-conformance-runner-failures.test.ts | 6 +- tests/{ => lab}/lab-evidence-ledger.test.ts | 26 +++--- .../lab-evidence-sanitization.test.ts | 20 ++-- .../lab-fabric-outcome-validation.test.ts | 4 +- .../lab-fabric-persistence-boundary.test.ts | 2 +- tests/{ => lab}/lab-fabric-task.test.ts | 39 ++++---- .../lab-installation-salt-cache.test.ts | 6 +- .../lab-ledger-mutation-lock.test.ts | 19 ++-- .../lab-live-pinned-timeouts.test.ts | 4 +- tests/{ => lab}/lab-live-probe.test.ts | 20 ++-- .../lab-live-receipt-integrity.test.ts | 10 +- .../lab-live-review-regressions.test.ts | 6 +- tests/{ => lab}/lab-live-sandbox.test.ts | 14 +-- .../lab-passive-production-evidence.test.ts | 8 +- .../lab-passive-production-surfaces.test.ts | 12 +-- tests/{ => lab}/lab-paths-security.test.ts | 4 +- .../lab-post-merge-hardening.test.ts | 14 +-- .../lab-post-merge-projection.test.ts | 8 +- ...lab-private-file-consumer-recovery.test.ts | 12 +-- .../lab-private-file-durability.test.ts | 4 +- tests/{ => lab}/lab-public-api-json.test.ts | 6 +- .../lab-public-artifact-policy.test.ts | 6 +- .../lab-public-coderabbit-regressions.test.ts | 12 +-- .../lab-public-core-contract.test.ts | 24 ++--- ...lab-public-deep-review-regressions.test.ts | 8 +- tests/{ => lab}/lab-public-evidence.test.ts | 8 +- .../lab-public-export-transaction.test.ts | 16 ++-- .../{ => lab}/lab-public-file-safety.test.ts | 6 +- ...ab-public-final-review-regressions.test.ts | 10 +- .../lab-public-lifecycle-hardening.test.ts | 8 +- .../{ => lab}/lab-public-privacy-ipv6.test.ts | 2 +- .../lab-public-provenance-recovery.test.ts | 8 +- .../{ => lab}/lab-public-review-fixes.test.ts | 14 +-- .../lab-public-route-registry.test.ts | 2 +- .../lab-public-security-regressions.test.ts | 22 ++--- tests/{ => lab}/lab-public-surfaces.test.ts | 24 ++--- .../lab-public-wire-contract.test.ts | 6 +- .../lab-read-filter-validation.test.ts | 6 +- tests/{ => lab}/lab-read-surfaces.test.ts | 26 +++--- .../apply-patch-envelope.test.ts | 4 +- .../chat-completions-endpoint.test.ts | 92 +++++++++---------- .../{ => responses}/citation-markers.test.ts | 2 +- .../continuation-dedup.test.ts | 4 +- .../custom-tool-compat.test.ts | 2 +- .../empty-completion-core.test.ts | 14 +-- .../empty-completion-guard.test.ts | 4 +- .../empty-completion-hardening.test.ts | 4 +- .../eventstream-decoder.test.ts | 2 +- .../legacy-shell-compat.test.ts | 2 +- .../namespace-tool-compat.test.ts | 2 +- .../openai-responses-passthrough.test.ts | 24 ++--- .../{ => responses}/passthrough-abort.test.ts | 6 +- .../passthrough-headers.test.ts | 2 +- .../passthrough-override.test.ts | 6 +- .../responses-account-label.test.ts | 18 ++-- .../responses-compaction-routing.test.ts | 32 +++---- .../responses-compaction.test.ts | 16 ++-- .../responses-context-overflow.test.ts | 10 +- .../responses-custom-tool-guidance.test.ts | 4 +- .../responses-custom-tool-repair.test.ts | 12 +-- .../responses-fetch-helpers-boundary.test.ts | 5 +- .../responses-field-backfill.test.ts | 2 +- .../responses-forward-dangling-call.test.ts | 8 +- ...sponses-forward-posit-continuation.test.ts | 8 +- .../responses-forward-prompt-envelope.test.ts | 6 +- .../responses-image-gen-repair.test.ts | 10 +- .../responses-inbound-store-default.test.ts | 8 +- .../responses-item-id-repair.test.ts | 6 +- .../responses-json-events.test.ts | 2 +- .../responses-native-main-refresh.test.ts | 22 ++--- .../responses-opaque-blob-recovery.test.ts | 20 ++-- .../responses-parser-agent-message.test.ts | 2 +- ...responses-parser-malformed-content.test.ts | 8 +- .../{ => responses}/responses-parser.test.ts | 6 +- .../responses-pool-401-refresh.test.ts | 20 ++-- ...nses-reasoning-summary-passthrough.test.ts | 8 +- ...esponses-reasoning-summary-rewrite.test.ts | 2 +- ...responses-routed-web-search-fields.test.ts | 14 +-- ...sponses-self-named-namespace-scrub.test.ts | 6 +- .../responses-shadow-intercept.test.ts | 14 +-- .../responses-snapshot-repair-server.test.ts | 14 +-- .../responses-snapshot-repair.test.ts | 6 +- ...esponses-state-write-amplification.test.ts | 4 +- tests/{ => responses}/responses-state.test.ts | 39 ++++---- ...ses-stateless-dangling-call-repair.test.ts | 8 +- .../responses-stream-tool-events.test.ts | 4 +- .../responses-terminal-repair.test.ts | 8 +- .../responses-tool-conformance.test.ts | 8 +- .../responses-tool-groups.test.ts | 2 +- .../responses-tool-search-repair.test.ts | 12 +-- .../responses-undeclared-tool-guard.test.ts | 12 +-- .../responses-usage-passthrough.test.ts | 10 +- .../sse-client-frame-bounds.test.ts | 6 +- tests/{ => responses}/sse-decoder.test.ts | 4 +- tests/{ => responses}/sse-failed-tail.test.ts | 8 +- .../sse-inspector-bounds.test.ts | 4 +- .../sse-null-data-frame.test.ts | 12 +-- .../sse-payload-rewrite.test.ts | 10 +- .../sse-unspaced-data-fields.test.ts | 16 ++-- ...thought-signature-credential-scope.test.ts | 8 +- tests/{ => responses}/ws-endpoint.test.ts | 4 +- tests/{ => responses}/ws-upstream.test.ts | 16 ++-- 256 files changed, 1256 insertions(+), 1239 deletions(-) rename tests/{ => adapters}/abort-race.test.ts (97%) rename tests/{ => adapters}/adapter-buffered-tool-conformance.test.ts (93%) rename tests/{ => adapters}/adapter-error-inline.test.ts (96%) rename tests/{ => adapters}/adapter-registry-authority.test.ts (94%) rename tests/{ => adapters}/adapter-tool-conformance.test.ts (97%) rename tests/{ => adapters}/adapter-usage.test.ts (99%) rename tests/{ => adapters/anthropic}/anthropic-account-pool.test.ts (98%) rename tests/{ => adapters/anthropic}/anthropic-agentrouter-language-framing.test.ts (97%) rename tests/{ => adapters/anthropic}/anthropic-baseurl-override.test.ts (96%) rename tests/{ => adapters/anthropic}/anthropic-compatible-stream.test.ts (97%) rename tests/{ => adapters/anthropic}/anthropic-empty-content.test.ts (97%) rename tests/{ => adapters/anthropic}/anthropic-eof-tolerance.test.ts (97%) rename tests/{ => adapters/anthropic}/anthropic-error-body.test.ts (93%) rename tests/{ => adapters/anthropic}/anthropic-error-stop-reason.test.ts (95%) rename tests/{ => adapters/anthropic}/anthropic-hardening.test.ts (94%) rename tests/{ => adapters/anthropic}/anthropic-image-guard.test.ts (99%) rename tests/{ => adapters/anthropic}/anthropic-image-normalize.test.ts (99%) rename tests/{ => adapters/anthropic}/anthropic-image-retry-e2e.test.ts (93%) rename tests/{ => adapters/anthropic}/anthropic-image-retry.test.ts (91%) rename tests/{ => adapters/anthropic}/anthropic-pool-toggle-copy.test.ts (100%) rename tests/{ => adapters/anthropic}/anthropic-reasoning.test.ts (98%) rename tests/{ => adapters/anthropic}/anthropic-stream-hardening.test.ts (98%) rename tests/{ => adapters/anthropic}/anthropic-tail-guard.test.ts (96%) rename tests/{ => adapters/anthropic}/anthropic-thinking-signature.test.ts (97%) rename tests/{ => adapters/anthropic}/anthropic-tool-call-id.test.ts (98%) rename tests/{ => adapters/anthropic}/anthropic-tool-schema.test.ts (98%) rename tests/{ => adapters}/bridge-legacy-shell-normalization.test.ts (97%) rename tests/{ => adapters}/bridge-lifecycle.test.ts (98%) rename tests/{ => adapters}/bridge-nonstreaming-terminal.test.ts (98%) rename tests/{ => adapters}/bridge-raw-reasoning-hidden.test.ts (96%) rename tests/{ => adapters}/bridge-reasoning-replay-batch.test.ts (96%) rename tests/{ => adapters}/bridge-terminal-singleness.test.ts (98%) rename tests/{ => adapters}/bridge.test.ts (99%) rename tests/{ => adapters}/buffered-response-shape-guards.test.ts (97%) rename tests/{ => adapters}/empty-tool-output-annotation.test.ts (97%) rename tests/{ => adapters/google}/antigravity-baseurl-override.test.ts (95%) rename tests/{ => adapters/google}/antigravity-static-catalog.test.ts (76%) rename tests/{ => adapters/google}/gcp-adc.test.ts (97%) rename tests/{ => adapters/google}/gemini-37-flash-migration.test.ts (97%) rename tests/{ => adapters/google}/gemini-web-search.test.ts (93%) rename tests/{ => adapters/google}/google-adapter.test.ts (99%) rename tests/{ => adapters/google}/google-antigravity-oauth.test.ts (96%) rename tests/{ => adapters/google}/google-antigravity-replay.test.ts (99%) rename tests/{ => adapters/google}/google-antigravity-wire.test.ts (98%) rename tests/{ => adapters/google}/google-buffered-stop-reason.test.ts (91%) rename tests/{ => adapters/google}/google-claude-prefill-guard.test.ts (96%) rename tests/{ => adapters/google}/google-empty-content.test.ts (98%) rename tests/{ => adapters/google}/google-errors.test.ts (98%) rename tests/{ => adapters/google}/google-hardening.test.ts (99%) rename tests/{ => adapters/google}/google-models-listing.test.ts (97%) rename tests/{ => adapters/google}/google-output-clamp.test.ts (98%) rename tests/{ => adapters/google}/google-provider-metadata-roundtrip.test.ts (96%) rename tests/{ => adapters/google}/google-signature-history-roundtrip.test.ts (98%) rename tests/{ => adapters/google}/google-tool-result-adjacency.test.ts (98%) rename tests/{ => adapters/google}/google-tool-schema.test.ts (99%) rename tests/{ => adapters/google}/google-vertex-http.test.ts (98%) rename tests/{ => adapters/google}/google-vertex-stream.test.ts (95%) rename tests/{ => adapters/google}/google-vertex-thought-signature.test.ts (95%) rename tests/{ => adapters/google}/google-wire-compiler.test.ts (96%) rename tests/{ => adapters/google}/vertex-catalog.test.ts (96%) rename tests/{ => adapters}/identity-neutralize.test.ts (95%) rename tests/{ => adapters}/key-failover.test.ts (96%) rename tests/{ => adapters/openai}/openai-api-virtual-models.test.ts (97%) rename tests/{ => adapters/openai}/openai-chat-dangling-toolcalls.test.ts (98%) rename tests/{ => adapters/openai}/openai-chat-eof.test.ts (99%) rename tests/{ => adapters/openai}/openai-chat-hardening.test.ts (98%) rename tests/{ => adapters/openai}/openai-chat-invalid-tool-call-diagnostics.test.ts (95%) rename tests/{ => adapters/openai}/openai-chat-model-suffix.test.ts (95%) rename tests/{ => adapters/openai}/openai-chat-native-policy.test.ts (97%) rename tests/{ => adapters/openai}/openai-chat-parallel-stream.test.ts (98%) rename tests/{ => adapters/openai}/openai-chat-system-order.test.ts (95%) rename tests/{ => adapters/openai}/openai-chat-tool-result-images.test.ts (97%) rename tests/{ => adapters/openai}/openai-chat-url.test.ts (89%) rename tests/{ => adapters/openai}/openai-provider-option-e2e.test.ts (96%) rename tests/{ => adapters/openai}/openai-provider-option-migration.test.ts (99%) rename tests/{ => adapters/openai}/openai-provider-option-startup.test.ts (98%) rename tests/{ => adapters/openai}/openai-provider-option-tooling.test.ts (95%) rename tests/{ => adapters/openai}/openai-provider-option.test.ts (94%) rename tests/{ => adapters}/reasoning-replay-identity.test.ts (99%) rename tests/{ => adapters}/reasoning-replay-robustness.test.ts (92%) rename tests/{ => adapters}/run-turn-queue.test.ts (99%) rename tests/{ => adapters}/terminal-continuation-owner-rotation.test.ts (92%) rename tests/{ => adapters}/tool-argument-integers.test.ts (98%) rename tests/{ => adapters}/tool-catalog-nudge.test.ts (98%) rename tests/{ => adapters}/tool-choice-performance.test.ts (97%) rename tests/{ => adapters}/translator-budget.test.ts (96%) rename tests/{ => adapters}/upstream-http-error.test.ts (97%) rename tests/{ => gui}/alibaba-intl-token-plan.test.ts (97%) rename tests/{ => gui}/claude-manual-env.test.ts (94%) rename tests/{ => gui}/codex-account-mode-state.test.ts (94%) rename tests/{ => gui}/codex-auth-modal-status.test.ts (100%) rename tests/{ => gui}/combo-workspace-data.test.ts (99%) rename tests/{ => gui}/dashboard-uptime.test.ts (94%) rename tests/{ => gui}/gui-api-error.test.ts (93%) rename tests/{ => gui}/gui-management-session.test.ts (99%) rename tests/{ => gui}/gui-pair-capability.test.ts (98%) rename tests/{ => gui}/gui-pair-client.test.ts (96%) rename tests/{ => gui}/gui-static.test.ts (90%) rename tests/{ => gui}/integrations-invariants.test.ts (97%) rename tests/{ => gui}/logs-model-tier-confirmation.test.ts (96%) rename tests/{ => gui}/models-page-groups.test.ts (96%) rename tests/{ => gui}/models-workspace-tabs.test.ts (98%) rename tests/{ => gui}/oauth-first-add-hint.test.ts (96%) rename tests/{ => gui}/oauth-tos-warning.test.ts (98%) rename tests/{ => gui}/provider-payload.test.ts (96%) rename tests/{ => gui}/provider-workspace-auth.test.ts (98%) rename tests/{ => gui}/provider-workspace-data.test.ts (98%) rename tests/{ => gui}/provider-workspace-rail.test.ts (95%) rename tests/{ => gui}/provider-workspace-state.test.ts (99%) rename tests/{ => gui}/quota-bars-rows.test.ts (97%) rename tests/{ => gui}/qwen-cloud-endpoints.test.ts (93%) rename tests/{ => gui}/rate-limit-reset-credits.test.ts (99%) rename tests/{ => gui}/routing-intelligence-ui.test.ts (95%) rename tests/{ => gui}/routing-profile-editor-data.test.ts (99%) rename tests/{ => gui}/startup-health-ui.test.ts (99%) rename tests/{ => gui}/tencent-siliconflow-providers.test.ts (89%) rename tests/{ => gui}/vision-sidecar-timeout-bounds.test.ts (89%) rename tests/{ => gui}/volcengine-providers.test.ts (95%) rename tests/{ => lab}/core-lab-boundary.test.ts (99%) rename tests/{ => lab}/lab-activation.test.ts (94%) rename tests/{ => lab}/lab-automation-coderabbit-regressions.test.ts (91%) rename tests/{ => lab}/lab-automation-final-coderabbit-regressions.test.ts (88%) rename tests/{ => lab}/lab-automation-ingwannu-regressions.test.ts (87%) rename tests/{ => lab}/lab-automation-management-http.test.ts (90%) rename tests/{ => lab}/lab-automation-persisted-cap-regression.test.ts (80%) rename tests/{ => lab}/lab-automation-review-regressions.test.ts (93%) rename tests/{ => lab}/lab-automation.test.ts (93%) rename tests/{ => lab}/lab-community-evidence.test.ts (98%) rename tests/{ => lab}/lab-community-filename-contract.test.ts (94%) rename tests/{ => lab}/lab-community-mutation-lock.test.ts (92%) rename tests/{ => lab}/lab-community-publisher-continuity.test.ts (97%) rename tests/{ => lab}/lab-conformance-harness.test.ts (92%) rename tests/{ => lab}/lab-conformance-runner-failures.test.ts (89%) rename tests/{ => lab}/lab-evidence-ledger.test.ts (98%) rename tests/{ => lab}/lab-evidence-sanitization.test.ts (97%) rename tests/{ => lab}/lab-fabric-outcome-validation.test.ts (97%) rename tests/{ => lab}/lab-fabric-persistence-boundary.test.ts (82%) rename tests/{ => lab}/lab-fabric-task.test.ts (97%) rename tests/{ => lab}/lab-installation-salt-cache.test.ts (90%) rename tests/{ => lab}/lab-ledger-mutation-lock.test.ts (93%) rename tests/{ => lab}/lab-live-pinned-timeouts.test.ts (96%) rename tests/{ => lab}/lab-live-probe.test.ts (96%) rename tests/{ => lab}/lab-live-receipt-integrity.test.ts (90%) rename tests/{ => lab}/lab-live-review-regressions.test.ts (98%) rename tests/{ => lab}/lab-live-sandbox.test.ts (96%) rename tests/{ => lab}/lab-passive-production-evidence.test.ts (98%) rename tests/{ => lab}/lab-passive-production-surfaces.test.ts (91%) rename tests/{ => lab}/lab-paths-security.test.ts (93%) rename tests/{ => lab}/lab-post-merge-hardening.test.ts (96%) rename tests/{ => lab}/lab-post-merge-projection.test.ts (95%) rename tests/{ => lab}/lab-private-file-consumer-recovery.test.ts (88%) rename tests/{ => lab}/lab-private-file-durability.test.ts (98%) rename tests/{ => lab}/lab-public-api-json.test.ts (82%) rename tests/{ => lab}/lab-public-artifact-policy.test.ts (84%) rename tests/{ => lab}/lab-public-coderabbit-regressions.test.ts (96%) rename tests/{ => lab}/lab-public-core-contract.test.ts (91%) rename tests/{ => lab}/lab-public-deep-review-regressions.test.ts (97%) rename tests/{ => lab}/lab-public-evidence.test.ts (98%) rename tests/{ => lab}/lab-public-export-transaction.test.ts (86%) rename tests/{ => lab}/lab-public-file-safety.test.ts (88%) rename tests/{ => lab}/lab-public-final-review-regressions.test.ts (91%) rename tests/{ => lab}/lab-public-lifecycle-hardening.test.ts (97%) rename tests/{ => lab}/lab-public-privacy-ipv6.test.ts (95%) rename tests/{ => lab}/lab-public-provenance-recovery.test.ts (96%) rename tests/{ => lab}/lab-public-review-fixes.test.ts (95%) rename tests/{ => lab}/lab-public-route-registry.test.ts (95%) rename tests/{ => lab}/lab-public-security-regressions.test.ts (91%) rename tests/{ => lab}/lab-public-surfaces.test.ts (94%) rename tests/{ => lab}/lab-public-wire-contract.test.ts (96%) rename tests/{ => lab}/lab-read-filter-validation.test.ts (86%) rename tests/{ => lab}/lab-read-surfaces.test.ts (95%) rename tests/{ => responses}/apply-patch-envelope.test.ts (98%) rename tests/{ => responses}/chat-completions-endpoint.test.ts (97%) rename tests/{ => responses}/citation-markers.test.ts (98%) rename tests/{ => responses}/continuation-dedup.test.ts (99%) rename tests/{ => responses}/custom-tool-compat.test.ts (98%) rename tests/{ => responses}/empty-completion-core.test.ts (97%) rename tests/{ => responses}/empty-completion-guard.test.ts (99%) rename tests/{ => responses}/empty-completion-hardening.test.ts (97%) rename tests/{ => responses}/eventstream-decoder.test.ts (99%) rename tests/{ => responses}/legacy-shell-compat.test.ts (97%) rename tests/{ => responses}/namespace-tool-compat.test.ts (99%) rename tests/{ => responses}/openai-responses-passthrough.test.ts (99%) rename tests/{ => responses}/passthrough-abort.test.ts (99%) rename tests/{ => responses}/passthrough-headers.test.ts (96%) rename tests/{ => responses}/passthrough-override.test.ts (93%) rename tests/{ => responses}/responses-account-label.test.ts (92%) rename tests/{ => responses}/responses-compaction-routing.test.ts (98%) rename tests/{ => responses}/responses-compaction.test.ts (96%) rename tests/{ => responses}/responses-context-overflow.test.ts (96%) rename tests/{ => responses}/responses-custom-tool-guidance.test.ts (94%) rename tests/{ => responses}/responses-custom-tool-repair.test.ts (99%) rename tests/{ => responses}/responses-fetch-helpers-boundary.test.ts (97%) rename tests/{ => responses}/responses-field-backfill.test.ts (99%) rename tests/{ => responses}/responses-forward-dangling-call.test.ts (90%) rename tests/{ => responses}/responses-forward-posit-continuation.test.ts (95%) rename tests/{ => responses}/responses-forward-prompt-envelope.test.ts (96%) rename tests/{ => responses}/responses-image-gen-repair.test.ts (97%) rename tests/{ => responses}/responses-inbound-store-default.test.ts (94%) rename tests/{ => responses}/responses-item-id-repair.test.ts (97%) rename tests/{ => responses}/responses-json-events.test.ts (98%) rename tests/{ => responses}/responses-native-main-refresh.test.ts (94%) rename tests/{ => responses}/responses-opaque-blob-recovery.test.ts (97%) rename tests/{ => responses}/responses-parser-agent-message.test.ts (98%) rename tests/{ => responses}/responses-parser-malformed-content.test.ts (96%) rename tests/{ => responses}/responses-parser.test.ts (99%) rename tests/{ => responses}/responses-pool-401-refresh.test.ts (98%) rename tests/{ => responses}/responses-reasoning-summary-passthrough.test.ts (95%) rename tests/{ => responses}/responses-reasoning-summary-rewrite.test.ts (99%) rename tests/{ => responses}/responses-routed-web-search-fields.test.ts (96%) rename tests/{ => responses}/responses-self-named-namespace-scrub.test.ts (98%) rename tests/{ => responses}/responses-shadow-intercept.test.ts (96%) rename tests/{ => responses}/responses-snapshot-repair-server.test.ts (94%) rename tests/{ => responses}/responses-snapshot-repair.test.ts (99%) rename tests/{ => responses}/responses-state-write-amplification.test.ts (99%) rename tests/{ => responses}/responses-state.test.ts (99%) rename tests/{ => responses}/responses-stateless-dangling-call-repair.test.ts (98%) rename tests/{ => responses}/responses-stream-tool-events.test.ts (98%) rename tests/{ => responses}/responses-terminal-repair.test.ts (98%) rename tests/{ => responses}/responses-tool-conformance.test.ts (98%) rename tests/{ => responses}/responses-tool-groups.test.ts (93%) rename tests/{ => responses}/responses-tool-search-repair.test.ts (98%) rename tests/{ => responses}/responses-undeclared-tool-guard.test.ts (99%) rename tests/{ => responses}/responses-usage-passthrough.test.ts (95%) rename tests/{ => responses}/sse-client-frame-bounds.test.ts (97%) rename tests/{ => responses}/sse-decoder.test.ts (97%) rename tests/{ => responses}/sse-failed-tail.test.ts (97%) rename tests/{ => responses}/sse-inspector-bounds.test.ts (99%) rename tests/{ => responses}/sse-null-data-frame.test.ts (97%) rename tests/{ => responses}/sse-payload-rewrite.test.ts (93%) rename tests/{ => responses}/sse-unspaced-data-fields.test.ts (94%) rename tests/{ => responses}/thought-signature-credential-scope.test.ts (96%) rename tests/{ => responses}/ws-endpoint.test.ts (99%) rename tests/{ => responses}/ws-upstream.test.ts (98%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ae2c27bce7..fabb5a31bc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -37,7 +37,7 @@ # These four files carry every user's request path, including users of no optional # subsystem. Optional subsystems (Compatibility Lab and anything added later) register # into core-owned slots at activation instead of being imported here; the invariant is -# enforced by tests/core-lab-boundary.test.ts and designed in +# enforced by tests/lab/core-lab-boundary.test.ts and designed in # devlog/_fin/260814_lab_core_decoupling/. # Last-match-wins: this block must stay below /src/server/ to take effect. /src/router.ts @lidge-jun diff --git a/AGENTS.md b/AGENTS.md index eb8e0f47af..d011af129b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -51,7 +51,7 @@ directly or transitively: - `src/server/lifecycle.ts` - `src/server/responses/core.ts` -`tests/core-lab-boundary.test.ts` enforces this by walking the runtime import +`tests/lab/core-lab-boundary.test.ts` enforces this by walking the runtime import graph and printing the offending chain on failure. It is not a style rule: the original violation hid in a six-hop chain (`assemble → quota → auth-api → native-main-admission → lifecycle → lab`) where 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 de1983ef81..11976200cd 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 @@ -26,9 +26,9 @@ - `src/providers/registry.ts` — declares and resolves the built-in per-model terminal-repair policy. - `src/server/responses-terminal-repair.ts` — owns SSE lifecycle tracking, bounded retained state, grace scheduling, and synthetic terminal creation. - `src/server/responses/core.ts` — activates the repair before existing transport-specific relay branches. -- `tests/responses-terminal-repair.test.ts` — unit state-machine and stream-race coverage. +- `tests/responses/responses-terminal-repair.test.ts` — unit state-machine and stream-race coverage. - `tests/deepseek-inbound-wire.test.ts` — end-to-end official DeepSeek wire and HTTP activation. -- `tests/ws-endpoint.test.ts` — WebSocket event parity for real and repaired terminals. +- `tests/responses/ws-endpoint.test.ts` — WebSocket event parity for real and repaired terminals. - `structure/04_transports-and-sidecars.md` — architectural contract for the provider-scoped streaming repair. - `docs/superpowers/specs/2026-08-06-deepseek-responses-streaming-terminal-repair-design.md` — approved design authority; implementation must remain consistent with it. @@ -153,7 +153,7 @@ git commit -m "fix(deepseek): restore Responses upstream streaming" **Files:** - Create: `src/server/responses-terminal-repair.ts` -- Create: `tests/responses-terminal-repair.test.ts` +- Create: `tests/responses/responses-terminal-repair.test.ts` **Interfaces:** - Consumes: `ResponsesTerminalRepairPolicy` @@ -201,7 +201,7 @@ terminal followed by one `[DONE]`. Run: ```bash -bun test tests/responses-terminal-repair.test.ts +bun test tests/responses/responses-terminal-repair.test.ts ``` Expected: module-not-found failure for @@ -251,7 +251,7 @@ an item and release every remaining charge during disposal. Run: ```bash -bun test tests/responses-terminal-repair.test.ts +bun test tests/responses/responses-terminal-repair.test.ts ``` Expected: healthy pass-through and five-second grace completion both pass; @@ -260,7 +260,7 @@ translator-budget current bytes return to zero after drain. - [ ] **Step 5: Commit** ```bash -git add src/server/responses-terminal-repair.ts tests/responses-terminal-repair.test.ts +git add src/server/responses-terminal-repair.ts tests/responses/responses-terminal-repair.test.ts git commit -m "feat(responses): repair complete terminal-less streams" ``` @@ -270,7 +270,7 @@ git commit -m "feat(responses): repair complete terminal-less streams" **Files:** - Modify: `src/server/responses-terminal-repair.ts` -- Modify: `tests/responses-terminal-repair.test.ts` +- Modify: `tests/responses/responses-terminal-repair.test.ts` **Interfaces:** - Preserves Task 2 public signatures. @@ -305,7 +305,7 @@ cancellation, an empty scheduler queue, and Run: ```bash -bun test tests/responses-terminal-repair.test.ts +bun test tests/responses/responses-terminal-repair.test.ts ``` Expected: the newly added boundary tests fail because Task 2 implements only @@ -366,7 +366,7 @@ abort/cancel, taint, and candidate completeness immediately before enqueueing. Run: ```bash -bun test tests/responses-terminal-repair.test.ts tests/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/relay-eager.test.ts ``` Expected: all tests pass with no duplicate terminal, timer leak, or retained @@ -375,7 +375,7 @@ budget after teardown. - [ ] **Step 5: Commit** ```bash -git add src/server/responses-terminal-repair.ts tests/responses-terminal-repair.test.ts +git add src/server/responses-terminal-repair.ts tests/responses/responses-terminal-repair.test.ts git commit -m "fix(responses): fail closed on unsafe terminal repair" ``` @@ -388,7 +388,7 @@ git commit -m "fix(responses): fail closed on unsafe terminal repair" - Modify: `src/server/responses/core.ts:2030-2230` - Modify: `tests/deepseek-inbound-wire.test.ts:115-330` - Modify: `tests/deepseek-responses-item-id-repair.test.ts` -- Modify: `tests/ws-endpoint.test.ts` +- Modify: `tests/responses/ws-endpoint.test.ts` **Interfaces:** - Consumes: `providerModelResponsesTerminalRepair(...)` @@ -432,7 +432,7 @@ WebSocket handling. Assert the client receives progressive delta frames, one Run: ```bash -bun test tests/deepseek-inbound-wire.test.ts tests/ws-endpoint.test.ts +bun test tests/deepseek-inbound-wire.test.ts tests/responses/ws-endpoint.test.ts ``` Expected: requests now carry `stream:true` from Task 1 but no provider-scoped @@ -482,7 +482,7 @@ streaming resolver still returns `false`. Run: ```bash -bun test tests/deepseek-inbound-wire.test.ts tests/ws-endpoint.test.ts tests/responses-state.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/deepseek-reasoning-replay.test.ts +bun test tests/deepseek-inbound-wire.test.ts tests/responses/ws-endpoint.test.ts tests/responses/responses-state.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/deepseek-reasoning-replay.test.ts ``` Expected: progressive output precedes terminal, both transports close once, @@ -491,7 +491,7 @@ item ids are stable, and continuation state retains reasoning/function output. - [ ] **Step 6: Commit** ```bash -git add src/server/responses/core.ts tests/deepseek-inbound-wire.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/ws-endpoint.test.ts +git add src/server/responses/core.ts tests/deepseek-inbound-wire.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/responses/ws-endpoint.test.ts git commit -m "fix(deepseek): repair terminal-less Responses streams" ``` @@ -560,7 +560,7 @@ git commit -m "docs(deepseek): describe streaming terminal repair" Run: ```bash -bun test tests/responses-terminal-repair.test.ts tests/deepseek-inbound-wire.test.ts tests/ws-endpoint.test.ts tests/sse-failed-tail.test.ts tests/relay-eager.test.ts tests/responses-item-id-repair.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/deepseek-reasoning-replay.test.ts tests/responses-state.test.ts +bun test tests/responses/responses-terminal-repair.test.ts tests/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/deepseek-responses-item-id-repair.test.ts tests/deepseek-reasoning-replay.test.ts tests/responses/responses-state.test.ts ``` Expected: 0 failures. diff --git a/docs/superpowers/plans/2026-08-09-routed-computer-use-browser.md b/docs/superpowers/plans/2026-08-09-routed-computer-use-browser.md index 19c0f34842..55121abd8e 100644 --- a/docs/superpowers/plans/2026-08-09-routed-computer-use-browser.md +++ b/docs/superpowers/plans/2026-08-09-routed-computer-use-browser.md @@ -229,7 +229,7 @@ git commit -m "docs(codex): explain routed local tool access" Run: ```bash -bun test tests/responses-parser.test.ts tests/bridge.test.ts tests/multi-agent-compat.test.ts +bun test tests/responses/responses-parser.test.ts tests/adapters/bridge.test.ts tests/multi-agent-compat.test.ts ``` Expected: custom declaration, streaming `custom_tool_call`, exact freeform input, and output replay remain green. Add no production protocol change unless one of these tests proves a real gap. @@ -239,7 +239,7 @@ Expected: custom declaration, streaming `custom_tool_call`, exact freeform input Run: ```bash -bun test tests/responses-terminal-repair.test.ts tests/deepseek-inbound-wire.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/passthrough-abort.test.ts +bun test tests/responses/responses-terminal-repair.test.ts tests/deepseek-inbound-wire.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/responses/passthrough-abort.test.ts ``` Expected: progressive deltas, strict terminal repair, item IDs, and cancellation pass. @@ -249,7 +249,7 @@ Expected: progressive deltas, strict terminal repair, item IDs, and cancellation Run: ```bash -bun test tests/vision/vision-sidecar-e2e.test.ts tests/vision/vision-anthropic.test.ts tests/vision/vision-cache.test.ts tests/vision/vision-fail-closed.test.ts tests/catalog-vision-sidecar-modalities.test.ts tests/openai-responses-passthrough.test.ts +bun test tests/vision/vision-sidecar-e2e.test.ts tests/vision/vision-anthropic.test.ts tests/vision/vision-cache.test.ts tests/vision/vision-fail-closed.test.ts tests/catalog-vision-sidecar-modalities.test.ts tests/responses/openai-responses-passthrough.test.ts ``` Expected: captions replace raw image parts in passthrough bodies, empty references do not consume captions, and partial/failure paths omit pixels safely. @@ -259,7 +259,7 @@ Expected: captions replace raw image parts in passthrough bodies, empty referenc Run: ```bash -bun test tests/images/plan.test.ts tests/images/synthetic-tool.test.ts tests/images/z-handler-activation.test.ts tests/images/loop-reasoning-replay.test.ts tests/responses-image-gen-repair.test.ts +bun test tests/images/plan.test.ts tests/images/synthetic-tool.test.ts tests/images/z-handler-activation.test.ts tests/images/loop-reasoning-replay.test.ts tests/responses/responses-image-gen-repair.test.ts ``` Expected: image tool planning, activation, alias restoration, replay, and result repair pass. diff --git a/docs/superpowers/plans/2026-08-12-cl10-public-evidence-implementation.md b/docs/superpowers/plans/2026-08-12-cl10-public-evidence-implementation.md index 54f6a99062..4dc585bec2 100644 --- a/docs/superpowers/plans/2026-08-12-cl10-public-evidence-implementation.md +++ b/docs/superpowers/plans/2026-08-12-cl10-public-evidence-implementation.md @@ -49,14 +49,14 @@ - Create: `src/lab/public/project.ts` - Create: `src/lab/public/index.ts` - Modify: `src/lab/index.ts` -- Test: `tests/lab-public-evidence.test.ts` +- Test: `tests/lab/lab-public-evidence.test.ts` **Interfaces:** - Produces: `PublicEvidenceBundleUnsignedV1`, `PublicEvidenceRecordV1`, `PublicEvidenceSubjectV1`, `PublicRouteRegistryManifestV1`, `projectPublicEvidence()`, `validatePublicEvidenceBundle()`. - [ ] **Step 1: Write RED tests** for closed-schema rejection, deterministic public IDs/day buckets, protocol/route/task subject discrimination, exact route allowlist, private-route `not_exportable`, IC-only incident refs, no local ID leakage, and secret/PII canaries. - [ ] **Step 2: Run focused test and verify expected RED failures.** - Run: `bun test tests/lab-public-evidence.test.ts` + Run: `bun test tests/lab/lab-public-evidence.test.ts` - [ ] **Step 3: Implement minimal closed public types/registry/validator/projector.** Public identities use domain-separated SHA-256 over JCS public-safe bytes. The registry manifest is repo-owned, versioned, digested, and cannot be supplied by an imported bundle as trust authority. - [ ] **Step 4: Run focused test and verify GREEN.** @@ -67,7 +67,7 @@ - Create: `src/lab/public/signature.ts` - Create: `src/lab/public/storage.ts` - Modify: `src/lab/paths.ts` -- Test: `tests/lab-public-evidence.test.ts` +- Test: `tests/lab/lab-public-evidence.test.ts` **Interfaces:** - Produces: `getOrCreatePublicPublisher()`, `signPublicEvidenceBundle()`, `verifyPublicEvidenceBundle()`, `writePublicEvidenceBundle()`, `readPublicEvidenceBundle()`. @@ -82,7 +82,7 @@ **Files:** - Create: `src/lab/public/revocation.ts` - Create: `src/lab/public/community.ts` -- Test: `tests/lab-public-evidence.test.ts` +- Test: `tests/lab/lab-public-evidence.test.ts` **Interfaces:** - Produces: `PublicEvidenceRevocationV1`, `verifyPublicEvidenceRevocation()`, `importCommunityBundle()`, `listCommunityBundles()`. @@ -97,8 +97,8 @@ **Files:** - Modify: `src/lab/ledger/purge.ts` - Modify: `src/lab/paths.ts` -- Test: `tests/lab-public-evidence.test.ts` -- Test: `tests/lab-evidence-ledger.test.ts` +- Test: `tests/lab/lab-public-evidence.test.ts` +- Test: `tests/lab/lab-evidence-ledger.test.ts` **Interfaces:** - Consumes: existing `purgeSensitiveEvidence()` and `purgeActions: export`. @@ -114,7 +114,7 @@ **Files:** - Modify: `src/cli/lab.ts` - Modify: `src/server/management/lab-routes.ts` -- Test: `tests/lab-public-evidence.test.ts` +- Test: `tests/lab/lab-public-evidence.test.ts` - Test: relevant Lab CLI/management tests discovered in repository. **Interfaces:** @@ -147,7 +147,7 @@ **Files:** - Modify docs only if validation findings require factual updates. -- [ ] **Step 1:** Run `bun test tests/lab-public-evidence.test.ts tests/lab-evidence-ledger.test.ts`. +- [ ] **Step 1:** Run `bun test tests/lab/lab-public-evidence.test.ts tests/lab/lab-evidence-ledger.test.ts`. - [ ] **Step 2:** Run `bun x tsc --noEmit`. - [ ] **Step 3:** Run `bun run privacy:scan`. - [ ] **Step 4:** Run relevant Lab query/ledger/CLI/GUI tests. 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 e1ccfccbcf..32abc929e5 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 @@ -26,7 +26,7 @@ ### Task 1: Add adversarial RED coverage **Files:** -- Create: `tests/lab-public-deep-review-regressions.test.ts` +- Create: `tests/lab/lab-public-deep-review-regressions.test.ts` - Modify: `tests/ci-workflows.test.ts` **Interfaces:** @@ -135,7 +135,7 @@ - Modify: `src/lab/public/operator.ts` - Modify: `src/cli/lab.ts` - Modify: `src/server/management/lab-routes.ts` -- Modify: `tests/lab-public-surfaces.test.ts` +- Modify: `tests/lab/lab-public-surfaces.test.ts` **Interfaces:** - Produces: preview/export results that expose exclusion indices/reasons and `stored.created` only, never local event IDs or filesystem paths. diff --git a/docs/superpowers/specs/2026-08-06-deepseek-responses-streaming-terminal-repair-design.md b/docs/superpowers/specs/2026-08-06-deepseek-responses-streaming-terminal-repair-design.md index 9acf1aab7e..da50bea61a 100644 --- a/docs/superpowers/specs/2026-08-06-deepseek-responses-streaming-terminal-repair-design.md +++ b/docs/superpowers/specs/2026-08-06-deepseek-responses-streaming-terminal-repair-design.md @@ -227,7 +227,7 @@ The implementation is expected to touch these responsibility boundaries: wrapper. - `src/server/responses/core.ts`: resolve the provider policy and wrap the SSE body before transport-specific relay branches. -- `tests/responses-terminal-repair.test.ts`: unit state-machine coverage. +- `tests/responses/responses-terminal-repair.test.ts`: unit state-machine coverage. - `tests/deepseek-inbound-wire.test.ts`: end-to-end wire, progressive delivery, repair composition, and WebSocket/HTTP activation. - Existing relay and item-id tests only where an explicit integration contract diff --git a/gui/src/pages/claude-manual-env.ts b/gui/src/pages/claude-manual-env.ts index 5f22e37165..fca18fb61c 100644 --- a/gui/src/pages/claude-manual-env.ts +++ b/gui/src/pages/claude-manual-env.ts @@ -1,7 +1,7 @@ /** * Pure manual-env builder for the Claude Code page (devlog * 260720_claude_authmode_persist/020): extracted from ClaudeCode.tsx so the - * copy-paste shell block is directly unit-testable (tests/claude-manual-env.test.ts). + * copy-paste shell block is directly unit-testable (tests/gui/claude-manual-env.test.ts). */ import { AUTO_COMPACT_WINDOW_DEFAULT } from "./claude-code-types"; diff --git a/gui/src/pages/dashboard-shared.ts b/gui/src/pages/dashboard-shared.ts index 84d2da1523..0793a7def2 100644 --- a/gui/src/pages/dashboard-shared.ts +++ b/gui/src/pages/dashboard-shared.ts @@ -241,7 +241,7 @@ export function visionTimeoutPatch(timeoutMs: number): SidecarPatch { /** * Dashboard names for the runtime timeout contract in `src/vision/timeout-bounds.ts`. - * Pinned by `tests/vision-sidecar-timeout-bounds.test.ts`. + * Pinned by `tests/gui/vision-sidecar-timeout-bounds.test.ts`. */ export const VISION_TIMEOUT_MS_DEFAULT = DEFAULT_VISION_TIMEOUT_MS; export const VISION_TIMEOUT_MS_MAX = MAX_VISION_TIMEOUT_MS; diff --git a/gui/src/pages/integrations/integration-tabs.ts b/gui/src/pages/integrations/integration-tabs.ts index 7f1c59ad34..33c4f04358 100644 --- a/gui/src/pages/integrations/integration-tabs.ts +++ b/gui/src/pages/integrations/integration-tabs.ts @@ -4,7 +4,7 @@ * A separate module rather than exports on Integrations.tsx, because a file that * exports both a component and constants breaks React fast refresh * (react/only-export-components). These need to be importable: they are the only - * client lists in the GUI that neither tests/integrations-invariants.test.ts + * client lists in the GUI that neither tests/gui/integrations-invariants.test.ts * compares nor the compiler forces, so a client added everywhere else still gets * no tab and nothing fails. gui/tests/integrations-tab-coverage.test.ts stands in * that gap and reads them from here. diff --git a/gui/tests/integrations-tab-coverage.test.ts b/gui/tests/integrations-tab-coverage.test.ts index 91f24af2b9..0d08c47aa2 100644 --- a/gui/tests/integrations-tab-coverage.test.ts +++ b/gui/tests/integrations-tab-coverage.test.ts @@ -6,7 +6,7 @@ import { INTEGRATION_TAB_HASHES } from "../src/app-routing"; /* * The gap this closes. * - * tests/integrations-invariants.test.ts compares five client lists, and the + * tests/gui/integrations-invariants.test.ts compares five client lists, and the * per-page label maps are Record so the compiler * forces those. TABS and FILE_CLIENTS are neither: they are a plain array and a * plain Set, so a client added everywhere else still gets no tab and nothing diff --git a/gui/tests/models-workspace-panels.test.tsx b/gui/tests/models-workspace-panels.test.tsx index 252edd46e8..5cb9098e48 100644 --- a/gui/tests/models-workspace-panels.test.tsx +++ b/gui/tests/models-workspace-panels.test.tsx @@ -1,7 +1,7 @@ /** * Models tab workspace — mounted behaviour. * - * The routing helpers are unit-tested at `tests/models-workspace-tabs.test.ts`. This file + * The routing helpers are unit-tested at `tests/gui/models-workspace-tabs.test.ts`. This file * exists because those assertions cannot see the failures that actually happened here: * a component-level early return that unmounted the whole tab tree while the catalog * loaded, and a disabled resource that swapped the combo editor for an empty state and diff --git a/scripts/openai-provider-option-final-gates.ts b/scripts/openai-provider-option-final-gates.ts index cce9242bab..d07458721c 100644 --- a/scripts/openai-provider-option-final-gates.ts +++ b/scripts/openai-provider-option-final-gates.ts @@ -42,14 +42,14 @@ export async function runGateSequence(plan: GateSpec[], deps: GateDeps): Promise } const focusedTests = [ - "tests/openai-provider-option.test.ts", - "tests/openai-provider-option-migration.test.ts", - "tests/openai-provider-option-startup.test.ts", - "tests/openai-provider-option-e2e.test.ts", - "tests/openai-provider-option-tooling.test.ts", + "tests/adapters/openai/openai-provider-option.test.ts", + "tests/adapters/openai/openai-provider-option-migration.test.ts", + "tests/adapters/openai/openai-provider-option-startup.test.ts", + "tests/adapters/openai/openai-provider-option-e2e.test.ts", + "tests/adapters/openai/openai-provider-option-tooling.test.ts", "tests/provider-registry-parity.test.ts", - "tests/provider-payload.test.ts", - "tests/codex-account-mode-state.test.ts", + "tests/gui/provider-payload.test.ts", + "tests/gui/codex-account-mode-state.test.ts", "tests/routing/router.test.ts", "tests/codex-routing.test.ts", "tests/server-auth.test.ts", @@ -70,7 +70,7 @@ export function finalGatePlan(root: string, evidenceDir: string, unitRoot = dirn const env = { ...process.env, OCX_EVIDENCE_DIR: evidenceDir } as Record; const unitPath = relative(root, unitRoot); return [ - { name: "openai-provider-option-e2e", command: ["bun", "test", "tests/openai-provider-option-e2e.test.ts"], cwd: root, env }, + { name: "openai-provider-option-e2e", command: ["bun", "test", "tests/adapters/openai/openai-provider-option-e2e.test.ts"], cwd: root, env }, { name: "provider-option-focused", command: ["bun", "test", "--isolate", ...focusedTests], cwd: root, env }, { name: "isolated-runtime-smoke", command: ["bun", "scripts/openai-provider-option-runtime-smoke.ts", "--unit-root", unitPath, "--evidence-dir", evidenceDir], cwd: root }, { name: "live-key-status", command: ["bun", "scripts/openai-provider-option-runtime-smoke.ts", "--check-live-key", "--unit-root", unitPath, "--evidence-dir", evidenceDir], cwd: root }, @@ -91,8 +91,8 @@ export function finalGatePlan(root: string, evidenceDir: string, unitRoot = dirn { name: "scoped-diff-check", command: ["git", "diff", "--check", "--", "README.md", "readme/README.ko.md", "readme/README.zh-CN.md", "structure", - "docs-site/src/content/docs", "devlog/_chase/_model", "tests/openai-provider-option-e2e.test.ts", - "tests/openai-provider-option-tooling.test.ts", "tests/fixtures/openai-provider-option-migration-child.ts", + "docs-site/src/content/docs", "devlog/_chase/_model", "tests/adapters/openai/openai-provider-option-e2e.test.ts", + "tests/adapters/openai/openai-provider-option-tooling.test.ts", "tests/fixtures/openai-provider-option-migration-child.ts", "scripts/openai-provider-option-runtime-child.ts", "scripts/openai-provider-option-runtime-smoke.ts", "scripts/openai-provider-option-evidence-scan.ts", "scripts/openai-provider-option-final-gates.ts", "scripts/openai-hardening-live-policy.ts", "scripts/openai-hardening-runtime-env.ts", diff --git a/scripts/test-layout/layout.json b/scripts/test-layout/layout.json index 9c2444011a..e81cd5f009 100644 --- a/scripts/test-layout/layout.json +++ b/scripts/test-layout/layout.json @@ -1227,12 +1227,16 @@ "zz-pr-coderabbit-readiness-revalidation.test.ts": "ci-workflows" }, "migrated": [ + "adapters", "claude-integration", "cli", "clients", "config", + "gui", + "lab", "lib", "oauth", + "responses", "routing", "service", "update", diff --git a/scripts/test.ts b/scripts/test.ts index 0e6721deca..7b95acf35e 100644 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -328,7 +328,7 @@ export const SERIAL_FULL_SUITE_FILES = [ "codex-shim.test.ts", "cursor-native-exec-shell.test.ts", "issue-452-empty-503.test.ts", - "openai-provider-option-e2e.test.ts", + "adapters/openai/openai-provider-option-e2e.test.ts", "release-helper.test.ts", "update/update-stop-first.test.ts", ] as const; diff --git a/src/adapters/openai-responses.ts b/src/adapters/openai-responses.ts index d46bd5d80a..22b7edadd7 100644 --- a/src/adapters/openai-responses.ts +++ b/src/adapters/openai-responses.ts @@ -187,7 +187,7 @@ const CANONICAL_ONLY_TOOL_FIELDS: readonly { field: string; toolTypes?: Readonly // OWNERSHIP: official OpenAI API-key traffic and unclassified gateways ACCEPT this field, so // it is only stripped when the provider capability denies it (supportsOpenAiWebSearchToolFields // === false), matching stripOpenAiOnlyWebSearchFields; see - // tests/responses-routed-web-search-fields.test.ts. + // tests/responses/responses-routed-web-search-fields.test.ts. { field: "external_web_access", toolTypes: new Set(["web_search", "web_search_preview"]), capabilityGated: true }, // Deferred-discovery marker. `activateDeferredTool` clears it only for tools a `tool_search_output` // already loaded, so a still-deferred declaration — including one promoted out of a namespace diff --git a/src/adapters/xai-web-search.ts b/src/adapters/xai-web-search.ts index 15273c4caf..e558e39f2e 100644 --- a/src/adapters/xai-web-search.ts +++ b/src/adapters/xai-web-search.ts @@ -55,7 +55,7 @@ function normalizeToolGroup(tools: unknown[]): ToolGroupRewrite { // `search_context_size` 400s, while `user_location`, `search_content_types`, `filters` and // `enable_image_search` are all accepted. Deleting the accepted ones was a silent capability // loss, and it contradicted the sibling layer, whose own probe note already records - // user_location/filters as accepted (tests/responses-routed-web-search-fields.test.ts). + // user_location/filters as accepted (tests/responses/responses-routed-web-search-fields.test.ts). delete next.external_web_access; delete next.search_context_size; if (enableImageSearch && !Object.hasOwn(next, "enable_image_search")) { diff --git a/src/providers/label.ts b/src/providers/label.ts index e2eed04021..099bf04870 100644 --- a/src/providers/label.ts +++ b/src/providers/label.ts @@ -36,7 +36,7 @@ export function baseProviderLabel(provider: string): string { * It lives here rather than in `account-label.ts` because it needs `baseProviderLabel`, and this * module already imports from that one -- the reverse direction would be an import cycle. This * file stays Lab-clean, which matters because `core.ts` is one of the three files - * `tests/core-lab-boundary.test.ts` guards. + * `tests/lab/core-lab-boundary.test.ts` guards. */ export function stampOAuthAccountLabel( logCtx: { accountLogLabel?: string }, diff --git a/src/server/index.ts b/src/server/index.ts index af2382f59e..ff71c73ddb 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -512,7 +512,7 @@ function attachLiveSidebandUpstream( // Adapter resolution + wire-protocol override extracted to ./server/adapter-resolve. -// Source invariant for tests/passthrough-abort.test.ts after the pure module split: +// Source invariant for tests/responses/passthrough-abort.test.ts after the pure module split: // if (isEventStream && upstreamResponse.body) { // const repairConfig = route.provider.responsesItemIdRepair; // const needsClientRewrite = imageGenCallAliases.size > 0 diff --git a/src/server/management/route-registry.ts b/src/server/management/route-registry.ts index 06dcabb331..bfc98adb78 100644 --- a/src/server/management/route-registry.ts +++ b/src/server/management/route-registry.ts @@ -8,7 +8,7 @@ * shadowed copy in `logs-usage-routes.ts` and never the live one. * * This module is pure DATA and must stay that way. It is imported by - * `src/server/management-api.ts`, which `tests/core-lab-boundary.test.ts` protects: a user + * `src/server/management-api.ts`, which `tests/lab/core-lab-boundary.test.ts` protects: a user * with one provider and no Lab must execute no Lab code. Route paths are strings, so * declaring `/api/lab/status` here creates no module edge. Never import a handler, and * never import anything from `src/lab/`. The `module` field names the owning file as text diff --git a/structure/04_transports-and-sidecars.md b/structure/04_transports-and-sidecars.md index 404174b748..d652a99082 100644 --- a/structure/04_transports-and-sidecars.md +++ b/structure/04_transports-and-sidecars.md @@ -362,7 +362,7 @@ Native passthrough SSE has TWO shapes, selected per request in including the #44 late-terminal semantics. The two-shape contract is mirror-commented in `src/server/index.ts`; the real -`core.ts` gate is source-invariant-tested by `tests/passthrough-abort.test.ts`, +`core.ts` gate is source-invariant-tested by `tests/responses/passthrough-abort.test.ts`, and the platform matrix lives in `tests/lib/bun-stream-caps.test.ts`. Keep all three in lockstep with any passthrough-policy change. diff --git a/tests/abort-race.test.ts b/tests/adapters/abort-race.test.ts similarity index 97% rename from tests/abort-race.test.ts rename to tests/adapters/abort-race.test.ts index 1c2605647a..33a6da1ab4 100644 --- a/tests/abort-race.test.ts +++ b/tests/adapters/abort-race.test.ts @@ -1,18 +1,18 @@ import { afterEach, describe, expect, mock, test } from "bun:test"; -import type { ProviderAdapter } from "../src/adapters/base"; -import type { AdapterEvent, OcxConfig, OcxProviderConfig } from "../src/types"; +import type { ProviderAdapter } from "../../src/adapters/base"; +import type { AdapterEvent, OcxConfig, OcxProviderConfig } from "../../src/types"; -const actualResolver = await import("../src/server/adapter-resolve"); +const actualResolver = await import("../../src/server/adapter-resolve"); let adapterFactory: ((provider: OcxProviderConfig) => ProviderAdapter) | undefined; -mock.module("../src/server/adapter-resolve", () => ({ +mock.module("../../src/server/adapter-resolve", () => ({ ...actualResolver, resolveAdapter(provider: OcxProviderConfig, cacheRetention?: "none" | "short" | "long") { return adapterFactory?.(provider) ?? actualResolver.resolveAdapter(provider, cacheRetention); }, })); -const { handleResponses } = await import("../src/server/responses"); +const { handleResponses } = await import("../../src/server/responses"); afterEach(() => { adapterFactory = undefined; diff --git a/tests/adapter-buffered-tool-conformance.test.ts b/tests/adapters/adapter-buffered-tool-conformance.test.ts similarity index 93% rename from tests/adapter-buffered-tool-conformance.test.ts rename to tests/adapters/adapter-buffered-tool-conformance.test.ts index 3472afdd67..81a736bee9 100644 --- a/tests/adapter-buffered-tool-conformance.test.ts +++ b/tests/adapters/adapter-buffered-tool-conformance.test.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from "bun:test"; -import { adapterDefinitions, createRegisteredAdapter, effectiveAdapterContract, type AdapterWire } from "../src/adapters/registry"; -import { buildResponseJSON } from "../src/bridge"; -import { encodeMessage } from "../src/lib/eventstream-decoder"; -import { parseRequest } from "../src/responses/parser"; -import { buildToolBridgeMaps } from "../src/server/responses"; -import type { OcxProviderConfig } from "../src/types"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +import { adapterDefinitions, createRegisteredAdapter, effectiveAdapterContract, type AdapterWire } from "../../src/adapters/registry"; +import { buildResponseJSON } from "../../src/bridge"; +import { encodeMessage } from "../../src/lib/eventstream-decoder"; +import { parseRequest } from "../../src/responses/parser"; +import { buildToolBridgeMaps } from "../../src/server/responses"; +import type { OcxProviderConfig } from "../../src/types"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; const PATCH = `*** Begin Patch *** Add File: buffered-안녕.txt diff --git a/tests/adapter-error-inline.test.ts b/tests/adapters/adapter-error-inline.test.ts similarity index 96% rename from tests/adapter-error-inline.test.ts rename to tests/adapters/adapter-error-inline.test.ts index 7642f3bbf5..99087e0f43 100644 --- a/tests/adapter-error-inline.test.ts +++ b/tests/adapters/adapter-error-inline.test.ts @@ -1,9 +1,9 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { adapterFailureFromMessage, bridgeToResponsesSSE } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../src/adapters/openai-chat"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../src/adapters/google"; +import { adapterFailureFromMessage, bridgeToResponsesSSE } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createOpenAIChatAdapter = (...args: Parameters) => withTestTranslatorBudget(createOpenAIChatAdapterProduction(...args)); diff --git a/tests/adapter-registry-authority.test.ts b/tests/adapters/adapter-registry-authority.test.ts similarity index 94% rename from tests/adapter-registry-authority.test.ts rename to tests/adapters/adapter-registry-authority.test.ts index 1bbfc28c40..3d19f8132e 100644 --- a/tests/adapter-registry-authority.test.ts +++ b/tests/adapters/adapter-registry-authority.test.ts @@ -4,10 +4,10 @@ import { createRegisteredAdapter, effectiveAdapterContract, getAdapterDefinition, -} from "../src/adapters/registry"; -import { resolveAdapter } from "../src/server/adapter-resolve"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/adapters/registry"; +import { resolveAdapter } from "../../src/server/adapter-resolve"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const EXPECTED_ADAPTER_NAMES = { "command-code": "command-code", diff --git a/tests/adapter-tool-conformance.test.ts b/tests/adapters/adapter-tool-conformance.test.ts similarity index 97% rename from tests/adapter-tool-conformance.test.ts rename to tests/adapters/adapter-tool-conformance.test.ts index a3a6ae2800..8ebfad627f 100644 --- a/tests/adapter-tool-conformance.test.ts +++ b/tests/adapters/adapter-tool-conformance.test.ts @@ -5,15 +5,15 @@ import { effectiveAdapterContract, getAdapterDefinition, type AdapterWire, -} from "../src/adapters/registry"; -import { resetMimoJwtCache } from "../src/adapters/mimo-free"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { parseRequest } from "../src/responses/parser"; -import { buildToolBridgeMaps } from "../src/server/responses"; -import { MODEL_ADAPTER_OVERRIDE_ALLOWED, type OcxParsedRequest, type OcxProviderConfig } from "../src/types"; -import { TOOL_WIRE_DRIVERS } from "./helpers/adapter-conformance/wire-drivers"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/adapters/registry"; +import { resetMimoJwtCache } from "../../src/adapters/mimo-free"; +import { bridgeToResponsesSSE } from "../../src/bridge"; +import { PROVIDER_REGISTRY } from "../../src/providers/registry"; +import { parseRequest } from "../../src/responses/parser"; +import { buildToolBridgeMaps } from "../../src/server/responses"; +import { MODEL_ADAPTER_OVERRIDE_ALLOWED, type OcxParsedRequest, type OcxProviderConfig } from "../../src/types"; +import { TOOL_WIRE_DRIVERS } from "../helpers/adapter-conformance/wire-drivers"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; const PATCH = `*** Begin Patch *** Add File: conformance-안녕.txt diff --git a/tests/adapter-usage.test.ts b/tests/adapters/adapter-usage.test.ts similarity index 99% rename from tests/adapter-usage.test.ts rename to tests/adapters/adapter-usage.test.ts index 5fd93b9d7c..5912a65315 100644 --- a/tests/adapter-usage.test.ts +++ b/tests/adapters/adapter-usage.test.ts @@ -1,9 +1,9 @@ import { describe, expect, test } from "bun:test"; -import { anthropicToolCallId, MAX_TOOL_CALL_ID_LENGTH } from "../src/adapters/tool-call-id"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { anthropicToolCallId, MAX_TOOL_CALL_ID_LENGTH } from "../../src/adapters/tool-call-id"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../src/adapters/anthropic"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../src/adapters/google"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../src/adapters/openai-chat"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); diff --git a/tests/anthropic-account-pool.test.ts b/tests/adapters/anthropic/anthropic-account-pool.test.ts similarity index 98% rename from tests/anthropic-account-pool.test.ts rename to tests/adapters/anthropic/anthropic-account-pool.test.ts index e0d73a5189..7817fd7104 100644 --- a/tests/anthropic-account-pool.test.ts +++ b/tests/adapters/anthropic/anthropic-account-pool.test.ts @@ -2,7 +2,7 @@ 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 { clearPoolRotationState, notePoolRotationFailure, POOL_KEY_ANTHROPIC } from "../src/codex/pool-rotation"; +import { clearPoolRotationState, notePoolRotationFailure, POOL_KEY_ANTHROPIC } from "../../../src/codex/pool-rotation"; import { anthropicQuotaWindow, anthropicSessionKeyFromParts, @@ -16,11 +16,11 @@ import { resolveAnthropicAccountForSession, resetAnthropicRoutingForManualSelection, rotateAnthropicAccountOn429, -} from "../src/oauth/anthropic-routing"; -import { getAccountSet, saveCredential, setActiveAccount } from "../src/oauth/store"; -import { clearAccountQuotaCache, setCachedProviderAccountQuotaForTests } from "../src/providers/quota"; -import type { OcxAccountPoolQuotaWindow, OcxAccountPoolRotationStrategy, OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../../src/oauth/anthropic-routing"; +import { getAccountSet, saveCredential, setActiveAccount } from "../../../src/oauth/store"; +import { clearAccountQuotaCache, setCachedProviderAccountQuotaForTests } from "../../../src/providers/quota"; +import type { OcxAccountPoolQuotaWindow, OcxAccountPoolRotationStrategy, OcxConfig } from "../../../src/types"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const originalHome = process.env.OPENCODEX_HOME; let home: string; @@ -58,7 +58,7 @@ async function seedTwoAccounts() { email: "b@example.test", }); // saveCredential activates the newly appended account (B). Pin A as active for predictable tests. - const { getAccountSet } = await import("../src/oauth/store"); + const { getAccountSet } = await import("../../../src/oauth/store"); const set = getAccountSet("anthropic")!; const a = set.accounts.find(acc => acc.credential.accountId === "uuid-aaaa")!; const b = set.accounts.find(acc => acc.credential.accountId === "uuid-bbbb")!; @@ -111,7 +111,7 @@ async function seedThreeAccounts() { accountId: "uuid-cccc", email: "c@example.test", }); - const { getAccountSet } = await import("../src/oauth/store"); + const { getAccountSet } = await import("../../../src/oauth/store"); const set = getAccountSet("anthropic")!; const a = set.accounts.find(acc => acc.credential.accountId === "uuid-aaaa")!; const b = set.accounts.find(acc => acc.credential.accountId === "uuid-bbbb")!; diff --git a/tests/anthropic-agentrouter-language-framing.test.ts b/tests/adapters/anthropic/anthropic-agentrouter-language-framing.test.ts similarity index 97% rename from tests/anthropic-agentrouter-language-framing.test.ts rename to tests/adapters/anthropic/anthropic-agentrouter-language-framing.test.ts index 09782a6835..ddef3cdb16 100644 --- a/tests/anthropic-agentrouter-language-framing.test.ts +++ b/tests/adapters/anthropic/anthropic-agentrouter-language-framing.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; -import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; +import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); diff --git a/tests/anthropic-baseurl-override.test.ts b/tests/adapters/anthropic/anthropic-baseurl-override.test.ts similarity index 96% rename from tests/anthropic-baseurl-override.test.ts rename to tests/adapters/anthropic/anthropic-baseurl-override.test.ts index 992652b2a2..4ce30505d3 100644 --- a/tests/anthropic-baseurl-override.test.ts +++ b/tests/adapters/anthropic/anthropic-baseurl-override.test.ts @@ -1,7 +1,7 @@ import { expect, test } from "bun:test"; -import { routeModel } from "../src/router"; -import { providerDestinationConfigError } from "../src/lib/destination-policy"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; +import { routeModel } from "../../../src/router"; +import { providerDestinationConfigError } from "../../../src/lib/destination-policy"; +import type { OcxConfig, OcxProviderConfig } from "../../../src/types"; /** * Regression coverage for the allowBaseUrlOverride opt-in on the anthropic diff --git a/tests/anthropic-compatible-stream.test.ts b/tests/adapters/anthropic/anthropic-compatible-stream.test.ts similarity index 97% rename from tests/anthropic-compatible-stream.test.ts rename to tests/adapters/anthropic/anthropic-compatible-stream.test.ts index bb1de09923..c8ee51d77f 100644 --- a/tests/anthropic-compatible-stream.test.ts +++ b/tests/adapters/anthropic/anthropic-compatible-stream.test.ts @@ -1,9 +1,9 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import { responsesSseToAnthropicSse as responsesSseToAnthropicSseProduction } from "../src/claude/outbound"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { createTestTranslatorBudget, withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import { bridgeToResponsesSSE } from "../../../src/bridge"; +import { responsesSseToAnthropicSse as responsesSseToAnthropicSseProduction } from "../../../src/claude/outbound"; +import type { AdapterEvent, OcxProviderConfig } from "../../../src/types"; +import { createTestTranslatorBudget, withTestTranslatorBudget } from "../../helpers/translator-budget"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); diff --git a/tests/anthropic-empty-content.test.ts b/tests/adapters/anthropic/anthropic-empty-content.test.ts similarity index 97% rename from tests/anthropic-empty-content.test.ts rename to tests/adapters/anthropic/anthropic-empty-content.test.ts index 2a60d3d9ad..d9b90dd9e5 100644 --- a/tests/anthropic-empty-content.test.ts +++ b/tests/adapters/anthropic/anthropic-empty-content.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createAnthropicAdapter } from "../../../src/adapters/anthropic"; +import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; const provider = { adapter: "anthropic", baseUrl: "https://api.anthropic.com", apiKey: "sk-x", authMode: "apiKey" } as unknown as OcxProviderConfig; diff --git a/tests/anthropic-eof-tolerance.test.ts b/tests/adapters/anthropic/anthropic-eof-tolerance.test.ts similarity index 97% rename from tests/anthropic-eof-tolerance.test.ts rename to tests/adapters/anthropic/anthropic-eof-tolerance.test.ts index 1a29b95177..12936ead45 100644 --- a/tests/anthropic-eof-tolerance.test.ts +++ b/tests/adapters/anthropic/anthropic-eof-tolerance.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { FREE_PROVIDER_DIRECTORY } from "../src/providers/free-directory"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { createTestTranslatorBudget, withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import { FREE_PROVIDER_DIRECTORY } from "../../../src/providers/free-directory"; +import type { AdapterEvent, OcxProviderConfig } from "../../../src/types"; +import { createTestTranslatorBudget, withTestTranslatorBudget } from "../../helpers/translator-budget"; /** * #658: AgentRouter's Anthropic-compatible endpoint can close the stream before diff --git a/tests/anthropic-error-body.test.ts b/tests/adapters/anthropic/anthropic-error-body.test.ts similarity index 93% rename from tests/anthropic-error-body.test.ts rename to tests/adapters/anthropic/anthropic-error-body.test.ts index e880fa49d8..91f84507dc 100644 --- a/tests/anthropic-error-body.test.ts +++ b/tests/adapters/anthropic/anthropic-error-body.test.ts @@ -1,11 +1,11 @@ import { afterEach, describe, expect, test } from "bun:test"; -import type { ProviderAdapter } from "../src/adapters/base"; -import { createAnthropicAdapter, formatAnthropicErrorBody } from "../src/adapters/anthropic"; -import { parseRequest } from "../src/responses/parser"; -import { responseWithDeferredRequestLog, type RequestLogEntry } from "../src/server"; -import { runWithWebSearch as runWithWebSearchProduction, type WebSearchLoopDeps } from "../src/web-search/loop"; -import type { OcxProviderConfig } from "../src/types"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +import type { ProviderAdapter } from "../../../src/adapters/base"; +import { createAnthropicAdapter, formatAnthropicErrorBody } from "../../../src/adapters/anthropic"; +import { parseRequest } from "../../../src/responses/parser"; +import { responseWithDeferredRequestLog, type RequestLogEntry } from "../../../src/server"; +import { runWithWebSearch as runWithWebSearchProduction, type WebSearchLoopDeps } from "../../../src/web-search/loop"; +import type { OcxProviderConfig } from "../../../src/types"; +import { createTestTranslatorBudget } from "../../helpers/translator-budget"; const originalFetch = globalThis.fetch; diff --git a/tests/anthropic-error-stop-reason.test.ts b/tests/adapters/anthropic/anthropic-error-stop-reason.test.ts similarity index 95% rename from tests/anthropic-error-stop-reason.test.ts rename to tests/adapters/anthropic/anthropic-error-stop-reason.test.ts index d4b2a750d3..b30cb9641d 100644 --- a/tests/anthropic-error-stop-reason.test.ts +++ b/tests/adapters/anthropic/anthropic-error-stop-reason.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { buildResponseJSON } from "../src/bridge"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import { buildResponseJSON } from "../../../src/bridge"; +import type { AdapterEvent, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); diff --git a/tests/anthropic-hardening.test.ts b/tests/adapters/anthropic/anthropic-hardening.test.ts similarity index 94% rename from tests/anthropic-hardening.test.ts rename to tests/adapters/anthropic/anthropic-hardening.test.ts index 95cc575322..1a50aba4e5 100644 --- a/tests/anthropic-hardening.test.ts +++ b/tests/adapters/anthropic/anthropic-hardening.test.ts @@ -1,8 +1,8 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { AnthropicTokenError, refreshAnthropicToken } from "../src/oauth/anthropic"; +import { createAnthropicAdapter } from "../../../src/adapters/anthropic"; +import { PROVIDER_REGISTRY } from "../../../src/providers/registry"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { AnthropicTokenError, refreshAnthropicToken } from "../../../src/oauth/anthropic"; const originalFetch = globalThis.fetch; afterEach(() => { globalThis.fetch = originalFetch; }); diff --git a/tests/anthropic-image-guard.test.ts b/tests/adapters/anthropic/anthropic-image-guard.test.ts similarity index 99% rename from tests/anthropic-image-guard.test.ts rename to tests/adapters/anthropic/anthropic-image-guard.test.ts index 23af8fb5d1..8858d5521e 100644 --- a/tests/anthropic-image-guard.test.ts +++ b/tests/adapters/anthropic/anthropic-image-guard.test.ts @@ -4,7 +4,7 @@ import { sniffImageDimensions, MAX_IMAGE_BASE64_LENGTH, TOTAL_IMAGE_BASE64_BUDGET, -} from "../src/adapters/anthropic-image-guard"; +} from "../../../src/adapters/anthropic-image-guard"; function b64(bytes: number[]): string { return Buffer.from(Uint8Array.from(bytes)).toString("base64"); diff --git a/tests/anthropic-image-normalize.test.ts b/tests/adapters/anthropic/anthropic-image-normalize.test.ts similarity index 99% rename from tests/anthropic-image-normalize.test.ts rename to tests/adapters/anthropic/anthropic-image-normalize.test.ts index 68d0185a24..350e322d9c 100644 --- a/tests/anthropic-image-normalize.test.ts +++ b/tests/adapters/anthropic/anthropic-image-normalize.test.ts @@ -11,12 +11,12 @@ import { normalizeImageTargets, type NormalizeTarget, type EncodeFn, -} from "../src/adapters/anthropic-image-normalize"; +} from "../../../src/adapters/anthropic-image-normalize"; import { enforceAnthropicImageLimits, sniffImageDimensions, TOTAL_IMAGE_BASE64_BUDGET, -} from "../src/adapters/anthropic-image-guard"; +} from "../../../src/adapters/anthropic-image-guard"; /** 1x1 red PNG — the smallest real, fully-decodable fixture. */ const ONE_PX_PNG = diff --git a/tests/anthropic-image-retry-e2e.test.ts b/tests/adapters/anthropic/anthropic-image-retry-e2e.test.ts similarity index 93% rename from tests/anthropic-image-retry-e2e.test.ts rename to tests/adapters/anthropic/anthropic-image-retry-e2e.test.ts index ae96301a56..df6ab9a4d6 100644 --- a/tests/anthropic-image-retry-e2e.test.ts +++ b/tests/adapters/anthropic/anthropic-image-retry-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 { startServer } from "../src/server"; -import { resetNormalizeStateForTests } from "../src/adapters/anthropic-image-normalize"; -import { sniffImageDimensions } from "../src/adapters/anthropic-image-guard"; -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 { resetNormalizeStateForTests } from "../../../src/adapters/anthropic-image-normalize"; +import { sniffImageDimensions } from "../../../src/adapters/anthropic-image-guard"; +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/anthropic-image-retry.test.ts b/tests/adapters/anthropic/anthropic-image-retry.test.ts similarity index 91% rename from tests/anthropic-image-retry.test.ts rename to tests/adapters/anthropic/anthropic-image-retry.test.ts index 8125f85e5a..3bbe06facf 100644 --- a/tests/anthropic-image-retry.test.ts +++ b/tests/adapters/anthropic/anthropic-image-retry.test.ts @@ -1,9 +1,9 @@ import { beforeEach, describe, expect, test } from "bun:test"; -import { parsedHasInlineImage, shouldAttemptImageTierRetry } from "../src/server/image-retry"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import { resetNormalizeStateForTests } from "../src/adapters/anthropic-image-normalize"; -import { sniffImageDimensions } from "../src/adapters/anthropic-image-guard"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { parsedHasInlineImage, shouldAttemptImageTierRetry } from "../../../src/server/image-retry"; +import { createAnthropicAdapter } from "../../../src/adapters/anthropic"; +import { resetNormalizeStateForTests } from "../../../src/adapters/anthropic-image-normalize"; +import { sniffImageDimensions } from "../../../src/adapters/anthropic-image-guard"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; const ONE_PX_PNG = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="; diff --git a/tests/anthropic-pool-toggle-copy.test.ts b/tests/adapters/anthropic/anthropic-pool-toggle-copy.test.ts similarity index 100% rename from tests/anthropic-pool-toggle-copy.test.ts rename to tests/adapters/anthropic/anthropic-pool-toggle-copy.test.ts diff --git a/tests/anthropic-reasoning.test.ts b/tests/adapters/anthropic/anthropic-reasoning.test.ts similarity index 98% rename from tests/anthropic-reasoning.test.ts rename to tests/adapters/anthropic/anthropic-reasoning.test.ts index a1e2eacc17..7b895538fc 100644 --- a/tests/anthropic-reasoning.test.ts +++ b/tests/adapters/anthropic/anthropic-reasoning.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { chatCompletionsToResponsesBody } from "../src/chat/inbound"; -import { parseRequest } from "../src/responses/parser"; -import { anthropicToResponsesBody } from "../src/claude/inbound"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import { chatCompletionsToResponsesBody } from "../../../src/chat/inbound"; +import { parseRequest } from "../../../src/responses/parser"; +import { anthropicToResponsesBody } from "../../../src/claude/inbound"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); diff --git a/tests/anthropic-stream-hardening.test.ts b/tests/adapters/anthropic/anthropic-stream-hardening.test.ts similarity index 98% rename from tests/anthropic-stream-hardening.test.ts rename to tests/adapters/anthropic/anthropic-stream-hardening.test.ts index a4f03caf0b..f3a82e3175 100644 --- a/tests/anthropic-stream-hardening.test.ts +++ b/tests/adapters/anthropic/anthropic-stream-hardening.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { anthropicMessagesUrl, createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import type { AdapterEvent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { anthropicMessagesUrl, createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import type { AdapterEvent } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); diff --git a/tests/anthropic-tail-guard.test.ts b/tests/adapters/anthropic/anthropic-tail-guard.test.ts similarity index 96% rename from tests/anthropic-tail-guard.test.ts rename to tests/adapters/anthropic/anthropic-tail-guard.test.ts index 792a237b0c..710d32f730 100644 --- a/tests/anthropic-tail-guard.test.ts +++ b/tests/adapters/anthropic/anthropic-tail-guard.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createAnthropicAdapter } from "../../../src/adapters/anthropic"; +import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; const provider = { adapter: "anthropic", baseUrl: "https://api.anthropic.com", apiKey: "sk-x", authMode: "apiKey" } as unknown as OcxProviderConfig; diff --git a/tests/anthropic-thinking-signature.test.ts b/tests/adapters/anthropic/anthropic-thinking-signature.test.ts similarity index 97% rename from tests/anthropic-thinking-signature.test.ts rename to tests/adapters/anthropic/anthropic-thinking-signature.test.ts index e1227e33ab..efb9338b41 100644 --- a/tests/anthropic-thinking-signature.test.ts +++ b/tests/adapters/anthropic/anthropic-thinking-signature.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { parseRequest } from "../src/responses/parser"; -import { encodeReasoningEnvelope, decodeReasoningEnvelope, OCX_REASONING_PREFIX } from "../src/responses/reasoning-envelope"; -import type { AdapterEvent, OcxProviderConfig, OcxThinkingContent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../../src/bridge"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../../src/adapters/anthropic"; +import { parseRequest } from "../../../src/responses/parser"; +import { encodeReasoningEnvelope, decodeReasoningEnvelope, OCX_REASONING_PREFIX } from "../../../src/responses/reasoning-envelope"; +import type { AdapterEvent, OcxProviderConfig, OcxThinkingContent } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createAnthropicAdapter = (...args: Parameters) => withTestTranslatorBudget(createAnthropicAdapterProduction(...args)); @@ -309,7 +309,7 @@ describe("parser ocxr1 decode + anthropic replay", () => { describe("passthrough scrub of ocxr1 envelopes", () => { test("sanitize strips ocxr1 encrypted_content even with empty content", async () => { - const { createResponsesPassthroughAdapter } = await import("../src/adapters/openai-responses"); + const { createResponsesPassthroughAdapter } = await import("../../../src/adapters/openai-responses"); const adapter = withTestTranslatorBudget(createResponsesPassthroughAdapter({ adapter: "openai-responses", baseUrl: "https://chatgpt.com/backend-api/codex", passthrough: true, } as OcxProviderConfig)); diff --git a/tests/anthropic-tool-call-id.test.ts b/tests/adapters/anthropic/anthropic-tool-call-id.test.ts similarity index 98% rename from tests/anthropic-tool-call-id.test.ts rename to tests/adapters/anthropic/anthropic-tool-call-id.test.ts index 8164182ffe..0eaad85749 100644 --- a/tests/anthropic-tool-call-id.test.ts +++ b/tests/adapters/anthropic/anthropic-tool-call-id.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { anthropicToolCallId, createToolCallIdAllocator, MAX_TOOL_CALL_ID_LENGTH } from "../src/adapters/tool-call-id"; +import { anthropicToolCallId, createToolCallIdAllocator, MAX_TOOL_CALL_ID_LENGTH } from "../../../src/adapters/tool-call-id"; // #1767: Anthropic validates tool_use.id against [a-zA-Z0-9_-]. A history replayed from another // provider path can carry ids that do not conform, and one of them anywhere in the transcript diff --git a/tests/anthropic-tool-schema.test.ts b/tests/adapters/anthropic/anthropic-tool-schema.test.ts similarity index 98% rename from tests/anthropic-tool-schema.test.ts rename to tests/adapters/anthropic/anthropic-tool-schema.test.ts index 46109161d2..ae3659c75f 100644 --- a/tests/anthropic-tool-schema.test.ts +++ b/tests/adapters/anthropic/anthropic-tool-schema.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import type { OcxParsedRequest, OcxProviderConfig, OcxTool } from "../src/types"; +import { createAnthropicAdapter } from "../../../src/adapters/anthropic"; +import type { OcxParsedRequest, OcxProviderConfig, OcxTool } from "../../../src/types"; const provider = { adapter: "anthropic", baseUrl: "https://api.anthropic.com", apiKey: "sk-x", authMode: "apiKey" } as unknown as OcxProviderConfig; diff --git a/tests/bridge-legacy-shell-normalization.test.ts b/tests/adapters/bridge-legacy-shell-normalization.test.ts similarity index 97% rename from tests/bridge-legacy-shell-normalization.test.ts rename to tests/adapters/bridge-legacy-shell-normalization.test.ts index 36600084d9..c6d5cdbe2d 100644 --- a/tests/bridge-legacy-shell-normalization.test.ts +++ b/tests/adapters/bridge-legacy-shell-normalization.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; +import { bridgeToResponsesSSE } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; async function drain(stream: ReadableStream): Promise { const reader = stream.getReader(); diff --git a/tests/bridge-lifecycle.test.ts b/tests/adapters/bridge-lifecycle.test.ts similarity index 98% rename from tests/bridge-lifecycle.test.ts rename to tests/adapters/bridge-lifecycle.test.ts index 7caaec643d..9193d26e9f 100644 --- a/tests/bridge-lifecycle.test.ts +++ b/tests/adapters/bridge-lifecycle.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; +import { bridgeToResponsesSSE } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; -import { watchdogMs } from "./helpers/ci-watchdog"; +import { watchdogMs } from "../helpers/ci-watchdog"; async function* replay(events: AdapterEvent[]): AsyncGenerator { for (const event of events) yield event; } diff --git a/tests/bridge-nonstreaming-terminal.test.ts b/tests/adapters/bridge-nonstreaming-terminal.test.ts similarity index 98% rename from tests/bridge-nonstreaming-terminal.test.ts rename to tests/adapters/bridge-nonstreaming-terminal.test.ts index a137b676a2..7fe0a705ab 100644 --- a/tests/bridge-nonstreaming-terminal.test.ts +++ b/tests/adapters/bridge-nonstreaming-terminal.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import { isTruncatedStopReason, truncationReasonFor } from "../src/responses/truncated-stop-reason"; -import type { AdapterEvent } from "../src/types"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import { isTruncatedStopReason, truncationReasonFor } from "../../src/responses/truncated-stop-reason"; +import type { AdapterEvent } from "../../src/types"; async function sseText(events: AdapterEvent[]): Promise { async function* source(): AsyncGenerator { diff --git a/tests/bridge-raw-reasoning-hidden.test.ts b/tests/adapters/bridge-raw-reasoning-hidden.test.ts similarity index 96% rename from tests/bridge-raw-reasoning-hidden.test.ts rename to tests/adapters/bridge-raw-reasoning-hidden.test.ts index f84c896ecd..4acc66ce62 100644 --- a/tests/bridge-raw-reasoning-hidden.test.ts +++ b/tests/adapters/bridge-raw-reasoning-hidden.test.ts @@ -1,13 +1,13 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import { decodeReasoningEnvelope } from "../src/responses/reasoning-envelope"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import { decodeReasoningEnvelope } from "../../src/responses/reasoning-envelope"; import { clearReasoningReplayCacheForTests, peekReasoningForCall, -} from "../src/responses/reasoning-replay-cache"; -import { parseRequest } from "../src/responses/parser"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../src/types"; +} from "../../src/responses/reasoning-replay-cache"; +import { parseRequest } from "../../src/responses/parser"; +import { createOpenAIChatAdapter } from "../../src/adapters/openai-chat"; +import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../../src/types"; async function* replay(events: AdapterEvent[]): AsyncGenerator { for (const event of events) yield event; diff --git a/tests/bridge-reasoning-replay-batch.test.ts b/tests/adapters/bridge-reasoning-replay-batch.test.ts similarity index 96% rename from tests/bridge-reasoning-replay-batch.test.ts rename to tests/adapters/bridge-reasoning-replay-batch.test.ts index fa288b210e..50ba96fd4e 100644 --- a/tests/bridge-reasoning-replay-batch.test.ts +++ b/tests/adapters/bridge-reasoning-replay-batch.test.ts @@ -1,10 +1,10 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; import { clearReasoningReplayCacheForTests, peekReasoningForCall, -} from "../src/responses/reasoning-replay-cache"; -import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../src/types"; +} from "../../src/responses/reasoning-replay-cache"; +import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../../src/types"; /** * Regression for issue #950's non-streaming path: chat-completions batch diff --git a/tests/bridge-terminal-singleness.test.ts b/tests/adapters/bridge-terminal-singleness.test.ts similarity index 98% rename from tests/bridge-terminal-singleness.test.ts rename to tests/adapters/bridge-terminal-singleness.test.ts index 726871449e..d6371f5351 100644 --- a/tests/bridge-terminal-singleness.test.ts +++ b/tests/adapters/bridge-terminal-singleness.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; +import { bridgeToResponsesSSE } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; async function collectSseText(stream: ReadableStream): Promise { const reader = stream.getReader(); diff --git a/tests/bridge.test.ts b/tests/adapters/bridge.test.ts similarity index 99% rename from tests/bridge.test.ts rename to tests/adapters/bridge.test.ts index ebf49724d5..e9c2b050b6 100644 --- a/tests/bridge.test.ts +++ b/tests/adapters/bridge.test.ts @@ -1,13 +1,13 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON, setOwnedBudgetAbandonedMsForTests } from "../src/bridge"; +import { bridgeToResponsesSSE, buildResponseJSON, setOwnedBudgetAbandonedMsForTests } from "../../src/bridge"; import { createTranslatorBudget, resetTranslatorAggregateForTests, retainTranslatedEventBatch, translatorAggregateCurrentBytesForTests, translatorLiveBudgetCountForTests, -} from "../src/lib/translator-budget"; -import type { AdapterEvent } from "../src/types"; +} from "../../src/lib/translator-budget"; +import type { AdapterEvent } from "../../src/types"; async function* replay(events: AdapterEvent[]): AsyncGenerator { for (const event of events) yield event; diff --git a/tests/buffered-response-shape-guards.test.ts b/tests/adapters/buffered-response-shape-guards.test.ts similarity index 97% rename from tests/buffered-response-shape-guards.test.ts rename to tests/adapters/buffered-response-shape-guards.test.ts index ba0f309451..6f435f8726 100644 --- a/tests/buffered-response-shape-guards.test.ts +++ b/tests/adapters/buffered-response-shape-guards.test.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from "bun:test"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import { createCommandCodeAdapter } from "../src/adapters/command-code"; -import { createGoogleAdapter } from "../src/adapters/google"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; -import { createTranslatorBudget, translatorObservedBufferSnapshot } from "../src/lib/translator-budget"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; +import { createAnthropicAdapter } from "../../src/adapters/anthropic"; +import { createCommandCodeAdapter } from "../../src/adapters/command-code"; +import { createGoogleAdapter } from "../../src/adapters/google"; +import { createOpenAIChatAdapter } from "../../src/adapters/openai-chat"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; +import { createTranslatorBudget, translatorObservedBufferSnapshot } from "../../src/lib/translator-budget"; +import type { AdapterEvent, OcxProviderConfig } from "../../src/types"; /** * `JSON.parse("null")` returns `null` without throwing, so a `try/catch` around a body parse diff --git a/tests/empty-tool-output-annotation.test.ts b/tests/adapters/empty-tool-output-annotation.test.ts similarity index 97% rename from tests/empty-tool-output-annotation.test.ts rename to tests/adapters/empty-tool-output-annotation.test.ts index 2d97e15730..d0acc8213b 100644 --- a/tests/empty-tool-output-annotation.test.ts +++ b/tests/adapters/empty-tool-output-annotation.test.ts @@ -1,10 +1,10 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import { providerConfigSeed } from "../src/providers/derive"; -import { getProviderRegistryEntry } from "../src/providers/registry"; -import { routedProviderConfig } from "../src/router"; -import { handleResponses } from "../src/server/responses/core"; -import type { OcxConfig, OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createOpenAIChatAdapter } from "../../src/adapters/openai-chat"; +import { providerConfigSeed } from "../../src/providers/derive"; +import { getProviderRegistryEntry } from "../../src/providers/registry"; +import { routedProviderConfig } from "../../src/router"; +import { handleResponses } from "../../src/server/responses/core"; +import type { OcxConfig, OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../src/types"; const ANNOTATION = "[ocx] empty tool output: the tool ran but produced no stdout or return value; do not treat this as success, failure, or user-provided input."; diff --git a/tests/antigravity-baseurl-override.test.ts b/tests/adapters/google/antigravity-baseurl-override.test.ts similarity index 95% rename from tests/antigravity-baseurl-override.test.ts rename to tests/adapters/google/antigravity-baseurl-override.test.ts index 98d23b6c9c..d293c2a91b 100644 --- a/tests/antigravity-baseurl-override.test.ts +++ b/tests/adapters/google/antigravity-baseurl-override.test.ts @@ -1,7 +1,7 @@ import { expect, test } from "bun:test"; -import { routeModel } from "../src/router"; -import { providerDestinationConfigError } from "../src/lib/destination-policy"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; +import { routeModel } from "../../../src/router"; +import { providerDestinationConfigError } from "../../../src/lib/destination-policy"; +import type { OcxConfig, OcxProviderConfig } from "../../../src/types"; /** * Regression coverage for the allowBaseUrlOverride opt-in on the diff --git a/tests/antigravity-static-catalog.test.ts b/tests/adapters/google/antigravity-static-catalog.test.ts similarity index 76% rename from tests/antigravity-static-catalog.test.ts rename to tests/adapters/google/antigravity-static-catalog.test.ts index baafe53b6d..ff523036a0 100644 --- a/tests/antigravity-static-catalog.test.ts +++ b/tests/adapters/google/antigravity-static-catalog.test.ts @@ -1,9 +1,9 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { gatherRoutedModels } from "../src/codex/catalog"; -import { clearModelCache } from "../src/codex/model-cache"; -import { providerConfigSeed } from "../src/providers/derive"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { withStubbedProviderFetch } from "./helpers/catalog-provider-fetch"; +import { gatherRoutedModels } from "../../../src/codex/catalog"; +import { clearModelCache } from "../../../src/codex/model-cache"; +import { providerConfigSeed } from "../../../src/providers/derive"; +import { PROVIDER_REGISTRY } from "../../../src/providers/registry"; +import { withStubbedProviderFetch } from "../../helpers/catalog-provider-fetch"; const originalFetch = globalThis.fetch; diff --git a/tests/gcp-adc.test.ts b/tests/adapters/google/gcp-adc.test.ts similarity index 97% rename from tests/gcp-adc.test.ts rename to tests/adapters/google/gcp-adc.test.ts index cdf0162320..e7234848dc 100644 --- a/tests/gcp-adc.test.ts +++ b/tests/adapters/google/gcp-adc.test.ts @@ -3,12 +3,12 @@ import { Buffer } from "node:buffer"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { getVertexAccessToken, __resetVertexTokenCache } from "../src/lib/gcp-adc"; -import { createGoogleAdapter } from "../src/adapters/google"; -import { providerManagementConfigError } from "../src/server/auth-cors"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { STATE_STORE_REGISTRATIONS } from "../src/lib/state-store-registrations"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { getVertexAccessToken, __resetVertexTokenCache } from "../../../src/lib/gcp-adc"; +import { createGoogleAdapter } from "../../../src/adapters/google"; +import { providerManagementConfigError } from "../../../src/server/auth-cors"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { STATE_STORE_REGISTRATIONS } from "../../../src/lib/state-store-registrations"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const OAUTH_TOKEN_URL = "https://oauth2.googleapis.com/token"; let tmp: string; diff --git a/tests/gemini-37-flash-migration.test.ts b/tests/adapters/google/gemini-37-flash-migration.test.ts similarity index 97% rename from tests/gemini-37-flash-migration.test.ts rename to tests/adapters/google/gemini-37-flash-migration.test.ts index 968de54fb7..0ea67ac68a 100644 --- a/tests/gemini-37-flash-migration.test.ts +++ b/tests/adapters/google/gemini-37-flash-migration.test.ts @@ -8,14 +8,14 @@ import { parseAntigravityAvailableModels, resolveAntigravityEffortWireModel, retiredAntigravityFlashTier, -} from "../src/providers/antigravity-models"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { projectModelRenames } from "../src/providers/model-rename-migration"; -import { EXPECTED_PRICE_OVERLAYS } from "../src/usage/expected-prices"; -import { mapReasoningEffort } from "../src/reasoning-effort"; -import { resolveMatchedPrice } from "../src/usage/cost"; -import { createGoogleAdapter } from "../src/adapters/google"; -import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +} from "../../../src/providers/antigravity-models"; +import { PROVIDER_REGISTRY } from "../../../src/providers/registry"; +import { projectModelRenames } from "../../../src/providers/model-rename-migration"; +import { EXPECTED_PRICE_OVERLAYS } from "../../../src/usage/expected-prices"; +import { mapReasoningEffort } from "../../../src/reasoning-effort"; +import { resolveMatchedPrice } from "../../../src/usage/cost"; +import { createGoogleAdapter } from "../../../src/adapters/google"; +import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; // Google takes the previous Antigravity Flash generation off Cloud Code Assist almost // immediately once the next one ships. That makes 3.6 -> 3.7 a REPLACEMENT, and the diff --git a/tests/gemini-web-search.test.ts b/tests/adapters/google/gemini-web-search.test.ts similarity index 93% rename from tests/gemini-web-search.test.ts rename to tests/adapters/google/gemini-web-search.test.ts index 8dedb42063..ac70e588c0 100644 --- a/tests/gemini-web-search.test.ts +++ b/tests/adapters/google/gemini-web-search.test.ts @@ -1,18 +1,18 @@ import { afterEach, describe, expect, mock, test } from "bun:test"; -import * as storeModule from "../src/oauth/store"; -import { MAX_SIDECAR_RESPONSE_BYTES } from "../src/web-search/parse"; +import * as storeModule from "../../../src/oauth/store"; +import { MAX_SIDECAR_RESPONSE_BYTES } from "../../../src/web-search/parse"; let accountSets: Record }>; activeAccountId?: string }> = {}; -mock.module("../src/oauth/store", () => ({ +mock.module("../../../src/oauth/store", () => ({ ...storeModule, getAccountSet: (provider: string) => accountSets[provider] ?? null, })); -import { mapCcaGroundedResponse } from "../src/web-search/gemini-executor"; -import { findGeminiSidecarProvider, planWebSearch } from "../src/web-search"; -import { resolveAntigravityEffortWireModel } from "../src/providers/antigravity-models"; -import { parseRequest } from "../src/responses/parser"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; +import { mapCcaGroundedResponse } from "../../../src/web-search/gemini-executor"; +import { findGeminiSidecarProvider, planWebSearch } from "../../../src/web-search"; +import { resolveAntigravityEffortWireModel } from "../../../src/providers/antigravity-models"; +import { parseRequest } from "../../../src/responses/parser"; +import type { OcxConfig, OcxProviderConfig } from "../../../src/types"; const routed: OcxProviderConfig = { adapter: "openai-chat", baseUrl: "https://routed.test/v1", apiKey: "k" }; const cca: OcxProviderConfig = { adapter: "google", baseUrl: "https://daily-cloudcode-pa.googleapis.com", authMode: "oauth" }; @@ -109,9 +109,9 @@ describe("planWebSearch gemini arm (L8)", () => { }); }); -import { runGeminiWebSearch } from "../src/web-search/gemini-executor"; -import * as oauthModule from "../src/oauth"; -mock.module("../src/oauth", () => ({ +import { runGeminiWebSearch } from "../../../src/web-search/gemini-executor"; +import * as oauthModule from "../../../src/oauth"; +mock.module("../../../src/oauth", () => ({ ...oauthModule, getValidAccessTokenSnapshot: async () => { const snapshot = accessSnapshot; @@ -119,9 +119,9 @@ mock.module("../src/oauth", () => ({ return snapshot; }, })); -import { runWithWebSearch, type WebSearchLoopDeps } from "../src/web-search/loop"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; -import type { AdapterEvent, ProviderAdapter } from "../src/adapters/base"; +import { runWithWebSearch, type WebSearchLoopDeps } from "../../../src/web-search/loop"; +import { createTestTranslatorBudget } from "../../helpers/translator-budget"; +import type { AdapterEvent, ProviderAdapter } from "../../../src/adapters/base"; describe("runGeminiWebSearch request shape (review P1)", () => { test("malicious baseUrl ignored: registry destination, manual redirect, bearer + IDE UA, full envelope, thinkingConfig", async () => { diff --git a/tests/google-adapter.test.ts b/tests/adapters/google/google-adapter.test.ts similarity index 99% rename from tests/google-adapter.test.ts rename to tests/adapters/google/google-adapter.test.ts index 295c92dd67..80ad0e9f4c 100644 --- a/tests/google-adapter.test.ts +++ b/tests/adapters/google/google-adapter.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter } from "../src/adapters/google"; -import { chatCompletionsToResponsesBody } from "../src/chat/inbound"; -import { parseRequest } from "../src/responses/parser"; -import type { OcxParsedRequest } from "../src/types"; +import { createGoogleAdapter } from "../../../src/adapters/google"; +import { chatCompletionsToResponsesBody } from "../../../src/chat/inbound"; +import { parseRequest } from "../../../src/responses/parser"; +import type { OcxParsedRequest } from "../../../src/types"; const provider = { adapter: "google", baseUrl: "https://generativelanguage.googleapis.com", apiKey: "key" }; diff --git a/tests/google-antigravity-oauth.test.ts b/tests/adapters/google/google-antigravity-oauth.test.ts similarity index 96% rename from tests/google-antigravity-oauth.test.ts rename to tests/adapters/google/google-antigravity-oauth.test.ts index 6aac66c0aa..68cf6f49e6 100644 --- a/tests/google-antigravity-oauth.test.ts +++ b/tests/adapters/google/google-antigravity-oauth.test.ts @@ -1,11 +1,11 @@ import { afterEach, describe, expect, spyOn, test } from "bun:test"; -import { discoverAntigravityProject, refreshAntigravityToken } from "../src/oauth/google-antigravity"; +import { discoverAntigravityProject, refreshAntigravityToken } from "../../../src/oauth/google-antigravity"; import { mkdirSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { getCredential, saveCredential } from "../src/oauth/store"; -import { ANTIGRAVITY_IDE_VERSION } from "../src/adapters/client-fingerprint"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { getCredential, saveCredential } from "../../../src/oauth/store"; +import { ANTIGRAVITY_IDE_VERSION } from "../../../src/adapters/client-fingerprint"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const realFetch = globalThis.fetch; afterEach(() => { globalThis.fetch = realFetch; }); diff --git a/tests/google-antigravity-replay.test.ts b/tests/adapters/google/google-antigravity-replay.test.ts similarity index 99% rename from tests/google-antigravity-replay.test.ts rename to tests/adapters/google/google-antigravity-replay.test.ts index 537f5f3d0e..d811c4f20f 100644 --- a/tests/google-antigravity-replay.test.ts +++ b/tests/adapters/google/google-antigravity-replay.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { getConfigDir } from "../src/config"; +import { getConfigDir } from "../../../src/config"; import { antigravityCanonicalJsonBoundedForTests, antigravityFunctionCallKeyForTests, @@ -24,11 +24,11 @@ import { setAntigravityReplaySnapshotMaxBytesForTests, setAntigravityReplayWriteSeamForTests, sweepExpiredAntigravityReplay, -} from "../src/adapters/google-antigravity-replay"; -import { sanitizeAntigravityClaudeSignatures } from "../src/adapters/google-antigravity-wire"; +} from "../../../src/adapters/google-antigravity-replay"; +import { sanitizeAntigravityClaudeSignatures } from "../../../src/adapters/google-antigravity-wire"; -import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../src/lib/windows-secret-acl"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../../../src/lib/windows-secret-acl"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; afterEach(() => { setAntigravityReplayLimitsForTests(); diff --git a/tests/google-antigravity-wire.test.ts b/tests/adapters/google/google-antigravity-wire.test.ts similarity index 98% rename from tests/google-antigravity-wire.test.ts rename to tests/adapters/google/google-antigravity-wire.test.ts index 65d74be116..528ea4c6ca 100644 --- a/tests/google-antigravity-wire.test.ts +++ b/tests/adapters/google/google-antigravity-wire.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { antigravitySessionId, isLikelyRealThoughtSignature } from "../src/adapters/google-antigravity-wire"; -import { ANTIGRAVITY_MODELS, ANTIGRAVITY_MODEL_EFFORTS, canonicalAntigravityUsageModel, parseAntigravityAvailableModels, registerAntigravityDiscoveredWireModels, resolveAntigravityEffortWireModel, resolveAntigravityWireModelId } from "../src/providers/antigravity-models"; -import { MODEL_DISCOVERY_MAX_MODEL_ID_LENGTH, MODEL_DISCOVERY_MAX_MODELS } from "../src/providers/model-discovery"; -import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; +import { antigravitySessionId, isLikelyRealThoughtSignature } from "../../../src/adapters/google-antigravity-wire"; +import { ANTIGRAVITY_MODELS, ANTIGRAVITY_MODEL_EFFORTS, canonicalAntigravityUsageModel, parseAntigravityAvailableModels, registerAntigravityDiscoveredWireModels, resolveAntigravityEffortWireModel, resolveAntigravityWireModelId } from "../../../src/providers/antigravity-models"; +import { MODEL_DISCOVERY_MAX_MODEL_ID_LENGTH, MODEL_DISCOVERY_MAX_MODELS } from "../../../src/providers/model-discovery"; +import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); @@ -725,7 +725,7 @@ describe("antigravity parseResponse unwraps response (non-streaming)", () => { }); test("non-streaming observes thoughtSignatures so the next turn can replay them", async () => { - const { __resetAntigravityReplayCache, applyAntigravityReplay } = await import("../src/adapters/google-antigravity-replay"); + const { __resetAntigravityReplayCache, applyAntigravityReplay } = await import("../../../src/adapters/google-antigravity-replay"); __resetAntigravityReplayCache(); const adapter = createGoogleAdapter(provider); // buildRequest first to set the per-adapter model/session, then parseResponse to observe. @@ -746,7 +746,7 @@ describe("antigravity parseResponse unwraps response (non-streaming)", () => { // thought part with a signed function call is the direct proof, rather than inferring it // from unrelated fixtures that happen to still pass. test("a thought part alongside a signed function call does not disturb replay", async () => { - const { __resetAntigravityReplayCache, applyAntigravityReplay } = await import("../src/adapters/google-antigravity-replay"); + const { __resetAntigravityReplayCache, applyAntigravityReplay } = await import("../../../src/adapters/google-antigravity-replay"); __resetAntigravityReplayCache(); const adapter = createGoogleAdapter(provider); await adapter.buildRequest(parsed("hello world")); diff --git a/tests/google-buffered-stop-reason.test.ts b/tests/adapters/google/google-buffered-stop-reason.test.ts similarity index 91% rename from tests/google-buffered-stop-reason.test.ts rename to tests/adapters/google/google-buffered-stop-reason.test.ts index 5934f04a40..810e8791c0 100644 --- a/tests/google-buffered-stop-reason.test.ts +++ b/tests/adapters/google/google-buffered-stop-reason.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { buildResponseJSON } from "../src/bridge"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; +import { buildResponseJSON } from "../../../src/bridge"; +import type { AdapterEvent, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); diff --git a/tests/google-claude-prefill-guard.test.ts b/tests/adapters/google/google-claude-prefill-guard.test.ts similarity index 96% rename from tests/google-claude-prefill-guard.test.ts rename to tests/adapters/google/google-claude-prefill-guard.test.ts index e18b3e9284..72dbd1d0e4 100644 --- a/tests/google-claude-prefill-guard.test.ts +++ b/tests/adapters/google/google-claude-prefill-guard.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; +import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); diff --git a/tests/google-empty-content.test.ts b/tests/adapters/google/google-empty-content.test.ts similarity index 98% rename from tests/google-empty-content.test.ts rename to tests/adapters/google/google-empty-content.test.ts index 29351f5db9..de1ab8a49d 100644 --- a/tests/google-empty-content.test.ts +++ b/tests/adapters/google/google-empty-content.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter } from "../src/adapters/google"; -import type { OcxParsedRequest } from "../src/types"; +import { createGoogleAdapter } from "../../../src/adapters/google"; +import type { OcxParsedRequest } from "../../../src/types"; // Antigravity translates these Gemini `contents` into Anthropic `messages` for Claude models, and // Anthropic rejects empty/absent text and empty content arrays. An empty Gemini text part reaches diff --git a/tests/google-errors.test.ts b/tests/adapters/google/google-errors.test.ts similarity index 98% rename from tests/google-errors.test.ts rename to tests/adapters/google/google-errors.test.ts index c47d7cbbbb..c31da10556 100644 --- a/tests/google-errors.test.ts +++ b/tests/adapters/google/google-errors.test.ts @@ -5,7 +5,7 @@ import { safeAntigravityHttpErrorMessage, safeGoogleHttpErrorMessage, safeVertexHttpErrorMessage, -} from "../src/adapters/google-errors"; +} from "../../../src/adapters/google-errors"; describe("google error classification & quota exhaustion", () => { const antigravityPhrases = [ diff --git a/tests/google-hardening.test.ts b/tests/adapters/google/google-hardening.test.ts similarity index 99% rename from tests/google-hardening.test.ts rename to tests/adapters/google/google-hardening.test.ts index a187b9c3d2..3e6d909a31 100644 --- a/tests/google-hardening.test.ts +++ b/tests/adapters/google/google-hardening.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { getDebugLogEntries, resetDebugLogBufferForTests } from "../src/lib/debug-log-buffer"; -import { resetDebugSettingsForTests, setDebugSettings } from "../src/lib/debug-settings"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; +import { getDebugLogEntries, resetDebugLogBufferForTests } from "../../../src/lib/debug-log-buffer"; +import { resetDebugSettingsForTests, setDebugSettings } from "../../../src/lib/debug-settings"; +import { PROVIDER_REGISTRY } from "../../../src/providers/registry"; +import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); diff --git a/tests/google-models-listing.test.ts b/tests/adapters/google/google-models-listing.test.ts similarity index 97% rename from tests/google-models-listing.test.ts rename to tests/adapters/google/google-models-listing.test.ts index 5a36700063..3440ef30a7 100644 --- a/tests/google-models-listing.test.ts +++ b/tests/adapters/google/google-models-listing.test.ts @@ -2,13 +2,13 @@ import { afterEach, describe, expect, spyOn, test } from "bun:test"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { buildCatalogEntries, gatherRoutedModels as gatherRoutedModelsDirect } from "../src/codex/catalog"; -import { buildModelsRequest } from "../src/oauth"; -import { captureModelCacheGeneration, clearModelCache, getStaleCached } from "../src/codex/model-cache"; -import { registerAntigravityDiscoveredWireModels, resolveAntigravityWireModelId } from "../src/providers/antigravity-models"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; -import { withStubbedProviderFetch } from "./helpers/catalog-provider-fetch"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { buildCatalogEntries, gatherRoutedModels as gatherRoutedModelsDirect } from "../../../src/codex/catalog"; +import { buildModelsRequest } from "../../../src/oauth"; +import { captureModelCacheGeneration, clearModelCache, getStaleCached } from "../../../src/codex/model-cache"; +import { registerAntigravityDiscoveredWireModels, resolveAntigravityWireModelId } from "../../../src/providers/antigravity-models"; +import type { OcxConfig, OcxProviderConfig } from "../../../src/types"; +import { withStubbedProviderFetch } from "../../helpers/catalog-provider-fetch"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; /** Discovery runs on the pinned transport; hand it back the stubbed global. */ const gatherRoutedModels: typeof gatherRoutedModelsDirect = (config, options) => diff --git a/tests/google-output-clamp.test.ts b/tests/adapters/google/google-output-clamp.test.ts similarity index 98% rename from tests/google-output-clamp.test.ts rename to tests/adapters/google/google-output-clamp.test.ts index f49aa41a2c..614ef14b10 100644 --- a/tests/google-output-clamp.test.ts +++ b/tests/adapters/google/google-output-clamp.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { clampGoogleMaxOutputTokens, maxOutputTokensForGoogleModel } from "../src/adapters/google"; +import { clampGoogleMaxOutputTokens, maxOutputTokensForGoogleModel } from "../../../src/adapters/google"; describe("google maxOutputTokens clamp", () => { test("returns model-specific max output tokens limit", () => { diff --git a/tests/google-provider-metadata-roundtrip.test.ts b/tests/adapters/google/google-provider-metadata-roundtrip.test.ts similarity index 96% rename from tests/google-provider-metadata-roundtrip.test.ts rename to tests/adapters/google/google-provider-metadata-roundtrip.test.ts index 16d22aacc8..59aa05c92e 100644 --- a/tests/google-provider-metadata-roundtrip.test.ts +++ b/tests/adapters/google/google-provider-metadata-roundtrip.test.ts @@ -3,8 +3,8 @@ import { cloneProviderOpaqueToolCallMetadata, providerMetadataFromResponsesFunctionCall, responsesExtraContentFromProviderMetadata, -} from "../src/responses/provider-opaque-metadata"; -import type { OcxProviderOpaqueToolCallMetadata } from "../src/types"; +} from "../../../src/responses/provider-opaque-metadata"; +import type { OcxProviderOpaqueToolCallMetadata } from "../../../src/types"; const SIG_A = "sig-alpha-opaque-value"; const SIG_B = "sig-beta-opaque-value"; diff --git a/tests/google-signature-history-roundtrip.test.ts b/tests/adapters/google/google-signature-history-roundtrip.test.ts similarity index 98% rename from tests/google-signature-history-roundtrip.test.ts rename to tests/adapters/google/google-signature-history-roundtrip.test.ts index 48a5ddc2b6..9695622d19 100644 --- a/tests/google-signature-history-roundtrip.test.ts +++ b/tests/adapters/google/google-signature-history-roundtrip.test.ts @@ -6,25 +6,25 @@ 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 { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; import { __resetAntigravityReplayCache, applyAntigravityReplay, observeAntigravityReplay, -} from "../src/adapters/google-antigravity-replay"; -import { parseRequest } from "../src/responses/parser"; +} from "../../../src/adapters/google-antigravity-replay"; +import { parseRequest } from "../../../src/responses/parser"; import { flushThoughtSignatureReplayForTests, forgetThoughtSignatureForReplay, lookupReplayThoughtSignature, rememberThoughtSignatureForReplay, resetThoughtSignatureReplayForTests, -} from "../src/responses/thought-signature-replay"; -import { durableReplayDestinationIdentity } from "../src/responses/reasoning-replay-cache"; -import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../src/lib/windows-secret-acl"; -import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig, OcxReasoningReplayScopeRef } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../../src/responses/thought-signature-replay"; +import { durableReplayDestinationIdentity } from "../../../src/responses/reasoning-replay-cache"; +import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../../../src/lib/windows-secret-acl"; +import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig, OcxReasoningReplayScopeRef } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); diff --git a/tests/google-tool-result-adjacency.test.ts b/tests/adapters/google/google-tool-result-adjacency.test.ts similarity index 98% rename from tests/google-tool-result-adjacency.test.ts rename to tests/adapters/google/google-tool-result-adjacency.test.ts index 796136e96b..59c556b1d8 100644 --- a/tests/google-tool-result-adjacency.test.ts +++ b/tests/adapters/google/google-tool-result-adjacency.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter } from "../src/adapters/google"; -import type { OcxContentPart, OcxMessage, OcxParsedRequest } from "../src/types"; +import { createGoogleAdapter } from "../../../src/adapters/google"; +import type { OcxContentPart, OcxMessage, OcxParsedRequest } from "../../../src/types"; const provider = { adapter: "google", baseUrl: "https://generativelanguage.googleapis.com", apiKey: "key" }; diff --git a/tests/google-tool-schema.test.ts b/tests/adapters/google/google-tool-schema.test.ts similarity index 99% rename from tests/google-tool-schema.test.ts rename to tests/adapters/google/google-tool-schema.test.ts index 79d7b19a2b..776a513867 100644 --- a/tests/google-tool-schema.test.ts +++ b/tests/adapters/google/google-tool-schema.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { sanitizeGeminiToolParameters } from "../src/adapters/google-tool-schema"; +import { sanitizeGeminiToolParameters } from "../../../src/adapters/google-tool-schema"; function countSchemaNodes(value: unknown): number { if (!value || typeof value !== "object" || Array.isArray(value)) return 0; diff --git a/tests/google-vertex-http.test.ts b/tests/adapters/google/google-vertex-http.test.ts similarity index 98% rename from tests/google-vertex-http.test.ts rename to tests/adapters/google/google-vertex-http.test.ts index 496fb56a1a..8ad138741d 100644 --- a/tests/google-vertex-http.test.ts +++ b/tests/adapters/google/google-vertex-http.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, test } from "bun:test"; -import type { AdapterRequest } from "../src/adapters/base"; -import { fetchAntigravityWithRetry, fetchDirectGeminiWithRetry, fetchVertexWithRetry } from "../src/adapters/google-http"; -import { safeVertexHttpErrorMessage, retryableGoogleStatus } from "../src/adapters/google-errors"; +import type { AdapterRequest } from "../../../src/adapters/base"; +import { fetchAntigravityWithRetry, fetchDirectGeminiWithRetry, fetchVertexWithRetry } from "../../../src/adapters/google-http"; +import { safeVertexHttpErrorMessage, retryableGoogleStatus } from "../../../src/adapters/google-errors"; const realFetch = globalThis.fetch; afterEach(() => { globalThis.fetch = realFetch; }); @@ -313,7 +313,7 @@ describe("safeVertexHttpErrorMessage classification + redaction", () => { describe("adapter fetchResponse wiring", () => { test("vertex and antigravity adapters expose fetchResponse; ai-studio direct delegates to canonical server transport", async () => { - const { createGoogleAdapter } = await import("../src/adapters/google"); + const { createGoogleAdapter } = await import("../../../src/adapters/google"); const vertex = createGoogleAdapter({ adapter: "google", baseUrl: "https://aiplatform.googleapis.com", googleMode: "vertex" } as never); const aistudio = createGoogleAdapter({ adapter: "google", baseUrl: "https://generativelanguage.googleapis.com", apiKey: "k" } as never); const antigravity = createGoogleAdapter({ adapter: "google", baseUrl: "https://daily-cloudcode-pa.googleapis.com", googleMode: "cloud-code-assist" } as never); @@ -326,7 +326,7 @@ describe("adapter fetchResponse wiring", () => { }); test("Vertex and Antigravity formatter hooks are provider-classified and leak-negative", async () => { - const { createGoogleAdapter } = await import("../src/adapters/google"); + const { createGoogleAdapter } = await import("../../../src/adapters/google"); const payload = vertexError(400, "INVALID_ARGUMENT", "Bearer secret-token at /Users/example/key.json"); const vertex = createGoogleAdapter({ adapter: "google", googleMode: "vertex" } as never); const antigravity = createGoogleAdapter({ adapter: "google", googleMode: "cloud-code-assist" } as never); diff --git a/tests/google-vertex-stream.test.ts b/tests/adapters/google/google-vertex-stream.test.ts similarity index 95% rename from tests/google-vertex-stream.test.ts rename to tests/adapters/google/google-vertex-stream.test.ts index 996c9ba738..f965cb6132 100644 --- a/tests/google-vertex-stream.test.ts +++ b/tests/adapters/google/google-vertex-stream.test.ts @@ -1,9 +1,9 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { isVertexTruncatedTurn, isVertexTruncationReason, vertexTruncationErrorMessage } from "../src/adapters/google-truncation"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; +import { isVertexTruncatedTurn, isVertexTruncationReason, vertexTruncationErrorMessage } from "../../../src/adapters/google-truncation"; +import { bridgeToResponsesSSE } from "../../../src/bridge"; +import type { AdapterEvent, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); @@ -136,7 +136,7 @@ describe("vertex parseResponse fail-closed truncation (non-streaming)", () => { describe("usage status for google-vertex stays reported", () => { test("usageForFinalLog does not force-estimate google-vertex (but does for kiro)", async () => { - const { usageForFinalLog, usageStatusForFinalLog } = await import("../src/usage/log"); + const { usageForFinalLog, usageStatusForFinalLog } = await import("../../../src/usage/log"); const usage = { inputTokens: 5, outputTokens: 2 }; const vertex = usageForFinalLog("google-vertex", usage); expect(vertex?.estimated).toBeUndefined(); diff --git a/tests/google-vertex-thought-signature.test.ts b/tests/adapters/google/google-vertex-thought-signature.test.ts similarity index 95% rename from tests/google-vertex-thought-signature.test.ts rename to tests/adapters/google/google-vertex-thought-signature.test.ts index 99d262ba2d..9a95896a4c 100644 --- a/tests/google-vertex-thought-signature.test.ts +++ b/tests/adapters/google/google-vertex-thought-signature.test.ts @@ -1,12 +1,12 @@ import { beforeEach, describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; import { __resetAntigravityReplayCache, applyAntigravityReplay, -} from "../src/adapters/google-antigravity-replay"; -import { antigravitySessionId } from "../src/adapters/google-antigravity-wire"; -import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../../src/adapters/google-antigravity-replay"; +import { antigravitySessionId } from "../../../src/adapters/google-antigravity-wire"; +import type { AdapterEvent, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); diff --git a/tests/google-wire-compiler.test.ts b/tests/adapters/google/google-wire-compiler.test.ts similarity index 96% rename from tests/google-wire-compiler.test.ts rename to tests/adapters/google/google-wire-compiler.test.ts index 97a3a7ca0a..1523d11d85 100644 --- a/tests/google-wire-compiler.test.ts +++ b/tests/adapters/google/google-wire-compiler.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { compileGoogleWireBody, repairGoogleInvalidRequestBody } from "../src/adapters/google-wire-compiler"; -import type { OcxParsedRequest } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../../src/adapters/google"; +import { compileGoogleWireBody, repairGoogleInvalidRequestBody } from "../../../src/adapters/google-wire-compiler"; +import type { OcxParsedRequest } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createGoogleAdapter = (...args: Parameters) => withTestTranslatorBudget(createGoogleAdapterProduction(...args)); diff --git a/tests/vertex-catalog.test.ts b/tests/adapters/google/vertex-catalog.test.ts similarity index 96% rename from tests/vertex-catalog.test.ts rename to tests/adapters/google/vertex-catalog.test.ts index 0e462146d8..0c3a336f82 100644 --- a/tests/vertex-catalog.test.ts +++ b/tests/adapters/google/vertex-catalog.test.ts @@ -1,8 +1,8 @@ import { afterEach, describe, expect, spyOn, test } from "bun:test"; -import { gatherRoutedModels as gatherRoutedModelsDirect } from "../src/codex/catalog"; -import { clearModelCache, markModelsFetchFailure, setCached } from "../src/codex/model-cache"; -import type { OcxConfig } from "../src/types"; -import { withStubbedProviderFetch } from "./helpers/catalog-provider-fetch"; +import { gatherRoutedModels as gatherRoutedModelsDirect } from "../../../src/codex/catalog"; +import { clearModelCache, markModelsFetchFailure, setCached } from "../../../src/codex/model-cache"; +import type { OcxConfig } from "../../../src/types"; +import { withStubbedProviderFetch } from "../../helpers/catalog-provider-fetch"; /** Discovery runs on the pinned transport; hand it back the stubbed global. */ const gatherRoutedModels: typeof gatherRoutedModelsDirect = (config, options) => diff --git a/tests/identity-neutralize.test.ts b/tests/adapters/identity-neutralize.test.ts similarity index 95% rename from tests/identity-neutralize.test.ts rename to tests/adapters/identity-neutralize.test.ts index 200999c62d..356f3fd940 100644 --- a/tests/identity-neutralize.test.ts +++ b/tests/adapters/identity-neutralize.test.ts @@ -8,13 +8,13 @@ import { identifyRoutedModel, NEUTRAL_IDENTITY_LINE, neutralizeIdentity, -} from "../src/adapters/identity"; -import { createGoogleAdapter } from "../src/adapters/google"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import { createKiroAdapter } from "../src/adapters/kiro"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/adapters/identity"; +import { createGoogleAdapter } from "../../src/adapters/google"; +import { createAnthropicAdapter } from "../../src/adapters/anthropic"; +import { createKiroAdapter } from "../../src/adapters/kiro"; +import { createOpenAIChatAdapter } from "../../src/adapters/openai-chat"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const SYS = CODEX_GPT5_IDENTITY_LINE; diff --git a/tests/key-failover.test.ts b/tests/adapters/key-failover.test.ts similarity index 96% rename from tests/key-failover.test.ts rename to tests/adapters/key-failover.test.ts index b95d0981f4..5cff50912d 100644 --- a/tests/key-failover.test.ts +++ b/tests/adapters/key-failover.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 { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; +import { createOpenAIChatAdapter } from "../../src/adapters/openai-chat"; import { clearKeyCooldowns, getKeyCooldownUntil, hasKeyPoolFailover, rotateKeyOn429, rotateProviderTransportOn429, -} from "../src/providers/key-failover"; -import { resolveOpenCodeGoTransport } from "../src/providers/opencode-go-transport"; -import { deriveXaiConvId } from "../src/providers/xai-transport"; -import { routeModel } from "../src/router"; -import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/providers/key-failover"; +import { resolveOpenCodeGoTransport } from "../../src/providers/opencode-go-transport"; +import { deriveXaiConvId } from "../../src/providers/xai-transport"; +import { routeModel } from "../../src/router"; +import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let home: string; diff --git a/tests/openai-api-virtual-models.test.ts b/tests/adapters/openai/openai-api-virtual-models.test.ts similarity index 97% rename from tests/openai-api-virtual-models.test.ts rename to tests/adapters/openai/openai-api-virtual-models.test.ts index a0deba38f6..55656f86ee 100644 --- a/tests/openai-api-virtual-models.test.ts +++ b/tests/adapters/openai/openai-api-virtual-models.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { logsFromApiBody } from "./helpers/logs-api"; -import { managementHeaders } from "./helpers/management-auth"; +import { logsFromApiBody } from "../../helpers/logs-api"; +import { managementHeaders } from "../../helpers/management-auth"; import { existsSync, mkdtempSync, readFileSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; @@ -10,15 +10,15 @@ import { resolveOpenAiCompactModel, resolveOpenAiVirtualModel, validateOpenAiVirtualModelDefinition, -} from "../src/providers/openai-virtual-models"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { resolveWireProtocolOverride } from "../src/server/adapter-resolve"; -import { saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { usageLogPath } from "../src/usage/log"; - -import { watchdogMs } from "./helpers/ci-watchdog"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../../src/providers/openai-virtual-models"; +import { PROVIDER_REGISTRY } from "../../../src/providers/registry"; +import { resolveWireProtocolOverride } from "../../../src/server/adapter-resolve"; +import { saveConfig } from "../../../src/config"; +import { startServer } from "../../../src/server"; +import { usageLogPath } from "../../../src/usage/log"; + +import { watchdogMs } from "../../helpers/ci-watchdog"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const moduleOriginalFetch = globalThis.fetch; const moduleOriginalHome = process.env.OPENCODEX_HOME; afterEach(() => { diff --git a/tests/openai-chat-dangling-toolcalls.test.ts b/tests/adapters/openai/openai-chat-dangling-toolcalls.test.ts similarity index 98% rename from tests/openai-chat-dangling-toolcalls.test.ts rename to tests/adapters/openai/openai-chat-dangling-toolcalls.test.ts index b04ce5cc92..df5e8afc5b 100644 --- a/tests/openai-chat-dangling-toolcalls.test.ts +++ b/tests/adapters/openai/openai-chat-dangling-toolcalls.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createOpenAIChatAdapter } from "../../../src/adapters/openai-chat"; +import type { OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; // 260718 dangling tool_calls hardening (devlog/_plan/260718_dangling_toolcall_hardening): // strict chat providers (Kimi/Moonshot) 400 unless every assistant tool_call is answered diff --git a/tests/openai-chat-eof.test.ts b/tests/adapters/openai/openai-chat-eof.test.ts similarity index 99% rename from tests/openai-chat-eof.test.ts rename to tests/adapters/openai/openai-chat-eof.test.ts index 66eb211b71..9a3448cd08 100644 --- a/tests/openai-chat-eof.test.ts +++ b/tests/adapters/openai/openai-chat-eof.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { bridgeToResponsesSSE } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; -import { createTestTranslatorBudget, withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../../src/adapters/openai-chat"; +import { bridgeToResponsesSSE } from "../../../src/bridge"; +import type { AdapterEvent } from "../../../src/types"; +import { createTestTranslatorBudget, withTestTranslatorBudget } from "../../helpers/translator-budget"; const createOpenAIChatAdapter = (...args: Parameters) => withTestTranslatorBudget(createOpenAIChatAdapterProduction(...args)); diff --git a/tests/openai-chat-hardening.test.ts b/tests/adapters/openai/openai-chat-hardening.test.ts similarity index 98% rename from tests/openai-chat-hardening.test.ts rename to tests/adapters/openai/openai-chat-hardening.test.ts index cd89a8aff6..c5050a3ced 100644 --- a/tests/openai-chat-hardening.test.ts +++ b/tests/adapters/openai/openai-chat-hardening.test.ts @@ -1,11 +1,11 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { buildOpenAIChatPassthroughRequest, createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { stripResponsesOnlyEncryptedMarker } from "../src/adapters/responses-tool-schema"; -import { getDebugLogEntries, resetDebugLogBufferForTests } from "../src/lib/debug-log-buffer"; -import { resetDebugSettingsForTests } from "../src/lib/debug-settings"; -import { routeModel } from "../src/router"; -import type { AdapterEvent, OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { buildOpenAIChatPassthroughRequest, createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../../src/adapters/openai-chat"; +import { stripResponsesOnlyEncryptedMarker } from "../../../src/adapters/responses-tool-schema"; +import { getDebugLogEntries, resetDebugLogBufferForTests } from "../../../src/lib/debug-log-buffer"; +import { resetDebugSettingsForTests } from "../../../src/lib/debug-settings"; +import { routeModel } from "../../../src/router"; +import type { AdapterEvent, OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createOpenAIChatAdapter = (...args: Parameters) => withTestTranslatorBudget(createOpenAIChatAdapterProduction(...args)); diff --git a/tests/openai-chat-invalid-tool-call-diagnostics.test.ts b/tests/adapters/openai/openai-chat-invalid-tool-call-diagnostics.test.ts similarity index 95% rename from tests/openai-chat-invalid-tool-call-diagnostics.test.ts rename to tests/adapters/openai/openai-chat-invalid-tool-call-diagnostics.test.ts index 4a8704ab48..ae803fecec 100644 --- a/tests/openai-chat-invalid-tool-call-diagnostics.test.ts +++ b/tests/adapters/openai/openai-chat-invalid-tool-call-diagnostics.test.ts @@ -1,9 +1,9 @@ import { afterEach, beforeEach, expect, test } from "bun:test"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { getDebugLogEntries, resetDebugLogBufferForTests } from "../src/lib/debug-log-buffer"; -import { resetDebugSettingsForTests } from "../src/lib/debug-settings"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../../src/adapters/openai-chat"; +import { getDebugLogEntries, resetDebugLogBufferForTests } from "../../../src/lib/debug-log-buffer"; +import { resetDebugSettingsForTests } from "../../../src/lib/debug-settings"; +import type { AdapterEvent, OcxProviderConfig } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createOpenAIChatAdapter = (...args: Parameters) => withTestTranslatorBudget(createOpenAIChatAdapterProduction(...args)); diff --git a/tests/openai-chat-model-suffix.test.ts b/tests/adapters/openai/openai-chat-model-suffix.test.ts similarity index 95% rename from tests/openai-chat-model-suffix.test.ts rename to tests/adapters/openai/openai-chat-model-suffix.test.ts index 1f9a658386..69dcee5b59 100644 --- a/tests/openai-chat-model-suffix.test.ts +++ b/tests/adapters/openai/openai-chat-model-suffix.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter, stripBracketedModelSuffix } from "../src/adapters/openai-chat"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import { routeModel } from "../src/router"; -import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createOpenAIChatAdapter, stripBracketedModelSuffix } from "../../../src/adapters/openai-chat"; +import { createAnthropicAdapter } from "../../../src/adapters/anthropic"; +import { routeModel } from "../../../src/router"; +import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; function parsed(modelId: string): OcxParsedRequest { return { diff --git a/tests/openai-chat-native-policy.test.ts b/tests/adapters/openai/openai-chat-native-policy.test.ts similarity index 97% rename from tests/openai-chat-native-policy.test.ts rename to tests/adapters/openai/openai-chat-native-policy.test.ts index 2a50d7e9d1..95b39c065f 100644 --- a/tests/openai-chat-native-policy.test.ts +++ b/tests/adapters/openai/openai-chat-native-policy.test.ts @@ -5,16 +5,16 @@ import { join } from "node:path"; import { buildOpenAIChatPassthroughRequest, createOpenAIChatAdapter, -} from "../src/adapters/openai-chat"; +} from "../../../src/adapters/openai-chat"; import { decideTier, tierValueAfterDecision, -} from "../src/providers/fastwire"; -import { clearKeyCooldowns } from "../src/providers/key-failover"; -import { fastPolicyForModel } from "../src/providers/service-tier"; -import { handleChatCompletions } from "../src/server/chat-completions"; -import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../../src/providers/fastwire"; +import { clearKeyCooldowns } from "../../../src/providers/key-failover"; +import { fastPolicyForModel } from "../../../src/providers/service-tier"; +import { handleChatCompletions } from "../../../src/server/chat-completions"; +import type { OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const PROVIDER_NAME = "native-tier-fixture"; const MODEL_ID = "model"; diff --git a/tests/openai-chat-parallel-stream.test.ts b/tests/adapters/openai/openai-chat-parallel-stream.test.ts similarity index 98% rename from tests/openai-chat-parallel-stream.test.ts rename to tests/adapters/openai/openai-chat-parallel-stream.test.ts index 53d74f906f..238faa9082 100644 --- a/tests/openai-chat-parallel-stream.test.ts +++ b/tests/adapters/openai/openai-chat-parallel-stream.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import type { AdapterEvent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../../src/adapters/openai-chat"; +import type { AdapterEvent } from "../../../src/types"; +import { withTestTranslatorBudget } from "../../helpers/translator-budget"; const createOpenAIChatAdapter = (...args: Parameters) => withTestTranslatorBudget(createOpenAIChatAdapterProduction(...args)); diff --git a/tests/openai-chat-system-order.test.ts b/tests/adapters/openai/openai-chat-system-order.test.ts similarity index 95% rename from tests/openai-chat-system-order.test.ts rename to tests/adapters/openai/openai-chat-system-order.test.ts index b39792ccaf..d01ad96810 100644 --- a/tests/openai-chat-system-order.test.ts +++ b/tests/adapters/openai/openai-chat-system-order.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createOpenAIChatAdapter } from "../../../src/adapters/openai-chat"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; const provider: OcxProviderConfig = { adapter: "openai-chat", diff --git a/tests/openai-chat-tool-result-images.test.ts b/tests/adapters/openai/openai-chat-tool-result-images.test.ts similarity index 97% rename from tests/openai-chat-tool-result-images.test.ts rename to tests/adapters/openai/openai-chat-tool-result-images.test.ts index 307ba9b07f..65e4555bc1 100644 --- a/tests/openai-chat-tool-result-images.test.ts +++ b/tests/adapters/openai/openai-chat-tool-result-images.test.ts @@ -1,6 +1,6 @@ import { expect, test } from "bun:test"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import type { OcxContentPart, OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createOpenAIChatAdapter } from "../../../src/adapters/openai-chat"; +import type { OcxContentPart, OcxMessage, OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; // Issue #888: role:"tool" content is text-only on chat-completions providers, so images inside a // tool result ride in a follow-up user vision message released when the tool round closes. When diff --git a/tests/openai-chat-url.test.ts b/tests/adapters/openai/openai-chat-url.test.ts similarity index 89% rename from tests/openai-chat-url.test.ts rename to tests/adapters/openai/openai-chat-url.test.ts index d1a04c3624..151a0ad7b3 100644 --- a/tests/openai-chat-url.test.ts +++ b/tests/adapters/openai/openai-chat-url.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; -import { openaiChatCompletionsUrl } from "../src/adapters/openai-chat-url"; -import type { OcxParsedRequest, OcxProviderConfig } from "../src/types"; +import { createOpenAIChatAdapter } from "../../../src/adapters/openai-chat"; +import { openaiChatCompletionsUrl } from "../../../src/adapters/openai-chat-url"; +import type { OcxParsedRequest, OcxProviderConfig } from "../../../src/types"; describe("openai-chat URL normalization", () => { test("maps the four common paste shapes to the canonical chat endpoint", () => { diff --git a/tests/openai-provider-option-e2e.test.ts b/tests/adapters/openai/openai-provider-option-e2e.test.ts similarity index 96% rename from tests/openai-provider-option-e2e.test.ts rename to tests/adapters/openai/openai-provider-option-e2e.test.ts index d21276754b..903d85c82a 100644 --- a/tests/openai-provider-option-e2e.test.ts +++ b/tests/adapters/openai/openai-provider-option-e2e.test.ts @@ -1,6 +1,6 @@ -import { logsFromApiBody } from "./helpers/logs-api"; +import { logsFromApiBody } from "../../helpers/logs-api"; import { describe, expect, test } from "bun:test"; -import { managementFetch as fetch } from "./helpers/management-auth"; +import { managementFetch as fetch } from "../../helpers/management-auth"; import { createHash } from "node:crypto"; import { chmodSync, @@ -16,8 +16,9 @@ import { import { homedir, tmpdir } from "node:os"; import { join, relative } from "node:path"; -import { watchdogMs } from "./helpers/ci-watchdog"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { watchdogMs } from "../../helpers/ci-watchdog"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; +import { repoPath } from "../../helpers/repo-root"; type Capture = { url: string; method: string; @@ -255,21 +256,21 @@ describe("OpenAI provider-option integration spine", () => { windowsAcl, windowsPrincipal, ] = await Promise.all([ - import("../src/config"), - import("../src/providers/derive"), - import("../src/providers/registry"), - import("../src/codex/account-store"), - import("../src/codex/auth-api"), - import("../src/codex/routing"), - import("../src/codex/websocket-registry"), - import("../src/server/request-log"), - import("../src/codex/catalog"), - import("../src/codex/model-entitlements"), - import("../src/server"), - import("../src/codex/main-account"), - import("../src/providers/openai-sidecar"), - import("../src/lib/windows-secret-acl"), - import("../src/lib/windows-user-principal"), + import("../../../src/config"), + import("../../../src/providers/derive"), + import("../../../src/providers/registry"), + import("../../../src/codex/account-store"), + import("../../../src/codex/auth-api"), + import("../../../src/codex/routing"), + import("../../../src/codex/websocket-registry"), + import("../../../src/server/request-log"), + import("../../../src/codex/catalog"), + import("../../../src/codex/model-entitlements"), + import("../../../src/server"), + import("../../../src/codex/main-account"), + import("../../../src/providers/openai-sidecar"), + import("../../../src/lib/windows-secret-acl"), + import("../../../src/lib/windows-user-principal"), ]); windowsAcl.setIcaclsRunnerForTests(() => { @@ -576,7 +577,7 @@ describe("OpenAI provider-option integration spine", () => { try { const child = Bun.spawn([ process.execPath, - join(import.meta.dir, "fixtures/openai-provider-option-migration-child.ts"), + repoPath("tests", "fixtures", "openai-provider-option-migration-child.ts"), join(migrationRoot, "opencodex"), join(migrationRoot, "codex"), ], { stdout: "pipe", stderr: "pipe", env: { ...process.env } }); diff --git a/tests/openai-provider-option-migration.test.ts b/tests/adapters/openai/openai-provider-option-migration.test.ts similarity index 99% rename from tests/openai-provider-option-migration.test.ts rename to tests/adapters/openai/openai-provider-option-migration.test.ts index 436b78912f..379ba10bf6 100644 --- a/tests/openai-provider-option-migration.test.ts +++ b/tests/adapters/openai/openai-provider-option-migration.test.ts @@ -3,8 +3,8 @@ import { LEGACY_OPENAI_MULTI_PROVIDER_ID, OpenAiTierMigrationCollisionError, projectOpenAiTierMigration, -} from "../src/providers/openai-tiers"; -import type { OcxConfig, OcxProviderConfig, ProviderCostOverlay } from "../src/types"; +} from "../../../src/providers/openai-tiers"; +import type { OcxConfig, OcxProviderConfig, ProviderCostOverlay } from "../../../src/types"; const forward: OcxProviderConfig = { adapter: "openai-responses", diff --git a/tests/openai-provider-option-startup.test.ts b/tests/adapters/openai/openai-provider-option-startup.test.ts similarity index 98% rename from tests/openai-provider-option-startup.test.ts rename to tests/adapters/openai/openai-provider-option-startup.test.ts index a01ca67063..64bf211fdb 100644 --- a/tests/openai-provider-option-startup.test.ts +++ b/tests/adapters/openai/openai-provider-option-startup.test.ts @@ -26,12 +26,12 @@ import { preserveOpenAiTierRollbackSnapshot, type OpenAiTierBackupIO, type OpenAiTierRollbackPreserveIO, -} from "../src/config"; -import { runOpenAiTierStartupMigration } from "../src/providers/openai-tier-startup"; -import { OpenAiTierMigrationCollisionError, projectOpenAiTierMigration } from "../src/providers/openai-tiers"; -import type { OcxConfig } from "../src/types"; -import * as windowsAcl from "../src/lib/windows-secret-acl"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../../src/config"; +import { runOpenAiTierStartupMigration } from "../../../src/providers/openai-tier-startup"; +import { OpenAiTierMigrationCollisionError, projectOpenAiTierMigration } from "../../../src/providers/openai-tiers"; +import type { OcxConfig } from "../../../src/types"; +import * as windowsAcl from "../../../src/lib/windows-secret-acl"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const config: OcxConfig = { port: 10100, diff --git a/tests/openai-provider-option-tooling.test.ts b/tests/adapters/openai/openai-provider-option-tooling.test.ts similarity index 95% rename from tests/openai-provider-option-tooling.test.ts rename to tests/adapters/openai/openai-provider-option-tooling.test.ts index eff728ffb0..7fc8f5e402 100644 --- a/tests/openai-provider-option-tooling.test.ts +++ b/tests/adapters/openai/openai-provider-option-tooling.test.ts @@ -2,12 +2,12 @@ import { afterEach, describe, expect, test } from "bun:test"; import { chmodSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { evidenceDenyFindings, scanEvidence } from "../scripts/openai-provider-option-evidence-scan"; -import { runGateSequence, type GateResult, type GateSpec } from "../scripts/openai-provider-option-final-gates"; -import { evaluateLivePolicy, type LiveOutcome } from "../scripts/openai-hardening-live-policy"; -import { buildSanitizedRuntimeEnv } from "../scripts/openai-hardening-runtime-env"; -import { buildUnixCodexShim } from "../src/codex/shim"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { evidenceDenyFindings, scanEvidence } from "../../../scripts/openai-provider-option-evidence-scan"; +import { runGateSequence, type GateResult, type GateSpec } from "../../../scripts/openai-provider-option-final-gates"; +import { evaluateLivePolicy, type LiveOutcome } from "../../../scripts/openai-hardening-live-policy"; +import { buildSanitizedRuntimeEnv } from "../../../scripts/openai-hardening-runtime-env"; +import { buildUnixCodexShim } from "../../../src/codex/shim"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/openai-provider-option.test.ts b/tests/adapters/openai/openai-provider-option.test.ts similarity index 94% rename from tests/openai-provider-option.test.ts rename to tests/adapters/openai/openai-provider-option.test.ts index ab1155ca69..fa80f73556 100644 --- a/tests/openai-provider-option.test.ts +++ b/tests/adapters/openai/openai-provider-option.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { getDefaultConfig } from "../src/config"; -import { deriveInitProviders, deriveProviderPresets, listRegistryEntries, providerConfigSeed } from "../src/providers/derive"; -import { getProviderRegistryEntry, providerCodexAccountMode } from "../src/providers/registry"; +import { getDefaultConfig } from "../../../src/config"; +import { deriveInitProviders, deriveProviderPresets, listRegistryEntries, providerConfigSeed } from "../../../src/providers/derive"; +import { getProviderRegistryEntry, providerCodexAccountMode } from "../../../src/providers/registry"; import { isCanonicalOpenAiForwardProvider, isOpenAiOperatedResponsesDestination, @@ -9,8 +9,8 @@ import { LEGACY_OPENAI_MULTI_PROVIDER_ID, OPENAI_API_PROVIDER_ID, OPENAI_CODEX_PROVIDER_ID, -} from "../src/providers/openai-tiers"; -import { OPENAI_PROVIDER_TIER_VERSION } from "../src/types"; +} from "../../../src/providers/openai-tiers"; +import { OPENAI_PROVIDER_TIER_VERSION } from "../../../src/types"; describe("OpenAI single-provider option foundation", () => { test("locks exact ids, modes, and migration version", () => { diff --git a/tests/reasoning-replay-identity.test.ts b/tests/adapters/reasoning-replay-identity.test.ts similarity index 99% rename from tests/reasoning-replay-identity.test.ts rename to tests/adapters/reasoning-replay-identity.test.ts index 659d4c9cde..8709c6ea65 100644 --- a/tests/reasoning-replay-identity.test.ts +++ b/tests/adapters/reasoning-replay-identity.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE } from "../src/bridge"; +import { bridgeToResponsesSSE } from "../../src/bridge"; import { bindReasoningReplayScope, clearReasoningReplayCacheForTests, @@ -15,8 +15,8 @@ import { reasoningReplayServingIdentityChanged, rememberReasoningForCall, rememberReasoningReplayOpaqueBlobRejection, -} from "../src/responses/reasoning-replay-cache"; -import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../src/types"; +} from "../../src/responses/reasoning-replay-cache"; +import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../../src/types"; const THREAD = "thread-identity"; const CALL_ID = "call_identity_collision"; diff --git a/tests/reasoning-replay-robustness.test.ts b/tests/adapters/reasoning-replay-robustness.test.ts similarity index 92% rename from tests/reasoning-replay-robustness.test.ts rename to tests/adapters/reasoning-replay-robustness.test.ts index 0e050fc556..75f85d729d 100644 --- a/tests/reasoning-replay-robustness.test.ts +++ b/tests/adapters/reasoning-replay-robustness.test.ts @@ -3,14 +3,15 @@ import { existsSync, mkdtempSync, readdirSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { pathToFileURL } from "node:url"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; import { clearReasoningReplayCacheForTests, peekReasoningForCall, rememberReasoningForCall, -} from "../src/responses/reasoning-replay-cache"; -import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/responses/reasoning-replay-cache"; +import type { AdapterEvent, OcxReasoningReplayScopeRef } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoPath } from "../helpers/repo-root"; const REASONING = "I need to inspect files before answering."; const SCOPE: OcxReasoningReplayScopeRef = { @@ -99,7 +100,7 @@ describe("reasoning replay empty-delta robustness", () => { test("the memory-only cache writes no reasoning state to disk even when persistence env vars are set", async () => { const scratch = mkdtempSync(join(tmpdir(), "ocx-reasoning-memory-only-")); const spill = join(scratch, "must-not-exist.json"); - const moduleUrl = pathToFileURL(join(import.meta.dir, "../src/responses/reasoning-replay-cache.ts")).href; + const moduleUrl = pathToFileURL(repoPath("src/responses/reasoning-replay-cache.ts")).href; const script = [ `const cache = await import(${JSON.stringify(moduleUrl)});`, `const scope = {clientThreadId:"disk-guard",current:{providerName:"test",providerDestinationIdentity:"destination:test",adapterName:"openai-chat",modelId:"model",credentialIdentity:"key:test"}};`, diff --git a/tests/run-turn-queue.test.ts b/tests/adapters/run-turn-queue.test.ts similarity index 99% rename from tests/run-turn-queue.test.ts rename to tests/adapters/run-turn-queue.test.ts index 57406a2e1f..234b861792 100644 --- a/tests/run-turn-queue.test.ts +++ b/tests/adapters/run-turn-queue.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { COALESCE_MAX_CHUNK_LENGTH, createAdapterEventQueue, PREFLIGHT_HEARTBEAT_RETAIN_LIMIT, preflightAdapterEvents } from "../src/adapters/run-turn-queue"; -import type { AdapterEvent } from "../src/types"; +import { COALESCE_MAX_CHUNK_LENGTH, createAdapterEventQueue, PREFLIGHT_HEARTBEAT_RETAIN_LIMIT, preflightAdapterEvents } from "../../src/adapters/run-turn-queue"; +import type { AdapterEvent } from "../../src/types"; const text = (value: string): AdapterEvent => ({ type: "text_delta", text: value }); const phasedText = (value: string, phase: "final" | "commentary"): AdapterEvent => ({ type: "text_delta", text: value, phase }); diff --git a/tests/terminal-continuation-owner-rotation.test.ts b/tests/adapters/terminal-continuation-owner-rotation.test.ts similarity index 92% rename from tests/terminal-continuation-owner-rotation.test.ts rename to tests/adapters/terminal-continuation-owner-rotation.test.ts index 666d264743..458f8237b6 100644 --- a/tests/terminal-continuation-owner-rotation.test.ts +++ b/tests/adapters/terminal-continuation-owner-rotation.test.ts @@ -2,21 +2,21 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { ProviderAdapter } from "../src/adapters/base"; -import { saveConfig } from "../src/config"; -import { clearKeyCooldowns } from "../src/providers/key-failover"; -import { reasoningReplayKeyCredentialIdentity } from "../src/responses/reasoning-replay-cache"; +import type { ProviderAdapter } from "../../src/adapters/base"; +import { saveConfig } from "../../src/config"; +import { clearKeyCooldowns } from "../../src/providers/key-failover"; +import { reasoningReplayKeyCredentialIdentity } from "../../src/responses/reasoning-replay-cache"; import { clearResponseStateForTests, previousResponseProviderState, -} from "../src/responses/state"; +} from "../../src/responses/state"; import type { AdapterEvent, OcxConfig, OcxParsedRequest, OcxProviderConfig, -} from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; interface BuildObservation { key: string; @@ -69,10 +69,10 @@ function eventsForPhase(phase: string): AdapterEvent[] { throw new Error(`unexpected test phase: ${phase}`); } -const actualResolver = await import("../src/server/adapter-resolve"); +const actualResolver = await import("../../src/server/adapter-resolve"); const actualResolveAdapter = actualResolver.resolveAdapter; -mock.module("../src/server/adapter-resolve", () => ({ +mock.module("../../src/server/adapter-resolve", () => ({ ...actualResolver, resolveAdapter(provider: OcxProviderConfig, cacheRetention?: "none" | "short" | "long") { if (provider.adapter !== "test-terminal-owned") { @@ -104,7 +104,7 @@ mock.module("../src/server/adapter-resolve", () => ({ }, })); -const { handleResponses } = await import("../src/server/responses"); +const { handleResponses } = await import("../../src/server/responses"); describe("terminal continuation provider-owner rotation", () => { let originalFetch: typeof fetch; diff --git a/tests/tool-argument-integers.test.ts b/tests/adapters/tool-argument-integers.test.ts similarity index 98% rename from tests/tool-argument-integers.test.ts rename to tests/adapters/tool-argument-integers.test.ts index 590be64194..18cce8524c 100644 --- a/tests/tool-argument-integers.test.ts +++ b/tests/adapters/tool-argument-integers.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { coerceIntegerToolArguments } from "../src/lib/tool-argument-integers"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; +import { coerceIntegerToolArguments } from "../../src/lib/tool-argument-integers"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; async function* replay(events: AdapterEvent[]): AsyncGenerator { for (const event of events) yield event; diff --git a/tests/tool-catalog-nudge.test.ts b/tests/adapters/tool-catalog-nudge.test.ts similarity index 98% rename from tests/tool-catalog-nudge.test.ts rename to tests/adapters/tool-catalog-nudge.test.ts index 9c3efaf3d7..18fc5a301c 100644 --- a/tests/tool-catalog-nudge.test.ts +++ b/tests/adapters/tool-catalog-nudge.test.ts @@ -3,9 +3,9 @@ import { buildNonOpenAIToolCatalogNudgeForTools, buildNonOpenAIToolCatalogNudgeFromNames, shouldInjectNonOpenAIToolCatalogNudge, -} from "../src/adapters/tool-catalog-nudge"; -import { CODE_MODE_RESULT_ECHO_SENTENCE, EMPTY_EXEC_OUTPUT_MESSAGE } from "../src/adapters/exec-tool-result-normalize"; -import type { OcxTool } from "../src/types"; +} from "../../src/adapters/tool-catalog-nudge"; +import { CODE_MODE_RESULT_ECHO_SENTENCE, EMPTY_EXEC_OUTPUT_MESSAGE } from "../../src/adapters/exec-tool-result-normalize"; +import type { OcxTool } from "../../src/types"; describe("non-OpenAI tool catalog nudge", () => { test("builds a compact catalog-grounding note from wire names", () => { diff --git a/tests/tool-choice-performance.test.ts b/tests/adapters/tool-choice-performance.test.ts similarity index 97% rename from tests/tool-choice-performance.test.ts rename to tests/adapters/tool-choice-performance.test.ts index d1d99dee3c..6d3275b514 100644 --- a/tests/tool-choice-performance.test.ts +++ b/tests/adapters/tool-choice-performance.test.ts @@ -1,6 +1,6 @@ import { expect, test } from "bun:test"; -import type { OcxTool } from "../src/types"; -import { toolChoiceCandidates, toolChoiceToolPredicate } from "../src/types"; +import type { OcxTool } from "../../src/types"; +import { toolChoiceCandidates, toolChoiceToolPredicate } from "../../src/types"; test("allowed_tools resolves an ambiguous bare name without replaying the candidate list", () => { const size = 256; diff --git a/tests/translator-budget.test.ts b/tests/adapters/translator-budget.test.ts similarity index 96% rename from tests/translator-budget.test.ts rename to tests/adapters/translator-budget.test.ts index 149f08afdc..8e9800899c 100644 --- a/tests/translator-budget.test.ts +++ b/tests/adapters/translator-budget.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import { createGoogleAdapter } from "../src/adapters/google"; -import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import { createAnthropicAdapter } from "../../src/adapters/anthropic"; +import { createGoogleAdapter } from "../../src/adapters/google"; +import { createOpenAIChatAdapter } from "../../src/adapters/openai-chat"; import { TRANSLATOR_MAX_CALL_ARGUMENT_BYTES, TRANSLATOR_MAX_TURN_BYTES, @@ -10,9 +10,9 @@ import { releaseTranslatedEvent, retainTranslatedEvent, translatorObservedBufferSnapshot, -} from "../src/lib/translator-budget"; -import type { AdapterEvent } from "../src/types"; -import { SPAWN_BUDGET_MS } from "./helpers/test-budget"; +} from "../../src/lib/translator-budget"; +import type { AdapterEvent } from "../../src/types"; +import { SPAWN_BUDGET_MS } from "../helpers/test-budget"; async function textWithin(stream: ReadableStream, timeoutMs = 2_000): Promise { return await Promise.race([ diff --git a/tests/upstream-http-error.test.ts b/tests/adapters/upstream-http-error.test.ts similarity index 97% rename from tests/upstream-http-error.test.ts rename to tests/adapters/upstream-http-error.test.ts index 2514caf8e0..5c08fc823f 100644 --- a/tests/upstream-http-error.test.ts +++ b/tests/adapters/upstream-http-error.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; import { normalizeUpstreamHttpErrorResponse, sanitizeUpstreamErrorText, -} from "../src/adapters/upstream-http-error"; +} from "../../src/adapters/upstream-http-error"; describe("sanitizeUpstreamErrorText", () => { test("redacts secrets and absolute paths", () => { diff --git a/tests/alibaba-intl-token-plan.test.ts b/tests/gui/alibaba-intl-token-plan.test.ts similarity index 97% rename from tests/alibaba-intl-token-plan.test.ts rename to tests/gui/alibaba-intl-token-plan.test.ts index c76a9c364b..e5fb297e0d 100644 --- a/tests/alibaba-intl-token-plan.test.ts +++ b/tests/gui/alibaba-intl-token-plan.test.ts @@ -3,15 +3,15 @@ import { baseUrlForChoice, matchChoiceId, resolvedBaseUrlForChoice, -} from "../gui/src/base-url-choice"; +} from "../../gui/src/base-url-choice"; import { ALIBABA_INTL_BASE_URL_CHOICES, ALIBABA_INTL_TOKEN_PLAN_BASE_URL, ALIBABA_INTL_PAYG_BASE_URL, matchBaseUrlChoice, -} from "../src/providers/base-url-choices"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { deriveProviderPresets, enrichProviderFromRegistry } from "../src/providers/derive"; +} from "../../src/providers/base-url-choices"; +import { PROVIDER_REGISTRY } from "../../src/providers/registry"; +import { deriveProviderPresets, enrichProviderFromRegistry } from "../../src/providers/derive"; const CHOICES = [...ALIBABA_INTL_BASE_URL_CHOICES]; diff --git a/tests/claude-manual-env.test.ts b/tests/gui/claude-manual-env.test.ts similarity index 94% rename from tests/claude-manual-env.test.ts rename to tests/gui/claude-manual-env.test.ts index bed92a6a9a..36ecfef4d2 100644 --- a/tests/claude-manual-env.test.ts +++ b/tests/gui/claude-manual-env.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { buildManualEnv, type ClaudeManualEnvState } from "../gui/src/pages/claude-manual-env"; +import { buildManualEnv, type ClaudeManualEnvState } from "../../gui/src/pages/claude-manual-env"; const CONDITIONAL_FLAG_LINE = '[ -z "${CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST+x}" ] && export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1'; diff --git a/tests/codex-account-mode-state.test.ts b/tests/gui/codex-account-mode-state.test.ts similarity index 94% rename from tests/codex-account-mode-state.test.ts rename to tests/gui/codex-account-mode-state.test.ts index f7c0c61dd5..a0e2cf4fd0 100644 --- a/tests/codex-account-mode-state.test.ts +++ b/tests/gui/codex-account-mode-state.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { codexAccountModeState } from "../gui/src/codex-multi-state"; +import { codexAccountModeState } from "../../gui/src/codex-multi-state"; describe("OpenAI provider account-mode presentation state", () => { test("distinguishes absent, disabled, pool, and direct configurations", () => { diff --git a/tests/codex-auth-modal-status.test.ts b/tests/gui/codex-auth-modal-status.test.ts similarity index 100% rename from tests/codex-auth-modal-status.test.ts rename to tests/gui/codex-auth-modal-status.test.ts diff --git a/tests/combo-workspace-data.test.ts b/tests/gui/combo-workspace-data.test.ts similarity index 99% rename from tests/combo-workspace-data.test.ts rename to tests/gui/combo-workspace-data.test.ts index b7d1147161..e3d340f2f8 100644 --- a/tests/combo-workspace-data.test.ts +++ b/tests/gui/combo-workspace-data.test.ts @@ -16,8 +16,8 @@ import { toPutBody, updateComboAliasDraft, validateComboDraft, -} from "../gui/src/combo-workspace-data"; -import { comboImagesSupported } from "../gui/src/combo-capabilities"; +} from "../../gui/src/combo-workspace-data"; +import { comboImagesSupported } from "../../gui/src/combo-capabilities"; const configuredProviders = { a: {}, diff --git a/tests/dashboard-uptime.test.ts b/tests/gui/dashboard-uptime.test.ts similarity index 94% rename from tests/dashboard-uptime.test.ts rename to tests/gui/dashboard-uptime.test.ts index 4ae38bc756..3f43b08676 100644 --- a/tests/dashboard-uptime.test.ts +++ b/tests/gui/dashboard-uptime.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { formatUptime } from "../gui/src/formatUptime"; +import { formatUptime } from "../../gui/src/formatUptime"; describe("dashboard uptime formatting", () => { test("keeps short uptimes in seconds", () => { diff --git a/tests/gui-api-error.test.ts b/tests/gui/gui-api-error.test.ts similarity index 93% rename from tests/gui-api-error.test.ts rename to tests/gui/gui-api-error.test.ts index 5db5324ec3..e41ca33ce4 100644 --- a/tests/gui-api-error.test.ts +++ b/tests/gui/gui-api-error.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { apiErrorMessage } from "../gui/src/api-error"; +import { apiErrorMessage } from "../../gui/src/api-error"; describe("GUI management API errors", () => { test("surfaces an actionable server error", async () => { diff --git a/tests/gui-management-session.test.ts b/tests/gui/gui-management-session.test.ts similarity index 99% rename from tests/gui-management-session.test.ts rename to tests/gui/gui-management-session.test.ts index a6f32aa5db..492851cfda 100644 --- a/tests/gui-management-session.test.ts +++ b/tests/gui/gui-management-session.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { installApiAuthFetch, resetApiAuthFetchForTests } from "../gui/src/api"; +import { installApiAuthFetch, resetApiAuthFetchForTests } from "../../gui/src/api"; const originalWindow = globalThis.window; const originalDocument = globalThis.document; diff --git a/tests/gui-pair-capability.test.ts b/tests/gui/gui-pair-capability.test.ts similarity index 98% rename from tests/gui-pair-capability.test.ts rename to tests/gui/gui-pair-capability.test.ts index cab507afb9..a7a1b49a33 100644 --- a/tests/gui-pair-capability.test.ts +++ b/tests/gui/gui-pair-capability.test.ts @@ -5,7 +5,7 @@ import { GUI_PAIR_PATH, createGuiPairCapability, verifyGuiPairCapability, -} from "../src/lib/gui-pair-capability"; +} from "../../src/lib/gui-pair-capability"; const SECRET = "A".repeat(43); const NONCE = "B".repeat(43); diff --git a/tests/gui-pair-client.test.ts b/tests/gui/gui-pair-client.test.ts similarity index 96% rename from tests/gui-pair-client.test.ts rename to tests/gui/gui-pair-client.test.ts index 63bd9195db..7e1809554d 100644 --- a/tests/gui-pair-client.test.ts +++ b/tests/gui/gui-pair-client.test.ts @@ -1,18 +1,18 @@ import { describe, expect, test } from "bun:test"; -import { requestBoundGuiPairingGrant } from "../src/cli/gui-pair-client"; +import { requestBoundGuiPairingGrant } from "../../src/cli/gui-pair-client"; import { LOCAL_ATTESTATION_CHALLENGE_HEADER, LOCAL_ATTESTATION_PROOF_HEADER, createLocalAttestationProof, -} from "../src/lib/local-management-attestation"; +} from "../../src/lib/local-management-attestation"; import { GUI_PAIR_BROWSER_ORIGIN_HEADER, GUI_PAIR_CAPABILITY_HEADER, GUI_PAIR_CAPABILITY_VERSION, GUI_PAIR_PATH, verifyGuiPairCapability, -} from "../src/lib/gui-pair-capability"; -import type { LiveProxy } from "../src/server/proxy-liveness"; +} from "../../src/lib/gui-pair-capability"; +import type { LiveProxy } from "../../src/server/proxy-liveness"; const secret = "A".repeat(43); const nonce = "B".repeat(43); diff --git a/tests/gui-static.test.ts b/tests/gui/gui-static.test.ts similarity index 90% rename from tests/gui-static.test.ts rename to tests/gui/gui-static.test.ts index 74136e7912..e8536fac52 100644 --- a/tests/gui-static.test.ts +++ b/tests/gui/gui-static.test.ts @@ -2,8 +2,8 @@ import { afterEach, expect, test } from "bun:test"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { serveGuiFile } from "../src/server/gui-static"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { serveGuiFile } from "../../src/server/gui-static"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const temporaryDirectories: string[] = []; diff --git a/tests/integrations-invariants.test.ts b/tests/gui/integrations-invariants.test.ts similarity index 97% rename from tests/integrations-invariants.test.ts rename to tests/gui/integrations-invariants.test.ts index b14a6e908c..33e7480f86 100644 --- a/tests/integrations-invariants.test.ts +++ b/tests/gui/integrations-invariants.test.ts @@ -2,15 +2,15 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; -import { EXPORT_CLIENTS, EXPORT_CLIENT_IDS, type ExportModel } from "../src/clients/config-export"; -import { parseConfig } from "../src/integrations/config-io"; -import { INTEGRATION_CLIENTS, INTEGRATION_CLIENT_IDS, type IntegrationClientId } from "../src/integrations/registry"; -import { createIntegrationStateStore, type IntegrationStateStore } from "../src/integrations/store"; -import { readIntegrationState } from "../src/integrations/state"; -import { applyIntegration, disableIntegration, restoreIntegration } from "../src/integrations/writer"; -import { printSubcommandUsage, printUsage } from "../src/cli/help"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { EXPORT_CLIENTS, EXPORT_CLIENT_IDS, type ExportModel } from "../../src/clients/config-export"; +import { parseConfig } from "../../src/integrations/config-io"; +import { INTEGRATION_CLIENTS, INTEGRATION_CLIENT_IDS, type IntegrationClientId } from "../../src/integrations/registry"; +import { createIntegrationStateStore, type IntegrationStateStore } from "../../src/integrations/store"; +import { readIntegrationState } from "../../src/integrations/state"; +import { applyIntegration, disableIntegration, restoreIntegration } from "../../src/integrations/writer"; +import { printSubcommandUsage, printUsage } from "../../src/cli/help"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** * Properties that hold ACROSS the whole client-integration feature, which is @@ -86,9 +86,9 @@ describe("the client registries cannot drift apart", () => { * server-side renders no row until someone remembers the tuple, and the * only thing that catches forgetting is this test. */ - const gui = await import("../gui/src/components/apikeys-workspace/client-config-clients"); - const guiIntegrations = await import("../gui/src/pages/integrations/integration-api"); - const guiRouting = await import("../gui/src/app-routing"); + const gui = await import("../../gui/src/components/apikeys-workspace/client-config-clients"); + const guiIntegrations = await import("../../gui/src/pages/integrations/integration-api"); + const guiRouting = await import("../../gui/src/app-routing"); const expected = [...EXPORT_CLIENT_IDS].sort(); expect(expected).toHaveLength(12); diff --git a/tests/logs-model-tier-confirmation.test.ts b/tests/gui/logs-model-tier-confirmation.test.ts similarity index 96% rename from tests/logs-model-tier-confirmation.test.ts rename to tests/gui/logs-model-tier-confirmation.test.ts index 995b76f793..c43491e6f0 100644 --- a/tests/logs-model-tier-confirmation.test.ts +++ b/tests/gui/logs-model-tier-confirmation.test.ts @@ -1,7 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { modelTitle, type ModelTitleEntry } from "../gui/src/pages/logs-model-title"; +import { modelTitle, type ModelTitleEntry } from "../../gui/src/pages/logs-model-title"; import { readFileSync, readdirSync } from "node:fs"; import { join } from "node:path"; +import { repoPath } from "../helpers/repo-root"; /** * #2455: a user routing gpt-5.x through the proxy asked for `service_tier: priority`, @@ -91,7 +92,7 @@ describe("model tooltip tier confirmation (#2455)", () => { const LOCALE_FILES = [ "en.ts", "de.ts", "fr.ts", "ko.ts", "zh.ts", "zh-TW.ts", "ru.ts", "ja.ts", "tr.ts", ]; - const dir = join(import.meta.dir, "..", "gui", "src", "i18n"); + const dir = repoPath("gui", "src", "i18n"); const present = readdirSync(dir); for (const file of LOCALE_FILES) { expect(present, `${file} disappeared from i18n/`).toContain(file); diff --git a/tests/models-page-groups.test.ts b/tests/gui/models-page-groups.test.ts similarity index 96% rename from tests/models-page-groups.test.ts rename to tests/gui/models-page-groups.test.ts index 1d88a83cf3..98a59490ca 100644 --- a/tests/models-page-groups.test.ts +++ b/tests/gui/models-page-groups.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { buildProviderModelGroups } from "../gui/src/models-groups"; +import { buildProviderModelGroups } from "../../gui/src/models-groups"; type Row = { provider: string; id: string; native?: boolean }; diff --git a/tests/models-workspace-tabs.test.ts b/tests/gui/models-workspace-tabs.test.ts similarity index 98% rename from tests/models-workspace-tabs.test.ts rename to tests/gui/models-workspace-tabs.test.ts index 53109c7f2b..2eb8138f2c 100644 --- a/tests/models-workspace-tabs.test.ts +++ b/tests/gui/models-workspace-tabs.test.ts @@ -11,7 +11,7 @@ import { hashBelongsToPage, readPageFromHash, resolveAppHashChange, -} from "../gui/src/app-routing"; +} from "../../gui/src/app-routing"; import { MODELS_TABS, modelsPanelDomId, @@ -19,7 +19,7 @@ import { modelsTabHash, readModelsTab, type ModelsTab, -} from "../gui/src/pages/models-tab"; +} from "../../gui/src/pages/models-tab"; describe("nested Models hashes", () => { test("all tab hashes are registered and belong to the models page", () => { diff --git a/tests/oauth-first-add-hint.test.ts b/tests/gui/oauth-first-add-hint.test.ts similarity index 96% rename from tests/oauth-first-add-hint.test.ts rename to tests/gui/oauth-first-add-hint.test.ts index da66f7a9f7..cd9da44fd8 100644 --- a/tests/oauth-first-add-hint.test.ts +++ b/tests/gui/oauth-first-add-hint.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { shouldShowLoginHint } from "../gui/src/components/provider-catalog/login-hint-visibility"; +import { shouldShowLoginHint } from "../../gui/src/components/provider-catalog/login-hint-visibility"; /** * A first-time provider add is the one moment the operator has no other way in. diff --git a/tests/oauth-tos-warning.test.ts b/tests/gui/oauth-tos-warning.test.ts similarity index 98% rename from tests/oauth-tos-warning.test.ts rename to tests/gui/oauth-tos-warning.test.ts index 2859b14711..afa8e554f1 100644 --- a/tests/oauth-tos-warning.test.ts +++ b/tests/gui/oauth-tos-warning.test.ts @@ -3,7 +3,7 @@ import { oauthTosRisk, oauthTosRiskBodyKey, oauthTosRiskTitleKey, -} from "../gui/src/oauth-tos-risk"; +} from "../../gui/src/oauth-tos-risk"; describe("oauth ToS risk map", () => { test("flags high-risk subscription OAuth providers", () => { diff --git a/tests/provider-payload.test.ts b/tests/gui/provider-payload.test.ts similarity index 96% rename from tests/provider-payload.test.ts rename to tests/gui/provider-payload.test.ts index 5bda1ccabe..b99d8c574f 100644 --- a/tests/provider-payload.test.ts +++ b/tests/gui/provider-payload.test.ts @@ -8,13 +8,13 @@ import { isReservedCodexForwardPreset, openAiAccountProviderState, OpenAiEnableError, -} from "../gui/src/provider-payload"; -import { en } from "../gui/src/i18n/en"; -import { ko } from "../gui/src/i18n/ko"; -import { de } from "../gui/src/i18n/de"; -import { zh } from "../gui/src/i18n/zh"; -import { deriveProviderPresets, providerConfigSeed } from "../src/providers/derive"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; +} from "../../gui/src/provider-payload"; +import { en } from "../../gui/src/i18n/en"; +import { ko } from "../../gui/src/i18n/ko"; +import { de } from "../../gui/src/i18n/de"; +import { zh } from "../../gui/src/i18n/zh"; +import { deriveProviderPresets, providerConfigSeed } from "../../src/providers/derive"; +import { PROVIDER_REGISTRY } from "../../src/providers/registry"; describe("provider dashboard payload", () => { test("keeps OpenAI in the account entry even when its provider is absent", () => { diff --git a/tests/provider-workspace-auth.test.ts b/tests/gui/provider-workspace-auth.test.ts similarity index 98% rename from tests/provider-workspace-auth.test.ts rename to tests/gui/provider-workspace-auth.test.ts index 6e8fd045d8..edc407906b 100644 --- a/tests/provider-workspace-auth.test.ts +++ b/tests/gui/provider-workspace-auth.test.ts @@ -2,9 +2,9 @@ import { describe, expect, test } from "bun:test"; import { oauthAccountDisplayLabel, providerAuthSurface, -} from "../gui/src/provider-workspace/auth"; -import type { WorkspaceItem } from "../gui/src/provider-workspace/catalog"; -import type { TFn } from "../gui/src/i18n"; +} from "../../gui/src/provider-workspace/auth"; +import type { WorkspaceItem } from "../../gui/src/provider-workspace/catalog"; +import type { TFn } from "../../gui/src/i18n"; function provider(name: string, overrides: Partial = {}): WorkspaceItem { return { diff --git a/tests/provider-workspace-data.test.ts b/tests/gui/provider-workspace-data.test.ts similarity index 98% rename from tests/provider-workspace-data.test.ts rename to tests/gui/provider-workspace-data.test.ts index a17b6e8729..68a653f4b2 100644 --- a/tests/provider-workspace-data.test.ts +++ b/tests/gui/provider-workspace-data.test.ts @@ -10,7 +10,7 @@ import { sortWorkspaceItems, type WorkspaceItem, type WorkspaceProvider, -} from "../gui/src/provider-workspace/catalog"; +} from "../../gui/src/provider-workspace/catalog"; import { buildAttentionItems, buildMostUsedProviders, @@ -21,22 +21,22 @@ import { parseAvailableModels, parseSelectedModels, relativeTimeLabelsFromT, -} from "../gui/src/provider-workspace/usage"; +} from "../../gui/src/provider-workspace/usage"; import { formatNamespacedModelId, formatProviderDisplayName, isCatalogProviderId, providerIconSrc, -} from "../gui/src/provider-icons"; -import { en } from "../gui/src/i18n/en"; -import { interpolate, type TFn } from "../gui/src/i18n/shared"; +} from "../../gui/src/provider-icons"; +import { en } from "../../gui/src/i18n/en"; +import { interpolate, type TFn } from "../../gui/src/i18n/shared"; import { bucketPresets, filterPresets, presetTier, type CatalogPreset, -} from "../gui/src/components/provider-catalog/provider-presets"; -import { isLocalProvider, providerKind } from "../gui/src/provider-workspace/kind"; +} from "../../gui/src/components/provider-catalog/provider-presets"; +import { isLocalProvider, providerKind } from "../../gui/src/provider-workspace/kind"; const englishT: TFn = (key, vars) => interpolate(en[key], vars); diff --git a/tests/provider-workspace-rail.test.ts b/tests/gui/provider-workspace-rail.test.ts similarity index 95% rename from tests/provider-workspace-rail.test.ts rename to tests/gui/provider-workspace-rail.test.ts index fdfcf3e59d..faf389b5a8 100644 --- a/tests/provider-workspace-rail.test.ts +++ b/tests/gui/provider-workspace-rail.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { railStatusCls, statusLabel } from "../gui/src/components/provider-workspace/ProviderRail"; -import type { WorkspaceItem } from "../gui/src/provider-workspace/catalog"; -import type { TFn } from "../gui/src/i18n"; +import { railStatusCls, statusLabel } from "../../gui/src/components/provider-workspace/ProviderRail"; +import type { WorkspaceItem } from "../../gui/src/provider-workspace/catalog"; +import type { TFn } from "../../gui/src/i18n"; const t = ((key: string) => ({ "prov.disabledBadge": "Disabled", @@ -73,7 +73,7 @@ describe("provider rail source contract", () => { }); test("redirects the legacy workspace subroute and normalizes unknown suffixes", async () => { - const { hashBelongsToPage, resolveAppHashChange } = await import("../gui/src/app-routing"); + const { hashBelongsToPage, resolveAppHashChange } = await import("../../gui/src/app-routing"); // WP5 (Q1): the dual-layout hash is no longer a Providers route. It must not belong, // and it must be passively replaced so an old bookmark still lands somewhere real. expect(hashBelongsToPage("providers/workspace", "providers")).toBe(false); diff --git a/tests/provider-workspace-state.test.ts b/tests/gui/provider-workspace-state.test.ts similarity index 99% rename from tests/provider-workspace-state.test.ts rename to tests/gui/provider-workspace-state.test.ts index 455cd82d1d..9043a1229d 100644 --- a/tests/provider-workspace-state.test.ts +++ b/tests/gui/provider-workspace-state.test.ts @@ -3,7 +3,7 @@ import { accountQuotaFromReport, filterModels, formatQuotaSourceLabel, -} from "../gui/src/provider-workspace/report"; +} from "../../gui/src/provider-workspace/report"; describe("workspace detail derived states (WP090)", () => { describe("filterModels", () => { diff --git a/tests/quota-bars-rows.test.ts b/tests/gui/quota-bars-rows.test.ts similarity index 97% rename from tests/quota-bars-rows.test.ts rename to tests/gui/quota-bars-rows.test.ts index 2f8b8de5bf..b9f834efc6 100644 --- a/tests/quota-bars-rows.test.ts +++ b/tests/gui/quota-bars-rows.test.ts @@ -7,9 +7,9 @@ import { isQuotaWarn, maxQuotaUtilisation, quotaBarTone, -} from "../gui/src/components/QuotaBars"; -import type { AccountQuota } from "../gui/src/codex-quota-utils"; -import type { TFn } from "../gui/src/i18n"; +} from "../../gui/src/components/QuotaBars"; +import type { AccountQuota } from "../../gui/src/codex-quota-utils"; +import type { TFn } from "../../gui/src/i18n"; /** Key-echoing translator: rows carry their key so ordering is assertable. */ const t: TFn = ((key: string, vars?: Record) => diff --git a/tests/qwen-cloud-endpoints.test.ts b/tests/gui/qwen-cloud-endpoints.test.ts similarity index 93% rename from tests/qwen-cloud-endpoints.test.ts rename to tests/gui/qwen-cloud-endpoints.test.ts index 6390701756..2b024f395a 100644 --- a/tests/qwen-cloud-endpoints.test.ts +++ b/tests/gui/qwen-cloud-endpoints.test.ts @@ -3,15 +3,15 @@ import { baseUrlForChoice, matchChoiceId, resolvedBaseUrlForChoice, -} from "../gui/src/base-url-choice"; +} from "../../gui/src/base-url-choice"; import { QWEN_CLOUD_BASE_URL_CHOICES, QWEN_CLOUD_PAYG_BASE_URL, QWEN_CLOUD_TOKEN_PLAN_BASE_URL, matchBaseUrlChoice, -} from "../src/providers/base-url-choices"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { deriveProviderPresets } from "../src/providers/derive"; +} from "../../src/providers/base-url-choices"; +import { PROVIDER_REGISTRY } from "../../src/providers/registry"; +import { deriveProviderPresets } from "../../src/providers/derive"; const CHOICES = [...QWEN_CLOUD_BASE_URL_CHOICES]; diff --git a/tests/rate-limit-reset-credits.test.ts b/tests/gui/rate-limit-reset-credits.test.ts similarity index 99% rename from tests/rate-limit-reset-credits.test.ts rename to tests/gui/rate-limit-reset-credits.test.ts index 45b9950fdf..4300136701 100644 --- a/tests/rate-limit-reset-credits.test.ts +++ b/tests/gui/rate-limit-reset-credits.test.ts @@ -7,7 +7,7 @@ import { getAccountQuota, clearAccountQuota, type WhamUsageResponse, -} from "../src/codex/quota"; +} from "../../src/codex/quota"; describe("rate-limit reset credits", () => { describe("parseUsageQuota", () => { @@ -214,7 +214,7 @@ describe("rate-limit reset credits", () => { describe("CodexAuth reset credit UI", () => { it("normalizes Go and Free quota displays to 30d only", async () => { - const { normalizeQuotaForPlan } = await import("../gui/src/codex-quota-utils"); + const { normalizeQuotaForPlan } = await import("../../gui/src/codex-quota-utils"); const quota = { weeklyPercent: 98, monthlyPercent: 12, @@ -252,7 +252,7 @@ describe("rate-limit reset credits", () => { * an override, or a pool snapshot could quietly replace a probe reading. */ it("renders the Codex pool's short window as the five-hour window (#2616)", async () => { - const { normalizeQuotaForPlan } = await import("../gui/src/codex-quota-utils"); + const { normalizeQuotaForPlan } = await import("../../gui/src/codex-quota-utils"); expect(normalizeQuotaForPlan({ shortPercent: 71, shortResetAt: 555, updatedAt: 1 }, "pro")) .toMatchObject({ fiveHourPercent: 71, fiveHourResetAt: 555 }); diff --git a/tests/routing-intelligence-ui.test.ts b/tests/gui/routing-intelligence-ui.test.ts similarity index 95% rename from tests/routing-intelligence-ui.test.ts rename to tests/gui/routing-intelligence-ui.test.ts index c557d37254..7718619ef6 100644 --- a/tests/routing-intelligence-ui.test.ts +++ b/tests/gui/routing-intelligence-ui.test.ts @@ -1,14 +1,15 @@ import { expect, test } from "bun:test"; import { readFileSync } from "node:fs"; import { join } from "node:path"; -import { hashBelongsToPage, readPageFromHash, resolveAppHashChange, VALID_PAGES } from "../gui/src/app-routing"; +import { hashBelongsToPage, readPageFromHash, resolveAppHashChange, VALID_PAGES } from "../../gui/src/app-routing"; import { sanitizeLogEntryRouteDecision, validCachedRouteDecision, type LogEntryBase as LogEntry, -} from "../gui/src/pages/log-route-decision"; +} from "../../gui/src/pages/log-route-decision"; +import { repoPath } from "../helpers/repo-root"; -const guiRoot = join(import.meta.dir, "..", "gui", "src"); +const guiRoot = repoPath("gui", "src"); test("routing is a Models tab with a registered nested hash", () => { // It used to be a first-class page. Both ids are gone from the union now, and the diff --git a/tests/routing-profile-editor-data.test.ts b/tests/gui/routing-profile-editor-data.test.ts similarity index 99% rename from tests/routing-profile-editor-data.test.ts rename to tests/gui/routing-profile-editor-data.test.ts index 963793f5f0..5a07439923 100644 --- a/tests/routing-profile-editor-data.test.ts +++ b/tests/gui/routing-profile-editor-data.test.ts @@ -9,7 +9,7 @@ import { routingProfileResponseError, routingProfileResponseSucceeded, type RoutingProfileDto, -} from "../gui/src/routing-profile-editor-data"; +} from "../../gui/src/routing-profile-editor-data"; const profile: RoutingProfileDto = { id: "fast", diff --git a/tests/startup-health-ui.test.ts b/tests/gui/startup-health-ui.test.ts similarity index 99% rename from tests/startup-health-ui.test.ts rename to tests/gui/startup-health-ui.test.ts index c4e359787d..b66a907f3a 100644 --- a/tests/startup-health-ui.test.ts +++ b/tests/gui/startup-health-ui.test.ts @@ -7,7 +7,7 @@ import { seedStartupHealthFromSettings, settingsPollMayCommit, startupRiskDetailKey, -} from "../gui/src/startup-health-ui"; +} from "../../gui/src/startup-health-ui"; describe("startup health UI decisions", () => { test("selects the shared risk-detail message", () => { diff --git a/tests/tencent-siliconflow-providers.test.ts b/tests/gui/tencent-siliconflow-providers.test.ts similarity index 89% rename from tests/tencent-siliconflow-providers.test.ts rename to tests/gui/tencent-siliconflow-providers.test.ts index 9669180736..5c3ca97539 100644 --- a/tests/tencent-siliconflow-providers.test.ts +++ b/tests/gui/tencent-siliconflow-providers.test.ts @@ -1,12 +1,12 @@ import { describe, expect, test } from "bun:test"; -import { KEY_LOGIN_PROVIDERS } from "../src/oauth/key-providers"; -import { deriveProviderPresets } from "../src/providers/derive"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { routeModel } from "../src/router"; -import type { OcxConfig } from "../src/types"; -import { en } from "../gui/src/i18n/en"; -import { interpolate, type TFn } from "../gui/src/i18n/shared"; -import { formatProviderDisplayName, isCatalogProviderId } from "../gui/src/provider-icons"; +import { KEY_LOGIN_PROVIDERS } from "../../src/oauth/key-providers"; +import { deriveProviderPresets } from "../../src/providers/derive"; +import { PROVIDER_REGISTRY } from "../../src/providers/registry"; +import { routeModel } from "../../src/router"; +import type { OcxConfig } from "../../src/types"; +import { en } from "../../gui/src/i18n/en"; +import { interpolate, type TFn } from "../../gui/src/i18n/shared"; +import { formatProviderDisplayName, isCatalogProviderId } from "../../gui/src/provider-icons"; const englishT: TFn = (key, vars) => interpolate(en[key], vars); diff --git a/tests/vision-sidecar-timeout-bounds.test.ts b/tests/gui/vision-sidecar-timeout-bounds.test.ts similarity index 89% rename from tests/vision-sidecar-timeout-bounds.test.ts rename to tests/gui/vision-sidecar-timeout-bounds.test.ts index 8ab436537d..d525a30dd7 100644 --- a/tests/vision-sidecar-timeout-bounds.test.ts +++ b/tests/gui/vision-sidecar-timeout-bounds.test.ts @@ -4,13 +4,13 @@ import { DEFAULT_VISION_TIMEOUT_MS, MAX_VISION_TIMEOUT_MS, MIN_VISION_TIMEOUT_MS, -} from "../src/vision"; +} from "../../src/vision"; import { VISION_MAX_DESCRIPTIONS_DEFAULT, VISION_TIMEOUT_MS_DEFAULT, VISION_TIMEOUT_MS_MAX, VISION_TIMEOUT_MS_MIN, -} from "../gui/src/pages/dashboard-shared"; +} from "../../gui/src/pages/dashboard-shared"; test("Dashboard timeout bounds are the runtime vision sidecar contract", () => { expect(VISION_TIMEOUT_MS_MIN).toBe(MIN_VISION_TIMEOUT_MS); diff --git a/tests/volcengine-providers.test.ts b/tests/gui/volcengine-providers.test.ts similarity index 95% rename from tests/volcengine-providers.test.ts rename to tests/gui/volcengine-providers.test.ts index 2dba569a24..c6bcf2c743 100644 --- a/tests/volcengine-providers.test.ts +++ b/tests/gui/volcengine-providers.test.ts @@ -1,18 +1,18 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../src/adapters/openai-responses"; -import { applyProviderConfigHints, buildCatalogEntries } from "../src/codex/catalog"; -import { KEY_LOGIN_PROVIDERS } from "../src/oauth/key-providers"; -import { deriveProviderPresets, providerConfigSeed } from "../src/providers/derive"; -import { PROVIDER_REGISTRY } from "../src/providers/registry"; -import { safeConfigDTO } from "../src/server/auth-cors"; -import { routeModel } from "../src/router"; -import type { OcxConfig } from "../src/types"; -import { buildProviderPostBody } from "../gui/src/provider-payload"; -import { en } from "../gui/src/i18n/en"; -import { interpolate, type TFn } from "../gui/src/i18n/shared"; -import { formatProviderDisplayName, isCatalogProviderId } from "../gui/src/provider-icons"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../src/adapters/openai-chat"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; +import { applyProviderConfigHints, buildCatalogEntries } from "../../src/codex/catalog"; +import { KEY_LOGIN_PROVIDERS } from "../../src/oauth/key-providers"; +import { deriveProviderPresets, providerConfigSeed } from "../../src/providers/derive"; +import { PROVIDER_REGISTRY } from "../../src/providers/registry"; +import { safeConfigDTO } from "../../src/server/auth-cors"; +import { routeModel } from "../../src/router"; +import type { OcxConfig } from "../../src/types"; +import { buildProviderPostBody } from "../../gui/src/provider-payload"; +import { en } from "../../gui/src/i18n/en"; +import { interpolate, type TFn } from "../../gui/src/i18n/shared"; +import { formatProviderDisplayName, isCatalogProviderId } from "../../gui/src/provider-icons"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createOpenAIChatAdapter = (...args: Parameters) => withTestTranslatorBudget(createOpenAIChatAdapterProduction(...args)); diff --git a/tests/helpers/dead-pid.ts b/tests/helpers/dead-pid.ts index c963b35556..c987df51c9 100644 --- a/tests/helpers/dead-pid.ts +++ b/tests/helpers/dead-pid.ts @@ -11,7 +11,7 @@ * That is not hypothetical. On the macOS host where this helper was written, pid * 4242 was `liveactivitiesd`, and every suite that assumed it dead failed at once: * `periodic reclaim frees abandoned temps`, both `doctor reclaim wiring` cases and - * both `status reports stale process records` cases. `tests/responses-state.test.ts` + * both `status reports stale process records` cases. `tests/responses/responses-state.test.ts` * already probed for a free pid inline, with a comment naming this exact hazard; * this helper is that probe, shared instead of copied. * diff --git a/tests/core-lab-boundary.test.ts b/tests/lab/core-lab-boundary.test.ts similarity index 99% rename from tests/core-lab-boundary.test.ts rename to tests/lab/core-lab-boundary.test.ts index ffbfa6176c..57fcb0bc71 100644 --- a/tests/core-lab-boundary.test.ts +++ b/tests/lab/core-lab-boundary.test.ts @@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test"; import { readFileSync, existsSync, writeFileSync, rmSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; +import { repoRoot as resolveRepoRoot } from "../helpers/repo-root"; /** * The proxy core must not reach Compatibility Lab. @@ -31,7 +32,7 @@ const PROTECTED = [ // ENOENT instead of reading a file. A boundary test that cannot open its own sources // reports a broken path as a failure and would report a real Lab import the same way, // which means it was proving nothing on this platform. -const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const repoRoot = resolveRepoRoot(); /** * Runtime imports only: `import type` is erased and costs nothing at runtime. diff --git a/tests/lab-activation.test.ts b/tests/lab/lab-activation.test.ts similarity index 94% rename from tests/lab-activation.test.ts rename to tests/lab/lab-activation.test.ts index 3011cea270..6a4f5a1a92 100644 --- a/tests/lab-activation.test.ts +++ b/tests/lab/lab-activation.test.ts @@ -8,20 +8,20 @@ import { labAutomationEnabledOnDisk, isLabActivated, resetLabActivationForTests, -} from "../src/lib/lab-activation"; +} from "../../src/lib/lab-activation"; import { resolveCompatibilityEvidenceProvider, resetCompatibilityEvidenceProviderForTests, -} from "../src/routing/compatibility/provider-slot"; -import { defaultLabAutomationPolicyV1 } from "../src/lab/automation/policy"; -import { isLabAutomationSchedulerRunning, stopLabAutomationScheduler } from "../src/lab/automation/orchestrator"; -import { runOptionalShutdownHooks, resetOptionalShutdownHooksForTests } from "../src/lib/optional-shutdown-hooks"; +} from "../../src/routing/compatibility/provider-slot"; +import { defaultLabAutomationPolicyV1 } from "../../src/lab/automation/policy"; +import { isLabAutomationSchedulerRunning, stopLabAutomationScheduler } from "../../src/lab/automation/orchestrator"; +import { runOptionalShutdownHooks, resetOptionalShutdownHooksForTests } from "../../src/lib/optional-shutdown-hooks"; import { acquireServerResourceOwner, resetServerResourceOwnershipForTests, -} from "../src/lib/server-resource-ownership"; -import { hasPassiveRouteLinker, resetPassiveRouteLinkerForTests } from "../src/server/passive-route-linker"; -import type { OcxConfig } from "../src/types"; +} from "../../src/lib/server-resource-ownership"; +import { hasPassiveRouteLinker, resetPassiveRouteLinkerForTests } from "../../src/server/passive-route-linker"; +import type { OcxConfig } from "../../src/types"; function scratch(): string { const dir = mkdtempSync(join(tmpdir(), "ocx-activation-")); @@ -253,8 +253,8 @@ describe("R3-1 a profile-less dry-run registers no slot", () => { }); test("an unknown profile on an install with no profiles fills neither slot", async () => { - const { handleManagementAPI } = await import("../src/server/management-api"); - const { ManagementRequest } = await import("./helpers/management-auth"); + const { handleManagementAPI } = await import("../../src/server/management-api"); + const { ManagementRequest } = await import("../helpers/management-auth"); const cfg = { port: 10100, @@ -288,8 +288,8 @@ describe("R3-1 a profile-less dry-run registers no slot", () => { }); test("the same route DOES register once a profile exists, so the assertion above is not vacuous", async () => { - const { handleManagementAPI } = await import("../src/server/management-api"); - const { ManagementRequest } = await import("./helpers/management-auth"); + const { handleManagementAPI } = await import("../../src/server/management-api"); + const { ManagementRequest } = await import("../helpers/management-auth"); const cfg = { port: 10100, diff --git a/tests/lab-automation-coderabbit-regressions.test.ts b/tests/lab/lab-automation-coderabbit-regressions.test.ts similarity index 91% rename from tests/lab-automation-coderabbit-regressions.test.ts rename to tests/lab/lab-automation-coderabbit-regressions.test.ts index d9fd5519f3..3f65ad4ab1 100644 --- a/tests/lab-automation-coderabbit-regressions.test.ts +++ b/tests/lab/lab-automation-coderabbit-regressions.test.ts @@ -2,35 +2,35 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import type { OcxConfig } from "../src/types"; -import { defaultLabAutomationPolicyV1, normalizeLabAutomationPolicyV1 } from "../src/lab/automation/policy"; +import type { OcxConfig } from "../../src/types"; +import { defaultLabAutomationPolicyV1, normalizeLabAutomationPolicyV1 } from "../../src/lab/automation/policy"; import { defaultLabAutomationStateV1, loadLabAutomationPolicy, loadLabAutomationState, saveLabAutomationPolicy, saveLabAutomationState, -} from "../src/lab/automation/persistence"; -import { loadLabAutomationConfig } from "../src/lab/automation/config-persistence"; -import { LAB_AUTOMATION_HARD_MAX } from "../src/lab/automation/constants"; -import { enqueuePlannedRuns } from "../src/lab/automation/queue"; -import { runBudgetRemaining } from "../src/lab/automation/budgets"; -import { cooldownActive, setCooldown } from "../src/lab/automation/cooldown"; -import { listLabAutomationRuns } from "../src/lab/automation/runs-query"; +} from "../../src/lab/automation/persistence"; +import { loadLabAutomationConfig } from "../../src/lab/automation/config-persistence"; +import { LAB_AUTOMATION_HARD_MAX } from "../../src/lab/automation/constants"; +import { enqueuePlannedRuns } from "../../src/lab/automation/queue"; +import { runBudgetRemaining } from "../../src/lab/automation/budgets"; +import { cooldownActive, setCooldown } from "../../src/lab/automation/cooldown"; +import { listLabAutomationRuns } from "../../src/lab/automation/runs-query"; import { cancelLabAutomationRun, requestLabAutomationShutdown, resetLabAutomationSchedulerStateForTests, stopLabAutomationScheduler, -} from "../src/lab/automation/orchestrator"; -import type { LabAutomationRunRecordV1, PlannedLabRunV1 } from "../src/lab/automation/types"; -import { LabAutomationError } from "../src/lab/automation/types"; -import { ensureLabDirs, labAutomationStatePath } from "../src/lab/paths"; -import { handleManagementAPI } from "../src/server/management-api"; -import { ManagementRequest } from "./helpers/management-auth"; -import { handleLabCommand } from "../src/cli/lab"; -import { createProductionLabRouteExecutor } from "../src/lib/lab-live-route-production"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/automation/orchestrator"; +import type { LabAutomationRunRecordV1, PlannedLabRunV1 } from "../../src/lab/automation/types"; +import { LabAutomationError } from "../../src/lab/automation/types"; +import { ensureLabDirs, labAutomationStatePath } from "../../src/lab/paths"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { ManagementRequest } from "../helpers/management-auth"; +import { handleLabCommand } from "../../src/cli/lab"; +import { createProductionLabRouteExecutor } from "../../src/lib/lab-live-route-production"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; diff --git a/tests/lab-automation-final-coderabbit-regressions.test.ts b/tests/lab/lab-automation-final-coderabbit-regressions.test.ts similarity index 88% rename from tests/lab-automation-final-coderabbit-regressions.test.ts rename to tests/lab/lab-automation-final-coderabbit-regressions.test.ts index 058a376803..b563359bfa 100644 --- a/tests/lab-automation-final-coderabbit-regressions.test.ts +++ b/tests/lab/lab-automation-final-coderabbit-regressions.test.ts @@ -3,20 +3,20 @@ import { Database } from "bun:sqlite"; import { mkdirSync, readFileSync} from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import type { OcxConfig } from "../src/types"; -import { LAB_PROJECTION_SPEC_VERSION } from "../src/lab/constants"; -import { ensureLabDirs, labSqlitePath } from "../src/lab/paths"; -import { LAB_SQLITE_DDL, LAB_SQLITE_SCHEMA_VERSION } from "../src/lab/projection/schema"; -import { queryLatestLabObservation } from "../src/lab/query/latest-observation"; -import { defaultLabAutomationPolicyV1 } from "../src/lab/automation/policy"; +import type { OcxConfig } from "../../src/types"; +import { LAB_PROJECTION_SPEC_VERSION } from "../../src/lab/constants"; +import { ensureLabDirs, labSqlitePath } from "../../src/lab/paths"; +import { LAB_SQLITE_DDL, LAB_SQLITE_SCHEMA_VERSION } from "../../src/lab/projection/schema"; +import { queryLatestLabObservation } from "../../src/lab/query/latest-observation"; +import { defaultLabAutomationPolicyV1 } from "../../src/lab/automation/policy"; import { defaultLabAutomationStateV1, loadLabAutomationState, saveLabAutomationPolicy, saveLabAutomationRoutes, saveLabAutomationState, -} from "../src/lab/automation/persistence"; -import { planLabAutomationRuns, planManualLabRun } from "../src/lab/automation/planner"; +} from "../../src/lab/automation/persistence"; +import { planLabAutomationRuns, planManualLabRun } from "../../src/lab/automation/planner"; import { cancelLabAutomationRun, requestLabAutomationShutdown, @@ -24,17 +24,18 @@ import { runLabAutomationTick, setLabAutomationDispatchDeps, stopLabAutomationScheduler, -} from "../src/lab/automation/orchestrator"; -import { LAB_AUTOMATION_HARD_MAX } from "../src/lab/automation/constants"; -import type { LabAutomationRunRecordV1 } from "../src/lab/automation/types"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import type { NormalizedObservation } from "../src/lab/conformance/types"; -import { readInstallationSalt } from "../src/lab/subject/installation-salt"; +} from "../../src/lab/automation/orchestrator"; +import { LAB_AUTOMATION_HARD_MAX } from "../../src/lab/automation/constants"; +import type { LabAutomationRunRecordV1 } from "../../src/lab/automation/types"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import type { NormalizedObservation } from "../../src/lab/conformance/types"; +import { readInstallationSalt } from "../../src/lab/subject/installation-salt"; import { resetCompatibilityVersionCacheForTests, setCompatibilityVersionOverrideForTests, -} from "../src/routing/compatibility/version"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/routing/compatibility/version"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoPath } from "../helpers/repo-root"; const HOMES: string[] = []; const COMPAT_VERSION = "9".repeat(64); @@ -172,7 +173,7 @@ describe("CL-08 final CodeRabbit regressions", () => { test("freshness lookup stays exact and bounded across large irrelevant history", () => { const home = tempHome(); buildFreshnessProjection(home); - const plannerSource = readFileSync(join(import.meta.dir, "../src/lab/automation/planner.ts"), "utf8"); + const plannerSource = readFileSync(repoPath("src/lab/automation/planner.ts"), "utf8"); expect(plannerSource).not.toContain("FRESHNESS_QUERY_PAGE_SIZE"); expect(plannerSource).toContain("queryLatestLabObservation"); expect(LAB_SQLITE_DDL).toContain("idx_observations_exact_identity"); diff --git a/tests/lab-automation-ingwannu-regressions.test.ts b/tests/lab/lab-automation-ingwannu-regressions.test.ts similarity index 87% rename from tests/lab-automation-ingwannu-regressions.test.ts rename to tests/lab/lab-automation-ingwannu-regressions.test.ts index a30f395a0a..d71c2d77f9 100644 --- a/tests/lab-automation-ingwannu-regressions.test.ts +++ b/tests/lab/lab-automation-ingwannu-regressions.test.ts @@ -2,26 +2,27 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdirSync, readFileSync} from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import type { OcxConfig } from "../src/types"; -import { defaultLabAutomationPolicyV1 } from "../src/lab/automation/policy"; -import * as persistence from "../src/lab/automation/persistence"; +import type { OcxConfig } from "../../src/types"; +import { defaultLabAutomationPolicyV1 } from "../../src/lab/automation/policy"; +import * as persistence from "../../src/lab/automation/persistence"; import { loadLabAutomationConfig, saveLabAutomationConfig, setLabAutomationConfigCommitFaultForTests, -} from "../src/lab/automation/config-persistence"; +} from "../../src/lab/automation/config-persistence"; import { isLabAutomationSchedulerRunning, resetLabAutomationSchedulerStateForTests, runLabAutomationTick, setLabAutomationDispatchDeps, startLabAutomationScheduler, -} from "../src/lab/automation/orchestrator"; +} from "../../src/lab/automation/orchestrator"; import { acquireServerResourceOwner, resetServerResourceOwnershipForTests, -} from "../src/lib/server-resource-ownership"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lib/server-resource-ownership"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoPath } from "../helpers/repo-root"; const HOMES: string[] = []; @@ -118,7 +119,7 @@ describe("CL-08 Ingwannu regressions", () => { test("CL-08 plan has no trailing whitespace", () => { const text = readFileSync( - join(import.meta.dir, "..", "devlog", "_fin", "260807_compatibility_lab", "008_cl08_automation.md"), + repoPath("devlog", "_fin", "260807_compatibility_lab", "008_cl08_automation.md"), "utf8", ); const offenders = text diff --git a/tests/lab-automation-management-http.test.ts b/tests/lab/lab-automation-management-http.test.ts similarity index 90% rename from tests/lab-automation-management-http.test.ts rename to tests/lab/lab-automation-management-http.test.ts index 78f8d619a7..ea2f08b257 100644 --- a/tests/lab-automation-management-http.test.ts +++ b/tests/lab/lab-automation-management-http.test.ts @@ -2,20 +2,20 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdirSync} from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import type { OcxConfig } from "../src/types"; -import { handleManagementAPI } from "../src/server/management-api"; -import { ManagementRequest } from "./helpers/management-auth"; +import type { OcxConfig } from "../../src/types"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { ManagementRequest } from "../helpers/management-auth"; import { defaultLabAutomationStateV1, saveLabAutomationState, -} from "../src/lab/automation/persistence"; +} from "../../src/lab/automation/persistence"; import { requestLabAutomationShutdown, resetLabAutomationSchedulerStateForTests, stopLabAutomationScheduler, -} from "../src/lab/automation/orchestrator"; -import type { LabAutomationRunRecordV1 } from "../src/lab/automation/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/automation/orchestrator"; +import type { LabAutomationRunRecordV1 } from "../../src/lab/automation/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; diff --git a/tests/lab-automation-persisted-cap-regression.test.ts b/tests/lab/lab-automation-persisted-cap-regression.test.ts similarity index 80% rename from tests/lab-automation-persisted-cap-regression.test.ts rename to tests/lab/lab-automation-persisted-cap-regression.test.ts index 3c1ead2034..c8200a86a1 100644 --- a/tests/lab-automation-persisted-cap-regression.test.ts +++ b/tests/lab/lab-automation-persisted-cap-regression.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { LAB_AUTOMATION_HARD_MAX } from "../src/lab/automation/constants"; -import { defaultLabAutomationStateV1 } from "../src/lab/automation/persistence"; -import { trimTerminalRuns } from "../src/lab/automation/queue"; -import type { LabAutomationRunRecordV1 } from "../src/lab/automation/types"; +import { LAB_AUTOMATION_HARD_MAX } from "../../src/lab/automation/constants"; +import { defaultLabAutomationStateV1 } from "../../src/lab/automation/persistence"; +import { trimTerminalRuns } from "../../src/lab/automation/queue"; +import type { LabAutomationRunRecordV1 } from "../../src/lab/automation/types"; function cancelledScheduledRun(index: number, now: number): LabAutomationRunRecordV1 { return { diff --git a/tests/lab-automation-review-regressions.test.ts b/tests/lab/lab-automation-review-regressions.test.ts similarity index 93% rename from tests/lab-automation-review-regressions.test.ts rename to tests/lab/lab-automation-review-regressions.test.ts index 0f8d41683b..7042835927 100644 --- a/tests/lab-automation-review-regressions.test.ts +++ b/tests/lab/lab-automation-review-regressions.test.ts @@ -2,18 +2,18 @@ import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync} from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import type { OcxConfig } from "../src/types"; -import { defaultLabAutomationPolicyV1, normalizeLabAutomationPolicyV1 } from "../src/lab/automation/policy"; +import type { OcxConfig } from "../../src/types"; +import { defaultLabAutomationPolicyV1, normalizeLabAutomationPolicyV1 } from "../../src/lab/automation/policy"; import { defaultLabAutomationStateV1, loadLabAutomationState, saveLabAutomationPolicy, saveLabAutomationRoutes, saveLabAutomationState, -} from "../src/lab/automation/persistence"; -import { planLabAutomationRuns, planManualLabRun } from "../src/lab/automation/planner"; -import { enqueuePlannedRuns } from "../src/lab/automation/queue"; -import { rollBudgetWindow, runBudgetRemaining } from "../src/lab/automation/budgets"; +} from "../../src/lab/automation/persistence"; +import { planLabAutomationRuns, planManualLabRun } from "../../src/lab/automation/planner"; +import { enqueuePlannedRuns } from "../../src/lab/automation/queue"; +import { rollBudgetWindow, runBudgetRemaining } from "../../src/lab/automation/budgets"; import { enqueueManualLabRun, requestLabAutomationShutdown, @@ -21,23 +21,23 @@ import { runLabAutomationTick, setLabAutomationDispatchDeps, stopLabAutomationScheduler, -} from "../src/lab/automation/orchestrator"; -import { dispatchLabAutomationRun } from "../src/lab/automation/dispatch"; +} from "../../src/lab/automation/orchestrator"; +import { dispatchLabAutomationRun } from "../../src/lab/automation/dispatch"; import type { LabAutomationRunRecordV1, LabAutomationStateV1, PlannedLabRunV1, -} from "../src/lab/automation/types"; -import { LabAutomationError } from "../src/lab/automation/types"; -import { LAB_AUTOMATION_HARD_MAX } from "../src/lab/automation/constants"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import { readInstallationSalt } from "../src/lab/subject/installation-salt"; -import type { NormalizedObservation } from "../src/lab/conformance/types"; +} from "../../src/lab/automation/types"; +import { LabAutomationError } from "../../src/lab/automation/types"; +import { LAB_AUTOMATION_HARD_MAX } from "../../src/lab/automation/constants"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import { readInstallationSalt } from "../../src/lab/subject/installation-salt"; +import type { NormalizedObservation } from "../../src/lab/conformance/types"; import { resetCompatibilityVersionCacheForTests, setCompatibilityVersionOverrideForTests, -} from "../src/routing/compatibility/version"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/routing/compatibility/version"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const COMPAT_VERSION = "e".repeat(64); const HOMES: string[] = []; diff --git a/tests/lab-automation.test.ts b/tests/lab/lab-automation.test.ts similarity index 93% rename from tests/lab-automation.test.ts rename to tests/lab/lab-automation.test.ts index 4dc89e59ee..080ed834a3 100644 --- a/tests/lab-automation.test.ts +++ b/tests/lab/lab-automation.test.ts @@ -2,20 +2,20 @@ import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import { handleManagementAPI } from "../src/server/management-api"; -import { ManagementRequest } from "./helpers/management-auth"; -import type { OcxConfig } from "../src/types"; -import { defaultLabAutomationPolicyV1 } from "../src/lab/automation/policy"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { ManagementRequest } from "../helpers/management-auth"; +import type { OcxConfig } from "../../src/types"; +import { defaultLabAutomationPolicyV1 } from "../../src/lab/automation/policy"; import { loadLabAutomationPolicy, loadLabAutomationState, saveLabAutomationPolicy, saveLabAutomationRoutes, saveLabAutomationState, -} from "../src/lab/automation/persistence"; -import { planLabAutomationRuns, planManualLabRun } from "../src/lab/automation/planner"; -import { enqueuePlannedRuns, selectDispatchableRuns } from "../src/lab/automation/queue"; -import { recoverLabAutomationState } from "../src/lab/automation/recovery"; +} from "../../src/lab/automation/persistence"; +import { planLabAutomationRuns, planManualLabRun } from "../../src/lab/automation/planner"; +import { enqueuePlannedRuns, selectDispatchableRuns } from "../../src/lab/automation/queue"; +import { recoverLabAutomationState } from "../../src/lab/automation/recovery"; import { buildLabAutomationStatus, cancelLabAutomationRun, @@ -25,22 +25,22 @@ import { stopLabAutomationScheduler, requestLabAutomationShutdown, resetLabAutomationSchedulerStateForTests, -} from "../src/lab/automation/orchestrator"; -import { dispatchLabAutomationRun } from "../src/lab/automation/dispatch"; -import { LAB_AUTOMATION_HARD_MAX } from "../src/lab/automation/constants"; -import { LabAutomationError } from "../src/lab/automation/types"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import { isTrustedLabRouteExecutor } from "../src/lib/lab-live-execution-authority"; -import { createProductionLabRouteExecutor } from "../src/lib/lab-live-route-production"; -import { readInstallationSalt } from "../src/lab/subject/installation-salt"; -import { loadLiveCaseAuthority } from "../src/lab/live/manifest"; -import { TransportError } from "../src/lab/live/transport"; -import type { NormalizedObservation } from "../src/lab/conformance/types"; +} from "../../src/lab/automation/orchestrator"; +import { dispatchLabAutomationRun } from "../../src/lab/automation/dispatch"; +import { LAB_AUTOMATION_HARD_MAX } from "../../src/lab/automation/constants"; +import { LabAutomationError } from "../../src/lab/automation/types"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import { isTrustedLabRouteExecutor } from "../../src/lib/lab-live-execution-authority"; +import { createProductionLabRouteExecutor } from "../../src/lib/lab-live-route-production"; +import { readInstallationSalt } from "../../src/lab/subject/installation-salt"; +import { loadLiveCaseAuthority } from "../../src/lab/live/manifest"; +import { TransportError } from "../../src/lab/live/transport"; +import type { NormalizedObservation } from "../../src/lab/conformance/types"; import { resetCompatibilityVersionCacheForTests, setCompatibilityVersionOverrideForTests, -} from "../src/routing/compatibility/version"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/routing/compatibility/version"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const COMPAT_VERSION = "f".repeat(64); const HOMES: string[] = []; diff --git a/tests/lab-community-evidence.test.ts b/tests/lab/lab-community-evidence.test.ts similarity index 98% rename from tests/lab-community-evidence.test.ts rename to tests/lab/lab-community-evidence.test.ts index 286e60664d..e2c9ca3cdd 100644 --- a/tests/lab-community-evidence.test.ts +++ b/tests/lab/lab-community-evidence.test.ts @@ -12,8 +12,8 @@ import { subjectIdForSubject, type ObservationEvent, type ProtocolSubjectV1, -} from "../src/lab"; -import { labCommunityDir } from "../src/lab/paths"; +} from "../../src/lab"; +import { labCommunityDir } from "../../src/lab/paths"; import { buildPublicEvidenceBundle, createPublicEvidenceRevocation, @@ -27,8 +27,8 @@ import { signPublicPublisherDigest, verifyPublicEvidenceRevocation, writePublicEvidenceBundle, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-community-filename-contract.test.ts b/tests/lab/lab-community-filename-contract.test.ts similarity index 94% rename from tests/lab-community-filename-contract.test.ts rename to tests/lab/lab-community-filename-contract.test.ts index d8a417d4af..7b0a30f34c 100644 --- a/tests/lab-community-filename-contract.test.ts +++ b/tests/lab/lab-community-filename-contract.test.ts @@ -7,11 +7,11 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { basename, join } from "node:path"; -import { labPublicOriginDir } from "../src/lab/paths"; +import { labPublicOriginDir } from "../../src/lab/paths"; import { communityBundleFileName, communityRevocationFileName, -} from "../src/lab/public/community-files"; +} from "../../src/lab/public/community-files"; import { createPublicEvidenceRevocation, importCommunityEvidenceBundle, @@ -21,8 +21,8 @@ import { recordLocalPublicOrigin, signPublicEvidenceBundle, type PublicEvidenceRecordV1, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-community-mutation-lock.test.ts b/tests/lab/lab-community-mutation-lock.test.ts similarity index 92% rename from tests/lab-community-mutation-lock.test.ts rename to tests/lab/lab-community-mutation-lock.test.ts index 49952aa5ab..ced17392a0 100644 --- a/tests/lab-community-mutation-lock.test.ts +++ b/tests/lab/lab-community-mutation-lock.test.ts @@ -2,14 +2,14 @@ import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync, mkdtempSync, utimesSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { ensureLabDirs, labCommunityDir } from "../src/lab/paths"; -import { listCommunityEvidence } from "../src/lab/public/community"; +import { ensureLabDirs, labCommunityDir } from "../../src/lab/paths"; +import { listCommunityEvidence } from "../../src/lab/public/community"; import { publicEvidenceMutationLockIsReclaimableForTests, publicEvidenceTryReclaimMutationLockForTests, -} from "../src/lab/public/mutation-lock"; -import { PublicEvidenceValidationError } from "../src/lab/public/validate"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public/mutation-lock"; +import { PublicEvidenceValidationError } from "../../src/lab/public/validate"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/lab-community-publisher-continuity.test.ts b/tests/lab/lab-community-publisher-continuity.test.ts similarity index 97% rename from tests/lab-community-publisher-continuity.test.ts rename to tests/lab/lab-community-publisher-continuity.test.ts index 0c4fdb7f63..caa86dc8f4 100644 --- a/tests/lab-community-publisher-continuity.test.ts +++ b/tests/lab/lab-community-publisher-continuity.test.ts @@ -9,7 +9,7 @@ import { subjectIdForSubject, type ObservationEvent, type ProtocolSubjectV1, -} from "../src/lab"; +} from "../../src/lab"; import { createPublicEvidenceRevocation, importCommunityEvidenceBundle, @@ -17,8 +17,8 @@ import { listCommunityEvidence, projectPublicEvidence, signPublicEvidenceBundle, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-conformance-harness.test.ts b/tests/lab/lab-conformance-harness.test.ts similarity index 92% rename from tests/lab-conformance-harness.test.ts rename to tests/lab/lab-conformance-harness.test.ts index a8208da98d..d248e56414 100644 --- a/tests/lab-conformance-harness.test.ts +++ b/tests/lab/lab-conformance-harness.test.ts @@ -1,25 +1,25 @@ import { describe, expect, test } from "bun:test"; -import { evaluateAssertion } from "../src/lab/conformance/assertion"; -import { fixtureDigest, scenarioManifestDigest } from "../src/lab/conformance/digest"; -import { jcsEqual, jcsStringify } from "../src/lab/conformance/jcs"; -import { resolveJsonPointer } from "../src/lab/conformance/json-pointer"; -import { runScenario } from "../src/lab/conformance/executor"; +import { evaluateAssertion } from "../../src/lab/conformance/assertion"; +import { fixtureDigest, scenarioManifestDigest } from "../../src/lab/conformance/digest"; +import { jcsEqual, jcsStringify } from "../../src/lab/conformance/jcs"; +import { resolveJsonPointer } from "../../src/lab/conformance/json-pointer"; +import { runScenario } from "../../src/lab/conformance/executor"; import { discoverScenarios, expandScenario, loadCaseAuthority, validateExpandedFixtureRef, validateFixtureDigests, -} from "../src/lab/conformance/manifest"; -import { buildNegativeControls, NEGATIVE_CONTROL_FIXTURES } from "../src/lab/conformance/negative-controls"; -import { emptyObservation } from "../src/lab/conformance/observation"; +} from "../../src/lab/conformance/manifest"; +import { buildNegativeControls, NEGATIVE_CONTROL_FIXTURES } from "../../src/lab/conformance/negative-controls"; +import { emptyObservation } from "../../src/lab/conformance/observation"; import { listScenarioIds, runConformanceSuite, runNegativeControls, -} from "../src/lab/conformance/runner"; -import { CL01_SUITES, SYNTHETIC_MARKER } from "../src/lab/conformance/types"; -import { normalizeSseBytes } from "../src/lab/conformance/sse-normalize"; +} from "../../src/lab/conformance/runner"; +import { CL01_SUITES, SYNTHETIC_MARKER } from "../../src/lab/conformance/types"; +import { normalizeSseBytes } from "../../src/lab/conformance/sse-normalize"; describe("CL-01 conformance harness infrastructure", () => { test("loads the frozen 35-case authority and validates fixture digests", () => { diff --git a/tests/lab-conformance-runner-failures.test.ts b/tests/lab/lab-conformance-runner-failures.test.ts similarity index 89% rename from tests/lab-conformance-runner-failures.test.ts rename to tests/lab/lab-conformance-runner-failures.test.ts index 47fc707bd9..5821f2ed53 100644 --- a/tests/lab-conformance-runner-failures.test.ts +++ b/tests/lab/lab-conformance-runner-failures.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { runScenario } from "../src/lab/conformance/executor"; -import { NEGATIVE_CONTROL_FIXTURES } from "../src/lab/conformance/negative-controls"; -import { runNegativeControls } from "../src/lab/conformance/runner"; +import { runScenario } from "../../src/lab/conformance/executor"; +import { NEGATIVE_CONTROL_FIXTURES } from "../../src/lab/conformance/negative-controls"; +import { runNegativeControls } from "../../src/lab/conformance/runner"; function unexpectedNegativeControlResults( results: Awaited>["results"], diff --git a/tests/lab-evidence-ledger.test.ts b/tests/lab/lab-evidence-ledger.test.ts similarity index 98% rename from tests/lab-evidence-ledger.test.ts rename to tests/lab/lab-evidence-ledger.test.ts index 1ac2e9d498..c7ecdeff83 100644 --- a/tests/lab-evidence-ledger.test.ts +++ b/tests/lab/lab-evidence-ledger.test.ts @@ -30,19 +30,19 @@ import { LAB_PRODUCER, LAB_PROJECTION_SPEC_VERSION, behaviorFingerprintForCase, -} from "../src/lab"; -import { appendLabEventIfAbsent } from "../src/lab/ledger/store"; -import { ArtifactFsError, closeTrustedArtifactDir, putArtifactBytes, putNamedDigestBytes, readArtifactBytes, digestFileName } from "../src/lab/artifacts/secure-fs"; -import { expandSuiteManifest } from "../src/lab/conformance/suite-manifest"; -import { evaluateAllApplicableRequiredPassV1 } from "../src/lab/projection/verification"; -import { discoverScenarios, expandScenario, loadCaseAuthority } from "../src/lab/conformance/manifest"; -import { artifactBytesDigest, scenarioManifestDigest } from "../src/lab/digest"; -import type { CaseRecord } from "../src/lab/conformance/types"; -import { runScenario, resolveProtocolExecutionContext } from "../src/lab/conformance/executor"; -import { LabValidationError } from "../src/lab/events/validate"; -import { enforceEventStructureLimits } from "../src/lab/events/limits"; -import type { ClaimSnapshotEvent, ObservationEvent, ProtocolSubjectV1 } from "../src/lab/events/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab"; +import { appendLabEventIfAbsent } from "../../src/lab/ledger/store"; +import { ArtifactFsError, closeTrustedArtifactDir, putArtifactBytes, putNamedDigestBytes, readArtifactBytes, digestFileName } from "../../src/lab/artifacts/secure-fs"; +import { expandSuiteManifest } from "../../src/lab/conformance/suite-manifest"; +import { evaluateAllApplicableRequiredPassV1 } from "../../src/lab/projection/verification"; +import { discoverScenarios, expandScenario, loadCaseAuthority } from "../../src/lab/conformance/manifest"; +import { artifactBytesDigest, scenarioManifestDigest } from "../../src/lab/digest"; +import type { CaseRecord } from "../../src/lab/conformance/types"; +import { runScenario, resolveProtocolExecutionContext } from "../../src/lab/conformance/executor"; +import { LabValidationError } from "../../src/lab/events/validate"; +import { enforceEventStructureLimits } from "../../src/lab/events/limits"; +import type { ClaimSnapshotEvent, ObservationEvent, ProtocolSubjectV1 } from "../../src/lab/events/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; diff --git a/tests/lab-evidence-sanitization.test.ts b/tests/lab/lab-evidence-sanitization.test.ts similarity index 97% rename from tests/lab-evidence-sanitization.test.ts rename to tests/lab/lab-evidence-sanitization.test.ts index 3cc3ba4c9f..595b57e175 100644 --- a/tests/lab-evidence-sanitization.test.ts +++ b/tests/lab/lab-evidence-sanitization.test.ts @@ -16,16 +16,16 @@ import { observationFromConformanceResult, observationFromLiveResult, runLiveScenario, -} from "../src/lab"; -import { discoverScenarios, loadCaseAuthority } from "../src/lab/conformance/manifest"; -import { runScenario } from "../src/lab/conformance/executor"; -import { sanitizeDiagnostic, truncateUtf8 } from "../src/lab/artifacts/sanitize"; -import { createArtifactStore } from "../src/lab/artifacts/store"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import { ensureLabDirs } from "../src/lab/paths"; -import type { LabBehaviorValues, LabRouteContext } from "../src/lab/live/types"; -import type { NormalizedObservation } from "../src/lab/conformance/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab"; +import { discoverScenarios, loadCaseAuthority } from "../../src/lab/conformance/manifest"; +import { runScenario } from "../../src/lab/conformance/executor"; +import { sanitizeDiagnostic, truncateUtf8 } from "../../src/lab/artifacts/sanitize"; +import { createArtifactStore } from "../../src/lab/artifacts/store"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import { ensureLabDirs } from "../../src/lab/paths"; +import type { LabBehaviorValues, LabRouteContext } from "../../src/lab/live/types"; +import type { NormalizedObservation } from "../../src/lab/conformance/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; function tempHome(): string { diff --git a/tests/lab-fabric-outcome-validation.test.ts b/tests/lab/lab-fabric-outcome-validation.test.ts similarity index 97% rename from tests/lab-fabric-outcome-validation.test.ts rename to tests/lab/lab-fabric-outcome-validation.test.ts index d5d0ee0bb7..92685543cb 100644 --- a/tests/lab-fabric-outcome-validation.test.ts +++ b/tests/lab/lab-fabric-outcome-validation.test.ts @@ -7,8 +7,8 @@ import { subjectIdForSubject, type FabricTaskOutcomeV1, type RouteSubjectV1, -} from "../src/lab"; -import { FabricTaskError } from "../src/lab/fabric/types"; +} from "../../src/lab"; +import { FabricTaskError } from "../../src/lab/fabric/types"; function routeSubject(): RouteSubjectV1 { return { diff --git a/tests/lab-fabric-persistence-boundary.test.ts b/tests/lab/lab-fabric-persistence-boundary.test.ts similarity index 82% rename from tests/lab-fabric-persistence-boundary.test.ts rename to tests/lab/lab-fabric-persistence-boundary.test.ts index 572c7ed6cf..8257ea58b1 100644 --- a/tests/lab-fabric-persistence-boundary.test.ts +++ b/tests/lab/lab-fabric-persistence-boundary.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; describe("CL-07 fabric persistence export boundary", () => { test("authority-free persistence helper is module-private", async () => { - const observeExports = await import("../src/lab/fabric/observe"); + const observeExports = await import("../../src/lab/fabric/observe"); expect("persistFabricOutcome" in observeExports).toBe(false); expect(typeof observeExports.persistFabricRunResult).toBe("function"); diff --git a/tests/lab-fabric-task.test.ts b/tests/lab/lab-fabric-task.test.ts similarity index 97% rename from tests/lab-fabric-task.test.ts rename to tests/lab/lab-fabric-task.test.ts index e82a494913..5bc000ff3a 100644 --- a/tests/lab-fabric-task.test.ts +++ b/tests/lab/lab-fabric-task.test.ts @@ -44,31 +44,32 @@ import { verifierManifestDigest, verifierManifestObject, type RouteSubjectV1, -} from "../src/lab"; -import { FabricTaskError } from "../src/lab/fabric/types"; -import { writeScratchFileUtf8, readScratchFileUtf8 } from "../src/lab/fabric/scratch"; -import { routingProfileIssues } from "../src/routing/profile"; -import { buildInvalidationIndex } from "../src/lab/ledger/invalidation"; -import { createArtifactStore } from "../src/lab/artifacts/store"; -import { ensureLabDirs, ensureRestrictedDir } from "../src/lab/paths"; -import { verifyExactTreeDiffV1 } from "../src/lab/fabric/verifier"; -import { parseSyntheticPatchV1 } from "../src/lab/fabric/patch"; -import { FABRIC_LIMITS } from "../src/lab/fabric/constants"; -import { minimalFabricChildEnv, setFabricProducerIsolationLimitsForTests } from "../src/lab/fabric/producer-isolate"; -import { taskSubjectApplicableToRequirements } from "../src/lab/projection/verification"; -import { createHostIssuedFabricPatchExecutor } from "../src/lib/fabric-task-host"; -import type { TrustedFabricPatchExecutor } from "../src/lab/fabric/types"; -import { isolationBudgetMs, watchdogMs } from "./helpers/ci-watchdog"; +} from "../../src/lab"; +import { FabricTaskError } from "../../src/lab/fabric/types"; +import { writeScratchFileUtf8, readScratchFileUtf8 } from "../../src/lab/fabric/scratch"; +import { routingProfileIssues } from "../../src/routing/profile"; +import { buildInvalidationIndex } from "../../src/lab/ledger/invalidation"; +import { createArtifactStore } from "../../src/lab/artifacts/store"; +import { ensureLabDirs, ensureRestrictedDir } from "../../src/lab/paths"; +import { verifyExactTreeDiffV1 } from "../../src/lab/fabric/verifier"; +import { parseSyntheticPatchV1 } from "../../src/lab/fabric/patch"; +import { FABRIC_LIMITS } from "../../src/lab/fabric/constants"; +import { minimalFabricChildEnv, setFabricProducerIsolationLimitsForTests } from "../../src/lab/fabric/producer-isolate"; +import { taskSubjectApplicableToRequirements } from "../../src/lab/projection/verification"; +import { createHostIssuedFabricPatchExecutor } from "../../src/lib/fabric-task-host"; +import type { TrustedFabricPatchExecutor } from "../../src/lab/fabric/types"; +import { isolationBudgetMs, watchdogMs } from "../helpers/ci-watchdog"; import { fabricCorrectPatchExecutor, fabricMockRoute, fabricOversizedPatchExecutor, fabricRouteBoundPatchExecutor, runTrustedFabricTask, -} from "./helpers/fabric-task-test"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../helpers/fabric-task-test"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoRoot } from "../helpers/repo-root"; -const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); +const REPO_ROOT = repoRoot(); const CHILD_REAP_GRACE_MS = 2_000; async function awaitChildExitWithin(child: Bun.Subprocess, timeoutMs: number): Promise { @@ -492,7 +493,7 @@ export async function execute() { } catch (error) { expect((error as FabricTaskError).code).toBe("malformed_producer_outcome"); } - const labExports = await import("../src/lab"); + const labExports = await import("../../src/lab"); expect("persistFabricOutcome" in labExports).toBe(false); }); diff --git a/tests/lab-installation-salt-cache.test.ts b/tests/lab/lab-installation-salt-cache.test.ts similarity index 90% rename from tests/lab-installation-salt-cache.test.ts rename to tests/lab/lab-installation-salt-cache.test.ts index 9b98a5809b..614af471f3 100644 --- a/tests/lab-installation-salt-cache.test.ts +++ b/tests/lab/lab-installation-salt-cache.test.ts @@ -3,13 +3,13 @@ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { labInstallationSaltPath } from "../src/lab/paths"; +import { labInstallationSaltPath } from "../../src/lab/paths"; import { INSTALLATION_SALT_CACHE_MAX_ENTRIES, installationSaltCache, readExistingInstallationSalt, -} from "../src/lab/subject/installation-salt"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/subject/installation-salt"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/lab-ledger-mutation-lock.test.ts b/tests/lab/lab-ledger-mutation-lock.test.ts similarity index 93% rename from tests/lab-ledger-mutation-lock.test.ts rename to tests/lab/lab-ledger-mutation-lock.test.ts index 5b56200ff3..ec52c79676 100644 --- a/tests/lab-ledger-mutation-lock.test.ts +++ b/tests/lab/lab-ledger-mutation-lock.test.ts @@ -14,13 +14,14 @@ import { purgeSensitiveEvidence, replayLabLedger, withLedgerMutation, -} from "../src/lab"; -import type { ArtifactStore } from "../src/lab/artifacts/store"; -import { discoverScenarios, loadCaseAuthority } from "../src/lab/conformance/manifest"; -import { resolveProtocolExecutionContext } from "../src/lab/conformance/executor"; -import type { CaseRecord } from "../src/lab/conformance/types"; -import type { InvalidationEvent } from "../src/lab/events/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab"; +import type { ArtifactStore } from "../../src/lab/artifacts/store"; +import { discoverScenarios, loadCaseAuthority } from "../../src/lab/conformance/manifest"; +import { resolveProtocolExecutionContext } from "../../src/lab/conformance/executor"; +import type { CaseRecord } from "../../src/lab/conformance/types"; +import type { InvalidationEvent } from "../../src/lab/events/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { repoRoot } from "../helpers/repo-root"; const HOMES: string[] = []; @@ -122,7 +123,7 @@ function spawnLiveLock( unlinkSync(${JSON.stringify(lockPath)}); `; return Bun.spawn([process.execPath, "-e", childSource], { - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), env: { ...process.env }, stdin: "ignore", stdout: "pipe", @@ -165,7 +166,7 @@ test("appendLabEventIfAbsent immediately recovers a lock owned by an exited proc writeFileSync(${JSON.stringify(readyPath)}, "ready"); `; const child = Bun.spawn([process.execPath, "-e", childSource], { - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), env: { ...process.env }, stdin: "ignore", stdout: "pipe", diff --git a/tests/lab-live-pinned-timeouts.test.ts b/tests/lab/lab-live-pinned-timeouts.test.ts similarity index 96% rename from tests/lab-live-pinned-timeouts.test.ts rename to tests/lab/lab-live-pinned-timeouts.test.ts index 4e9a37bfb0..91ad154297 100644 --- a/tests/lab-live-pinned-timeouts.test.ts +++ b/tests/lab/lab-live-pinned-timeouts.test.ts @@ -1,7 +1,7 @@ import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http"; import { afterEach, describe, expect, test } from "bun:test"; -import { createLabAuthorizedPinnedSender } from "../src/lib/lab-live-pinned-sender"; -import type { LabCredentialLeaseV1, LabDestinationV1, LiveRunConfig } from "../src/lab/live/types"; +import { createLabAuthorizedPinnedSender } from "../../src/lib/lab-live-pinned-sender"; +import type { LabCredentialLeaseV1, LabDestinationV1, LiveRunConfig } from "../../src/lab/live/types"; const SERVERS: Server[] = []; diff --git a/tests/lab-live-probe.test.ts b/tests/lab/lab-live-probe.test.ts similarity index 96% rename from tests/lab-live-probe.test.ts rename to tests/lab/lab-live-probe.test.ts index af43771313..4aec161522 100644 --- a/tests/lab-live-probe.test.ts +++ b/tests/lab/lab-live-probe.test.ts @@ -8,16 +8,16 @@ import { loadLiveCaseAuthority, observationFromLiveResult, persistLiveResult, rebuildLabProjection, registerMcpStubTool, routeSubjectApplicableToRequirements, runLiveScenario, runLiveSuite, scenarioManifestDigest, subjectIdForSubject, -} from "../src/lab"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import { replayLabLedger } from "../src/lab/ledger/store"; -import { clearMcpStub } from "../src/lab/live/mcp-loopback"; -import { TransportError } from "../src/lab/live/transport"; -import { expandLiveSuiteManifest } from "../src/lab/live/suite-manifest"; -import type { LabBehaviorValues, LabRouteContext, LiveScenarioRunResult } from "../src/lab/live/types"; -import type { ProtocolSubjectV1, RouteSubjectV1 } from "../src/lab/events/types"; -import type { NormalizedObservation } from "../src/lab/conformance/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import { replayLabLedger } from "../../src/lab/ledger/store"; +import { clearMcpStub } from "../../src/lab/live/mcp-loopback"; +import { TransportError } from "../../src/lab/live/transport"; +import { expandLiveSuiteManifest } from "../../src/lab/live/suite-manifest"; +import type { LabBehaviorValues, LabRouteContext, LiveScenarioRunResult } from "../../src/lab/live/types"; +import type { ProtocolSubjectV1, RouteSubjectV1 } from "../../src/lab/events/types"; +import type { NormalizedObservation } from "../../src/lab/conformance/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; function tempHome(): string { const dir = join(tmpdir(), `ocx-lab-probe-${process.pid}-${Math.random().toString(16).slice(2)}`); mkdirSync(dir, { recursive: true, mode: 0o700 }); HOMES.push(dir); return dir; } diff --git a/tests/lab-live-receipt-integrity.test.ts b/tests/lab/lab-live-receipt-integrity.test.ts similarity index 90% rename from tests/lab-live-receipt-integrity.test.ts rename to tests/lab/lab-live-receipt-integrity.test.ts index f7b14da960..285e6dadca 100644 --- a/tests/lab-live-receipt-integrity.test.ts +++ b/tests/lab/lab-live-receipt-integrity.test.ts @@ -2,11 +2,11 @@ import { expect, test } from "bun:test"; import { mkdirSync} from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import { loadLiveCaseAuthority, observationFromLiveResult, runLiveScenario } from "../src/lab"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import type { NormalizedObservation } from "../src/lab/conformance/types"; -import type { LabBehaviorValues, LabRouteContext } from "../src/lab/live/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { loadLiveCaseAuthority, observationFromLiveResult, runLiveScenario } from "../../src/lab"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import type { NormalizedObservation } from "../../src/lab/conformance/types"; +import type { LabBehaviorValues, LabRouteContext } from "../../src/lab/live/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function behavior(): LabBehaviorValues { return { diff --git a/tests/lab-live-review-regressions.test.ts b/tests/lab/lab-live-review-regressions.test.ts similarity index 98% rename from tests/lab-live-review-regressions.test.ts rename to tests/lab/lab-live-review-regressions.test.ts index 40778bff41..5215e8bd75 100644 --- a/tests/lab-live-review-regressions.test.ts +++ b/tests/lab/lab-live-review-regressions.test.ts @@ -13,14 +13,14 @@ import { loadLiveCaseAuthority, runLiveScenario, runLiveSuite, -} from "../src/lab"; +} from "../../src/lab"; import type { LabBehaviorValues, LabRouteContext, LabTransportResponse, LiveRunConfig, -} from "../src/lab/live/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/live/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; function tempHome(): string { diff --git a/tests/lab-live-sandbox.test.ts b/tests/lab/lab-live-sandbox.test.ts similarity index 96% rename from tests/lab-live-sandbox.test.ts rename to tests/lab/lab-live-sandbox.test.ts index f8980ac8c0..c4efc0185a 100644 --- a/tests/lab-live-sandbox.test.ts +++ b/tests/lab/lab-live-sandbox.test.ts @@ -8,12 +8,12 @@ import { createCredentialLease, createLabDestination, createMockTransport, createSandboxResourceState, enforceSandboxLimits, freezeRouteSubject, LabCredentialError, LabDestinationError, LabSandboxError, prepareLiveSandbox, readInstallationSalt, rejectProxyEnvironment, TransportError, -} from "../src/lab"; -import * as executionAuthority from "../src/lib/lab-live-execution-authority"; -import { isTrustedLabRouteExecutor } from "../src/lib/lab-live-execution-authority"; -import { createHostIssuedLabRouteExecutor } from "../src/lib/lab-live-host"; -import { REQUIRED_LAB_SANDBOX_BOUNDARIES, type LabBehaviorValues, type LabRouteContext, type TrustedLabRouteExecutor } from "../src/lab/live/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab"; +import * as executionAuthority from "../../src/lib/lab-live-execution-authority"; +import { isTrustedLabRouteExecutor } from "../../src/lib/lab-live-execution-authority"; +import { createHostIssuedLabRouteExecutor } from "../../src/lib/lab-live-host"; +import { REQUIRED_LAB_SANDBOX_BOUNDARIES, type LabBehaviorValues, type LabRouteContext, type TrustedLabRouteExecutor } from "../../src/lab/live/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; function tempHome(): string { const dir = join(tmpdir(), `ocx-lab-live-${process.pid}-${Math.random().toString(16).slice(2)}`); mkdirSync(dir, { recursive: true, mode: 0o700 }); HOMES.push(dir); return dir; } @@ -91,7 +91,7 @@ describe("CL-03 live sandbox security seams", () => { test("concurrent first-run salt initialization converges on one completed salt", async () => { const home = tempHome(); - const saltModule = new URL("../src/lab/subject/installation-salt.ts", import.meta.url).href; + const saltModule = new URL("../../src/lab/subject/installation-salt.ts", import.meta.url).href; const script = `import { readInstallationSalt } from ${JSON.stringify(saltModule)};\nconst salt = readInstallationSalt(${JSON.stringify(home)});\nprocess.stdout.write(Buffer.from(salt).toString("hex"));`; const [first, second] = await Promise.all([runSaltInitializer(script), runSaltInitializer(script)]); expect(first).toHaveLength(64); expect(second).toBe(first); diff --git a/tests/lab-passive-production-evidence.test.ts b/tests/lab/lab-passive-production-evidence.test.ts similarity index 98% rename from tests/lab-passive-production-evidence.test.ts rename to tests/lab/lab-passive-production-evidence.test.ts index 564ca95aad..fd8a18b7d1 100644 --- a/tests/lab-passive-production-evidence.test.ts +++ b/tests/lab/lab-passive-production-evidence.test.ts @@ -5,15 +5,15 @@ import { describe, expect, test } from "bun:test"; import { normalizeUsageEntryForTest, type PersistedUsageEntry, -} from "../src/usage/log"; -import { inboundProtocolForWire } from "../src/routing/compatibility/subject"; +} from "../../src/usage/log"; +import { inboundProtocolForWire } from "../../src/routing/compatibility/subject"; import { PASSIVE_PRODUCTION_MAX_LIMIT, PASSIVE_PRODUCTION_MAX_SCAN_ROWS, derivePassiveProductionSignals, queryPassiveProductionSignals, -} from "../src/lab/query/passive-production"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/query/passive-production"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function usageEntryWithAttempt(attempt: Record): PersistedUsageEntry { return { diff --git a/tests/lab-passive-production-surfaces.test.ts b/tests/lab/lab-passive-production-surfaces.test.ts similarity index 91% rename from tests/lab-passive-production-surfaces.test.ts rename to tests/lab/lab-passive-production-surfaces.test.ts index a9019e5436..d7ab6c1687 100644 --- a/tests/lab-passive-production-surfaces.test.ts +++ b/tests/lab/lab-passive-production-surfaces.test.ts @@ -2,15 +2,15 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdirSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleLabCommand } from "../src/cli/lab"; +import { handleLabCommand } from "../../src/cli/lab"; import { LAB_QUERY_MAX_PAGE_SIZE, PASSIVE_PRODUCTION_MAX_LIMIT, -} from "../src/lab/query"; -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"; +} from "../../src/lab/query"; +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 HOMES: string[] = []; const originalOpenCodexHome = process.env.OPENCODEX_HOME; diff --git a/tests/lab-paths-security.test.ts b/tests/lab/lab-paths-security.test.ts similarity index 93% rename from tests/lab-paths-security.test.ts rename to tests/lab/lab-paths-security.test.ts index 59ea1a5649..37b7248c58 100644 --- a/tests/lab-paths-security.test.ts +++ b/tests/lab/lab-paths-security.test.ts @@ -2,8 +2,8 @@ import { afterEach, expect, test } from "bun:test"; import { mkdirSync, mkdtempSync, realpathSync, symlinkSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { ensureRestrictedDir } from "../src/lab/paths"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { ensureRestrictedDir } from "../../src/lab/paths"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const ROOTS: string[] = []; diff --git a/tests/lab-post-merge-hardening.test.ts b/tests/lab/lab-post-merge-hardening.test.ts similarity index 96% rename from tests/lab-post-merge-hardening.test.ts rename to tests/lab/lab-post-merge-hardening.test.ts index 695b5526e1..0e8660a448 100644 --- a/tests/lab-post-merge-hardening.test.ts +++ b/tests/lab/lab-post-merge-hardening.test.ts @@ -12,18 +12,18 @@ import { validateLabEvent, LAB_EVENT_SCHEMA_VERSION, LAB_PRODUCER, -} from "../src/lab"; -import { createArtifactStore } from "../src/lab/artifacts/store"; +} from "../../src/lab"; +import { createArtifactStore } from "../../src/lab/artifacts/store"; import { ArtifactFsError, closeTrustedArtifactDir, openTrustedArtifactDir, putNamedDigestBytes, -} from "../src/lab/artifacts/secure-fs"; -import { suiteManifestDigest } from "../src/lab/digest"; -import { enforceEventStructureLimits } from "../src/lab/events/limits"; -import type { ObservationEvent, ProtocolSubjectV1 } from "../src/lab/events/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/artifacts/secure-fs"; +import { suiteManifestDigest } from "../../src/lab/digest"; +import { enforceEventStructureLimits } from "../../src/lab/events/limits"; +import type { ObservationEvent, ProtocolSubjectV1 } from "../../src/lab/events/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; diff --git a/tests/lab-post-merge-projection.test.ts b/tests/lab/lab-post-merge-projection.test.ts similarity index 95% rename from tests/lab-post-merge-projection.test.ts rename to tests/lab/lab-post-merge-projection.test.ts index 68793e591c..ccce3f5f09 100644 --- a/tests/lab-post-merge-projection.test.ts +++ b/tests/lab/lab-post-merge-projection.test.ts @@ -5,10 +5,10 @@ import { subjectIdForSubject, LAB_EVENT_SCHEMA_VERSION, LAB_PRODUCER, -} from "../src/lab"; -import type { SuiteManifestV1 } from "../src/lab/conformance/suite-manifest"; -import type { ObservationEvent, ProtocolSubjectV1 } from "../src/lab/events/types"; -import { evaluateAllApplicableRequiredPassV1 } from "../src/lab/projection/verification"; +} from "../../src/lab"; +import type { SuiteManifestV1 } from "../../src/lab/conformance/suite-manifest"; +import type { ObservationEvent, ProtocolSubjectV1 } from "../../src/lab/events/types"; +import { evaluateAllApplicableRequiredPassV1 } from "../../src/lab/projection/verification"; function hash(value: string): string { return Bun.CryptoHasher.hash("sha256", value, "hex"); diff --git a/tests/lab-private-file-consumer-recovery.test.ts b/tests/lab/lab-private-file-consumer-recovery.test.ts similarity index 88% rename from tests/lab-private-file-consumer-recovery.test.ts rename to tests/lab/lab-private-file-consumer-recovery.test.ts index eec07e1f34..0ac65c298c 100644 --- a/tests/lab-private-file-consumer-recovery.test.ts +++ b/tests/lab/lab-private-file-consumer-recovery.test.ts @@ -2,12 +2,12 @@ import { afterEach, expect, test } from "bun:test"; import { mkdtempSync, readdirSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { publicEvidenceId } from "../src/lab/public/ids"; -import { isPrivateFileStageName, setPrivateFileCommitFaultForTests } from "../src/lab/public/private-file"; -import { getOrCreatePublicPublisher, signPublicEvidenceBundle } from "../src/lab/public/signature"; -import { storePublicEvidenceBundle } from "../src/lab/public/storage"; -import type { PublicEvidenceRecordV1 } from "../src/lab/public/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { publicEvidenceId } from "../../src/lab/public/ids"; +import { isPrivateFileStageName, setPrivateFileCommitFaultForTests } from "../../src/lab/public/private-file"; +import { getOrCreatePublicPublisher, signPublicEvidenceBundle } from "../../src/lab/public/signature"; +import { storePublicEvidenceBundle } from "../../src/lab/public/storage"; +import type { PublicEvidenceRecordV1 } from "../../src/lab/public/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-private-file-durability.test.ts b/tests/lab/lab-private-file-durability.test.ts similarity index 98% rename from tests/lab-private-file-durability.test.ts rename to tests/lab/lab-private-file-durability.test.ts index aac98497e5..8956451a29 100644 --- a/tests/lab-private-file-durability.test.ts +++ b/tests/lab/lab-private-file-durability.test.ts @@ -9,8 +9,8 @@ import { publishPrivateFileExclusive, setPrivateFileCleanupSyncFaultForTests, setPrivateFileCommitFaultForTests, -} from "../src/lab/public/private-file"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public/private-file"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/lab-public-api-json.test.ts b/tests/lab/lab-public-api-json.test.ts similarity index 82% rename from tests/lab-public-api-json.test.ts rename to tests/lab/lab-public-api-json.test.ts index 79d6c2a95e..30378d2e0e 100644 --- a/tests/lab-public-api-json.test.ts +++ b/tests/lab/lab-public-api-json.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 } from "./helpers/management-auth"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { OcxConfig } from "../../src/types"; +import { ManagementRequest } from "../helpers/management-auth"; const config = { port: 0, defaultProvider: "openai-apikey", providers: {} } as OcxConfig; diff --git a/tests/lab-public-artifact-policy.test.ts b/tests/lab/lab-public-artifact-policy.test.ts similarity index 84% rename from tests/lab-public-artifact-policy.test.ts rename to tests/lab/lab-public-artifact-policy.test.ts index 7595a27a6a..5cd53b83b1 100644 --- a/tests/lab-public-artifact-policy.test.ts +++ b/tests/lab/lab-public-artifact-policy.test.ts @@ -2,9 +2,9 @@ import { afterEach, expect, test } from "bun:test"; import { existsSync, mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { labPublicPublisherKeyPath } from "../src/lab"; -import { publicEvidenceId, signPublicEvidenceBundle } from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { labPublicPublisherKeyPath } from "../../src/lab"; +import { publicEvidenceId, signPublicEvidenceBundle } from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-public-coderabbit-regressions.test.ts b/tests/lab/lab-public-coderabbit-regressions.test.ts similarity index 96% rename from tests/lab-public-coderabbit-regressions.test.ts rename to tests/lab/lab-public-coderabbit-regressions.test.ts index 557ecded4c..7653de2d68 100644 --- a/tests/lab-public-coderabbit-regressions.test.ts +++ b/tests/lab/lab-public-coderabbit-regressions.test.ts @@ -9,14 +9,14 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleLabCommand } from "../src/cli/lab"; -import { purgeSensitiveEvidence } from "../src/lab/ledger/purge"; +import { handleLabCommand } from "../../src/cli/lab"; +import { purgeSensitiveEvidence } from "../../src/lab/ledger/purge"; import { ensureLabDirs, labCommunityDir, labPublicOriginDir, labPublicPublisherKeyPath, -} from "../src/lab/paths"; +} from "../../src/lab/paths"; import { createPublicEvidenceRevocation, importCommunityEvidenceBundle, @@ -26,12 +26,12 @@ import { signPublicEvidenceBundle, writePublicEvidenceBundle, type PublicEvidenceRecordV1, -} from "../src/lab/public"; +} from "../../src/lab/public"; import { publicEvidenceMutationLockIsReclaimableForTests, publicEvidenceTryReclaimMutationLockForTests, -} from "../src/lab/public/mutation-lock"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public/mutation-lock"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/lab-public-core-contract.test.ts b/tests/lab/lab-public-core-contract.test.ts similarity index 91% rename from tests/lab-public-core-contract.test.ts rename to tests/lab/lab-public-core-contract.test.ts index 4a76f08a3d..e8afcd0fb9 100644 --- a/tests/lab-public-core-contract.test.ts +++ b/tests/lab/lab-public-core-contract.test.ts @@ -2,21 +2,21 @@ import { afterEach, describe, expect, test } from "bun:test"; import { chmodSync, existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { labPublicPublisherKeyPath } from "../src/lab/paths"; -import { buildPublicEvidenceBundle } from "../src/lab/public/bundle"; -import { validatePublicEvidenceAuthorities } from "../src/lab/public/community-authority"; -import { publicEvidenceId } from "../src/lab/public/ids"; -import { validatePublicEvidencePrivacy } from "../src/lab/public/privacy"; -import { PUBLIC_ROUTE_REGISTRY_V1 } from "../src/lab/public/registry"; -import { signPublicEvidenceBundle, verifyPublicEvidenceBundle } from "../src/lab/public/signature"; -import { parseStrictPublicJson } from "../src/lab/public/strict-json"; -import { publicUtcDay } from "../src/lab/public/time"; +import { labPublicPublisherKeyPath } from "../../src/lab/paths"; +import { buildPublicEvidenceBundle } from "../../src/lab/public/bundle"; +import { validatePublicEvidenceAuthorities } from "../../src/lab/public/community-authority"; +import { publicEvidenceId } from "../../src/lab/public/ids"; +import { validatePublicEvidencePrivacy } from "../../src/lab/public/privacy"; +import { PUBLIC_ROUTE_REGISTRY_V1 } from "../../src/lab/public/registry"; +import { signPublicEvidenceBundle, verifyPublicEvidenceBundle } from "../../src/lab/public/signature"; +import { parseStrictPublicJson } from "../../src/lab/public/strict-json"; +import { publicUtcDay } from "../../src/lab/public/time"; import { PUBLIC_ROUTE_REGISTRY_SCHEMA_VERSION, type PublicEvidenceBundleUnsignedV1, -} from "../src/lab/public/types"; -import { validatePublicRouteRegistryManifest } from "../src/lab/public/validate"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public/types"; +import { validatePublicRouteRegistryManifest } from "../../src/lab/public/validate"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const FIXED_PRIVATE_KEY = [ `-----BEGIN PRIVATE ${"KEY"}-----`, diff --git a/tests/lab-public-deep-review-regressions.test.ts b/tests/lab/lab-public-deep-review-regressions.test.ts similarity index 97% rename from tests/lab-public-deep-review-regressions.test.ts rename to tests/lab/lab-public-deep-review-regressions.test.ts index 16a1dd5f54..a8514cfe34 100644 --- a/tests/lab-public-deep-review-regressions.test.ts +++ b/tests/lab/lab-public-deep-review-regressions.test.ts @@ -2,8 +2,8 @@ import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { jcsStringify } from "../src/lab/conformance/jcs"; -import { labCommunityDir, labPublicPublisherKeyPath } from "../src/lab/paths"; +import { jcsStringify } from "../../src/lab/conformance/jcs"; +import { labCommunityDir, labPublicPublisherKeyPath } from "../../src/lab/paths"; import { buildPublicEvidenceBundle, createPublicEvidenceRevocation, @@ -20,8 +20,8 @@ import { type PublicArtifactV1, type PublicEvidenceBundleV1, type PublicEvidenceRecordV1, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-public-evidence.test.ts b/tests/lab/lab-public-evidence.test.ts similarity index 98% rename from tests/lab-public-evidence.test.ts rename to tests/lab/lab-public-evidence.test.ts index 39117de3dc..dd3918d796 100644 --- a/tests/lab-public-evidence.test.ts +++ b/tests/lab/lab-public-evidence.test.ts @@ -10,8 +10,8 @@ import { type ObservationEvent, type ProtocolSubjectV1, type RouteSubjectV1, -} from "../src/lab"; -import { labPublicPublisherKeyPath } from "../src/lab/paths"; +} from "../../src/lab"; +import { labPublicPublisherKeyPath } from "../../src/lab/paths"; import { PUBLIC_ROUTE_REGISTRY_V1, PublicEvidenceValidationError, @@ -27,8 +27,8 @@ import { validatePublicRouteRegistryManifest, verifyPublicEvidenceBundle, writePublicEvidenceBundle, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; const DEFAULT_COMPLETED_AT = Date.UTC(2026, 7, 12, 14, 37, 41); diff --git a/tests/lab-public-export-transaction.test.ts b/tests/lab/lab-public-export-transaction.test.ts similarity index 86% rename from tests/lab-public-export-transaction.test.ts rename to tests/lab/lab-public-export-transaction.test.ts index caa40ab8a2..c0e9147700 100644 --- a/tests/lab-public-export-transaction.test.ts +++ b/tests/lab/lab-public-export-transaction.test.ts @@ -7,19 +7,19 @@ import { labPublicOriginDir, persistConformanceResult, rebuildLabProjection, -} from "../src/lab"; -import { createArtifactStore } from "../src/lab/artifacts/store"; -import { resolveProtocolExecutionContext } from "../src/lab/conformance/executor"; -import { discoverScenarios, loadCaseAuthority } from "../src/lab/conformance/manifest"; -import type { CaseRecord } from "../src/lab/conformance/types"; +} from "../../src/lab"; +import { createArtifactStore } from "../../src/lab/artifacts/store"; +import { resolveProtocolExecutionContext } from "../../src/lab/conformance/executor"; +import { discoverScenarios, loadCaseAuthority } from "../../src/lab/conformance/manifest"; +import type { CaseRecord } from "../../src/lab/conformance/types"; import { buildPublicEvidenceBundle, exportLocalPublicEvidence, getOrCreatePublicPublisher, previewLocalPublicEvidence, -} from "../src/lab/public"; -import { queryLabObservations } from "../src/lab/query"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { queryLabObservations } from "../../src/lab/query"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const homes: string[] = []; diff --git a/tests/lab-public-file-safety.test.ts b/tests/lab/lab-public-file-safety.test.ts similarity index 88% rename from tests/lab-public-file-safety.test.ts rename to tests/lab/lab-public-file-safety.test.ts index d1336e3f6f..113d7837ac 100644 --- a/tests/lab-public-file-safety.test.ts +++ b/tests/lab/lab-public-file-safety.test.ts @@ -2,9 +2,9 @@ import { afterEach, expect, test } from "bun:test"; import { linkSync, mkdtempSync, symlinkSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { readPrivateRegularFile } from "../src/lab/public/file-safety"; -import { PublicEvidenceValidationError } from "../src/lab/public/validate"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { readPrivateRegularFile } from "../../src/lab/public/file-safety"; +import { PublicEvidenceValidationError } from "../../src/lab/public/validate"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-public-final-review-regressions.test.ts b/tests/lab/lab-public-final-review-regressions.test.ts similarity index 91% rename from tests/lab-public-final-review-regressions.test.ts rename to tests/lab/lab-public-final-review-regressions.test.ts index d0a02a07b7..a2ed0d2a2c 100644 --- a/tests/lab-public-final-review-regressions.test.ts +++ b/tests/lab/lab-public-final-review-regressions.test.ts @@ -2,7 +2,7 @@ import { afterEach, expect, test } from "bun:test"; import { existsSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { ensureLabDirs, labPublicOriginDir } from "../src/lab/paths"; +import { ensureLabDirs, labPublicOriginDir } from "../../src/lab/paths"; import { importCommunityEvidenceBundle, listLocalPublicOrigins, @@ -11,10 +11,10 @@ import { signPublicEvidenceBundle, writePublicEvidenceBundle, type PublicEvidenceRecordV1, -} from "../src/lab/public"; -import { listValidPublicOriginsForPurge } from "../src/lab/public/origin-purge"; -import { setPublicEvidencePurgeFaultForTests } from "../src/lab/public/purge-test-fault"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { listValidPublicOriginsForPurge } from "../../src/lab/public/origin-purge"; +import { setPublicEvidencePurgeFaultForTests } from "../../src/lab/public/purge-test-fault"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/lab-public-lifecycle-hardening.test.ts b/tests/lab/lab-public-lifecycle-hardening.test.ts similarity index 97% rename from tests/lab-public-lifecycle-hardening.test.ts rename to tests/lab/lab-public-lifecycle-hardening.test.ts index fb2607ce51..c8e390aad8 100644 --- a/tests/lab-public-lifecycle-hardening.test.ts +++ b/tests/lab/lab-public-lifecycle-hardening.test.ts @@ -15,11 +15,11 @@ import { labCommunityDir, labExportDir, labPublicPublisherKeyPath, -} from "../src/lab/paths"; +} from "../../src/lab/paths"; import { publishPrivateFileExclusive, setPrivateFileCommitFaultForTests, -} from "../src/lab/public/private-file"; +} from "../../src/lab/public/private-file"; import { createPublicEvidenceRevocation, importCommunityEvidenceBundle, @@ -32,8 +32,8 @@ import { signPublicEvidenceBundle, writePublicEvidenceBundle, type PublicEvidenceRecordV1, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-public-privacy-ipv6.test.ts b/tests/lab/lab-public-privacy-ipv6.test.ts similarity index 95% rename from tests/lab-public-privacy-ipv6.test.ts rename to tests/lab/lab-public-privacy-ipv6.test.ts index 1b8da1dae7..927e233843 100644 --- a/tests/lab-public-privacy-ipv6.test.ts +++ b/tests/lab/lab-public-privacy-ipv6.test.ts @@ -2,7 +2,7 @@ import { expect, test } from "bun:test"; import { validatePublicEvidencePrivacy, type PublicEvidenceBundleUnsignedV1, -} from "../src/lab/public"; +} from "../../src/lab/public"; test("public artifact privacy rejects embedded unbracketed IPv6 literals", () => { const bytes = Buffer.from("artifact 2001:db8::1 content", "utf8"); diff --git a/tests/lab-public-provenance-recovery.test.ts b/tests/lab/lab-public-provenance-recovery.test.ts similarity index 96% rename from tests/lab-public-provenance-recovery.test.ts rename to tests/lab/lab-public-provenance-recovery.test.ts index 9c78760315..f40e422d5c 100644 --- a/tests/lab-public-provenance-recovery.test.ts +++ b/tests/lab/lab-public-provenance-recovery.test.ts @@ -2,7 +2,7 @@ import { afterEach, expect, test } from "bun:test"; import { existsSync, mkdtempSync, readdirSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { labExportDir, labPublicOriginDir } from "../src/lab/paths"; +import { labExportDir, labPublicOriginDir } from "../../src/lab/paths"; import { createPublicEvidenceRevocation, importCommunityEvidenceBundle, @@ -15,9 +15,9 @@ import { signPublicEvidenceBundle, writePublicEvidenceBundle, type PublicEvidenceRecordV1, -} from "../src/lab/public"; -import { setPrivateFileCommitFaultForTests } from "../src/lab/public/private-file"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { setPrivateFileCommitFaultForTests } from "../../src/lab/public/private-file"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-public-review-fixes.test.ts b/tests/lab/lab-public-review-fixes.test.ts similarity index 95% rename from tests/lab-public-review-fixes.test.ts rename to tests/lab/lab-public-review-fixes.test.ts index bcb1286298..303998c538 100644 --- a/tests/lab-public-review-fixes.test.ts +++ b/tests/lab/lab-public-review-fixes.test.ts @@ -7,11 +7,11 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { ensureLabDirs, labPublicOriginDir } from "../src/lab/paths"; -import { purgeSensitiveEvidence } from "../src/lab/ledger/purge"; -import { replayLabLedger } from "../src/lab/ledger/store"; -import * as publicApi from "../src/lab/public"; -import { setPublicEvidencePurgeFaultForTests } from "../src/lab/public/purge-test-fault"; +import { ensureLabDirs, labPublicOriginDir } from "../../src/lab/paths"; +import { purgeSensitiveEvidence } from "../../src/lab/ledger/purge"; +import { replayLabLedger } from "../../src/lab/ledger/store"; +import * as publicApi from "../../src/lab/public"; +import { setPublicEvidencePurgeFaultForTests } from "../../src/lab/public/purge-test-fault"; import { importCommunityEvidenceBundle, importCommunityEvidenceRevocation, @@ -22,8 +22,8 @@ import { writePublicEvidenceBundle, PublicEvidenceValidationError, type PublicEvidenceRecordV1, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; afterEach(() => { diff --git a/tests/lab-public-route-registry.test.ts b/tests/lab/lab-public-route-registry.test.ts similarity index 95% rename from tests/lab-public-route-registry.test.ts rename to tests/lab/lab-public-route-registry.test.ts index e13b8fdb6c..42aee0cf08 100644 --- a/tests/lab-public-route-registry.test.ts +++ b/tests/lab/lab-public-route-registry.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { PUBLIC_ROUTE_REGISTRY_V1, validatePublicRouteRegistryManifest } from "../src/lab/public"; +import { PUBLIC_ROUTE_REGISTRY_V1, validatePublicRouteRegistryManifest } from "../../src/lab/public"; const REVIEWED_AUTHORITY_SOURCE_COMMIT = "75a21417657ba5a3033198be0d8ae949de723d11"; diff --git a/tests/lab-public-security-regressions.test.ts b/tests/lab/lab-public-security-regressions.test.ts similarity index 91% rename from tests/lab-public-security-regressions.test.ts rename to tests/lab/lab-public-security-regressions.test.ts index 76b38ff5b5..6d97d71383 100644 --- a/tests/lab-public-security-regressions.test.ts +++ b/tests/lab/lab-public-security-regressions.test.ts @@ -2,21 +2,21 @@ import { afterEach, expect, test } from "bun:test"; import { existsSync, mkdtempSync, statSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { jcsStringify } from "../src/lab/conformance/jcs"; -import type { ObservationEvent } from "../src/lab/events/types"; -import { labPublicPublisherKeyPath } from "../src/lab/paths"; -import { publishPrivateFileExclusive } from "../src/lab/public/private-file"; -import { validatePublicEvidencePrivacy } from "../src/lab/public/privacy"; -import { projectPublicEvidenceRecord } from "../src/lab/public/project"; -import { getOrCreatePublicPublisher } from "../src/lab/public/signature"; -import type { PublicEvidenceBundleUnsignedV1 } from "../src/lab/public/types"; +import { jcsStringify } from "../../src/lab/conformance/jcs"; +import type { ObservationEvent } from "../../src/lab/events/types"; +import { labPublicPublisherKeyPath } from "../../src/lab/paths"; +import { publishPrivateFileExclusive } from "../../src/lab/public/private-file"; +import { validatePublicEvidencePrivacy } from "../../src/lab/public/privacy"; +import { projectPublicEvidenceRecord } from "../../src/lab/public/project"; +import { getOrCreatePublicPublisher } from "../../src/lab/public/signature"; +import type { PublicEvidenceBundleUnsignedV1 } from "../../src/lab/public/types"; import { resetHardenedStateForTests, setIcaclsRunnerForTests, setPlatformForTests, -} from "../src/lib/windows-secret-acl"; -import { setWindowsPrincipalRunnerForTests } from "../src/lib/windows-user-principal"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lib/windows-secret-acl"; +import { setWindowsPrincipalRunnerForTests } from "../../src/lib/windows-user-principal"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const roots: string[] = []; diff --git a/tests/lab-public-surfaces.test.ts b/tests/lab/lab-public-surfaces.test.ts similarity index 94% rename from tests/lab-public-surfaces.test.ts rename to tests/lab/lab-public-surfaces.test.ts index e30240aa09..e28d601a2c 100644 --- a/tests/lab-public-surfaces.test.ts +++ b/tests/lab/lab-public-surfaces.test.ts @@ -2,23 +2,23 @@ import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleLabCommand } from "../src/cli/lab"; +import { handleLabCommand } from "../../src/cli/lab"; import { labExportDir, labPublicPublisherKeyPath, persistConformanceResult, rebuildLabProjection, -} from "../src/lab"; -import { labCommunityDir } from "../src/lab/paths"; -import { createArtifactStore } from "../src/lab/artifacts/store"; -import { resolveProtocolExecutionContext } from "../src/lab/conformance/executor"; -import { discoverScenarios, loadCaseAuthority } from "../src/lab/conformance/manifest"; -import type { CaseRecord } from "../src/lab/conformance/types"; -import { queryLabObservations } from "../src/lab/query"; -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"; +} from "../../src/lab"; +import { labCommunityDir } from "../../src/lab/paths"; +import { createArtifactStore } from "../../src/lab/artifacts/store"; +import { resolveProtocolExecutionContext } from "../../src/lab/conformance/executor"; +import { discoverScenarios, loadCaseAuthority } from "../../src/lab/conformance/manifest"; +import type { CaseRecord } from "../../src/lab/conformance/types"; +import { queryLabObservations } from "../../src/lab/query"; +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 HOMES: string[] = []; diff --git a/tests/lab-public-wire-contract.test.ts b/tests/lab/lab-public-wire-contract.test.ts similarity index 96% rename from tests/lab-public-wire-contract.test.ts rename to tests/lab/lab-public-wire-contract.test.ts index 27f0dfae93..9f2e05c6f1 100644 --- a/tests/lab-public-wire-contract.test.ts +++ b/tests/lab/lab-public-wire-contract.test.ts @@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test"; import { chmodSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; -import { labPublicPublisherKeyPath } from "../src/lab/paths"; +import { labPublicPublisherKeyPath } from "../../src/lab/paths"; import { buildPublicEvidenceBundle, importCommunityEvidenceBundle, @@ -10,8 +10,8 @@ import { publicEvidenceId, signPublicEvidenceBundle, verifyPublicEvidenceBundle, -} from "../src/lab/public"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/public"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; // Deterministic test-only key material is assembled at runtime so leak scanners do not // mistake the fixture for a deployable private-key credential. diff --git a/tests/lab-read-filter-validation.test.ts b/tests/lab/lab-read-filter-validation.test.ts similarity index 86% rename from tests/lab-read-filter-validation.test.ts rename to tests/lab/lab-read-filter-validation.test.ts index 48d93eaa0f..fc842adc4d 100644 --- a/tests/lab-read-filter-validation.test.ts +++ b/tests/lab/lab-read-filter-validation.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import type { OcxConfig } from "../src/types"; -import { handleManagementAPI } from "../src/server/management-api"; -import { ManagementRequest } from "./helpers/management-auth"; +import type { OcxConfig } from "../../src/types"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { ManagementRequest } from "../helpers/management-auth"; const config = { providers: {} } as OcxConfig; diff --git a/tests/lab-read-surfaces.test.ts b/tests/lab/lab-read-surfaces.test.ts similarity index 95% rename from tests/lab-read-surfaces.test.ts rename to tests/lab/lab-read-surfaces.test.ts index c8e3e17b80..078c3d2042 100644 --- a/tests/lab-read-surfaces.test.ts +++ b/tests/lab/lab-read-surfaces.test.ts @@ -3,8 +3,8 @@ import { existsSync, mkdirSync, readFileSync, statSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; import { Database } from "bun:sqlite"; -import { handleLabCommand } from "../src/cli/lab"; -import { skipsCodexShimAutoRestore } from "../src/cli/codex-shim-autorestore"; +import { handleLabCommand } from "../../src/cli/lab"; +import { skipsCodexShimAutoRestore } from "../../src/cli/codex-shim-autorestore"; import { appendLabEvent, assignEventId, @@ -16,11 +16,11 @@ import { LAB_PRODUCER, LAB_PROJECTION_SPEC_VERSION, LAB_SQLITE_SCHEMA_VERSION, -} from "../src/lab"; -import { createArtifactStore } from "../src/lab/artifacts/store"; -import { resolveProtocolExecutionContext } from "../src/lab/conformance/executor"; -import type { CaseRecord } from "../src/lab/conformance/types"; -import { discoverScenarios, loadCaseAuthority } from "../src/lab/conformance/manifest"; +} from "../../src/lab"; +import { createArtifactStore } from "../../src/lab/artifacts/store"; +import { resolveProtocolExecutionContext } from "../../src/lab/conformance/executor"; +import type { CaseRecord } from "../../src/lab/conformance/types"; +import { discoverScenarios, loadCaseAuthority } from "../../src/lab/conformance/manifest"; import { InvalidCursorError, LabProjectionIncompatibleError, @@ -38,12 +38,12 @@ import { queryLabSubjects, queryLabVerdicts, sanitizePublicText, -} from "../src/lab/query"; -import { encodeLabCursor, verdictCursor } from "../src/lab/query/cursor"; -import { handleManagementAPI } from "../src/server/management-api"; -import { ManagementRequest } from "./helpers/management-auth"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/lab/query"; +import { encodeLabCursor, verdictCursor } from "../../src/lab/query/cursor"; +import { handleManagementAPI } from "../../src/server/management-api"; +import { ManagementRequest } from "../helpers/management-auth"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const HOMES: string[] = []; diff --git a/tests/apply-patch-envelope.test.ts b/tests/responses/apply-patch-envelope.test.ts similarity index 98% rename from tests/apply-patch-envelope.test.ts rename to tests/responses/apply-patch-envelope.test.ts index 89dbca70d3..f5ee14663c 100644 --- a/tests/apply-patch-envelope.test.ts +++ b/tests/responses/apply-patch-envelope.test.ts @@ -4,8 +4,8 @@ import { mayBecomePatchEnvelope, normalizeApplyPatchDelimiters, repairFreeformToolInput, -} from "../src/responses/apply-patch-envelope"; -import { compileCodeModeHelperInput, resolveCodeModeHelperName } from "../src/responses/code-mode-helper-compat"; +} from "../../src/responses/apply-patch-envelope"; +import { compileCodeModeHelperInput, resolveCodeModeHelperName } from "../../src/responses/code-mode-helper-compat"; const DECORATED_PATCH = `*** Begin Patch *** *** Update File: README.md diff --git a/tests/chat-completions-endpoint.test.ts b/tests/responses/chat-completions-endpoint.test.ts similarity index 97% rename from tests/chat-completions-endpoint.test.ts rename to tests/responses/chat-completions-endpoint.test.ts index 824ba64013..7ca64ecdc6 100644 --- a/tests/chat-completions-endpoint.test.ts +++ b/tests/responses/chat-completions-endpoint.test.ts @@ -1,23 +1,23 @@ -import { waitForNativeMainStartupGate } from "../src/codex/native-profile-startup"; +import { waitForNativeMainStartupGate } from "../../src/codex/native-profile-startup"; import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { loadConfig, saveConfig } from "../src/config"; -import { startServer } from "../src/server"; -import { ownedServiceHomeInspection } from "./helpers/owned-service-home-inspection"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; -import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; -import { chatCompletionsToResponsesBody, ChatCompletionsRequestError } from "../src/chat/inbound"; -import { chatCompletionsUsage } from "../src/chat/outbound"; -import { parseRequest } from "../src/responses/parser"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; -import type { TranslatorBudget } from "../src/lib/translator-budget"; +import { loadConfig, saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { ownedServiceHomeInspection } from "../helpers/owned-service-home-inspection"; +import type { OcxConfig, OcxProviderConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; +import { chatCompletionsToResponsesBody, ChatCompletionsRequestError } from "../../src/chat/inbound"; +import { chatCompletionsUsage } from "../../src/chat/outbound"; +import { parseRequest } from "../../src/responses/parser"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; +import type { TranslatorBudget } from "../../src/lib/translator-budget"; import { resetProviderRequestPacingForTest, setProviderRequestPacingRuntimeForTest, -} from "../src/providers/request-pacing"; +} from "../../src/providers/request-pacing"; import { acquireNativeMainProfileDrain, activeRegistryMetrics, @@ -25,15 +25,15 @@ import { getNativeMainProfileRequestCount, resetLifecycleDrainStateForTests, tryAdmitTurn, -} from "../src/server/lifecycle"; +} from "../../src/server/lifecycle"; import { blockNativeMainRecovery, completeNativeMainRecovery, nativeMainStartupGateSnapshot, waitForNativeMainStartupGate, -} from "../src/codex/native-profile-startup"; +} from "../../src/codex/native-profile-startup"; -function budgetedChatOutbound(module: typeof import("../src/chat/outbound")) { +function budgetedChatOutbound(module: typeof import("../../src/chat/outbound")) { const translatorBudget = createTestTranslatorBudget(); return { ...module, @@ -178,7 +178,7 @@ type ChatStreamChunk = { }; async function convertResponsesFrames(frames: string[], model = "gpt-test") { - const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../../src/chat/outbound")); const stream = responsesSseToChatCompletionsSse(new ReadableStream({ start(controller) { const encoder = new TextEncoder(); @@ -260,7 +260,7 @@ describe("chatCompletionsToResponsesBody service_tier", () => { async function driveChatFallbackServiceTier( providerOverrides: Partial, ): Promise> { - const { handleChatCompletions } = await import("../src/server/chat-completions"); + const { handleChatCompletions } = await import("../../src/server/chat-completions"); const captured: Record[] = []; globalThis.fetch = (async (_input: RequestInfo | URL, init?: RequestInit) => { captured.push(JSON.parse(String(init?.body ?? "{}")) as Record); @@ -437,7 +437,7 @@ test("responsesSseToChatCompletionsSse consumes response.heartbeat without forwa // Upstream responses SSE may contain heartbeat events (SSE comment keep-alive in // bridge.ts, but some upstreams emit them as typed frames). The chat-completions // converter must drop them rather than forwarding raw Responses-vocab frames. - const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../../src/chat/outbound")); const upstream = new Response([ `event: response.heartbeat\ndata: ${JSON.stringify({ type: "response.heartbeat" })}\n\n`, `event: response.output_text.delta\ndata: ${JSON.stringify({ type: "response.output_text.delta", delta: "hi" })}\n\n`, @@ -653,7 +653,7 @@ test("responsesSseToChatCompletionsSse emits parallel tool calls once with stabl }); test("responsesSseToChatCompletionsSse bounds upstream reads until the chat client pulls", async () => { - const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../../src/chat/outbound")); const encoder = new TextEncoder(); let pulls = 0; const upstream = new ReadableStream({ @@ -674,7 +674,7 @@ test("responsesSseToChatCompletionsSse bounds upstream reads until the chat clie }); test("responsesSseToChatCompletionsSse delivers the first frame before a macrotask turn", async () => { - const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../../src/chat/outbound")); const encoder = new TextEncoder(); const upstream = new ReadableStream({ start(controller) { @@ -855,7 +855,7 @@ test("POST /v1/responses honors the per-model response_format opt-out", async () }); test("chat-native consumes pacing before the response-header timeout starts", async () => { - const { handleChatCompletions } = await import("../src/server/chat-completions"); + const { handleChatCompletions } = await import("../../src/server/chat-completions"); let pacingTimer: (() => void) | undefined; let now = 0; setProviderRequestPacingRuntimeForTest({ @@ -909,7 +909,7 @@ test("chat-native consumes pacing before the response-header timeout starts", as }); test("chat-native stays outside the Responses empty-completion retry guard", async () => { - const { handleChatCompletions } = await import("../src/server/chat-completions"); + const { handleChatCompletions } = await import("../../src/server/chat-completions"); let upstreamCalls = 0; const providerExecutor = Object.assign(async () => { upstreamCalls += 1; @@ -1423,7 +1423,7 @@ test("chat-native shares the transient send budget across same-target 429 recove }); test("chat-native shares the transient send budget across key rotation", async () => { - const { clearKeyCooldowns } = await import("../src/providers/key-failover"); + const { clearKeyCooldowns } = await import("../../src/providers/key-failover"); clearKeyCooldowns("mock"); const authorizations: Array = []; const upstream = Bun.serve({ @@ -1485,7 +1485,7 @@ test("chat-native shares the transient send budget across key rotation", async ( }); test("chat-native records terminal key cooldown after the send budget is exhausted", async () => { - const { clearKeyCooldowns, getKeyCooldownUntil } = await import("../src/providers/key-failover"); + const { clearKeyCooldowns, getKeyCooldownUntil } = await import("../../src/providers/key-failover"); clearKeyCooldowns("mock"); let upstreamSends = 0; const upstream = Bun.serve({ @@ -1527,8 +1527,8 @@ test("chat-native records terminal key cooldown after the send budget is exhaust }); test("chat-native preserves same-key retry, key rotation, usage, and request logging", async () => { - const { clearRequestLogsForTests, getRequestLogEntries } = await import("../src/server/request-log"); - const { clearKeyCooldowns } = await import("../src/providers/key-failover"); + const { clearRequestLogsForTests, getRequestLogEntries } = await import("../../src/server/request-log"); + const { clearKeyCooldowns } = await import("../../src/providers/key-failover"); clearRequestLogsForTests(); clearKeyCooldowns("mock"); const authorizations: Array = []; @@ -1578,8 +1578,8 @@ test("chat-native preserves same-key retry, key rotation, usage, and request log }); test("chat-native client cancellation cancels the upstream stream and logs 499", async () => { - const { clearRequestLogsForTests, getRequestLogEntries } = await import("../src/server/request-log"); - const { handleChatCompletions } = await import("../src/server/chat-completions"); + const { clearRequestLogsForTests, getRequestLogEntries } = await import("../../src/server/request-log"); + const { handleChatCompletions } = await import("../../src/server/chat-completions"); clearRequestLogsForTests(); let markCancelled!: () => void; const cancelled = new Promise(resolve => { markCancelled = resolve; }); @@ -1628,8 +1628,8 @@ test("chat-native client cancellation cancels the upstream stream and logs 499", }); test("chat-native request abort releases its active-turn lease and logs 499", async () => { - const { clearRequestLogsForTests, getRequestLogEntries } = await import("../src/server/request-log"); - const { handleChatCompletions } = await import("../src/server/chat-completions"); + const { clearRequestLogsForTests, getRequestLogEntries } = await import("../../src/server/request-log"); + const { handleChatCompletions } = await import("../../src/server/chat-completions"); clearRequestLogsForTests(); let markCancelled!: () => void; const cancelled = new Promise(resolve => { markCancelled = resolve; }); @@ -1683,7 +1683,7 @@ test("chat-native request abort releases its active-turn lease and logs 499", as }); test("chat-native direct streaming without an admission lease does not record a release miss", async () => { - const { handleChatCompletions } = await import("../src/server/chat-completions"); + const { handleChatCompletions } = await import("../../src/server/chat-completions"); const releaseMisses = activeRegistryMetrics().activeTurns.releaseMisses; globalThis.fetch = (async () => new Response( 'data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}\n\ndata: [DONE]\n\n', @@ -1935,7 +1935,7 @@ test("chat-native skips optional main enrichment while routed work survives drai }, 15_000); test("POST /v1/chat/completions finalizes native passthrough request logs", async () => { - const { clearRequestLogsForTests, getRequestLogEntries } = await import("../src/server/request-log"); + const { clearRequestLogsForTests, getRequestLogEntries } = await import("../../src/server/request-log"); clearRequestLogsForTests(); const upstream = Bun.serve({ port: 0, @@ -2001,7 +2001,7 @@ test("POST /v1/chat/completions finalizes native passthrough request logs", asyn }); test("POST /v1/chat/completions logs native cyber terminals as 400 cyber_policy", async () => { - const { clearRequestLogsForTests, getRequestLogEntries } = await import("../src/server/request-log"); + const { clearRequestLogsForTests, getRequestLogEntries } = await import("../../src/server/request-log"); clearRequestLogsForTests(); const upstream = Bun.serve({ port: 0, @@ -2076,7 +2076,7 @@ test("POST /v1/chat/completions logs native cyber terminals as 400 cyber_policy" test("responsesSseToChatCompletionsSse reconciles done-frame final arguments (last-write-wins)", async () => { - const { responsesSseToChatCompletionsSse, collectChatCompletion } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse, collectChatCompletion } = budgetedChatOutbound(await import("../../src/chat/outbound")); const frames = [ `event: response.output_item.added\ndata: ${JSON.stringify({ type: "response.output_item.added", item: { type: "function_call", id: "fc_a", call_id: "call_a", name: "alpha", arguments: "" } })}\n\n`, `event: response.function_call_arguments.delta\ndata: ${JSON.stringify({ type: "response.function_call_arguments.delta", item_id: "fc_a", delta: '{"q":"partial' })}\n\n`, @@ -2099,7 +2099,7 @@ test("responsesSseToChatCompletionsSse reconciles done-frame final arguments (la }); test("responsesSseToChatCompletionsSse emits error frame on response.failed (no clean DONE)", async () => { - const { responsesSseToChatCompletionsSse, collectChatCompletion, ChatCompletionsStreamError } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse, collectChatCompletion, ChatCompletionsStreamError } = budgetedChatOutbound(await import("../../src/chat/outbound")); const frames = [ `event: response.created\ndata: ${JSON.stringify({ type: "response.created", response: { id: "resp_fail" } })}\n\n`, `event: response.output_text.delta\ndata: ${JSON.stringify({ type: "response.output_text.delta", delta: "partial" })}\n\n`, @@ -2132,7 +2132,7 @@ test("responsesSseToChatCompletionsSse emits error frame on response.failed (no test("responsesSseToChatCompletionsSse preserves translator overflow and cancels upstream", async () => { const { responsesSseToChatCompletionsSse, collectChatCompletion, isChatCompletionsStreamError } = - budgetedChatOutbound(await import("../src/chat/outbound")); + budgetedChatOutbound(await import("../../src/chat/outbound")); const frame = `event: response.failed\ndata: ${JSON.stringify({ type: "response.failed", response: { @@ -2176,7 +2176,7 @@ test("responsesSseToChatCompletionsSse preserves translator overflow and cancels }); test("collectChatCompletion enforces the per-call argument cap", async () => { - const module = await import("../src/chat/outbound"); + const module = await import("../../src/chat/outbound"); const budget = createTestTranslatorBudget({ maxCallArgumentBytes: 1024 }); const bigArgs = "x".repeat(2048); const frame = `data: ${JSON.stringify({ @@ -2202,7 +2202,7 @@ test("collectChatCompletion enforces the per-call argument cap", async () => { }); test("collectChatCompletion enforces the turn cap across many calls", async () => { - const module = await import("../src/chat/outbound"); + const module = await import("../../src/chat/outbound"); const budget = createTestTranslatorBudget({ maxCallArgumentBytes: 512, maxTurnBytes: 4096 }); const encoder = new TextEncoder(); const stream = new ReadableStream({ @@ -2229,7 +2229,7 @@ test("collectChatCompletion enforces the turn cap across many calls", async () = }); test("collectChatCompletion releases every call scope after the final owner is charged", async () => { - const module = await import("../src/chat/outbound"); + const module = await import("../../src/chat/outbound"); const budget = createTestTranslatorBudget(); const encoder = new TextEncoder(); const frames = [ @@ -2261,7 +2261,7 @@ test("collectChatCompletion releases every call scope after the final owner is c }); test("collectChatCompletion final-copy overflow cleans up scopes and charges", async () => { - const module = await import("../src/chat/outbound"); + const module = await import("../../src/chat/outbound"); // Args (100 bytes) fit; args + serialized copy exceed the turn cap, so the // overflow fires during the final owner transfer, not mid-stream. The 250 // threshold lets the ~213-byte frame and the 100-byte args through first. @@ -2289,7 +2289,7 @@ test("collectChatCompletion final-copy overflow cleans up scopes and charges", a }); test("responsesSseToChatCompletionsSse emits error frame on truncated stream", async () => { - const { responsesSseToChatCompletionsSse, collectChatCompletion, ChatCompletionsStreamError } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse, collectChatCompletion, ChatCompletionsStreamError } = budgetedChatOutbound(await import("../../src/chat/outbound")); const frames = [ `event: response.created\ndata: ${JSON.stringify({ type: "response.created", response: { id: "resp_trunc" } })}\n\n`, `event: response.output_text.delta\ndata: ${JSON.stringify({ type: "response.output_text.delta", delta: "half" })}\n\n`, @@ -2437,7 +2437,7 @@ test("streaming /v1/chat/completions does not clean-DONE after response.failed", test("responsesSseToChatCompletionsSse emits one complete named tool call", async () => { - const { responsesSseToChatCompletionsSse, collectChatCompletion } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse, collectChatCompletion } = budgetedChatOutbound(await import("../../src/chat/outbound")); const frames = [ `event: response.output_item.added\ndata: ${JSON.stringify({ type: "response.output_item.added", item: { type: "function_call", id: "fc_a", call_id: "call_a", name: "exec_command", arguments: "" } })}\n\n`, `event: response.function_call_arguments.delta\ndata: ${JSON.stringify({ type: "response.function_call_arguments.delta", item_id: "fc_a", delta: '{"cmd":' })}\n\n`, @@ -2639,7 +2639,7 @@ test("chatCompletionsToResponsesBody indexes tool-call names once per call", () // CRLF framing and a terminal event without a trailing blank line must not be reported // as truncation now that the shared SSE decoder drives the converter. test("responsesSseToChatCompletionsSse accepts CRLF-framed SSE with terminal event at EOF", async () => { - const { responsesSseToChatCompletionsSse, collectChatCompletion } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse, collectChatCompletion } = budgetedChatOutbound(await import("../../src/chat/outbound")); const raw = [ `event: response.created\r\ndata: ${JSON.stringify({ type: "response.created", response: { id: "resp_crlf" } })}\r\n\r\n`, `event: response.output_text.delta\r\ndata: ${JSON.stringify({ type: "response.output_text.delta", delta: "hello" })}\r\n\r\n`, @@ -2667,7 +2667,7 @@ test("responsesSseToChatCompletionsSse accepts CRLF-framed SSE with terminal eve }); test("responsesSseToChatCompletionsSse cancel promptly cancels an idle upstream", async () => { - const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../src/chat/outbound")); + const { responsesSseToChatCompletionsSse } = budgetedChatOutbound(await import("../../src/chat/outbound")); let upstreamCancelled = false; // Never-ending upstream: enqueues one partial frame then goes silent. const idleUpstream = new ReadableStream({ @@ -2737,7 +2737,7 @@ test("content_filter incomplete still maps to finish_reason content_filter with test("collectChatCompletion throws ChatCompletionsStreamError on a stall incomplete (WP3)", async () => { const { responsesSseToChatCompletionsSse, collectChatCompletion, isChatCompletionsStreamError } = - budgetedChatOutbound(await import("../src/chat/outbound")); + budgetedChatOutbound(await import("../../src/chat/outbound")); const frames = [ `event: response.incomplete\ndata: ${JSON.stringify({ type: "response.incomplete", response: { status: "incomplete", incomplete_details: { reason: "upstream_stall_timeout" } } })}\n\n`, ]; diff --git a/tests/citation-markers.test.ts b/tests/responses/citation-markers.test.ts similarity index 98% rename from tests/citation-markers.test.ts rename to tests/responses/citation-markers.test.ts index 726585457c..0c1921750c 100644 --- a/tests/citation-markers.test.ts +++ b/tests/responses/citation-markers.test.ts @@ -6,7 +6,7 @@ import { createCitationMarkerFilter, hasCitationMarker, stripCitationMarkers, -} from "../src/responses/citation-markers"; +} from "../../src/responses/citation-markers"; /** * #3150: the ChatGPT backend delimits inline citations with private-use characters diff --git a/tests/continuation-dedup.test.ts b/tests/responses/continuation-dedup.test.ts similarity index 99% rename from tests/continuation-dedup.test.ts rename to tests/responses/continuation-dedup.test.ts index 26fef17322..fa6c3a0737 100644 --- a/tests/continuation-dedup.test.ts +++ b/tests/responses/continuation-dedup.test.ts @@ -18,8 +18,8 @@ import { replayOverlapSkipsForTests, responseStateMetrics, setResponseStateByteCapForTests, -} from "../src/responses/state"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/responses/state"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let home: string; let priorHome: string | undefined; diff --git a/tests/custom-tool-compat.test.ts b/tests/responses/custom-tool-compat.test.ts similarity index 98% rename from tests/custom-tool-compat.test.ts rename to tests/responses/custom-tool-compat.test.ts index 3d581f6e7d..530238c499 100644 --- a/tests/custom-tool-compat.test.ts +++ b/tests/responses/custom-tool-compat.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { rewriteRoutedCustomToolsForUpstream } from "../src/responses/custom-tool-compat"; +import { rewriteRoutedCustomToolsForUpstream } from "../../src/responses/custom-tool-compat"; function convertedInputDescription(name: string): string | undefined { const result = rewriteRoutedCustomToolsForUpstream({ diff --git a/tests/empty-completion-core.test.ts b/tests/responses/empty-completion-core.test.ts similarity index 97% rename from tests/empty-completion-core.test.ts rename to tests/responses/empty-completion-core.test.ts index 35c6c6b85e..d8d4d73325 100644 --- a/tests/empty-completion-core.test.ts +++ b/tests/responses/empty-completion-core.test.ts @@ -1,15 +1,15 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test"; -import type { ProviderAdapter } from "../src/adapters/base"; +import type { ProviderAdapter } from "../../src/adapters/base"; import { providerRequestPacingStatus, resetProviderRequestPacingForTest, setProviderRequestPacingLimitsForTest, setProviderRequestPacingRuntimeForTest, -} from "../src/providers/request-pacing"; -import type { RequestLogContext } from "../src/server/request-log"; -import type { AdapterEvent, OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../src/types"; +} from "../../src/providers/request-pacing"; +import type { RequestLogContext } from "../../src/server/request-log"; +import type { AdapterEvent, OcxConfig, OcxParsedRequest, OcxProviderConfig } from "../../src/types"; -const actualResolver = await import("../src/server/adapter-resolve"); +const actualResolver = await import("../../src/server/adapter-resolve"); const actualResolveAdapter = actualResolver.resolveAdapter; let attemptEvents: AdapterEvent[][] = []; @@ -88,7 +88,7 @@ function fixtureAdapter(provider: OcxProviderConfig): ProviderAdapter & { passth }; } -mock.module("../src/server/adapter-resolve", () => ({ +mock.module("../../src/server/adapter-resolve", () => ({ ...actualResolver, resolveAdapter(provider: OcxProviderConfig, cacheRetention?: "none" | "short" | "long") { if ( @@ -102,7 +102,7 @@ mock.module("../src/server/adapter-resolve", () => ({ }, })); -const { handleResponses } = await import("../src/server/responses"); +const { handleResponses } = await import("../../src/server/responses"); function config( adapter: "test-run-turn" | "test-http" | "test-passthrough", diff --git a/tests/empty-completion-guard.test.ts b/tests/responses/empty-completion-guard.test.ts similarity index 99% rename from tests/empty-completion-guard.test.ts rename to tests/responses/empty-completion-guard.test.ts index 18d3a32f5f..b1985f31b0 100644 --- a/tests/empty-completion-guard.test.ts +++ b/tests/responses/empty-completion-guard.test.ts @@ -7,8 +7,8 @@ import { guardEmptyCompletionEventStream, isContentEvent, observeEmptyCompletion, -} from "../src/server/responses/empty-completion-guard"; -import type { AdapterEvent } from "../src/types"; +} from "../../src/server/responses/empty-completion-guard"; +import type { AdapterEvent } from "../../src/types"; function collect(source: AsyncIterable): Promise { const events: AdapterEvent[] = []; diff --git a/tests/empty-completion-hardening.test.ts b/tests/responses/empty-completion-hardening.test.ts similarity index 97% rename from tests/empty-completion-hardening.test.ts rename to tests/responses/empty-completion-hardening.test.ts index 02233fbd51..d41dd6a299 100644 --- a/tests/empty-completion-hardening.test.ts +++ b/tests/responses/empty-completion-hardening.test.ts @@ -3,8 +3,8 @@ import { EMPTY_COMPLETION_MAX_BUFFERED_BYTES, EMPTY_COMPLETION_MAX_BUFFERED_EVENTS, guardEmptyCompletionEventStream, -} from "../src/server/responses/empty-completion-guard"; -import type { AdapterEvent } from "../src/types"; +} from "../../src/server/responses/empty-completion-guard"; +import type { AdapterEvent } from "../../src/types"; async function collect(source: AsyncIterable): Promise { const events: AdapterEvent[] = []; diff --git a/tests/eventstream-decoder.test.ts b/tests/responses/eventstream-decoder.test.ts similarity index 99% rename from tests/eventstream-decoder.test.ts rename to tests/responses/eventstream-decoder.test.ts index f84b52ebb3..960b0a5448 100644 --- a/tests/eventstream-decoder.test.ts +++ b/tests/responses/eventstream-decoder.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { crc32, decodeEventStream, decodeMessage, encodeMessage } from "../src/lib/eventstream-decoder"; +import { crc32, decodeEventStream, decodeMessage, encodeMessage } from "../../src/lib/eventstream-decoder"; const enc = new TextEncoder(); const dec = new TextDecoder(); diff --git a/tests/legacy-shell-compat.test.ts b/tests/responses/legacy-shell-compat.test.ts similarity index 97% rename from tests/legacy-shell-compat.test.ts rename to tests/responses/legacy-shell-compat.test.ts index 60b3fb4449..6503c3e6dd 100644 --- a/tests/legacy-shell-compat.test.ts +++ b/tests/responses/legacy-shell-compat.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { compileCodeModeHelperInput } from "../src/responses/code-mode-helper-compat"; +import { compileCodeModeHelperInput } from "../../src/responses/code-mode-helper-compat"; const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor as new ( ...args: string[] diff --git a/tests/namespace-tool-compat.test.ts b/tests/responses/namespace-tool-compat.test.ts similarity index 99% rename from tests/namespace-tool-compat.test.ts rename to tests/responses/namespace-tool-compat.test.ts index 9378938e78..7724661246 100644 --- a/tests/namespace-tool-compat.test.ts +++ b/tests/responses/namespace-tool-compat.test.ts @@ -4,7 +4,7 @@ import { restoreRoutedNamespaceCalls, restoreRoutedNamespaceCallsInJson, rewriteRoutedNamespaceToolsForUpstream, -} from "../src/responses/namespace-tool-compat"; +} from "../../src/responses/namespace-tool-compat"; describe("Responses namespace tool compatibility", () => { test("flattens builtin and routed namespaces across declarations, selectors, and replay", () => { diff --git a/tests/openai-responses-passthrough.test.ts b/tests/responses/openai-responses-passthrough.test.ts similarity index 99% rename from tests/openai-responses-passthrough.test.ts rename to tests/responses/openai-responses-passthrough.test.ts index d411614626..8f9648e951 100644 --- a/tests/openai-responses-passthrough.test.ts +++ b/tests/responses/openai-responses-passthrough.test.ts @@ -1,20 +1,20 @@ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../src/adapters/openai-responses"; -import { openaiResponsesUrl } from "../src/adapters/openai-responses-url"; -import { enrichProviderFromRegistry, providerConfigSeed } from "../src/providers/derive"; -import { getProviderRegistryEntry } from "../src/providers/registry"; -import { XAI_GROK_CLI_BASE_URL } from "../src/providers/xai-transport"; -import { routeModel } from "../src/router"; -import { resolveWireProtocolOverride } from "../src/server/adapter-resolve"; -import { handleResponses, sanitizeEncryptedContentInPlace } from "../src/server/responses"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; +import { openaiResponsesUrl } from "../../src/adapters/openai-responses-url"; +import { enrichProviderFromRegistry, providerConfigSeed } from "../../src/providers/derive"; +import { getProviderRegistryEntry } from "../../src/providers/registry"; +import { XAI_GROK_CLI_BASE_URL } from "../../src/providers/xai-transport"; +import { routeModel } from "../../src/router"; +import { resolveWireProtocolOverride } from "../../src/server/adapter-resolve"; +import { handleResponses, sanitizeEncryptedContentInPlace } from "../../src/server/responses"; import { encodeCompactionSummary, OPAQUE_COMPACTION_NOTE, SUMMARY_PREFIX, -} from "../src/responses/compaction"; -import { createTranslatorBudget } from "../src/lib/translator-budget"; -import type { OcxConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/responses/compaction"; +import { createTranslatorBudget } from "../../src/lib/translator-budget"; +import type { OcxConfig } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createResponsesPassthroughAdapter = (...args: Parameters) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); diff --git a/tests/passthrough-abort.test.ts b/tests/responses/passthrough-abort.test.ts similarity index 99% rename from tests/passthrough-abort.test.ts rename to tests/responses/passthrough-abort.test.ts index 1a6aae29cd..ef41494213 100644 --- a/tests/passthrough-abort.test.ts +++ b/tests/responses/passthrough-abort.test.ts @@ -1,7 +1,9 @@ import { describe, expect, test } from "bun:test"; -import { consumeForInspection, linkAbortSignal, relaySseWithFailedTail, relaySseWithHeartbeat, relayWithAbort } from "../src/server"; +import { consumeForInspection, linkAbortSignal, relaySseWithFailedTail, relaySseWithHeartbeat, relayWithAbort } from "../../src/server"; +import { pathToFileURL } from "node:url"; +import { repoRoot } from "../helpers/repo-root"; -const root = new URL("../", import.meta.url); +const root = pathToFileURL(repoRoot() + "/"); async function readSource(path: string): Promise { return await Bun.file(new URL(path, root)).text(); diff --git a/tests/passthrough-headers.test.ts b/tests/responses/passthrough-headers.test.ts similarity index 96% rename from tests/passthrough-headers.test.ts rename to tests/responses/passthrough-headers.test.ts index 70e77ff08e..8018e77906 100644 --- a/tests/passthrough-headers.test.ts +++ b/tests/responses/passthrough-headers.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { sanitizePassthroughHeaders } from "../src/server"; +import { sanitizePassthroughHeaders } from "../../src/server"; describe("passthrough header sanitization (RC5 / F4)", () => { test("content-type: text/event-stream survives sanitization", () => { diff --git a/tests/passthrough-override.test.ts b/tests/responses/passthrough-override.test.ts similarity index 93% rename from tests/passthrough-override.test.ts rename to tests/responses/passthrough-override.test.ts index 85a8630889..3890ba627c 100644 --- a/tests/passthrough-override.test.ts +++ b/tests/responses/passthrough-override.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../src/adapters/openai-responses"; -import { selectForwardHeaders } from "../src/server/ws-bridge"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; +import { selectForwardHeaders } from "../../src/server/ws-bridge"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createResponsesPassthroughAdapter = (...args: Parameters) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); diff --git a/tests/responses-account-label.test.ts b/tests/responses/responses-account-label.test.ts similarity index 92% rename from tests/responses-account-label.test.ts rename to tests/responses/responses-account-label.test.ts index bcdaef5d4c..16c493a006 100644 --- a/tests/responses-account-label.test.ts +++ b/tests/responses/responses-account-label.test.ts @@ -2,19 +2,19 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { fallbackCodexAccountLogLabel } from "../src/codex/account-label"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import { clearAccountQuota, updateAccountQuota } from "../src/codex/auth-api"; -import { MAIN_CODEX_ACCOUNT_ID } from "../src/codex/main-account"; +import { fallbackCodexAccountLogLabel } from "../../src/codex/account-label"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import { clearAccountQuota, updateAccountQuota } from "../../src/codex/auth-api"; +import { MAIN_CODEX_ACCOUNT_ID } from "../../src/codex/main-account"; import { clearCodexUpstreamHealth, clearThreadAccountMap, getCodexUpstreamHealth, -} from "../src/codex/routing"; -import type { RequestLogContext } from "../src/server/request-log"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/codex/routing"; +import type { RequestLogContext } from "../../src/server/request-log"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const originalFetch = globalThis.fetch; diff --git a/tests/responses-compaction-routing.test.ts b/tests/responses/responses-compaction-routing.test.ts similarity index 98% rename from tests/responses-compaction-routing.test.ts rename to tests/responses/responses-compaction-routing.test.ts index 0673f7dcb1..d9e8aa537c 100644 --- a/tests/responses-compaction-routing.test.ts +++ b/tests/responses/responses-compaction-routing.test.ts @@ -8,31 +8,31 @@ import { afterEach, describe, expect, spyOn, test } from "bun:test"; import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleResponses, handleResponsesCompact } from "../src/server/responses"; -import * as adapterResolveModule from "../src/server/adapter-resolve"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; +import { handleResponses, handleResponsesCompact } from "../../src/server/responses"; +import * as adapterResolveModule from "../../src/server/adapter-resolve"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; import { CODEX_QUOTA_PROBE_INTERVAL_MS, clearCodexUpstreamHealth, getCodexUpstreamHealth, recordCodexUpstreamOutcome, resolveCodexAccountForThread, -} from "../src/codex/routing"; -import { clearAccountQuota, updateAccountQuota } from "../src/codex/auth-api"; -import { MAIN_CODEX_ACCOUNT_ID, MainAccountTokenRefreshError } from "../src/codex/main-account"; -import { NativeProfileError } from "../src/codex/native-profile-types"; -import { fallbackCodexAccountLogLabel } from "../src/codex/account-label"; -import * as authContextModule from "../src/codex/auth-context"; +} from "../../src/codex/routing"; +import { clearAccountQuota, updateAccountQuota } from "../../src/codex/auth-api"; +import { MAIN_CODEX_ACCOUNT_ID, MainAccountTokenRefreshError } from "../../src/codex/main-account"; +import { NativeProfileError } from "../../src/codex/native-profile-types"; +import { fallbackCodexAccountLogLabel } from "../../src/codex/account-label"; +import * as authContextModule from "../../src/codex/auth-context"; import { releaseCodexAuthContextProbeLease, resolveCodexAuthContext, -} from "../src/codex/auth-context"; -import { clearUpstreamHostHealth } from "../src/codex/upstream-host-health"; -import { supportsNativeResponsesCompactEndpoint } from "../src/providers/openai-tiers"; -import type { RequestLogContext } from "../src/server/request-log"; -import { acquireNativeMainProfileDrain, tryAdmitTurn } from "../src/server/lifecycle"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/codex/auth-context"; +import { clearUpstreamHostHealth } from "../../src/codex/upstream-host-health"; +import { supportsNativeResponsesCompactEndpoint } from "../../src/providers/openai-tiers"; +import type { RequestLogContext } from "../../src/server/request-log"; +import { acquireNativeMainProfileDrain, tryAdmitTurn } from "../../src/server/lifecycle"; +import type { OcxConfig, OcxProviderConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const originalFetch = globalThis.fetch; diff --git a/tests/responses-compaction.test.ts b/tests/responses/responses-compaction.test.ts similarity index 96% rename from tests/responses-compaction.test.ts rename to tests/responses/responses-compaction.test.ts index 1f1ea9b25f..631ff48e2b 100644 --- a/tests/responses-compaction.test.ts +++ b/tests/responses/responses-compaction.test.ts @@ -1,9 +1,9 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../src/adapters/openai-responses"; -import { createTranslatorBudget } from "../src/lib/translator-budget"; -import { CODEX_FORWARD_BASE_URL } from "../src/providers/openai-tiers"; -import { parseRequest } from "../src/responses/parser"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; +import { createTranslatorBudget } from "../../src/lib/translator-budget"; +import { CODEX_FORWARD_BASE_URL } from "../../src/providers/openai-tiers"; +import { parseRequest } from "../../src/responses/parser"; import { COMPACT_PROMPT, OPAQUE_COMPACTION_NOTE, @@ -12,9 +12,9 @@ import { decodeCompactionSummary, encodeCompactionSummary, extractCompactUserMessages, -} from "../src/responses/compaction"; -import type { AdapterEvent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/responses/compaction"; +import type { AdapterEvent } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createResponsesPassthroughAdapter = (...args: Parameters) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); diff --git a/tests/responses-context-overflow.test.ts b/tests/responses/responses-context-overflow.test.ts similarity index 96% rename from tests/responses-context-overflow.test.ts rename to tests/responses/responses-context-overflow.test.ts index bf5b1c2ba2..d67800e04b 100644 --- a/tests/responses-context-overflow.test.ts +++ b/tests/responses/responses-context-overflow.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 { PROVIDER_INPUT_TOO_LARGE_MESSAGE } from "../src/server/responses/context-overflow"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { saveConfig } from "../../src/config"; +import { startServer } from "../../src/server"; +import { PROVIDER_INPUT_TOO_LARGE_MESSAGE } from "../../src/server/responses/context-overflow"; +import type { OcxConfig, OcxProviderConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; let testDir = ""; let previousOcxHome: string | undefined; diff --git a/tests/responses-custom-tool-guidance.test.ts b/tests/responses/responses-custom-tool-guidance.test.ts similarity index 94% rename from tests/responses-custom-tool-guidance.test.ts rename to tests/responses/responses-custom-tool-guidance.test.ts index f6c88cd7c5..e5e2516fb3 100644 --- a/tests/responses-custom-tool-guidance.test.ts +++ b/tests/responses/responses-custom-tool-guidance.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { parseRequest } from "../src/responses/parser"; -import type { OcxTool } from "../src/types"; +import { parseRequest } from "../../src/responses/parser"; +import type { OcxTool } from "../../src/types"; function inputDescription(tool: OcxTool | undefined): string | undefined { const properties = tool?.parameters.properties; diff --git a/tests/responses-custom-tool-repair.test.ts b/tests/responses/responses-custom-tool-repair.test.ts similarity index 99% rename from tests/responses-custom-tool-repair.test.ts rename to tests/responses/responses-custom-tool-repair.test.ts index 6c0394be2c..ac5995d912 100644 --- a/tests/responses-custom-tool-repair.test.ts +++ b/tests/responses/responses-custom-tool-repair.test.ts @@ -3,12 +3,12 @@ import { collectRoutedCustomToolNames, restoreRoutedCustomCallsInJson, rewriteRoutedCustomToolsForUpstream, -} from "../src/responses/custom-tool-compat"; -import { compileCodeModeHelperInput } from "../src/responses/code-mode-helper-compat"; -import { createRoutedCustomToolRestoreBlockRewrite } from "../src/server/responses-custom-tool-repair"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/responses/custom-tool-compat"; +import { compileCodeModeHelperInput } from "../../src/responses/code-mode-helper-compat"; +import { createRoutedCustomToolRestoreBlockRewrite } from "../../src/server/responses-custom-tool-repair"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; function dataPayload(block: string): Record { const line = block.split(/\r?\n/).find(entry => entry.startsWith("data:")); diff --git a/tests/responses-fetch-helpers-boundary.test.ts b/tests/responses/responses-fetch-helpers-boundary.test.ts similarity index 97% rename from tests/responses-fetch-helpers-boundary.test.ts rename to tests/responses/responses-fetch-helpers-boundary.test.ts index fc4c2e2fb3..55130f57cf 100644 --- a/tests/responses-fetch-helpers-boundary.test.ts +++ b/tests/responses/responses-fetch-helpers-boundary.test.ts @@ -3,9 +3,10 @@ import { readFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { createScanner, LanguageVariant, SyntaxKind } from "typescript/unstable/ast"; -import { fetchWithHeaderTimeout, storedPoolReplayDispatchNotifier } from "../src/server/responses/fetch-helpers"; +import { fetchWithHeaderTimeout, storedPoolReplayDispatchNotifier } from "../../src/server/responses/fetch-helpers"; +import { repoRoot as resolveRepoRoot } from "../helpers/repo-root"; -const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const repoRoot = resolveRepoRoot(); const helperPath = resolve(repoRoot, "src/server/responses/fetch-helpers.ts"); interface RuntimeImportScan { diff --git a/tests/responses-field-backfill.test.ts b/tests/responses/responses-field-backfill.test.ts similarity index 99% rename from tests/responses-field-backfill.test.ts rename to tests/responses/responses-field-backfill.test.ts index 8e7f33666d..289242dead 100644 --- a/tests/responses-field-backfill.test.ts +++ b/tests/responses/responses-field-backfill.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; import { createResponsesFieldBackfillBlockRewrite, backfillResponsesFieldsJson, -} from "../src/server/responses/responses-field-backfill"; +} from "../../src/server/responses/responses-field-backfill"; const rewrite = createResponsesFieldBackfillBlockRewrite(); diff --git a/tests/responses-forward-dangling-call.test.ts b/tests/responses/responses-forward-dangling-call.test.ts similarity index 90% rename from tests/responses-forward-dangling-call.test.ts rename to tests/responses/responses-forward-dangling-call.test.ts index dbc52a8288..5c6dd8b034 100644 --- a/tests/responses-forward-dangling-call.test.ts +++ b/tests/responses/responses-forward-dangling-call.test.ts @@ -1,15 +1,15 @@ /** * Forward-mode replay keeps the prior fail-closed behavior for orphaned tool CALLS. * - * The stateless-wire repair (tests/responses-stateless-dangling-call-repair.test.ts) + * The stateless-wire repair (tests/responses/responses-stateless-dangling-call-repair.test.ts) * synthesizes placeholder outputs only when statelessResponses is true. A forward-auth * provider (ChatGPT backend replay) must NOT synthesize: dangling calls stay exactly as * the client sent them so the strict upstream decides, mirroring the pre-fix contract. */ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../src/adapters/openai-responses"; -import { createTranslatorBudget } from "../src/lib/translator-budget"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; +import { createTranslatorBudget } from "../../src/lib/translator-budget"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createResponsesPassthroughAdapter = (...args: Parameters) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); diff --git a/tests/responses-forward-posit-continuation.test.ts b/tests/responses/responses-forward-posit-continuation.test.ts similarity index 95% rename from tests/responses-forward-posit-continuation.test.ts rename to tests/responses/responses-forward-posit-continuation.test.ts index 59b7e71c11..104e66ccee 100644 --- a/tests/responses-forward-posit-continuation.test.ts +++ b/tests/responses/responses-forward-posit-continuation.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createProductionAdapter } from "../src/adapters/openai-responses"; -import { parseRequest } from "../src/responses/parser"; -import type { OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createResponsesPassthroughAdapter as createProductionAdapter } from "../../src/adapters/openai-responses"; +import { parseRequest } from "../../src/responses/parser"; +import type { OcxProviderConfig } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createAdapter = (provider: OcxProviderConfig) => withTestTranslatorBudget(createProductionAdapter(provider)); diff --git a/tests/responses-forward-prompt-envelope.test.ts b/tests/responses/responses-forward-prompt-envelope.test.ts similarity index 96% rename from tests/responses-forward-prompt-envelope.test.ts rename to tests/responses/responses-forward-prompt-envelope.test.ts index 5df097f064..6f0b078818 100644 --- a/tests/responses-forward-prompt-envelope.test.ts +++ b/tests/responses/responses-forward-prompt-envelope.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createProductionAdapter } from "../src/adapters/openai-responses"; -import type { OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createResponsesPassthroughAdapter as createProductionAdapter } from "../../src/adapters/openai-responses"; +import type { OcxProviderConfig } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createAdapter = (provider: OcxProviderConfig) => withTestTranslatorBudget(createProductionAdapter(provider)); diff --git a/tests/responses-image-gen-repair.test.ts b/tests/responses/responses-image-gen-repair.test.ts similarity index 97% rename from tests/responses-image-gen-repair.test.ts rename to tests/responses/responses-image-gen-repair.test.ts index 9ed1e1f742..f5f358081e 100644 --- a/tests/responses-image-gen-repair.test.ts +++ b/tests/responses/responses-image-gen-repair.test.ts @@ -3,11 +3,11 @@ import { imageGenToolCallAliases, relaySseWithImageGenCallRestore as relaySseWithImageGenCallRestoreProduction, restoreImageGenCallsInJson, -} from "../src/server/responses-image-gen-repair"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; -import { finalizeTranslatorBudgetResponse } from "../src/lib/translator-budget"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/server/responses-image-gen-repair"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; +import { finalizeTranslatorBudgetResponse } from "../../src/lib/translator-budget"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; function relaySseWithImageGenCallRestore( body: ReadableStream, diff --git a/tests/responses-inbound-store-default.test.ts b/tests/responses/responses-inbound-store-default.test.ts similarity index 94% rename from tests/responses-inbound-store-default.test.ts rename to tests/responses/responses-inbound-store-default.test.ts index 85038187d1..0289e5b510 100644 --- a/tests/responses-inbound-store-default.test.ts +++ b/tests/responses/responses-inbound-store-default.test.ts @@ -11,13 +11,13 @@ * negatives, and explicit-value survival on both sides. * * End-to-end cases assert the captured upstream request body — the externally - * observable payload. Pattern mirrors tests/responses-compaction-routing.test.ts + * observable payload. Pattern mirrors tests/responses/responses-compaction-routing.test.ts * and tests/github-copilot-wire-defaults.test.ts. */ import { afterEach, describe, expect, test } from "bun:test"; -import { CODEX_FORWARD_BASE_URL } from "../src/providers/openai-tiers"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig, OcxProviderConfig } from "../src/types"; +import { CODEX_FORWARD_BASE_URL } from "../../src/providers/openai-tiers"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig, OcxProviderConfig } from "../../src/types"; function providerConfig(overrides: Partial = {}): OcxConfig { return { diff --git a/tests/responses-item-id-repair.test.ts b/tests/responses/responses-item-id-repair.test.ts similarity index 97% rename from tests/responses-item-id-repair.test.ts rename to tests/responses/responses-item-id-repair.test.ts index e708e6eb3a..33ffd452ba 100644 --- a/tests/responses-item-id-repair.test.ts +++ b/tests/responses/responses-item-id-repair.test.ts @@ -2,9 +2,9 @@ import { describe, expect, test } from "bun:test"; import { hasResponsesItemIdRepair, relaySseWithResponsesItemIdRepair as relaySseWithResponsesItemIdRepairProduction, -} from "../src/server/responses-item-id-repair"; -import { finalizeTranslatorBudgetResponse } from "../src/lib/translator-budget"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/server/responses-item-id-repair"; +import { finalizeTranslatorBudgetResponse } from "../../src/lib/translator-budget"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; function relaySseWithResponsesItemIdRepair( body: ReadableStream, diff --git a/tests/responses-json-events.test.ts b/tests/responses/responses-json-events.test.ts similarity index 98% rename from tests/responses-json-events.test.ts rename to tests/responses/responses-json-events.test.ts index 9e27ffc5cc..60623854f4 100644 --- a/tests/responses-json-events.test.ts +++ b/tests/responses/responses-json-events.test.ts @@ -4,7 +4,7 @@ import { responsesJsonEventSequence, responsesJsonToSseBody, responsesJsonToSseStream, -} from "../src/server/responses-json-events"; +} from "../../src/server/responses-json-events"; describe("responsesJsonEventSequence", () => { test("completed: created → per-item done → completed terminal", () => { diff --git a/tests/responses-native-main-refresh.test.ts b/tests/responses/responses-native-main-refresh.test.ts similarity index 94% rename from tests/responses-native-main-refresh.test.ts rename to tests/responses/responses-native-main-refresh.test.ts index 87fecf1067..3b78ff6402 100644 --- a/tests/responses-native-main-refresh.test.ts +++ b/tests/responses/responses-native-main-refresh.test.ts @@ -2,17 +2,17 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { clearAccountNeedsReauth } from "../src/codex/auth-api"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; -import { isAccountNeedsReauth } from "../src/codex/account-runtime-state"; -import { getValidMainAccountToken, MAIN_CODEX_ACCOUNT_ID } from "../src/codex/main-account"; -import { withNativeMainSharedClaim } from "../src/codex/native-main-claim"; -import type { NativeProfileContext } from "../src/codex/native-profile-store"; -import { clearCodexUpstreamHealth, clearThreadAccountMap } from "../src/codex/routing"; -import { handleResponses, handleResponsesCompact } from "../src/server/responses"; -import type { RequestLogContext } from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { clearAccountNeedsReauth } from "../../src/codex/auth-api"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; +import { isAccountNeedsReauth } from "../../src/codex/account-runtime-state"; +import { getValidMainAccountToken, MAIN_CODEX_ACCOUNT_ID } from "../../src/codex/main-account"; +import { withNativeMainSharedClaim } from "../../src/codex/native-main-claim"; +import type { NativeProfileContext } from "../../src/codex/native-profile-store"; +import { clearCodexUpstreamHealth, clearThreadAccountMap } from "../../src/codex/routing"; +import { handleResponses, handleResponsesCompact } from "../../src/server/responses"; +import type { RequestLogContext } from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const originalFetch = globalThis.fetch; let home = ""; diff --git a/tests/responses-opaque-blob-recovery.test.ts b/tests/responses/responses-opaque-blob-recovery.test.ts similarity index 97% rename from tests/responses-opaque-blob-recovery.test.ts rename to tests/responses/responses-opaque-blob-recovery.test.ts index 277561ba22..967909c154 100644 --- a/tests/responses-opaque-blob-recovery.test.ts +++ b/tests/responses/responses-opaque-blob-recovery.test.ts @@ -2,19 +2,19 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { ADAPTER_REGISTRY } from "../src/adapters/registry"; -import { clearReasoningReplayCacheForTests } from "../src/responses/reasoning-replay-cache"; -import { OPAQUE_COMPACTION_NOTE } from "../src/responses/compaction"; -import { resetThoughtSignatureReplayForTests } from "../src/responses/thought-signature-replay"; -import * as authContextModule from "../src/codex/auth-context"; -import { saveCodexAccountCredential } from "../src/codex/account-store"; +import { ADAPTER_REGISTRY } from "../../src/adapters/registry"; +import { clearReasoningReplayCacheForTests } from "../../src/responses/reasoning-replay-cache"; +import { OPAQUE_COMPACTION_NOTE } from "../../src/responses/compaction"; +import { resetThoughtSignatureReplayForTests } from "../../src/responses/thought-signature-replay"; +import * as authContextModule from "../../src/codex/auth-context"; +import { saveCodexAccountCredential } from "../../src/codex/account-store"; import { handleResponses, shouldAttemptOpaqueBlobRecovery, -} from "../src/server/responses/core"; -import type { RequestLogContext } from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/server/responses/core"; +import type { RequestLogContext } from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const originalFetch = globalThis.fetch; const originalOpenCodexHome = process.env.OPENCODEX_HOME; diff --git a/tests/responses-parser-agent-message.test.ts b/tests/responses/responses-parser-agent-message.test.ts similarity index 98% rename from tests/responses-parser-agent-message.test.ts rename to tests/responses/responses-parser-agent-message.test.ts index 683005de5d..8a52b7bbf7 100644 --- a/tests/responses-parser-agent-message.test.ts +++ b/tests/responses/responses-parser-agent-message.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { parseRequest } from "../src/responses/parser"; +import { parseRequest } from "../../src/responses/parser"; describe("Responses parser agent_message boundaries", () => { test("keeps agent_message between separate assistant reasoning turns", () => { diff --git a/tests/responses-parser-malformed-content.test.ts b/tests/responses/responses-parser-malformed-content.test.ts similarity index 96% rename from tests/responses-parser-malformed-content.test.ts rename to tests/responses/responses-parser-malformed-content.test.ts index 79545c1b6d..08a0a50972 100644 --- a/tests/responses-parser-malformed-content.test.ts +++ b/tests/responses/responses-parser-malformed-content.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { parseRequest } from "../src/responses/parser"; -import { createGoogleAdapter } from "../src/adapters/google"; -import { createAnthropicAdapter } from "../src/adapters/anthropic"; -import type { OcxProviderConfig } from "../src/types"; +import { parseRequest } from "../../src/responses/parser"; +import { createGoogleAdapter } from "../../src/adapters/google"; +import { createAnthropicAdapter } from "../../src/adapters/anthropic"; +import type { OcxProviderConfig } from "../../src/types"; // A message item whose content blocks do not match their strict schema fails // `userMessageItemSchema` / `assistantMessageItemSchema` and falls through to diff --git a/tests/responses-parser.test.ts b/tests/responses/responses-parser.test.ts similarity index 99% rename from tests/responses-parser.test.ts rename to tests/responses/responses-parser.test.ts index 2b53d2272c..1d0c46a05c 100644 --- a/tests/responses-parser.test.ts +++ b/tests/responses/responses-parser.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test"; -import { buildResponseJSON } from "../src/bridge"; -import { parseRequest } from "../src/responses/parser"; -import { buildToolBridgeMaps } from "../src/server/responses"; +import { buildResponseJSON } from "../../src/bridge"; +import { parseRequest } from "../../src/responses/parser"; +import { buildToolBridgeMaps } from "../../src/server/responses"; describe("Responses parser", () => { test("normalizes function tool schemas to an object root without corrupting valid schemas (#745)", () => { diff --git a/tests/responses-pool-401-refresh.test.ts b/tests/responses/responses-pool-401-refresh.test.ts similarity index 98% rename from tests/responses-pool-401-refresh.test.ts rename to tests/responses/responses-pool-401-refresh.test.ts index 194fb3b2d5..197191c92b 100644 --- a/tests/responses-pool-401-refresh.test.ts +++ b/tests/responses/responses-pool-401-refresh.test.ts @@ -3,22 +3,22 @@ import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { createHash } from "node:crypto"; -import { clearAccountNeedsReauth, isAccountNeedsReauth } from "../src/codex/auth-api"; +import { clearAccountNeedsReauth, isAccountNeedsReauth } from "../../src/codex/auth-api"; import { clearCodexUpstreamHealth, clearThreadAccountMap, resolveCodexAccountForThreadDetailed, -} from "../src/codex/routing"; -import { handleResponses, handleResponsesCompact } from "../src/server/responses"; -import { clearCompactHandoffRoutesForTests } from "../src/server/responses/compact"; +} from "../../src/codex/routing"; +import { handleResponses, handleResponsesCompact } from "../../src/server/responses"; +import { clearCompactHandoffRoutesForTests } from "../../src/server/responses/compact"; import { REQUEST_PACING_MAX_QUEUE_DEPTH, resetProviderRequestPacingForTest, setProviderRequestPacingLimitsForTest, -} from "../src/providers/request-pacing"; -import type { RequestLogContext } from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/providers/request-pacing"; +import type { RequestLogContext } from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** * #2887: an ordinary stored pool account holding a TIME-VALID access token that upstream @@ -550,7 +550,7 @@ describe("ordinary pool 401 refresh and replay (#2887)", () => { // Two requests can be in flight while an operator re-authenticates. The slower one comes // back 401 against a credential that no longer exists; without the generation fence it // takes the fresh credential out of rotation and sweeps affinities that belong to it. - const { recordCodexUpstreamOutcome } = await import("../src/codex/routing"); + const { recordCodexUpstreamOutcome } = await import("../../src/codex/routing"); // generation 3 is what the stored fixture was written at; 4 is the replacement. writeStoredAccount({ @@ -577,7 +577,7 @@ describe("ordinary pool 401 refresh and replay (#2887)", () => { // spent. The interesting case — a replacement landing WHILE the forced refresh runs — is // covered at the store level, where the handoff's `selfRefreshed` gate is observable // without racing the endpoint. - const { saveCodexAccountCredential } = await import("../src/codex/account-store"); + const { saveCodexAccountCredential } = await import("../../src/codex/account-store"); const harness = installHarness({ refresh: () => { throw new Error("the token endpoint must not be reached in this scenario"); diff --git a/tests/responses-reasoning-summary-passthrough.test.ts b/tests/responses/responses-reasoning-summary-passthrough.test.ts similarity index 95% rename from tests/responses-reasoning-summary-passthrough.test.ts rename to tests/responses/responses-reasoning-summary-passthrough.test.ts index 1327e0f759..5912221354 100644 --- a/tests/responses-reasoning-summary-passthrough.test.ts +++ b/tests/responses/responses-reasoning-summary-passthrough.test.ts @@ -1,8 +1,8 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { providerConfigSeed } from "../src/providers/derive"; -import { getProviderRegistryEntry } from "../src/providers/registry"; -import { handleResponses } from "../src/server/responses/core"; -import type { OcxConfig } from "../src/types"; +import { providerConfigSeed } from "../../src/providers/derive"; +import { getProviderRegistryEntry } from "../../src/providers/registry"; +import { handleResponses } from "../../src/server/responses/core"; +import type { OcxConfig } from "../../src/types"; /** * The passthrough relay for DeepSeek's native /responses endpoint emits diff --git a/tests/responses-reasoning-summary-rewrite.test.ts b/tests/responses/responses-reasoning-summary-rewrite.test.ts similarity index 99% rename from tests/responses-reasoning-summary-rewrite.test.ts rename to tests/responses/responses-reasoning-summary-rewrite.test.ts index 4ba42acf91..32940a24e7 100644 --- a/tests/responses-reasoning-summary-rewrite.test.ts +++ b/tests/responses/responses-reasoning-summary-rewrite.test.ts @@ -4,7 +4,7 @@ import { routeUsesContentChannelReasoning, rewriteReasoningSummaryInJson, rewriteReasoningSummaryInJsonString, -} from "../src/server/responses-reasoning-summary-rewrite"; +} from "../../src/server/responses-reasoning-summary-rewrite"; const rewrite = createReasoningSummaryChannelPayloadRewrite(); diff --git a/tests/responses-routed-web-search-fields.test.ts b/tests/responses/responses-routed-web-search-fields.test.ts similarity index 96% rename from tests/responses-routed-web-search-fields.test.ts rename to tests/responses/responses-routed-web-search-fields.test.ts index a2c2cb4136..dd5581925a 100644 --- a/tests/responses-routed-web-search-fields.test.ts +++ b/tests/responses/responses-routed-web-search-fields.test.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction, stripOpenAiOnlyWebSearchFields } from "../src/adapters/openai-responses"; -import { enrichProviderFromRegistry, providerConfigSeed } from "../src/providers/derive"; -import { getProviderRegistryEntry } from "../src/providers/registry"; -import { resolveProviderTransport } from "../src/providers/xai-transport"; -import { routedProviderConfig } from "../src/router"; -import type { OcxProviderConfig } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction, stripOpenAiOnlyWebSearchFields } from "../../src/adapters/openai-responses"; +import { enrichProviderFromRegistry, providerConfigSeed } from "../../src/providers/derive"; +import { getProviderRegistryEntry } from "../../src/providers/registry"; +import { resolveProviderTransport } from "../../src/providers/xai-transport"; +import { routedProviderConfig } from "../../src/router"; +import type { OcxProviderConfig } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createResponsesPassthroughAdapter = (...args: Parameters) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); diff --git a/tests/responses-self-named-namespace-scrub.test.ts b/tests/responses/responses-self-named-namespace-scrub.test.ts similarity index 98% rename from tests/responses-self-named-namespace-scrub.test.ts rename to tests/responses/responses-self-named-namespace-scrub.test.ts index 47cf6840f7..55dbf96def 100644 --- a/tests/responses-self-named-namespace-scrub.test.ts +++ b/tests/responses/responses-self-named-namespace-scrub.test.ts @@ -8,9 +8,9 @@ * the belt to that suspender on the client-facing passthrough (SSE and bounded JSON). */ import { afterEach, expect, test } from "bun:test"; -import { handleResponses } from "../src/server/responses"; -import { scrubSelfNamedToolCallNamespace } from "../src/server/responses-self-named-namespace-scrub"; -import type { OcxConfig } from "../src/types"; +import { handleResponses } from "../../src/server/responses"; +import { scrubSelfNamedToolCallNamespace } from "../../src/server/responses-self-named-namespace-scrub"; +import type { OcxConfig } from "../../src/types"; const originalFetch = globalThis.fetch; afterEach(() => { globalThis.fetch = originalFetch; }); diff --git a/tests/responses-shadow-intercept.test.ts b/tests/responses/responses-shadow-intercept.test.ts similarity index 96% rename from tests/responses-shadow-intercept.test.ts rename to tests/responses/responses-shadow-intercept.test.ts index 8d6379c295..3f7e12eb38 100644 --- a/tests/responses-shadow-intercept.test.ts +++ b/tests/responses/responses-shadow-intercept.test.ts @@ -7,13 +7,13 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdtempSync} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { handleResponses, isShadowSourceModel } from "../src/server/responses"; -import { shouldInterceptShadowCall } from "../src/lib/shadow-call"; -import { handleManagementAPI } from "../src/server/management-api"; -import type { RequestLogContext } from "../src/server/request-log"; -import type { OcxConfig } from "../src/types"; -import { catalogConvergenceFactory } from "./helpers/catalog-convergence"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +import { handleResponses, isShadowSourceModel } from "../../src/server/responses"; +import { shouldInterceptShadowCall } from "../../src/lib/shadow-call"; +import { handleManagementAPI } from "../../src/server/management-api"; +import type { RequestLogContext } from "../../src/server/request-log"; +import type { OcxConfig } from "../../src/types"; +import { catalogConvergenceFactory } from "../helpers/catalog-convergence"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const originalFetch = globalThis.fetch; diff --git a/tests/responses-snapshot-repair-server.test.ts b/tests/responses/responses-snapshot-repair-server.test.ts similarity index 94% rename from tests/responses-snapshot-repair-server.test.ts rename to tests/responses/responses-snapshot-repair-server.test.ts index 6e1f60ed8f..57916e8f4e 100644 --- a/tests/responses-snapshot-repair-server.test.ts +++ b/tests/responses/responses-snapshot-repair-server.test.ts @@ -2,13 +2,13 @@ import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from 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 { handleResponses } from "../src/server/responses"; -import { isEagerRelaySseResponse } from "../src/server/relay"; -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 { handleResponses } from "../../src/server/responses"; +import { isEagerRelaySseResponse } from "../../src/server/relay"; +import type { OcxConfig } from "../../src/types"; +import { installIsolatedCodexHome, type IsolatedCodexHome } from "../helpers/isolated-codex-home"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; setDefaultTimeout(30_000); diff --git a/tests/responses-snapshot-repair.test.ts b/tests/responses/responses-snapshot-repair.test.ts similarity index 99% rename from tests/responses-snapshot-repair.test.ts rename to tests/responses/responses-snapshot-repair.test.ts index 8bc019ac70..0231fdb77f 100644 --- a/tests/responses-snapshot-repair.test.ts +++ b/tests/responses/responses-snapshot-repair.test.ts @@ -3,13 +3,13 @@ import { createResponsesSnapshotBlockRewrite, hasResponsesSnapshotRepair, repairResponsesSnapshotJson, -} from "../src/server/responses-snapshot-repair"; +} from "../../src/server/responses-snapshot-repair"; import { composeSseBlockRewrites, payloadRewriteAsBlockRewrite, relaySseWithBlockRewrite, -} from "../src/server/sse-payload-rewrite"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/server/sse-payload-rewrite"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; function dataBlock(payload: unknown): string { diff --git a/tests/responses-state-write-amplification.test.ts b/tests/responses/responses-state-write-amplification.test.ts similarity index 99% rename from tests/responses-state-write-amplification.test.ts rename to tests/responses/responses-state-write-amplification.test.ts index 4bf720e548..9c339ee69b 100644 --- a/tests/responses-state-write-amplification.test.ts +++ b/tests/responses/responses-state-write-amplification.test.ts @@ -17,8 +17,8 @@ import { flushResponseState, rememberResponseState, setResponseStateByteCapForTests, -} from "../src/responses/state"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/responses/state"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; function remember(id: string, text: string): void { rememberResponseState( diff --git a/tests/responses-state.test.ts b/tests/responses/responses-state.test.ts similarity index 99% rename from tests/responses-state.test.ts rename to tests/responses/responses-state.test.ts index 44c10db4e0..1217bbbe25 100644 --- a/tests/responses-state.test.ts +++ b/tests/responses/responses-state.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"; -import { BULK_DURABLE_IO_BUDGET_MS } from "./helpers/test-budget"; -import { findDeadPid } from "./helpers/dead-pid"; +import { BULK_DURABLE_IO_BUDGET_MS } from "../helpers/test-budget"; +import { findDeadPid } from "../helpers/dead-pid"; import { closeSync, existsSync, @@ -18,12 +18,12 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { buildResponseJSON } from "../src/bridge"; -import { createCursorRequest } from "../src/adapters/cursor/request-builder"; -import { createCursorContextUsageTracker } from "../src/adapters/cursor/protobuf-events"; -import { parseRequest } from "../src/responses/parser"; -import { mergeProviderContinuationPayload } from "../src/responses/provider-continuation"; -import { createSseInspector } from "../src/server/relay"; +import { buildResponseJSON } from "../../src/bridge"; +import { createCursorRequest } from "../../src/adapters/cursor/request-builder"; +import { createCursorContextUsageTracker } from "../../src/adapters/cursor/protobuf-events"; +import { parseRequest } from "../../src/responses/parser"; +import { mergeProviderContinuationPayload } from "../../src/responses/provider-continuation"; +import { createSseInspector } from "../../src/server/relay"; import { clearResponseStateForTests, clearResponseStateMemoryForTests, @@ -55,7 +55,7 @@ import { getStoredResponseBytesForTests, flushPendingResponseSpillsForTests, pendingResponseSpillMetricsForTests, -} from "../src/responses/state"; +} from "../../src/responses/state"; import { RESPONSE_SPILL_DIR_NAME, readResponseSpill, @@ -66,10 +66,10 @@ import { setResponseSpillPayloadCapForTests, setSpillIoForTest, writeResponseSpillDurably, -} from "../src/responses/spill-store"; -import { adapterNeedsForcedContinuation, injectDeveloperMessage } from "../src/server/responses"; -import { watchdogMs } from "./helpers/ci-watchdog"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/responses/spill-store"; +import { adapterNeedsForcedContinuation, injectDeveloperMessage } from "../../src/server/responses"; +import { watchdogMs } from "../helpers/ci-watchdog"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; /** * Windows without Developer Mode or admin cannot create a file symlink (EPERM). @@ -99,12 +99,13 @@ import { setPlatformForTests, setStatForTests, timedOutSecretPathCountForTests, -} from "../src/lib/windows-secret-acl"; +} from "../../src/lib/windows-secret-acl"; import { resetWindowsPrincipalForTests, setAsyncWindowsPrincipalRunnerForTests, setWindowsPrincipalRunnerForTests, -} from "../src/lib/windows-user-principal"; +} from "../../src/lib/windows-user-principal"; +import { helperPath, repoRoot } from "../helpers/repo-root"; /** * Windows-lane fixture. Forcing the platform alone left the principal lookup real: on a @@ -197,10 +198,10 @@ async function runShutdownBudgetChild( const timeoutMs = watchdogMs(3_000); const child = Bun.spawn([ process.execPath, - join(import.meta.dir, "helpers", "responses-state-shutdown-budget-child.ts"), + helperPath("responses-state-shutdown-budget-child.ts"), scenario, ], { - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), env: { ...process.env }, stdout: "pipe", stderr: "pipe", @@ -236,10 +237,10 @@ async function runNeverSettlingAclChild( const timeoutMs = watchdogMs(1_500); const child = Bun.spawn([ process.execPath, - join(import.meta.dir, "helpers", "responses-state-never-settling-acl-child.ts"), + helperPath("responses-state-never-settling-acl-child.ts"), mode, ], { - cwd: join(import.meta.dir, ".."), + cwd: repoRoot(), env: { ...process.env }, stdout: "pipe", stderr: "pipe", diff --git a/tests/responses-stateless-dangling-call-repair.test.ts b/tests/responses/responses-stateless-dangling-call-repair.test.ts similarity index 98% rename from tests/responses-stateless-dangling-call-repair.test.ts rename to tests/responses/responses-stateless-dangling-call-repair.test.ts index bad70e0935..13b30573d9 100644 --- a/tests/responses-stateless-dangling-call-repair.test.ts +++ b/tests/responses/responses-stateless-dangling-call-repair.test.ts @@ -9,10 +9,10 @@ * mirrored repair: synthesize an honest placeholder output right after the orphaned call. */ import { afterEach, describe, expect, test } from "bun:test"; -import { providerConfigSeed } from "../src/providers/derive"; -import { getProviderRegistryEntry } from "../src/providers/registry"; -import { handleResponses } from "../src/server/responses/core"; -import type { OcxConfig } from "../src/types"; +import { providerConfigSeed } from "../../src/providers/derive"; +import { getProviderRegistryEntry } from "../../src/providers/registry"; +import { handleResponses } from "../../src/server/responses/core"; +import type { OcxConfig } from "../../src/types"; const MODEL = "deepseek-v4-flash"; diff --git a/tests/responses-stream-tool-events.test.ts b/tests/responses/responses-stream-tool-events.test.ts similarity index 98% rename from tests/responses-stream-tool-events.test.ts rename to tests/responses/responses-stream-tool-events.test.ts index a5e5838043..dea4b7c0f4 100644 --- a/tests/responses-stream-tool-events.test.ts +++ b/tests/responses/responses-stream-tool-events.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; async function* replay(events: AdapterEvent[]): AsyncGenerator { for (const event of events) yield event; diff --git a/tests/responses-terminal-repair.test.ts b/tests/responses/responses-terminal-repair.test.ts similarity index 98% rename from tests/responses-terminal-repair.test.ts rename to tests/responses/responses-terminal-repair.test.ts index b982357ac5..25ebebf207 100644 --- a/tests/responses-terminal-repair.test.ts +++ b/tests/responses/responses-terminal-repair.test.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from "bun:test"; -import type { ResponsesTerminalRepairPolicy } from "../src/providers/registry"; -import { relaySseWithFailedTail } from "../src/server/relay"; +import type { ResponsesTerminalRepairPolicy } from "../../src/providers/registry"; +import { relaySseWithFailedTail } from "../../src/server/relay"; import { relayResponsesSseWithTerminalRepair, type ResponsesTerminalRepairScheduler, -} from "../src/server/responses-terminal-repair"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/server/responses-terminal-repair"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; const encoder = new TextEncoder(); const decoder = new TextDecoder(); diff --git a/tests/responses-tool-conformance.test.ts b/tests/responses/responses-tool-conformance.test.ts similarity index 98% rename from tests/responses-tool-conformance.test.ts rename to tests/responses/responses-tool-conformance.test.ts index fd9763cbbe..1d540492a5 100644 --- a/tests/responses-tool-conformance.test.ts +++ b/tests/responses/responses-tool-conformance.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "bun:test"; -import { parseRequest } from "../src/responses/parser"; -import { cursorRequestUsesCodeMode } from "../src/adapters/cursor/tool-definitions"; -import type { AdapterEvent } from "../src/types"; -import { jsonItemTypes, jsonToolItems, streamedView } from "./helpers/responses-conformance"; +import { parseRequest } from "../../src/responses/parser"; +import { cursorRequestUsesCodeMode } from "../../src/adapters/cursor/tool-definitions"; +import type { AdapterEvent } from "../../src/types"; +import { jsonItemTypes, jsonToolItems, streamedView } from "../helpers/responses-conformance"; /** * Responses tool round-trip conformance diff --git a/tests/responses-tool-groups.test.ts b/tests/responses/responses-tool-groups.test.ts similarity index 93% rename from tests/responses-tool-groups.test.ts rename to tests/responses/responses-tool-groups.test.ts index a7a88e4db7..ce3fd0bbc4 100644 --- a/tests/responses-tool-groups.test.ts +++ b/tests/responses/responses-tool-groups.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { collectResponsesToolGroups } from "../src/responses/tool-groups"; +import { collectResponsesToolGroups } from "../../src/responses/tool-groups"; describe("Responses tool-group collection", () => { test("collects top-level and Responses Lite tools in wire order", () => { diff --git a/tests/responses-tool-search-repair.test.ts b/tests/responses/responses-tool-search-repair.test.ts similarity index 98% rename from tests/responses-tool-search-repair.test.ts rename to tests/responses/responses-tool-search-repair.test.ts index 0ebf5bae15..d415fff16e 100644 --- a/tests/responses-tool-search-repair.test.ts +++ b/tests/responses/responses-tool-search-repair.test.ts @@ -1,13 +1,13 @@ import { describe, expect, test } from "bun:test"; -import { isTranslatorBudgetExceededError } from "../src/lib/translator-budget"; +import { isTranslatorBudgetExceededError } from "../../src/lib/translator-budget"; import { restoreRoutedToolSearchCallsInJson, rewriteRoutedToolSearchForUpstream, -} from "../src/responses/tool-search-compat"; -import { createRoutedToolSearchRestoreBlockRewrite } from "../src/server/responses-tool-search-repair"; -import { handleResponses } from "../src/server/responses"; -import type { OcxConfig } from "../src/types"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/responses/tool-search-compat"; +import { createRoutedToolSearchRestoreBlockRewrite } from "../../src/server/responses-tool-search-repair"; +import { handleResponses } from "../../src/server/responses"; +import type { OcxConfig } from "../../src/types"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; function frame(event: string, payload: Record): string { return `event: ${event}\ndata: ${JSON.stringify({ type: event, ...payload })}`; diff --git a/tests/responses-undeclared-tool-guard.test.ts b/tests/responses/responses-undeclared-tool-guard.test.ts similarity index 99% rename from tests/responses-undeclared-tool-guard.test.ts rename to tests/responses/responses-undeclared-tool-guard.test.ts index 7d9d1d2bee..d9b2b8dc9f 100644 --- a/tests/responses-undeclared-tool-guard.test.ts +++ b/tests/responses/responses-undeclared-tool-guard.test.ts @@ -15,12 +15,12 @@ import { undeclaredToolCallNameInResponse, UNDECLARED_TOOL_CALL_ERROR_CODE, type ProviderExecutedCallType, -} from "../src/server/responses-undeclared-tool-guard"; -import { relaySseWithBlockRewrite } from "../src/server/sse-payload-rewrite"; -import { handleResponses } from "../src/server/responses"; -import { expandPreviousResponseInput } from "../src/responses/state"; -import type { OcxConfig } from "../src/types"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; +} from "../../src/server/responses-undeclared-tool-guard"; +import { relaySseWithBlockRewrite } from "../../src/server/sse-payload-rewrite"; +import { handleResponses } from "../../src/server/responses"; +import { expandPreviousResponseInput } from "../../src/responses/state"; +import type { OcxConfig } from "../../src/types"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; /** One SSE event block without its blank-line delimiter. */ function frame(type: string, payload: Record): string { diff --git a/tests/responses-usage-passthrough.test.ts b/tests/responses/responses-usage-passthrough.test.ts similarity index 95% rename from tests/responses-usage-passthrough.test.ts rename to tests/responses/responses-usage-passthrough.test.ts index f362bd7eb1..19d848fa9b 100644 --- a/tests/responses-usage-passthrough.test.ts +++ b/tests/responses/responses-usage-passthrough.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../src/adapters/openai-responses"; -import { bridgeToResponsesSSE, buildResponseJSON } from "../src/bridge"; -import type { AdapterEvent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; +import { bridgeToResponsesSSE, buildResponseJSON } from "../../src/bridge"; +import type { AdapterEvent } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; const createAdapter = (...args: Parameters) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); @@ -149,7 +149,7 @@ describe("raw usage passthrough (openai/codex#41980 parity)", () => { }); test("empty-completion retry merge keeps the content attempt's raw usage", async () => { - const { mergeUsage } = await import("../src/server/responses/empty-completion-guard"); + const { mergeUsage } = await import("../../src/server/responses/empty-completion-guard"); const first = { inputTokens: 0, outputTokens: 0, rawUsage: { marker: "first" } }; const second = { inputTokens: 3, outputTokens: 2, rawUsage: { subscription: { window: { used_percent: 9 } } } }; const merged = mergeUsage(first, second); diff --git a/tests/sse-client-frame-bounds.test.ts b/tests/responses/sse-client-frame-bounds.test.ts similarity index 97% rename from tests/sse-client-frame-bounds.test.ts rename to tests/responses/sse-client-frame-bounds.test.ts index eaf1979c5c..a48aea4e3a 100644 --- a/tests/sse-client-frame-bounds.test.ts +++ b/tests/responses/sse-client-frame-bounds.test.ts @@ -5,9 +5,9 @@ import { MAX_CLIENT_SSE_FRAME_BYTES, SseFrameCountLimitError, SseFrameTooLargeError, -} from "../src/server/sse-frame-buffer"; -import { relaySseWithFailedTail } from "../src/server/relay"; -import { pumpResponsesSseToWebSocket, type WsData } from "../src/server/ws-bridge"; +} from "../../src/server/sse-frame-buffer"; +import { relaySseWithFailedTail } from "../../src/server/relay"; +import { pumpResponsesSseToWebSocket, type WsData } from "../../src/server/ws-bridge"; const enc = new TextEncoder(); const dec = new TextDecoder(); diff --git a/tests/sse-decoder.test.ts b/tests/responses/sse-decoder.test.ts similarity index 97% rename from tests/sse-decoder.test.ts rename to tests/responses/sse-decoder.test.ts index 7c455b3fcc..efdfc28409 100644 --- a/tests/sse-decoder.test.ts +++ b/tests/responses/sse-decoder.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "bun:test"; -import { decodeServerSentEvents } from "../src/lib/sse-decoder"; +import { decodeServerSentEvents } from "../../src/lib/sse-decoder"; import { TRANSLATOR_MAX_SSE_EVENT_BYTES, TRANSLATOR_MAX_TURN_BYTES, createTranslatorBudget, -} from "../src/lib/translator-budget"; +} from "../../src/lib/translator-budget"; function chunkedStream(chunks: string[]): ReadableStream { const encoder = new TextEncoder(); diff --git a/tests/sse-failed-tail.test.ts b/tests/responses/sse-failed-tail.test.ts similarity index 97% rename from tests/sse-failed-tail.test.ts rename to tests/responses/sse-failed-tail.test.ts index 7be3e288ec..914818e27b 100644 --- a/tests/sse-failed-tail.test.ts +++ b/tests/responses/sse-failed-tail.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test"; -import { relaySseWithFailedTail, relayWithAbort } from "../src/server"; -import { relaySseEagerBounded, type EagerRelayHooks } from "../src/server/relay-eager"; -import { MAX_TAIL_ERROR_MESSAGE_CHARS } from "../src/server/relay"; -import { TranslatorBudgetExceededError } from "../src/lib/translator-budget"; +import { relaySseWithFailedTail, relayWithAbort } from "../../src/server"; +import { relaySseEagerBounded, type EagerRelayHooks } from "../../src/server/relay-eager"; +import { MAX_TAIL_ERROR_MESSAGE_CHARS } from "../../src/server/relay"; +import { TranslatorBudgetExceededError } from "../../src/lib/translator-budget"; const encoder = new TextEncoder(); const decoder = new TextDecoder(); diff --git a/tests/sse-inspector-bounds.test.ts b/tests/responses/sse-inspector-bounds.test.ts similarity index 99% rename from tests/sse-inspector-bounds.test.ts rename to tests/responses/sse-inspector-bounds.test.ts index b036b06005..10cda7ebda 100644 --- a/tests/sse-inspector-bounds.test.ts +++ b/tests/responses/sse-inspector-bounds.test.ts @@ -7,8 +7,8 @@ import { relaySseWithHeartbeat, resetInspectionCountersForTest, trackSseForRequestLog, -} from "../src/server/relay"; -import type { RequestLogContext } from "../src/server/request-log"; +} from "../../src/server/relay"; +import type { RequestLogContext } from "../../src/server/request-log"; const encoder = new TextEncoder(); diff --git a/tests/sse-null-data-frame.test.ts b/tests/responses/sse-null-data-frame.test.ts similarity index 97% rename from tests/sse-null-data-frame.test.ts rename to tests/responses/sse-null-data-frame.test.ts index 4cd260ea7b..2ea085d466 100644 --- a/tests/sse-null-data-frame.test.ts +++ b/tests/responses/sse-null-data-frame.test.ts @@ -1,10 +1,10 @@ import { describe, expect, spyOn, test } from "bun:test"; -import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../src/adapters/anthropic"; -import { createGoogleAdapter as createGoogleAdapterProduction } from "../src/adapters/google"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import type { AdapterEvent, OcxProviderConfig } from "../src/types"; -import { parseSidecarSSE } from "../src/web-search/parse"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createAnthropicAdapter as createAnthropicAdapterProduction } from "../../src/adapters/anthropic"; +import { createGoogleAdapter as createGoogleAdapterProduction } from "../../src/adapters/google"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../src/adapters/openai-chat"; +import type { AdapterEvent, OcxProviderConfig } from "../../src/types"; +import { parseSidecarSSE } from "../../src/web-search/parse"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; // `JSON.parse` returns a value, not necessarily an object: `JSON.parse("null")` is `null` and // never throws, so a `try/catch` around the parse cannot see it. Every payload below is diff --git a/tests/sse-payload-rewrite.test.ts b/tests/responses/sse-payload-rewrite.test.ts similarity index 93% rename from tests/sse-payload-rewrite.test.ts rename to tests/responses/sse-payload-rewrite.test.ts index 64d342a8d2..34dae59e07 100644 --- a/tests/sse-payload-rewrite.test.ts +++ b/tests/responses/sse-payload-rewrite.test.ts @@ -2,15 +2,15 @@ * Single-pass composition of client-facing SSE payload rewrites (#588 follow-up). */ import { describe, expect, test } from "bun:test"; -import { createImageGenCallRestoreRewrite } from "../src/server/responses-image-gen-repair"; -import { createResponsesItemIdPayloadRewrite } from "../src/server/responses-item-id-repair"; +import { createImageGenCallRestoreRewrite } from "../../src/server/responses-image-gen-repair"; +import { createResponsesItemIdPayloadRewrite } from "../../src/server/responses-item-id-repair"; import { composeSsePayloadRewrites, relaySseWithBlockRewrite, relaySseWithPayloadRewrite, -} from "../src/server/sse-payload-rewrite"; -import { createTestTranslatorBudget } from "./helpers/translator-budget"; -import { relaySseWithFailedTail } from "../src/server/relay"; +} from "../../src/server/sse-payload-rewrite"; +import { createTestTranslatorBudget } from "../helpers/translator-budget"; +import { relaySseWithFailedTail } from "../../src/server/relay"; function streamFromText(text: string): ReadableStream { const chunk = new TextEncoder().encode(text); diff --git a/tests/sse-unspaced-data-fields.test.ts b/tests/responses/sse-unspaced-data-fields.test.ts similarity index 94% rename from tests/sse-unspaced-data-fields.test.ts rename to tests/responses/sse-unspaced-data-fields.test.ts index a1b6322c93..14adbff29b 100644 --- a/tests/sse-unspaced-data-fields.test.ts +++ b/tests/responses/sse-unspaced-data-fields.test.ts @@ -1,12 +1,12 @@ import { describe, expect, test } from "bun:test"; -import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../src/adapters/openai-chat"; -import { sseFieldOffset, sseFieldValue } from "../src/lib/sse-decoder"; -import { parseSidecarSSE } from "../src/web-search/parse"; -import { collectChatCompletion } from "../src/chat/outbound"; -import { collectAnthropicMessage } from "../src/claude/outbound"; -import { createTranslatorBudget } from "../src/lib/translator-budget"; -import type { AdapterEvent } from "../src/types"; -import { withTestTranslatorBudget } from "./helpers/translator-budget"; +import { createOpenAIChatAdapter as createOpenAIChatAdapterProduction } from "../../src/adapters/openai-chat"; +import { sseFieldOffset, sseFieldValue } from "../../src/lib/sse-decoder"; +import { parseSidecarSSE } from "../../src/web-search/parse"; +import { collectChatCompletion } from "../../src/chat/outbound"; +import { collectAnthropicMessage } from "../../src/claude/outbound"; +import { createTranslatorBudget } from "../../src/lib/translator-budget"; +import type { AdapterEvent } from "../../src/types"; +import { withTestTranslatorBudget } from "../helpers/translator-budget"; // #1170: the space after the colon is optional in text/event-stream. Several parsers required it // and silently dropped every frame from a compliant producer that omits it, which surfaced to the diff --git a/tests/thought-signature-credential-scope.test.ts b/tests/responses/thought-signature-credential-scope.test.ts similarity index 96% rename from tests/thought-signature-credential-scope.test.ts rename to tests/responses/thought-signature-credential-scope.test.ts index e48fc6f55b..e1af3632eb 100644 --- a/tests/thought-signature-credential-scope.test.ts +++ b/tests/responses/thought-signature-credential-scope.test.ts @@ -14,10 +14,10 @@ import { rememberThoughtSignatureForReplay, resetThoughtSignatureReplayForTests, thoughtSignatureReplaySalt, -} from "../src/responses/thought-signature-replay"; -import { durableReplayCredentialIdentity, durableReplayDestinationIdentity } from "../src/responses/reasoning-replay-cache"; -import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../src/lib/windows-secret-acl"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../src/responses/thought-signature-replay"; +import { durableReplayCredentialIdentity, durableReplayDestinationIdentity } from "../../src/responses/reasoning-replay-cache"; +import { setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests } from "../../src/lib/windows-secret-acl"; +import { removeTreeWithRetry } from "../helpers/remove-tree"; const SIG = "CiQAx-credential-scope-signature-0123456789abcdef"; diff --git a/tests/ws-endpoint.test.ts b/tests/responses/ws-endpoint.test.ts similarity index 99% rename from tests/ws-endpoint.test.ts rename to tests/responses/ws-endpoint.test.ts index 9554ad7a44..9770530e26 100644 --- a/tests/ws-endpoint.test.ts +++ b/tests/responses/ws-endpoint.test.ts @@ -9,7 +9,7 @@ import { sendResponsesJsonAsEvents, sendResponseToWebSocket, type WsData, -} from "../src/server/ws-bridge"; +} from "../../src/server/ws-bridge"; import type { ServerWebSocket } from "bun"; function mockWs(sendResult = 1): { ws: ServerWebSocket; sent: string[] } { @@ -37,7 +37,7 @@ function sseStream(frames: string[], onCancel?: () => void): ReadableStream { test("server config declares explicit websocket idle timeout 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"); expect(source).toContain("const WEBSOCKET_IDLE_TIMEOUT_SECONDS = 0;"); expect(source).toContain("websocket: {"); expect(source).toContain("idleTimeout: WEBSOCKET_IDLE_TIMEOUT_SECONDS,"); diff --git a/tests/ws-upstream.test.ts b/tests/responses/ws-upstream.test.ts similarity index 98% rename from tests/ws-upstream.test.ts rename to tests/responses/ws-upstream.test.ts index 9ef4f9515d..02c4901a0a 100644 --- a/tests/ws-upstream.test.ts +++ b/tests/responses/ws-upstream.test.ts @@ -1,8 +1,8 @@ import { afterEach, describe, expect, jest, test } from "bun:test"; -import { providerFetch } from "../src/server/responses/fetch-helpers"; -import { handleResponses } from "../src/server/responses"; -import { isEagerRelaySseResponse } from "../src/server/relay"; -import { isWin32EagerRewrite } from "../src/lib/bun-stream-caps"; +import { providerFetch } from "../../src/server/responses/fetch-helpers"; +import { handleResponses } from "../../src/server/responses"; +import { isEagerRelaySseResponse } from "../../src/server/relay"; +import { isWin32EagerRewrite } from "../../src/lib/bun-stream-caps"; import { bunSupportsBoundedCodexWsRelay, CODEX_WS_CREATE_FRAME_LIMIT_BYTES, @@ -14,9 +14,9 @@ import { MAX_CODEX_WS_FRAME_BYTES, MAX_CODEX_WS_QUEUE_BYTES, shouldUseCodexWsUpstream as rawShouldUseCodexWsUpstream, -} from "../src/server/responses/ws-upstream"; -import type { OcxProviderConfig } from "../src/types"; -import type { OcxConfig } from "../src/types"; +} from "../../src/server/responses/ws-upstream"; +import type { OcxProviderConfig } from "../../src/types"; +import type { OcxConfig } from "../../src/types"; const CODEX_URL = "https://chatgpt.com/backend-api/codex/responses"; const BOUNDED_WS_RUNTIME = "1.4.0"; @@ -695,7 +695,7 @@ describe("codexWsUpstreamFetch", () => { }); test("a mid-stream drop surfaces as a synthesized failed terminal through the passthrough relay", async () => { - const { relaySseWithFailedTail } = await import("../src/server/relay"); + const { relaySseWithFailedTail } = await import("../../src/server/relay"); installFake(ws => { ws.emit("open", {}); ws.emit("message", { data: JSON.stringify({ type: "response.created", response: { id: "r1" } }) }); From 3c622803ecfe9b81e7cb316cea424b1787836c34 Mon Sep 17 00:00:00 2001 From: jun Date: Sat, 5 Sep 2026 04:39:14 +0900 Subject: [PATCH 2/2] test(layout): map anthropic-quorum-cache (landed on dev after the slice was cut) --- scripts/test-layout/layout.json | 1 + .../{ => adapters/anthropic}/anthropic-quorum-cache.test.ts | 6 +++--- tests/fixtures/test-layout-expected.json | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) rename tests/{ => adapters/anthropic}/anthropic-quorum-cache.test.ts (96%) diff --git a/scripts/test-layout/layout.json b/scripts/test-layout/layout.json index e81cd5f009..654ff71403 100644 --- a/scripts/test-layout/layout.json +++ b/scripts/test-layout/layout.json @@ -201,6 +201,7 @@ "anthropic-image-retry-e2e.test.ts": "adapters/anthropic", "anthropic-image-retry.test.ts": "adapters/anthropic", "anthropic-pool-toggle-copy.test.ts": "adapters/anthropic", + "anthropic-quorum-cache.test.ts": "adapters/anthropic", "anthropic-reasoning.test.ts": "adapters/anthropic", "anthropic-stream-hardening.test.ts": "adapters/anthropic", "anthropic-tail-guard.test.ts": "adapters/anthropic", diff --git a/tests/anthropic-quorum-cache.test.ts b/tests/adapters/anthropic/anthropic-quorum-cache.test.ts similarity index 96% rename from tests/anthropic-quorum-cache.test.ts rename to tests/adapters/anthropic/anthropic-quorum-cache.test.ts index 87e35aff2e..6aaad77aa8 100644 --- a/tests/anthropic-quorum-cache.test.ts +++ b/tests/adapters/anthropic/anthropic-quorum-cache.test.ts @@ -23,9 +23,9 @@ import { hasAnthropicFailoverQuorum, resetAnthropicRoutingForManualSelection, rotateAnthropicAccountOn429, -} from "../src/oauth/anthropic-routing"; -import { getAccountSet, saveCredential } from "../src/oauth/store"; -import { removeTreeWithRetry } from "./helpers/remove-tree"; +} from "../../../src/oauth/anthropic-routing"; +import { getAccountSet, saveCredential } from "../../../src/oauth/store"; +import { removeTreeWithRetry } from "../../helpers/remove-tree"; const originalHome = process.env.OPENCODEX_HOME; let home: string; diff --git a/tests/fixtures/test-layout-expected.json b/tests/fixtures/test-layout-expected.json index a89f225f71..802cb98a8d 100644 --- a/tests/fixtures/test-layout-expected.json +++ b/tests/fixtures/test-layout-expected.json @@ -38,6 +38,7 @@ "anthropic-image-retry-e2e.test.ts": "adapters/anthropic", "anthropic-image-retry.test.ts": "adapters/anthropic", "anthropic-pool-toggle-copy.test.ts": "adapters/anthropic", + "anthropic-quorum-cache.test.ts": "adapters/anthropic", "anthropic-reasoning.test.ts": "adapters/anthropic", "anthropic-stream-hardening.test.ts": "adapters/anthropic", "anthropic-tail-guard.test.ts": "adapters/anthropic",