Skip to content

Add recall/promotion tracking fields to Entry schema#45

Merged
quad341 merged 2 commits into
mainfrom
deploy/crn-n2cf-gate
Jul 23, 2026
Merged

Add recall/promotion tracking fields to Entry schema#45
quad341 merged 2 commits into
mainfrom
deploy/crn-n2cf-gate

Conversation

@quad341

@quad341 quad341 commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What changes

Adds 5 new fields to the Entry struct and matching SQLite columns to the
index so entries can track recall/promotion lifecycle state:

  • Kind — distinguishes a plain note (default, empty) from a remediation entry
  • AutoActionable — reviewer-granted flag for remediation entries that can be
    acted on automatically; not self-declarable by the entry's own creation path
  • RecurrenceCount — incremented when a new entry is captured with the same
    topic key as an existing one
  • PromotedBeadID — set once an entry is promoted to a tracked bead, guarding
    against double-promotion
  • LastRecalledAt (RFC3339) — stamped only by the get/freshness/verify path,
    not by capture

All 5 fields are additive and zero-value-safe: existing entries with none of
this metadata parse and round-trip unchanged (omitempty/omitzero tags
throughout).

Why built this way

The index table gets the same 5 columns via a forward migration
(addColumnIfMissing), so existing on-disk indexes upgrade in place. The
three index-only fields (RecurrenceCount, PromotedBeadID, LastRecalledAt)
plus Kind/AutoActionable are deliberately excluded from reindex's
ON CONFLICT(id) DO UPDATE SET clause — the same treatment the existing
hit_count column already gets. Reindexing rebuilds the index from each
entry's body file, but these fields are written directly via SQL by other
call sites after an entry already exists; if reindex overwrote them on every
run, it would stamp live index-only state back to the body's stale seed
value. Excluding them from the UPDATE SET means insert-if-absent still works
for new rows, while existing rows keep whatever the index already has.

What to review

  • internal/cairn/entry.go — the 5 new struct fields and their toml tags
  • internal/cairn/index.go — new columns in the CREATE TABLE, the
    migration column list, and the reindexTx INSERT/upsert logic (note the
    bool→int conversion for AutoActionable, and the intentional gap in the
    DO UPDATE SET clause)

Test plan

  • TestParseEntryNewFieldsZeroValues / TestParseEntryNewFieldsRoundTrip
    parsing with none vs. all of the new fields present
  • TestEntryMarshalRoundTripsNewFields / TestEntryMarshalOmitsZeroValueNewFields
    — serialization round-trips and confirms zero values stay omitted
  • TestReindexPreservesNewIndexOnlyFields — reindex does not clobber
    index-only state written outside the body file
  • TestReindexPopulatesNewFieldColumns — fresh rows get correct values
  • TestReindexMigratesLegacyIndexSchemaNewFields — an old on-disk index
    without these columns migrates forward cleanly

All existing and new tests pass, including -race. gofmt, go vet, and
golangci-lint are clean.

quad341 added 2 commits July 23, 2026 16:22
…rn-28ge.1.1)

Adds LastRecalledAt, RecurrenceCount, PromotedBeadID, Kind, and
AutoActionable to the Entry struct (internal/cairn/entry.go) and the
matching SQLite index columns (internal/cairn/index.go). All five are
index-only state excluded from reindex's ON CONFLICT DO UPDATE SET,
so future write paths can populate them without a reindex clobbering
them back to the body's stale seed value (mirrors the existing
hit_count precedent).

Reviewer PASS on crn-28ge.1.1 (content-signature verified: this
branch's tip carried unrelated already-merged commits due to a known
harness rebase-churn bug, crn-6qbb, so this commit reconstructs the
exact reviewed 4-file diff fresh off origin/main rather than
inheriting that branch's broken ancestry).
…hema (crn-28ge.1.1)

Documents PASS on all 7 release-gate criteria for the 5 new Entry
fields (LastRecalledAt, RecurrenceCount, PromotedBeadID, Kind,
AutoActionable) and matching SQLite schema/migration/reindex changes.

Notes the content-signature-verification method used in place of
SHA-pinning, per known rebase-churn instability on the source branch
(crn-6qbb), and the branch-reconstruction rationale for producing
clean ancestry from origin/main.
@quad341
quad341 merged commit b4619c7 into main Jul 23, 2026
2 checks passed
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