test(platform-agent): regression for core#2496 ON CONFLICT updates runtime #2629
Reference in New Issue
Block a user
Delete Branch "fix/core-2615-2496-platform-agent-on-conflict-runtime-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
CTO-mandated regression test for the core#2496 root-fix (commit
67c2fff3, "fix(platform-agent): update runtime to 'claude-code' on ON CONFLICT"). TheInstallPlatformAgentendpoint upserts the platform-agent row withruntime='claude-code', but the ON CONFLICT clause originally only updatedkindandparent_id. If the platform-agent container self-registered first (creating a row with the schema default runtime), the install endpoint would NOT correct the runtime — it would be left stale.#2496 added
runtime = 'claude-code'to the ON CONFLICT DO UPDATE SET clause, so the runtime is now corrected on every install, not just on the initial insert. The fix landed in main with NO test.What changed
This commit adds
TestIntegration_PlatformAgentInstall_OnConflictUpdatesRuntimetoplatform_agent_integration_test.go. The test:Seeds a platform-agent row with a deliberately STALE runtime (
'codex') — simulates the self-registered row scenario.Asserts the seed has the stale runtime (not
'claude-code'). If this fails, the test is meaningless — fix the seed, not the assertion.Calls
installPlatformAgent. Per the pre-#2499 bug, the ON CONFLICT DO UPDATE SET clause would have left runtime stuck at'codex'. Per the #2496 fix, it MUST be'claude-code'.PRIMARY ASSERTION: post-install runtime is
'claude-code'. The error message names the exact pre-#2496 vs post-#2496 clause shape so a future regressor sees what to fix:Idempotency: a second install (still the conflict path) keeps runtime at
'claude-code'.Fresh-insert path: also asserts
runtime='claude-code'on a brand-new row. Guards against a future refactor that moves the runtime to ONLY the conflict clause and removes it from the INSERT VALUES — a regression that would let a self-registering row skip the runtime entirely.Acceptance criteria (from the CTO spec)
workspace-server/internal/handlers/platform_agent.go:573, functioninstallPlatformAgent, theON CONFLICT (id) DO UPDATE SET kind = 'platform', runtime = 'claude-code', parent_id = NULLclause. See commit67c2fff3(the original fix).runtime='claude-code'when the row already exists (not just on insert) — see PRIMARY ASSERTION (step 4) and idempotency check (step 5). Pre-#2496, the assertion would fail because the conflict path would not updateruntime. Post-#2496, the assertion holds.//go:build integration+// +build integrationtags and theINTEGRATION_DB_URLenv var, following the same pattern as the other tests in the file. Runs against real Postgres in thehandlers-postgres-integrationCI workflow.fix/core-2615-2496-platform-agent-on-conflict-runtime-testis pushed to origin.Test results
The SKIP is expected — no
INTEGRATION_DB_URLset locally. The CIhandlers-postgres-integrationworkflow runs the integration tests with the real DB.Refs
67c2fff3)🤖 Generated with Claude Code
Approved on head
47b7ccb002.5-axis review:
installPlatformAgent, and asserts the conflict path updates runtime toclaude-code; it also checks a second idempotent conflict call and the fresh insert path.Verification note: attempted focused Go test, but
gois not installed in this runtime. Static review found no blocker.New commits pushed, approval review dismissed automatically according to repository settings
Approved on head
9227e2d48d.5-axis review:
installPlatformAgent, and verifies the conflict path updates runtime toclaude-code; it also covers idempotent second install and fresh insert.t.Parallel.Verification note: attempted focused Go test, but
gois not installed in this runtime. Static review found no blocker.Second CI attempt of the OnConflict test still failed, but with a different error this time: pre-seed: delete existing platform-agent rows: pq: update or delete on table "workspaces" violates foreign key constraint "workspaces_parent_id_fkey" on table "workspaces" The prior fix (DELETE all kind='platform' AND parent_id IS NULL) ran into the FK constraint because child workspaces can have parent_id pointing at the platform-agent row. The unique constraint allows at most one such row, but FK prevents deleting it while children reference it. The right shape: UPDATE (downgrade) instead of DELETE. This is exactly what installPlatformAgent itself does for prior roots (its step 0: `UPDATE workspaces SET kind = 'workspace' ... WHERE kind = 'platform' AND parent_id IS NULL AND id <> $1`). UPDATE is FK-safe (the children still have a valid parent_id, just pointing at a row that's no longer kind='platform') and clears the uniq-platform-root slot. This commit: - Replaces the pre-seed DELETE with an UPDATE. - Replaces the post-test DELETE in cleanup() with the same UPDATE (belt-and-suspenders: leave the slot in a state where the next test can seed cleanly). - The DELETE of OUR specific row by id still works (we created it with parent_id NULL, so nothing references it, and the UPDATE-kind change doesn't affect DELETE semantics on it). Refs: molecule-core#2615, core#2496, PR #2629 Co-Authored-By: Claude <noreply@anthropic.com>New commits pushed, approval review dismissed automatically according to repository settings
Approved on head
4ad8f22f5f.5-axis review:
installPlatformAgent, and verifies conflict, idempotent conflict, and fresh insert paths all force runtime toclaude-code.kind='workspace'downgrades to free the single platform-root slot rather than deleting possibly-referenced rows; the integration file does not uset.Parallel.Verification note: Go is not installed in this runtime, so I could not execute the focused integration test. Static review found no blocker.