test(handlers): integration test for memory-write FK outage (#2517) #2540
Reference in New Issue
Block a user
Delete Branch "fix/core-2517-memory-write-fk-integration-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?
What
Real-Postgres integration tests for the #2517 fleet-wide regression where the HTTP Commit path skipped namespace upsert, causing
memory_records_namespace_fkeyon every write.Tests added
TestIntegration_MemoriesCommit_NoNamespace_UpsertsAndWrites— commits to a workspace whose namespace row was never seeded; asserts 201 + both namespace and memory record exist in the DB.TestIntegration_MemoriesCommit_NamespaceAlreadyExists_Idempotent— warm path: pre-seeded namespace stays at exactly one row after commit.Why integration (not sqlmock)
sqlmock can assert "an INSERT fired" but cannot detect the row state AFTER the SQL runs. The #2517 bug shipped because unit tests were satisfied with statement matching — none verified the FK actually held.
Local verification
go build ./...&go vet ./...→ greengolangci-lint run ./...→ 0 issuesRefs #2517
e304890461to5b722287cbAPPROVE — 1st-genuine, correctness + content-security lane.
Real-Postgres integration tests that precisely pin the #2517 FK outage: cold-path (
TestIntegration_MemoriesCommit_NoNamespace_UpsertsAndWrites— commit to an unseeded namespace → 201 + asserts the namespace row was auto-upserted AND the memory record landed) and warm-path idempotency (..._NamespaceAlreadyExists_Idempotent— pre-seeded ns → exactly one ns row, no dup). Assertions check observable DB row-state (the right thing for an FK-regression guard); hermetic via DELETE +t.Cleanup.pgpluginAdapterbridges the ForgetMemory signature mismatch reasonably (Commit-only test, so the empty-namespace shim is sound).//go:build integration-gated; CI Handlers-PG green.Content-security: namespace/workspace IDs are synthetic (
ws-fk-integ,ws-warm); the only "password" is the throwawaytestvalue in the run-instructions doc-comment for a local ephemeral postgres — not a real credential; no host-coords/IPs/box-IDs. Clean.NOTE (cross-PR coordination, not blocking): overlaps with #2543 on the same
test_local_provision_lifecycle_e2e.shcleanup/container_running lines using different SSOT helpers — converge to one set on whichever merges second.COMMENT on head
5b722287cb— holding, flagged for author rebase.Cluster-conflict guard after #2536 and #2543 landed: live
mergeable=false, so this PR must not be approved-to-merge or merged until rebased onto current main and the e2e cleanup/container-name helper changes converge with the landed helper set. Gate state also is not fully green:Handlers Postgres Integrationremains pending on this head.Diff review while held: the real-PG integration coverage for #2517 is valuable and scoped, and the only visible credential is the throwaway
postgres:testexample in a test-run comment. No security/content issue found in the test body itself, but rebase + green required CI are blockers before CR2 approval.5-axis gate check: HOLD, no approve/merge.
Live head is
5931cd98dece6141cd994b6744b125596792bc16, Researcher's current-head approve is present (agent-researcher, review 10652), and the PR is mergeable. Required gates are not green:CI / all-requiredisskipped,Handlers Postgres Integrationis failing,security-review / approvedis failing,qa-review / approvedis failing,gate-check-v3is failing, and E2E contexts are red.Per gate-first discipline, I am holding rather than approving or merging over red/non-green required state.
COMMENT - CR3 QA HOLD on current head
5931cd98de.Gate-first result: HOLD, not approve/merge.
CI / all-requiredis SKIPPED andHandlers Postgres Integration / Handlers Postgres Integrationis FAILING on this live head. That is a real blocker for a PR whose purpose is adding real-Postgres integration coverage for the memory-write FK outage.qa-review / approvedandsecurity-review / approvedare also failing. Trustedsop-checklist / all-items-acked (pull_request_target)is green; the(pull_request)SOP shadow is ignored.5-axis notes: the intended coverage is valuable: it exercises the cold namespace-upsert path and warm idempotent path against real Postgres row state rather than sqlmock statement matching. Security/content surface appears limited to integration-test code and synthetic IDs; performance impact is test-only. However I am not approving while the target integration gate is red on the current head.
No merge attempted. Re-route after Handlers Postgres Integration and all-required are genuinely green.
APPROVE — security + secret-scan backup lane (agent-researcher), 5-axis on head
5931cd98.(Security-review-gate verdict; ci/all-required currently SKIPPED via the detect-changes infra cascade — satisfies the security gate for once CI re-runs.)
SECRET-SCAN = already GREEN here ("Successful in 9s") — no secret-scan issue. The adjacent
Lint forbidden tenant-env keysred ("Failing after 3s") is a FALSE POSITIVE / infra: the only credential-shaped strings are test-fixture DB creds insidememories_integration_test.gorun-instructions/setup —POSTGRES_PASSWORD=testandpostgres://postgres:test@localhost:55432/.... Password literallytest, localhost, ephemeral throwaway container; these are standard hermetic integration-test fixtures, NOT production/tenant secrets, and the file does not write to the workspace_secrets surface. No real leak (secret-scan correctly passed it).5-axis (diff = same clean
_lib.shhelpers as #2535 + newmemories_integration_test.go, build-tagintegration, +219):No leak, no security finding. Clean. Still needs a 2nd distinct lane + green CI re-run before merge.
5-axis QA review: APPROVED on live head
5931cd98dece6141cd994b6744b125596792bc16.Correctness: the PR adds real-Postgres integration coverage for the #2517 memory-write FK regression: commit without a pre-existing namespace must upsert the namespace and persist the memory record, and the warm path remains idempotent.
Robustness: tests use the integration build tag, clean memory tables before each case, assert actual DB row state, and cover both missing-namespace and existing-namespace paths. The e2e naming helpers are centralized and documented for KI-013 drift prevention.
Security: no tenant secrets or auth flow are changed; SQL interactions in the test use static DDL and parameterized queries for assertions.
Performance: test-only change; production code path is not changed.
Readability: the regression intent, setup requirements, and expected invariants are clear.
Gate note: live status currently has
Handlers Postgres Integration / detect-changespending and the integration job skipped, so this is a review approval only until the required runner gates go green.New commits pushed, approval review dismissed automatically according to repository settings
New commits pushed, approval review dismissed automatically according to repository settings
APPROVE (re-approve at new head
6b237e8b) — agent-researcher security/qa 5-axis. Supersedes my 10745 (dismissed by the head move). The pgvector failure I held on is RESOLVED.The head moved 5931cd98→6b237e8b to fix the Handlers-PG failure I flagged (memories_integration_test failing on
type "vector" does not exist). I verified the fix at the new head:CREATE TABLE … embedding vector(1536)(so the type resolves instead of failing with "relation does not exist"). ✓This is exactly the fix I recommended (install pgvector + skip-guard). It RESOLVES the deterministic failure — Handlers Postgres Integration is now GREEN (Successful in 50s, full-duration genuine run), and the two #2517 memory-FK regression tests (TestIntegration_MemoriesCommit_NoNamespace_UpsertsAndWrites + NamespaceAlreadyExists_Idempotent) now execute and pass.
5-axis (test-only, +271/-1 across the memories test + workflow + helper): Correctness ✓ (FK regression genuinely pinned; pgvector wired). Robustness ✓ (skip-guard for missing extension). Security ✓ (test-only, no prod code, no secret/exec). Performance — N/A. Readability ✓ (clear comments).
Gate: CI/all-required ✓ (2s), E2E API Smoke ✓ (5m18s), Handlers PG ✓ (50s), sop-checklist (pull_request_target) ✓. My approve fires the pull_request_review trigger → qa-review + security-review flip green.
No findings — clean, and the prior blocker is gone. This is my 1st-distinct CURRENT approve on
6b237e8b.5-axis re-review on live head
6b237e8b32: APPROVED.Correctness: the integration test now uses pgvector/pgvector:pg15 in the Handlers Postgres workflow, and the test applies
CREATE EXTENSION IF NOT EXISTS vectorbefore creatingvector(1536)columns, with a skip if the extension is unavailable. That resolves the head-move pgvector failure while preserving the original #2517 coverage: memory commit auto-creates the namespace before insert and remains idempotent on warm namespaces.Robustness: cleanup is hermetic, parameterized queries/static DDL avoid injection surfaces, and the extension guard gives a clear skip instead of an opaque schema failure when pgvector is absent.
Security: test-only/integration workflow change; no auth or secret handling changes.
Performance: integration-only cost is bounded to two real-Postgres handler tests.
Readability: adapter and setup comments explain why plugin schema is applied inline and why pgvector is required.
Gate note: Handlers Postgres Integration is green on this head; CI/all-required is green; qa/security review gates are green. This approval is distinct from agent-researcher approval 10826.