Skip to content

chore(ga): restore merge soft-close, drop dead refund path, dedup tests#34

Merged
Coding-Dev-Tools merged 2 commits into
mainfrom
chore/ga-cleanup
Jul 21, 2026
Merged

chore(ga): restore merge soft-close, drop dead refund path, dedup tests#34
Coding-Dev-Tools merged 2 commits into
mainfrom
chore/ga-cleanup

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Consolidated GA cleanup (follow-up to #24/#25/#30):

  1. service.py — restore bi-temporal SOFT-CLOSE in merge_workspaces() collision handling (ported from Codex/commercial v1 ga #30), replacing feat(commercial-v1-ga): sync working-tree changes for v1 GA #24's hard DELETE FROM edges. Matches the canonical Store._deduplicate_live_edges() convention (valid_to + expired_at + canonical_deduplicated_into marker); preserves temporal history.
  2. billing.py — remove ~86 lines of unreachable dead code in polar_webhook() (2nd refund/revoke dispatch pre-empted by the _REVOKING_EVENTS guard) plus its now-unused helpers (grep-confirmed no other callers).
  3. tests — update test_merge_deduplicates_colliding_live_edges to assert soft-close semantics; dedup the byte-identical _registry_rows() in test_billing.py (supersedes fix(tests): remove duplicate _registry_rows() definition in test_billing.py #32).

Validated locally: ruff clean; pytest 1605 passed / 14 skipped / 0 failed (identical pass count to unmodified main in the same env).

…up test fixture

- service.py merge_workspaces(): replace the hard DELETE on colliding live
  edges with the bi-temporal soft-close used elsewhere in the codebase
  (Store._deduplicate_live_edges): merge weight/provenance/valid_from/
  ingested_at and live edge_supports onto the surviving edge, then close the
  losing edge with valid_to+expired_at and a canonical_deduplicated_into
  provenance marker instead of deleting it. Ported from the validated
  closed-PR #30 (codex/commercial-v1-ga) implementation. Drops the now-orphaned
  _dumps import (its only call site was the removed hard-delete path).
- tests/test_workspace_ops.py: update
  test_merge_deduplicates_colliding_live_edges to assert soft-close semantics
  (losing edge still present with valid_to/expired_at set and the
  canonical_deduplicated_into marker pointing at the survivor) instead of
  asserting the row is gone.
- billing.py: remove polar_webhook()'s unreachable second refund/revoke
  dispatch (order.refunded / subscription.revoked / subscription.updated
  status==revoked) — the _REVOKING_EVENTS guard earlier in the function
  always returns first, so this code never ran. Also removes the
  now-fully-unused _revoke_refunded_order, _revoke_subscription_event,
  _polar_subscription_id and _polar_order_id (confirmed zero other
  callers/uses repo-wide via grep before deleting).
- tests/test_billing.py: remove the duplicate def _registry_rows() (two
  byte-identical definitions; Python silently kept only the second).

Validated: ruff check . clean; pytest tests/ 1605 passed, 14 skipped, 0
failed (identical to unmodified origin/main in this environment, confirming
no regressions).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner Author

Pre-PR Code Review — APPROVE ✅

CI: 8/8 checks passing (all green)

Analysis

  • billing.py (−99 lines): Removes _polar_subscription_id, _polar_order_id, _revoke_refunded_order, _revoke_subscription_event and their dispatch sites in polar_webhook(). These are unreachable — the _REVOKING_EVENTS guard (added in feat(billing): refund/revocation webhooks + Polar ID tracking + MCP role gate #25/Codex/commercial v1 ga #30) pre-empts the 2nd refund/revoke dispatch. Grep-confirmed no other callers. Clean dead-code removal.
  • service.py (merge_workspaces edge collision): Replaces feat(commercial-v1-ga): sync working-tree changes for v1 GA #24's hard row removal with bi-temporal soft-close (valid_to + expired_at + canonical_deduplicated_into provenance marker). Correctly mirrors Store._deduplicate_live_edges() convention. Uses json.dumps(..., ensure_ascii=False) directly instead of _dumps — equivalent and fine. The UPDATE edge_supports now filters on live rows only (valid_to IS NULL AND expired_at IS NULL), which is more precise than the old UPDATE OR IGNORE.
  • tests/test_billing.py (−13 lines): Removes duplicate _registry_rows() (supersedes fix(tests): remove duplicate _registry_rows() definition in test_billing.py #32).
  • tests/test_workspace_ops.py: Updated to assert soft-close semantics (row survives with valid_to/expired_at set + provenance marker) instead of hard removal. Correct.
  • Security: No issues. Removes dead code paths (reduces attack surface), no new logic that could introduce vulnerabilities.
  • Regressions: None detected. The soft-close convention is the canonical pattern.

Verdict: APPROVE — Clean consolidation PR. Dead code removed, soft-close restored, tests updated. CI green. Ready to merge pending branch protection approval from a human reviewer.

…e_workspaces

The soft-close support move (UPDATE edge_supports SET edge_id=...) was a plain
UPDATE. idx_edge_support_live_unique is a partial unique index on
(edge_id, memory_id, source_kind) WHERE live, so if the surviving target edge
already had a live support for the same memory (same memory_id + source_kind),
retargeting the source edge's identical live support onto it violated the
index and raised sqlite3.IntegrityError, rolling back the whole merge
transaction. Main's prior hard-delete code guarded against this with
UPDATE OR IGNORE; the soft-close port dropped that safeguard.

Fix: use UPDATE OR IGNORE for the move (matches main's original convention),
then soft-close (valid_to+expired_at) whatever live support OR IGNORE left
behind on the source edge, so nothing stays live on a now-closed edge --
mirroring how Store._deduplicate_live_edges() closes retired supports.

Added test_merge_deduplicates_colliding_live_edges_with_colliding_support to
tests/test_workspace_ops.py: both workspaces' colliding edges are backed by
the same memory id, so the support move itself collides. Verified this test
fails with the exact predicted IntegrityError against the pre-fix code and
passes against the fix.
@Coding-Dev-Tools
Coding-Dev-Tools merged commit 2200d36 into main Jul 21, 2026
8 checks passed
@Coding-Dev-Tools
Coding-Dev-Tools deleted the chore/ga-cleanup branch July 21, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant