Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
1 line
9.4 KiB
JSON
1 line
9.4 KiB
JSON
{"repo": "ai-eden/eden-agent", "files": {"packages/coding-runtime/test/provider-readiness.test.ts": {"3857c28069ef6d0c90ddf63417ea36c5faa8f065": {"t": 1786068367.4191482, "n": 9056, "h": "b77f0dc6fdfd3298", "c": "import assert from \"node:assert/strict\";\nimport { chmod, lstat, mkdtemp, readFile, stat, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { describe, it } from \"node:test\";\n\nimport { AgentClientError, InProcessAgentClient } from \"@eden/coding-runtime\";\nimport type { ProviderProfileInput } from \"@eden/contracts\";\nimport { ProviderAdapterError } from \"@eden/providers\";\n\nconst credentialCanary = \"SECRET_CANARY_READINESS_ONE\";\nconst profile = {\n baseUrl: \"https://api.deepseek.com\",\n billingSource: \"pay_as_you_go\",\n contextWindowTokens: 1_000_000,\n credential: { name: \"EDEN_DEEPSEEK_KEY\", source: \"environment\" },\n id: \"deepseek-v4\",\n maxOutputTokens: 393_216,\n model: \"deepseek-v4-pro\",\n protocol: \"openai_chat_completions\",\n reasoningDisplay: \"off\",\n} as const satisfies ProviderProfileInput;\n\nasync function paths(label: string) {\n const root = await mkdtemp(join(tmpdir(), `eden-readiness-${label}-`));\n const workspace = join(root, \"workspace\");\n const stateDirectory = join(root, \"state\");\n await import(\"node:fs/promises\").then(({ mkdir }) => mkdir(workspace));\n return { stateDirectory, workspace };\n}\n\nfunction successProvider(calls: { value: number }) {\n return () => ({\n checkReadiness: async () => {\n calls.value += 1;\n return {\n checkedAt: \"2026-07-19T12:00:00.000Z\",\n model: profile.model,\n profileId: profile.id,\n requestId: \"request-ready-1\",\n state: \"completion_ready\" as const,\n };\n },\n });\n}\n\nasync function saveProfile(client: InProcessAgentClient, value = profile) {\n const initial = await client.getProviderProfiles();\n return client.saveProviderProfile({\n commandId: \"command-save\",\n expectedRevision: initial.revision,\n profile: value,\n protocolVersion: 1,\n select: true,\n type: \"provider.profile.save\",\n });\n}\n\nfunction readinessCommand(revision: number) {\n return {\n commandId: \"command-readiness\",\n expectedRevision: revision,\n possibleChargeConfirmed: true,\n profileId: profile.id,\n protocolVersion: 1,\n type: \"provider.readiness.check\",\n } as const;\n}\n\ndescribe(\"provider readiness persistence\", () => {\n it(\"persists only a salted fingerprint and invalidates on profile or credential change\", async () => {\n const fixture = await paths(\"fingerprint\");\n const calls = { value: 0 };\n const client = await InProcessAgentClient.open({\n createReadinessProvider: successProvider(calls),\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: credentialCanary },\n stateDirectory: fixture.stateDirectory,\n });\n const saved = await saveProfile(client);\n assert.equal((await client.getProviderReadiness()).state, \"configured\");\n const ready = await client.checkProviderReadiness(readinessCommand(saved.revision));\n assert.equal(ready.state, \"completion_ready\");\n assert.equal(calls.value, 1);\n assert.equal((await client.getProviderProfiles()).profiles[0]?.readiness, \"completion_ready\");\n const readinessPath = join(fixture.stateDirectory, \"provider-readiness-v1.json\");\n const persisted = await readFile(readinessPath, \"utf8\");\n assert.equal(persisted.includes(credentialCanary), false);\n assert.equal(persisted.includes(profile.model), false);\n if (process.platform !== \"win32\") {\n assert.equal((await stat(readinessPath)).mode & 0o777, 0o600);\n }\n await client.close();\n\n const reopened = await InProcessAgentClient.open({\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: credentialCanary },\n stateDirectory: fixture.stateDirectory,\n });\n assert.equal((await reopened.getProviderReadiness()).state, \"completion_ready\");\n await reopened.close();\n\n const changedCredential = await InProcessAgentClient.open({\n createReadinessProvider: successProvider(calls),\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: \"SECRET_CANARY_READINESS_TWO\" },\n stateDirectory: fixture.stateDirectory,\n });\n assert.equal((await changedCredential.getProviderReadiness()).state, \"configured\");\n const catalog = await changedCredential.getProviderProfiles();\n assert.equal(\n (await changedCredential.checkProviderReadiness(readinessCommand(catalog.revision))).state,\n \"completion_ready\",\n );\n await changedCredential.saveProviderProfile({\n commandId: \"command-update\",\n expectedRevision: catalog.revision,\n profile: { ...profile, model: \"deepseek-chat\" },\n protocolVersion: 1,\n select: true,\n type: \"provider.profile.save\",\n });\n assert.equal((await changedCredential.getProviderReadiness()).state, \"configured\");\n assert.equal(calls.value, 2);\n await changedCredential.close();\n });\n\n it(\"projects redacted provider failures without persisting readiness\", async () => {\n const fixture = await paths(\"failure\");\n const client = await InProcessAgentClient.open({\n createReadinessProvider: () => ({\n checkReadiness: async () => {\n throw new ProviderAdapterError({\n checkedAt: \"2026-07-19T12:00:00.000Z\",\n code: \"authentication\",\n message: \"The provider rejected the configured credential.\",\n model: profile.model,\n profileId: profile.id,\n recoverability: \"reconfigure\",\n requestId: null,\n statusFamily: \"4xx\",\n suggestedActions: [\"Check the selected credential and retry.\"],\n });\n },\n }),\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: credentialCanary },\n stateDirectory: fixture.stateDirectory,\n });\n const saved = await saveProfile(client);\n const failed = await client.checkProviderReadiness(readinessCommand(saved.revision));\n assert.equal(failed.state, \"configured\");\n assert.equal(failed.error?.code, \"authentication\");\n assert.equal(JSON.stringify(failed).includes(credentialCanary), false);\n await assert.rejects(lstat(join(fixture.stateDirectory, \"provider-readiness-v1.json\")), {\n code: \"ENOENT\",\n });\n await client.close();\n });\n\n it(\"rechecks the content revision after network completion before persisting\", async () => {\n const fixture = await paths(\"stale\");\n let release: (() => void) | undefined;\n const providerResult = new Promise<void>((resolve) => {\n release = resolve;\n });\n const first = await InProcessAgentClient.open({\n createReadinessProvider: () => ({\n checkReadiness: async () => {\n await providerResult;\n return {\n checkedAt: \"2026-07-19T12:00:00.000Z\",\n model: profile.model,\n profileId: profile.id,\n requestId: null,\n state: \"completion_ready\" as const,\n };\n },\n }),\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: credentialCanary },\n stateDirectory: fixture.stateDirectory,\n });\n const saved = await saveProfile(first);\n const pending = first.checkProviderReadiness(readinessCommand(saved.revision));\n const second = await InProcessAgentClient.open({\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: credentialCanary },\n stateDirectory: fixture.stateDirectory,\n });\n await second.saveProviderProfile({\n commandId: \"command-concurrent-update\",\n expectedRevision: saved.revision,\n profile: { ...profile, model: \"changed-during-check\" },\n protocolVersion: 1,\n select: true,\n type: \"provider.profile.save\",\n });\n release?.();\n await assert.rejects(\n pending,\n (error) => error instanceof AgentClientError && error.productError.code === \"stale_revision\",\n );\n await assert.rejects(lstat(join(fixture.stateDirectory, \"provider-readiness-v1.json\")), {\n code: \"ENOENT\",\n });\n await first.close();\n await second.close();\n });\n\n it(\"surfaces invalid readiness state as a closed local recovery without secret echo\", async () => {\n const fixture = await paths(\"invalid\");\n const client = await InProcessAgentClient.open({\n createReadinessProvider: successProvider({ value: 0 }),\n cwd: fixture.workspace,\n profileEnvironment: { EDEN_DEEPSEEK_KEY: credentialCanary },\n stateDirectory: fixture.stateDirectory,\n });\n await saveProfile(client);\n const readinessPath = join(fixture.stateDirectory, \"provider-readiness-v1.json\");\n await writeFile(readinessPath, `{\"secret\":\"${credentialCanary}\"}\\n`, { mode: 0o600 });\n const invalid = await client.getProviderReadiness();\n assert.equal(invalid.state, \"configured\");\n assert.equal(invalid.error?.code, \"invalid_configuration\");\n assert.equal(JSON.stringify(invalid).includes(credentialCanary), false);\n if (process.platform !== \"win32\") {\n await chmod(readinessPath, 0o644);\n assert.equal((await client.getProviderReadiness()).error?.code, \"invalid_configuration\");\n }\n await client.close();\n });\n});\n"}}}} |