Skip to content

A rewritten open statement stays an open statement, with its phrase and the dates its sections speak from - #1469

Open
Aschenbath wants to merge 1 commit into
deeplethe:devfrom
Aschenbath:rewrite-keeps-section-dates
Open

Aschenbath wants to merge 1 commit into
deeplethe:devfrom
Aschenbath:rewrite-keeps-section-dates

Conversation

@Aschenbath

Copy link
Copy Markdown
Contributor

What happens

The three temporal rewrites insert a new row and invalidate the old one: rehome_tx (moving facts back when a merge is undone), correct_interval (a person corrects the interval) and rewrite_end_tx (the timeline writes an end). None of them copies layer or phrase. So a rewritten open statement lands as a typed row with a NULL predicate and a NULL phrase. facts_open_statement_shape only checks layer = 'open' rows, so nothing refuses it, and what the document said is gone from the row.

Two smaller losses on the same paths:

  • rehome_tx and correct_interval don't copy facts.attested_by, so the witness loses the name of its date. rewrite_end_tx already copies it.
  • copy_evidence doesn't copy fact_evidence.attested_at / attested_by (0104). If a document is deleted after the rewrite, documents::reattest_tx reads the evidence that remains, finds no chapter date on it, and falls back to the document's own date. The merge path already copies these columns since A merge keeps the identity evidence of the name it dedupes #1466.

The change

  • The three inserts copy layer and phrase; rehome_tx and correct_interval also copy attested_by.
  • copy_evidence copies attested_at and attested_by. Typed rows carry NULL there (0104: typed rows follow their source statement), so copying them changes nothing for typed rows.
  • New store test a_rewritten_statement_keeps_its_section_dates. A statement with evidence in two documents, each with its own chapter date, is rehomed, and another is corrected. The test checks that both new rows are still open statements with their phrase and the earliest chapter date with its name. Then it deletes the earlier document and checks that the witness moves to the remaining chapter date, not to that document's own date. On dev it fails at the first check, because the rewritten row has no attested_by.

Records

This doesn't implement or overturn an ADR. It makes the rewrite paths keep what 0061 (the open layer) and 0104 (evidence dates) already say a row carries, so no status line changes.

Checks

cargo fmt --check, clippy -D warnings, migrate and cargo test --workspace all pass locally, except real_postgres_backup_and_restore_require_force_and_preserve_files_on_sql_failure, which needs pg_dump, and my local image doesn't have it.

Not changed, noticed

rehome_tx and correct_interval also don't copy valid_from_grade. For a person's correction, an empty grade may be intended. For a rehome it looks like the same kind of loss, because the timeline reads the grade when it decides whether a row can close its predecessor. I've left it out so you can decide.

🤖 Generated with Claude Code

…corrected interval keeps its phrase and the dates its sections speak from

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Nash Aschenbath <wwh86696@163.com>
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