Skip to content

fix(admin): preserve hierarchy enabled_at on flip-off; add disabled_at for forensics#3475

Merged
bokelley merged 1 commit into
mainfrom
claude/issue-3466-disabled-at-forensic-preservation
Apr 28, 2026
Merged

fix(admin): preserve hierarchy enabled_at on flip-off; add disabled_at for forensics#3475
bokelley merged 1 commit into
mainfrom
claude/issue-3466-disabled-at-forensic-preservation

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Refs #3466. Delivers acceptance criteria items 2–4 only. Item 1 (IP + user-agent in audit details) is deferred — see triage comment on #3466 for the compliance decision needed first.

Summary

Migration 450 nulled auto_provision_hierarchy_enabled_at when auto_provision_brand_hierarchy_children was flipped off, silently destroying the forensic record of when the feature was last active. This PR:

  • Adds auto_provision_hierarchy_disabled_at TIMESTAMPTZ NULL to organizations (migration 452)
  • Updates the track_auto_provision_hierarchy_enabled_at trigger so flip-off sets disabled_at = NOW() and preserves enabled_at (which the cohort gate in autoLinkByVerifiedDomain reads exclusively — gate semantics unchanged)
  • Adds the field to the Organization TS interface
  • Updates both integration test suites (org-auto-provision-toggles, find-paying-org-for-domain) to match the new semantics and adds an enable → disable → re-enable cycle test

A complete (enabled_at, disabled_at) pair lets incident response trace the full on/off cycle without losing the original opt-in timestamp.

Non-breaking justification

Adds a single nullable column with no DEFAULT; existing rows get NULL (no table rewrite). No read path or gate logic changed. The Organization interface addition is additive.

Pre-PR review

  • code-reviewer: approved — trigger replacement via CREATE OR REPLACE FUNCTION is correct (PostgreSQL binds triggers by function name); test cycle assertions are sound; no flakiness risk. Nit: add trigger name to migration comment (not blocking).
  • internal-tools-strategist: approved — disabled_at correctly DB-only (not surfaced in GET /domains API); ADD COLUMN IF NOT EXISTS on nullable column is metadata-only in PG 11+, no lock concern. Identified blocker (stale assertion in find-paying-org-for-domain.test.ts) — fixed in this commit.

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See #3121
for context.

Session: https://claude.ai/code/session_01Pn9rJFGQxPJpKGfUyF6W2v


Generated by Claude Code

…t for forensics

Migration 450 nulled auto_provision_hierarchy_enabled_at when the flag was
flipped off, destroying the forensic record of when the feature was last active.

Adds auto_provision_hierarchy_disabled_at TIMESTAMPTZ NULL and updates the
trigger so flip-off sets disabled_at = NOW() and preserves enabled_at.
The cohort gate in autoLinkByVerifiedDomain continues to read only enabled_at
as authoritative — this change does not alter gate semantics.

Partial fix for #3466. IP/user-agent audit enrichment deferred separately.

Session: https://claude.ai/code/session_01Pn9rJFGQxPJpKGfUyF6W2v
@bokelley bokelley added the claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage. label Apr 28, 2026
@bokelley bokelley marked this pull request as ready for review April 28, 2026 19:45
@bokelley bokelley merged commit 2c5db4f into main Apr 28, 2026
14 checks passed
@bokelley bokelley deleted the claude/issue-3466-disabled-at-forensic-preservation branch April 28, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants