Documentation

Docs / Reference

ADR 0056 - Change journal, comparison bases and change impact

Status: Accepted (delegated review, 2026-11-14)

Context

Change impact is the first user-facing M2 feature after the schema work (project plan M2; VISION "Change impact"). Developer decisions of 2026-11-08 and 2026-11-09 fix its scope:

What exists today:

Options considered

1. Where comparisons come from

2. Pinned baselines

3. Branch versus base

How a ref's files reach the scanner:

4. Identity of facts across renames and moves

5. Where change semantics live

Decision

Options 1C, 2B, 3B with ls-tree/cat-file materialisation, 4C and 5B. Contract v1 is unchanged (contract_version stays 1).

Journal write path

Store schema (migration 0004, SQLite and Postgres)

Both dialects get 0004_graph.sql; migrations.Version becomes 4. Keys use C collation on Postgres like the graph tables.

CREATE TABLE change_runs (
  repository TEXT NOT NULL REFERENCES repositories(repository),
  seq INTEGER NOT NULL,             -- per repository, increasing
  run_id TEXT NOT NULL,             -- index_runs.id
  payload TEXT NOT NULL,            -- extractor, commit, dirty, counts, gaps
  PRIMARY KEY(repository, seq));
CREATE UNIQUE INDEX change_runs_run ON change_runs(repository, run_id);
CREATE TABLE change_entries (
  repository TEXT NOT NULL,
  seq INTEGER NOT NULL,             -- the run that made the change
  record TEXT NOT NULL,             -- 'file' | 'node' | 'edge'
  key TEXT NOT NULL,                -- path | identity | kind NUL source NUL target
  before TEXT,                      -- payload before the run; NULL = absent
  after_hash TEXT,                  -- sha256 of the payload after; NULL = absent
  PRIMARY KEY(repository, seq, record, key),
  FOREIGN KEY(repository, seq) REFERENCES change_runs(repository, seq) ON DELETE CASCADE);
CREATE INDEX change_entries_key ON change_entries(repository, record, key, seq);
CREATE TABLE change_pins (
  repository TEXT NOT NULL REFERENCES repositories(repository),
  id TEXT NOT NULL, name TEXT NOT NULL,
  seq INTEGER NOT NULL,             -- the pinned run
  payload TEXT NOT NULL,            -- copy of that run's change_runs payload, created_at
  PRIMARY KEY(repository, id));
CREATE UNIQUE INDEX change_pins_name ON change_pins(repository, name);
CREATE TABLE change_pin_entries (
  repository TEXT NOT NULL, pin TEXT NOT NULL,
  record TEXT NOT NULL, key TEXT NOT NULL,
  before TEXT,                      -- payload at the pin; NULL = absent at the pin
  PRIMARY KEY(repository, pin, record, key),
  FOREIGN KEY(repository, pin) REFERENCES change_pins(repository, id) ON DELETE CASCADE);
CREATE TABLE ref_snapshots (
  repository TEXT NOT NULL REFERENCES repositories(repository),
  namespace TEXT NOT NULL,          -- the reserved repository id holding the graph
  commit_id TEXT NOT NULL, extractor TEXT NOT NULL,
  payload TEXT NOT NULL,            -- run id, created_at, last_used_at, gaps, config source
  PRIMARY KEY(repository, namespace));

before alone is enough to compose any comparison: the state of a key at run R is the before of its earliest entry after R, or the current row when no later entry exists. after_hash lets the oracle and the composition skip a no-op chain without decoding payloads.

Retention

Branch versus base

Raw change sets (store) and the claim contract (Go)

HTTP API (additive, api_version 0)

All under /api/v0/changes/, read through internal/changes, with freshness (as /api/v0/status) in every response and the runs-before/ after check of ADR 0042 (409 index_changed).

CLI

graphvein changes [--base previous|run:ID|pin:NAME|ref:BASE[..HEAD]] [--group G] [--json], graphvein changes impact ID, graphvein changes pin NAME [--run ID], graphvein changes unpin NAME, opening the store like the other query commands (ADR 0009) except for pin, unpin and ref indexing, which take the index lock. JSON shapes equal the HTTP items.

Consequences

Known gaps

Implementation notes (T019a1)

Recorded by the implementation; the decision above is unchanged unless a note says otherwise. Open points O1 to O10 of the task use their provisional defaults (developer 2026-11-09).

Known gap found during implementation: on a checkout with CRLF conversion (Windows core.autocrlf=true, eol=crlf attributes) the working-tree index records the converted bytes' size and blob id, a ref snapshot the committed blob's. A ref comparison against the current index then shows those file records as changed (content hashes are equal, since the scanner normalises line endings). The classification (a2) has to treat such a difference as a move or the contract has to say how it is reported.

Implementation notes (T019a2)

Recorded by the implementation of internal/changes, the API and the CLI; the decision above is unchanged unless a note says otherwise.

Implementation notes (T019a, Revision 1)

Task revision 1 (2026-11-13) decided the A0 findings; the classification follows it (ContractVersion T019-r1).

Implementation notes (T019a, Revision 3)

Task revision 3 (2026-11-14) fixes the independent review's findings as class rules (ContractVersion T019-r3). Status stays Proposed.

Implementation notes (T019a gates)

Decision under the developer's delegation of 2026-11-13 (the gate was tried first, then raised with a reason). Status stays Proposed.

Implementation notes (T019a, Revision 4)

Task revision 4 (2026-11-14): row I8 follows T018h's code-to-table edges (ADR 0060, docs/extract/table-access.md) (ContractVersion T019-r4). Status stays Proposed.

Review notes (delegated review, 2026-11-14)

Accepted for T019a (backend: journal, comparisons, impact, API, CLI) after the green [ci windows] run 43585029421 on 681aaac (Windows and postgres green; postgres job 0 FAIL, only env-gated skips). T019b (the Changes view, design V3 with V1's density) follows under this ADR.

Implementation notes (git subprocess rule, 2026-11-14)

A Windows CI run failed the check that materialising a ref writes nothing into the repository's .git (intermittent; it passed in the run before). The git rule is now one class rule in one place:

Review notes, T019b (delegated review, 2026-11-14)

The Changes view merged after the green [ci windows] run 43598267568 on 4721fb2 (Windows and postgres green; postgres job 0 FAIL, only env-gated skips; check-web ok).

Implementation notes (T026 AG-F, T019 Revision 7)

Pending the developer's review. React bridges (ADR 0079 AG-B5) enter the claim contract as one class rule each (ContractVersion T019-r7):

Revision (T042): traversal depth maximum 10

Status of this revision: Proposed (pending the developer's review; the decisions above keep their status).

Report a problem with this pageSource: docs/adr/0056-change-journal-and-impact.md