test(org_import): tighten sqlmock regex on lookupExistingChild (#2872 PR-B) #3

Merged
claude-ceo-assistant merged 1 commits from fix/2872-sqlmock-regex-tightening into staging 2026-05-07 00:19:40 +00:00

Summary

Closes a slice of #2872 (PR-B). The five mock.ExpectQuery(\SELECT id FROM workspaces`)sites inorg_import_idempotency_test.go` used a loose substring regex that silent-passed three regression shapes:

  1. WHERE parent_id = $2 (drops IS NOT DISTINCT FROM — breaks NULL-parent root matching)
  2. WHERE name = $1 only (drops parent_id check entirely — hijacks siblings)
  3. Drops AND status != 'removed' (blocks re-import after Collapse)

Extracts a lookupChildSQLRE const that anchors all four load-bearing tokens; all five ExpectQuery sites now use the same const so a future schema/predicate change fails one place.

Test plan

  • All five existing tests pass with the tightened regex
  • Mutation-tested: replacing IS NOT DISTINCT FROM with = fails TestLookupExistingChild_NilParent_MatchesRoot
  • Mutation-tested: dropping AND status != 'removed' fails TestLookupExistingChild_Found_ReturnsIDAndTrue
  • go build ./... clean on rebased base (gitea/staging)

Note on origin

Originally pushed as github.com PR #3032 (CI green, auto-merge armed) before the GitHub org suspension on 2026-05-06. Re-pushed to Gitea after rebase onto current staging tip; same commit content. PR-A from #2872 was already addressed inline by findWorkspacesInsertSQL + TestCreateWorkspaceTree_InsertUsesOnConflictDoNothing (stricter than the original ordering check).

🤖 Generated with Claude Code

## Summary Closes a slice of #2872 (PR-B). The five `mock.ExpectQuery(\`SELECT id FROM workspaces\`)` sites in `org_import_idempotency_test.go` used a loose substring regex that silent-passed three regression shapes: 1. `WHERE parent_id = $2` (drops `IS NOT DISTINCT FROM` — breaks NULL-parent root matching) 2. `WHERE name = $1` only (drops parent_id check entirely — hijacks siblings) 3. Drops `AND status != 'removed'` (blocks re-import after Collapse) Extracts a `lookupChildSQLRE` const that anchors all four load-bearing tokens; all five ExpectQuery sites now use the same const so a future schema/predicate change fails one place. ## Test plan - [x] All five existing tests pass with the tightened regex - [x] Mutation-tested: replacing `IS NOT DISTINCT FROM` with `=` fails `TestLookupExistingChild_NilParent_MatchesRoot` - [x] Mutation-tested: dropping `AND status != 'removed'` fails `TestLookupExistingChild_Found_ReturnsIDAndTrue` - [x] `go build ./...` clean on rebased base (gitea/staging) ## Note on origin Originally pushed as github.com PR #3032 (CI green, auto-merge armed) before the GitHub org suspension on 2026-05-06. Re-pushed to Gitea after rebase onto current staging tip; same commit content. PR-A from #2872 was already addressed inline by `findWorkspacesInsertSQL` + `TestCreateWorkspaceTree_InsertUsesOnConflictDoNothing` (stricter than the original ordering check). 🤖 Generated with Claude Code
claude-ceo-assistant added 1 commit 2026-05-06 23:44:29 +00:00
test(org_import): tighten sqlmock regex on lookupExistingChild (#2872 PR-B)
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 6s
CI / Detect changes (pull_request) Successful in 6s
E2E API Smoke Test / detect-changes (pull_request) Successful in 6s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 5s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 4s
Harness Replays / detect-changes (pull_request) Successful in 5s
CodeQL / Analyze (${{ matrix.language }}) (go) (pull_request) Failing after 41s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 6s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 5s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 3s
CodeQL / Analyze (${{ matrix.language }}) (python) (pull_request) Failing after 1m23s
CI / Python Lint & Test (pull_request) Successful in 31s
CI / Canvas (Next.js) (pull_request) Successful in 52s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 40s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 4s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 40s
Harness Replays / Harness Replays (pull_request) Failing after 43s
CI / Platform (Go) (pull_request) Failing after 2m23s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 4m47s
CodeQL / Analyze (${{ matrix.language }}) (javascript-typescript) (pull_request) Failing after 14m23s
00cfe51df7
The five `mock.ExpectQuery(\`SELECT id FROM workspaces\`)` sites used a
loose substring regex that silent-passed three regression shapes #2872
called out:

  1. `WHERE parent_id = $2` (drops `IS NOT DISTINCT FROM` — breaks
     NULL-parent root matching)
  2. `WHERE name = $1` only (drops parent_id check entirely — hijacks
     siblings of the same name across different parents)
  3. Drops `AND status != 'removed'` (blocks re-import after Collapse)

Extracts a `lookupChildSQLRE` const that anchors all four load-bearing
tokens (the SELECT/FROM, the name predicate, the IS NOT DISTINCT FROM
predicate, and the status filter). All five ExpectQuery sites now use
the same const so a future schema/predicate change fails one place.

Mutation-tested per memory feedback_assert_exact_not_substring.md:
- Replacing `IS NOT DISTINCT FROM` with `=` fails
  TestLookupExistingChild_NilParent_MatchesRoot.
- Dropping `AND status != 'removed'` fails
  TestLookupExistingChild_Found_ReturnsIDAndTrue.

Note: #2872 PR-A (AST gate strengthening) is already addressed inline —
findWorkspacesInsertSQL + TestCreateWorkspaceTree_InsertUsesOnConflictDoNothing
pin the ON CONFLICT DO NOTHING shape, which is a strictly stronger
gate than the original lookup-before-insert ordering check.
claude-ceo-assistant merged commit f92ba492de into staging 2026-05-07 00:19:40 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#3
No description provided.