Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ EOF

**Files:**
- Modify: `src/cli/doctor.ts`
- Test: `tests/doctor-oauth.test.ts` (or extend `tests/doctor.test.ts`)
- Test: `tests/service/doctor-oauth.test.ts` (or extend `tests/doctor.test.ts`)

**Interfaces:**
- Consumes: `collectOAuthHealthEntries`, auth store writability checks, refresh lock path helpers if exported
Expand All @@ -519,7 +519,7 @@ Seed a temp account with `needsReauth`, run the new `collectOAuthDoctorChecks()`

- [ ] **Step 2: Run test to verify it fails**

Run: `bun test tests/doctor-oauth.test.ts`
Run: `bun test tests/service/doctor-oauth.test.ts`

Expected: FAIL

Expand All @@ -529,14 +529,14 @@ Add `collectOAuthDoctorChecks(): Array<{ level: "OK" | "WARN"; message: string }

- [ ] **Step 4: Run tests**

Run: `bun test tests/doctor-oauth.test.ts tests/doctor.test.ts`
Run: `bun test tests/service/doctor-oauth.test.ts tests/doctor.test.ts`

Expected: PASS

- [ ] **Step 5: Commit**

```bash
git add src/cli/doctor.ts tests/doctor-oauth.test.ts
git add src/cli/doctor.ts tests/service/doctor-oauth.test.ts
git commit -m "$(cat <<'EOF'
feat(cli): add OAuth reliability checks to ocx doctor

Expand Down Expand Up @@ -713,7 +713,7 @@ EOF
- [ ] **Step 1: Run verification commands**

```bash
bun test tests/privacy-mask-account.test.ts tests/oauth-log.test.ts tests/oauth-refresh-generic-lock.test.ts tests/oauth-health.test.ts tests/cli-status-oauth-health.test.ts tests/doctor-oauth.test.ts tests/oauth-accounts-api.test.ts tests/codex-metadata-integrity.test.ts
bun test tests/privacy-mask-account.test.ts tests/oauth-log.test.ts tests/oauth-refresh-generic-lock.test.ts tests/oauth-health.test.ts tests/cli-status-oauth-health.test.ts tests/service/doctor-oauth.test.ts tests/oauth-accounts-api.test.ts tests/codex-metadata-integrity.test.ts
bun test tests/oauth-refresh.test.ts tests/xai-refresh-lock.test.ts tests/codex-routing.test.ts tests/session-affinity.test.ts tests/codex-auth-context.test.ts
bun run test
bun run typecheck
Expand Down
6 changes: 5 additions & 1 deletion scripts/test-layout/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -1226,5 +1226,9 @@
"zz-ci-storage-policy-isolation.test.ts": "ci-workflows",
"zz-pr-coderabbit-readiness-revalidation.test.ts": "ci-workflows"
},
"migrated": []
"migrated": [
"service",
"update",
"windows"
]
}
8 changes: 4 additions & 4 deletions scripts/test-layout/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export interface VerifyReport {

/**
* Everything that may name a test path as text. Shared with move.ts so the preflight write set
* and the post-move STALE check see the same files. `devlog/_fin` is history: it records where
* a file lived when the unit closed and is deliberately not rewritten. Open `devlog/_plan` units
* are live documents and are.
* and the post-move STALE check see the same files. `devlog/` is deliberately absent: a unit
* records where a file lived when it was written, and rewriting 59 old plan documents per slice
* (measured on the first slice) buries the real diff without changing what any tool reads.
*/
export const SWEEP_ROOTS = [
"tests", "scripts", ".github", "src", "gui/src", "gui/tests", "bin", "docs", "docs-site", "structure", "devlog/_plan", "skills",
"tests", "scripts", ".github", "src", "gui/src", "gui/tests", "bin", "docs", "docs-site", "structure", "skills",
"AGENTS.md", "AGENTS_INSTALL.md", "MAINTAINERS.md", "CONTRIBUTING.md", "README.md", "CREDITS.md",
"bunfig.toml", "package.json", ".gitignore", ".npmignore",
];
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export const SERIAL_FULL_SUITE_FILES = [
"issue-452-empty-503.test.ts",
"openai-provider-option-e2e.test.ts",
"release-helper.test.ts",
"update-stop-first.test.ts",
"update/update-stop-first.test.ts",
] as const;

type SerialLaneBasename = (typeof SERIAL_FULL_SUITE_FILES)[number] extends infer P
Expand Down
2 changes: 1 addition & 1 deletion tests/codex-catalog-writer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ for (const mutator of mutators) {
// both run write → harden → publish). Supplying `io` bypasses the real
// implementations, so this proves hardening is REQUESTED on the temp before
// publication — not that it restricts. The Windows NTFS ACL that does the actual
// restricting is exercised in tests/windows-secret-acl.test.ts, and the POSIX mode
// restricting is exercised in tests/windows/windows-secret-acl.test.ts, and the POSIX mode
// below is the only half `statSync` can observe (Windows reports 0o666 whatever
// `chmodSync` did).
const tempEffect = effects.find(effect => effect.startsWith("temp:"));
Expand Down
4 changes: 2 additions & 2 deletions tests/grok-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function sliceFn(source: string, start: string, end: string): string {

// `src/cli/index.ts` runs its command switch on import, so the handlers cannot be called from a
// test. Wiring assertions therefore read the source — the house pattern established by
// tests/stale-state-purge.test.ts and tests/uninstall.test.ts.
// tests/service/stale-state-purge.test.ts and tests/uninstall.test.ts.
describe("Grok fence lifecycle wiring", () => {
test("handleStart syncs the Grok fence outside the Desktop-3P try", () => {
const startFn = sliceFn(CLI_SOURCE, "async function handleStart(", "async function handleEnsure(");
Expand Down Expand Up @@ -380,7 +380,7 @@ describe("POST /api/stop teardown", () => {
test("strips the Grok fence on an accepted stop", () => {
// The teardown moved to src/server/stop-teardown.ts so a test can call it: the route
// schedules process.exit 200ms after answering, which made the inline version
// unreachable. tests/stop-deferred-teardown.test.ts proves the behaviour; this proves
// unreachable. tests/service/stop-deferred-teardown.test.ts proves the behaviour; this proves
// the route still delegates to it rather than growing a second copy.
const handler = sliceFn(MANAGEMENT_SOURCE, '"/api/stop"', "/api/codex-auth/");
expect(handler).toContain("performStopTeardown(url, { ownsReceipt: deferralMatchesReceipt })");
Expand Down
2 changes: 1 addition & 1 deletion tests/native-main-claim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe("the default hardener is actually reached from a claim", () => {
*
* So this one runs a claim with the DEFAULT hardener and inspects the file it
* left behind. On POSIX that is the mode; the Windows branch is proven
* separately in tests/windows-secret-acl.test.ts, where the ACL runner can be
* separately in tests/windows/windows-secret-acl.test.ts, where the ACL runner can be
* observed.
*/
test("a shared claim narrows a permissive claim database to 0600", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { describe, expect, test } from "bun:test";
import { deriveStartupHealth, formatStartupRoutingDetail, startupHealthSummary } from "../src/codex/autostart-health";
import { unusedProxyWarningLines } from "../src/cli/status";
import { classifyCodexRouting, hasInjectedCodexRouting } from "../src/codex/inject";
import { handleManagementAPI } from "../src/server/management-api";
import { getCachedStartupHealth, invalidateStartupHealthCache, markStartupHealthDiagnosticStale } from "../src/server/startup-health-cache";
import type { OcxConfig } from "../src/types";
import { deriveStartupHealth, formatStartupRoutingDetail, startupHealthSummary } from "../../src/codex/autostart-health";
import { unusedProxyWarningLines } from "../../src/cli/status";
import { classifyCodexRouting, hasInjectedCodexRouting } from "../../src/codex/inject";
import { handleManagementAPI } from "../../src/server/management-api";
import { getCachedStartupHealth, invalidateStartupHealthCache, markStartupHealthDiagnosticStale } from "../../src/server/startup-health-cache";
import type { OcxConfig } from "../../src/types";

const base = {
routingKind: "opencodex-local" as const,
Expand Down Expand Up @@ -278,7 +278,7 @@ describe("Codex startup health", () => {
invalidateStartupHealthCache();
});
});
import { ManagementRequest as Request } from "./helpers/management-auth";
import { ManagementRequest as Request } from "../helpers/management-auth";

describe("routing visibility (#2411)", () => {
test("formatStartupRoutingDetail renders the token doctor already prints", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from "bun:test";
import { appendCrashTraceForTests, crashRingEntriesForTests, formatCrashEntry, installCrashGuards, isBenignAbortTeardown, resetCrashRingForTests } from "../src/lib/crash-guard";
import { RETAINED_TRUNCATION_MARKER, retainedUtf8Bytes } from "../src/lib/admission";
import { sidecarEnter } from "../src/lib/sidecar-tracker";
import { appendCrashTraceForTests, crashRingEntriesForTests, formatCrashEntry, installCrashGuards, isBenignAbortTeardown, resetCrashRingForTests } from "../../src/lib/crash-guard";
import { RETAINED_TRUNCATION_MARKER, retainedUtf8Bytes } from "../../src/lib/admission";
import { sidecarEnter } from "../../src/lib/sidecar-tracker";

describe("crash-guard diagnostics", () => {
test("the 13th fetch trace evicts the oldest and 8 KiB values truncate on UTF-8 boundaries", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test";
import { collectCodexEnvKeyReadiness } from "../src/cli/doctor";
import type { CodexShimDiagnostic } from "../src/codex/shim";
import { collectCodexEnvKeyReadiness } from "../../src/cli/doctor";
import type { CodexShimDiagnostic } from "../../src/codex/shim";

const config = `
model_provider = "opencodex"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { mkdirSync, readdirSync, writeFileSync, readFileSync, statSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { collectOAuthDoctorChecks } from "../src/cli/doctor";
import { MAIN_CODEX_ACCOUNT_ID } from "../src/codex/main-account";
import { CODEX_REAUTH_ACTION } from "../src/oauth/health";
import { getAccountSet, getAuthStorePath, markAccountNeedsReauth, saveCredential } from "../src/oauth/store";
import { removeTreeWithRetry } from "./helpers/remove-tree";
import { collectOAuthDoctorChecks } from "../../src/cli/doctor";
import { MAIN_CODEX_ACCOUNT_ID } from "../../src/codex/main-account";
import { CODEX_REAUTH_ACTION } from "../../src/oauth/health";
import { getAccountSet, getAuthStorePath, markAccountNeedsReauth, saveCredential } from "../../src/oauth/store";
import { removeTreeWithRetry } from "../helpers/remove-tree";

const origHome = process.env.HOME;
const origOcxHome = process.env.OPENCODEX_HOME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { collectProviderApiKeyDiagnostics } from "../src/cli/doctor";
import { collectProviderApiKeyDiagnostics } from "../../src/cli/doctor";

const prototypePropertyNames = [
"toString",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { fetchServiceMemory } from "../src/cli/doctor";
import { fetchServiceMemory } from "../../src/cli/doctor";

type ServiceMemoryDeps = NonNullable<Parameters<typeof fetchServiceMemory>[1]>;
type TimeoutOptionIsHidden = "timeoutMs" extends keyof ServiceMemoryDeps ? false : true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { afterEach, describe, expect, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { cleanupOpenAiTierBackupAfterInit } from "../src/cli/init";
import { classifyOpenAiTierBackup, OpenAiTierRollbackPreserveError, preserveOpenAiTierRollbackSnapshot } from "../src/config";
import { removeTreeWithRetry } from "./helpers/remove-tree";
import { cleanupOpenAiTierBackupAfterInit } from "../../src/cli/init";
import { classifyOpenAiTierBackup, OpenAiTierRollbackPreserveError, preserveOpenAiTierRollbackSnapshot } from "../../src/config";
import { removeTreeWithRetry } from "../helpers/remove-tree";

describe("cleanupOpenAiTierBackupAfterInit", () => {
const dirs: string[] = [];
Expand Down
5 changes: 3 additions & 2 deletions tests/init-eof.test.ts → tests/service/init-eof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { afterEach, describe, expect, test } from "bun:test";
import { existsSync, mkdtempSync} from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { removeTreeWithRetry } from "./helpers/remove-tree";
import { removeTreeWithRetry } from "../helpers/remove-tree";
import { repoPath } from "../helpers/repo-root";

async function waitForOutput(
stream: ReadableStream<Uint8Array>,
Expand Down Expand Up @@ -31,7 +32,7 @@ describe("ocx init piped stdin (#754)", () => {
test("exits cleanly when stdin closes before the first prompt answer", async () => {
const home = mkdtempSync(join(tmpdir(), "ocx-init-eof-"));
dirs.push(home);
const cli = join(import.meta.dir, "..", "src", "cli", "index.ts");
const cli = repoPath("src", "cli", "index.ts");
const proc = Bun.spawn({
cmd: [process.execPath, cli, "init"],
env: { ...process.env, OPENCODEX_HOME: home },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { delimiter, dirname, join } from "node:path";
import * as configFacade from "../src/config";
import * as configFacade from "../../src/config";
import {
getPidPath,
getRuntimePortPath,
Expand All @@ -18,9 +18,10 @@ import {
setProcessCommandLinePlatformForTests,
writePid,
writeRuntimePort,
} from "../src/config/process-state";
import { setTrustedWindowsSystemDirectoryResolverForTests } from "../src/lib/windows-elevation";
import { removeTreeWithRetry } from "./helpers/remove-tree";
} from "../../src/config/process-state";
import { setTrustedWindowsSystemDirectoryResolverForTests } from "../../src/lib/windows-elevation";
import { removeTreeWithRetry } from "../helpers/remove-tree";
import { repoPath } from "../helpers/repo-root";

let testDir = "";

Expand All @@ -42,7 +43,7 @@ afterEach(() => {

describe("proxy process-state ownership", () => {
test("the process-state leaf does not import the config facade", () => {
const source = readFileSync(join(import.meta.dir, "..", "src", "config", "process-state.ts"), "utf-8");
const source = readFileSync(repoPath("src", "config", "process-state.ts"), "utf-8");
expect(source).not.toMatch(/from\s+["']\.\.\/config["']/);
expect(source).toContain('from "./atomic-write"');
expect(source).toContain('from "./paths"');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { join } from "node:path";
import {
inspectServiceManagerInstallation,
type ProbeRunner,
} from "../src/service-manager-probe";
import { removeTreeWithRetry } from "./helpers/remove-tree";
} from "../../src/service-manager-probe";
import { removeTreeWithRetry } from "../helpers/remove-tree";

test("Linux reports systemd absent when systemctl cannot be spawned", () => {
const home = mkdtempSync(join(tmpdir(), "ocx-probe-docker-"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
serviceApiTokenFingerprint,
writeServiceApiTokenFile,
writeTokenBackup,
} from "../src/lib/service-secrets";
import { removeTreeWithRetry } from "./helpers/remove-tree";
} from "../../src/lib/service-secrets";
import { removeTreeWithRetry } from "../helpers/remove-tree";

let home = "";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { proxyStillLiveAfterStop } from "../src/service";
import { proxyStillLiveAfterStop } from "../../src/service";

/**
* #764: `ocx service stop` reported success while the proxy kept running, and native Codex was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
* ever receiving an injection (PR #860 family).
*/
import { afterEach, describe, expect, test } from "bun:test";
import { applyProviderConfigHints, buildCatalogEntries, gatherRoutedModels } from "../src/codex/catalog";
import { applyCatalogModelMetadata } from "../src/codex/catalog/effort";
import type { RawEntry } from "../src/codex/catalog/parsing";
import { providerConfigSeed, enrichProviderFromRegistry } from "../src/providers/derive";
import { getProviderRegistryEntry } from "../src/providers/registry";
import { decideTier } from "../src/providers/fastwire";
import type { RequestLogContext } from "../src/server/request-log";
import { applyServiceTierGate, handleResponses } from "../src/server/responses/core";
import { applyProviderConfigHints, buildCatalogEntries, gatherRoutedModels } from "../../src/codex/catalog";
import { applyCatalogModelMetadata } from "../../src/codex/catalog/effort";
import type { RawEntry } from "../../src/codex/catalog/parsing";
import { providerConfigSeed, enrichProviderFromRegistry } from "../../src/providers/derive";
import { getProviderRegistryEntry } from "../../src/providers/registry";
import { decideTier } from "../../src/providers/fastwire";
import type { RequestLogContext } from "../../src/server/request-log";
import { applyServiceTierGate, handleResponses } from "../../src/server/responses/core";
import {
canForwardServiceTierForModel,
fastPolicyForModel,
serviceTierAdapterForModel,
serviceTierSupportForModel,
serviceTierSupportFromPolicy,
supportsServiceTierForModel,
} from "../src/providers/service-tier";
import { candidateCapabilityEvidence } from "../src/routing/capability";
import { resolveProductionBehaviorValues } from "../src/routing/compatibility/behavior";
import type { OcxConfig, OcxProviderConfig } from "../src/types";
} from "../../src/providers/service-tier";
import { candidateCapabilityEvidence } from "../../src/routing/capability";
import { resolveProductionBehaviorValues } from "../../src/routing/compatibility/behavior";
import type { OcxConfig, OcxProviderConfig } from "../../src/types";

describe("registry capability reaches saved configs without overriding them", () => {
test("the registry holds the defaults; the seed stays free of them so explicit config stays distinguishable", () => {
Expand Down
Loading
Loading