Skip to content

[B-028] Persist a sidecar incident's parent identity across restarts - #166

Merged
jackspiering merged 2 commits into
cycle/batchfrom
cycle/B-028-persist-parent
Oct 29, 2026
Merged

jackspiering merged 2 commits into
cycle/batchfrom
cycle/B-028-persist-parent

Conversation

@jackspiering

Copy link
Copy Markdown
Owner

Closes #142

Packet: B-028 · Items: E-005 · Tier: complex · Implemented by: claude-sonnet-5-5
Version impact: minor

Acceptance

  • go vet ./... && go test -race -count=1 ./... — passes

Failing-first test

TestParentChangeAfterARestartOpensANewIncident: failed before (with only the IncidentRecord.Parent field added, not wired) with a new parent is repaired at once, not held by the cooldown of the repair before: {Act: ... RecheckAt: ...} (the restored incident had no parent, so the change was not seen); passes now. Store: the round trip (Parent added to sampleKey) and TestSchemaFourDatabaseIsMigratedToTheIncidentParent.

Deviations from the packet

  • Schema is 5 (B-027 took 4): ALTER TABLE incidents ADD COLUMN parent; migrate no longer returns at the schema-4 step.
  • The three older-schema migration tests now drop the parent column when they fake an old database (they reset user_version on a fresh one).
  • The schema-4 CHANGELOG/docs/running.md text now says schema 5.
  • docs/upgrading.md's schema table (outside files) still lacks a row for schema 5; not edited per the scope rule. Follow-up needed.
  • Also marks the key dirty when an incident learns its parent, so it is persisted.

@jackspiering

Copy link
Copy Markdown
Owner Author

Verified by claude-opus-5-5: plan followed. (Independent: the implementer was claude-sonnet-5-5.)

  • Test proves the fix: with internal/engine/engine.go and internal/store/store.go at the merge-base (keeping the IncidentRecord.Parent field so it compiles), TestParentChangeAfterARestartOpensANewIncident fails as the packet says (restored incident has no parent: no action, held by the old cooldown), and TestSchemaFourDatabaseIsMigratedToTheIncidentParent fails with no such column: "parent". Both pass with the fix.
  • Persisted both ways: flush writes and Restore reads Parent; SaveKey inserts and upserts the column, Load scans it. CloseIncident and Rekey (UPDATE ... SET key) keep the row's parent. Learning a parent now marks the key dirty, so it is saved. The new test checks IncidentClosed parent_changed, one IncidentOpened at rung 0, no Suspended, flaps unchanged, and the new parent persisted.
  • Migration: schema 3 → 5 with data (the schema-3 test, which now expects schemaVersion) and 4 → 5 with an open incident (new test); each step is its own transaction. The DROP COLUMN parent added to the three old-schema tests is needed: they downgrade a fresh schema-5 file, and ADD COLUMN would otherwise fail on a duplicate column. No assertion was weakened.
  • Deviations (schema 5 because B-027 took 4; dirty marking; schema text 4→5) are justified. docs/upgrading.md was outside files: I added the schema 5 row and replaced the sentence that a v0.1.0 database needs no migration. It now says every release up to v0.3.0-rc.1 is schema 3, and that v0.3.0's first start adds the schema-4 indexes and the schema-5 parent column. version_impact minor is fine (a new persisted column, no downgrade).
  • Merged cycle/batch ([B-004] Bound refusals that never clear (E-001) #165, [B-001] Compose-built images must not make their containers non-compose #161) in. In docs/running.md I kept [B-004] Bound refusals that never clear (E-001) #165's ladder line and this PR's Recovered line. go vet ./... && go test -race -count=1 ./... passes on head 2520413.

@jackspiering
jackspiering merged commit 53bb831 into cycle/batch Oct 29, 2026
10 checks passed
@jackspiering
jackspiering deleted the cycle/B-028-persist-parent branch October 29, 2026 00:37
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