Skip to content

fix(work): make each selection its own Work version line - #4994

Merged
ScriptedAlchemy merged 6 commits into
masterfrom
t3/fix-work-scope-selection-aggregates
Nov 27, 2026
Merged

ScriptedAlchemy merged 6 commits into
masterfrom
t3/fix-work-scope-selection-aggregates

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #4215

Problem

Work's covered_prefix stopped at the first journal event outside the request's selection. One repository-scoped event therefore froze every later no-Git mutation under SelectionCoverageIncomplete, permanently, and the authorization rules forbid widening the selection, so there was no remedy.

Change

Each scope set is now its own version line over the one owner journal.

  • An event carries the relation scopes it was admitted under, and its published version is keyed by that scope set, so a graph version is only ever read together with the line it belongs to.
  • A reader folds the events native to its selection plus the narrower events that are still its base, and skips the rest. An unrelated scoped event neither advances nor breaks a line it does not belong to.
  • Line membership is decided by the event's scope set, never by its version number. Versions are per-line counters, so two lines both produce version 2 and a version match proves nothing about which line an event is on. A narrower event is a line's base only until that line folds an event of its own; after that it is a sibling written against a head the line has moved past.
  • A change that genuinely depends on an entity only another line holds fails the graph's own validation as an unknown task, which names no hidden entity.
  • Optimistic concurrency is per line: two writers on one line still conflict while an event on another line does not stale either.
  • A journal written before version lines were keyed by scope set is refused as a typed reset rather than shimmed.

Removes WorkGraphSelectionCoverageV1 and SelectionCoverageIncomplete, with no remaining caller, and regenerates the dashboard schema, decoders, types and TypeScript SDK from the canonical generators.

Acceptance criteria

Criterion Evidence
No-Git work, then unrelated repository-scoped work, does not block another no-Git mutation an_unrelated_scoped_event_does_not_freeze_a_no_git_mutation
Later authorized events appear in a current narrow view a_scoped_event_beside_no_git_work_does_not_poison_the_no_git_selection
Cross-scope dependencies get a typed denial without leaking hidden entities a_cross_scope_dependency_is_refused_without_disclosing_the_hidden_entity; CLI journey asserts no hidden proposal or scope in the serialized refusal
Optimistic concurrency correct within the relevant aggregate two_writers_on_one_line_conflict_even_with_a_scoped_event_beside_them
Current requests never present a stale prefix as current a_wider_selection_reads_the_narrower_head_until_it_takes_root
Restart preserves the same boundaries selection_aggregate_boundaries_survive_a_registered_store_restart
Old stores refused, not shimmed a_work_product_journal_predating_selection_lines_is_refused_as_a_reset

Verification

All via Bazel, counts confirmed non-zero:

  • //crates/tracedecay-rusqlite-runtime:rusqlite_suite — 158 passed
  • //crates/tracedecay-contracts:contracts_suite — 278 passed
  • //crates/tracedecay-contracts:unit_test — 461 passed
  • //crates/tracedecay-global-db:unit_test — 586 passed
  • //crates/tracedecay-daemon-service:unit_test — 437 passed
  • //crates/tracedecay-cli:work_route_exposure_conformance — 5 passed

Dashboard: contracts:check reports up to date, check:embedded reports artifacts current, typecheck clean, vitest 2333 passed across 235 files. rustfmt_check_2024 clean for every touched crate. Commitlint passes.


Devin Review

Historical selection read follow-up

Commit eb5795a441cd916357e292403394b193ed624ad1 chooses a reader's chain head from publications visible at the request's observation time. Exact evidence readers also use the verified token's inclusive event-sequence bound, so later sibling writes—even with the same observation timestamp—cannot replace the named graph's ancestry. Scope containment and complete verified-identity checks are retained. The indexed writer query, current compare-and-swap, and ancestry sequence bounds are unchanged.

The registered-store regressions historical_combined_reads_survive_later_sibling_and_own_line_writes and exact_evidence_survives_sibling_writes_at_the_same_observation compare identical historical reads and rooted/evidence results before and after later writes. They also assert that current reads advance, a sibling scope cannot read the exact token, and a missing publication cannot silently reveal an older head.

Merge 4b78b121dcc630ffeac7a93278599258120f3ae4 integrates master 4baa310, including the already validated history-fixture and grammar corrections.

Commit d4b371c77f2f1c9357603bd03d4a055fc49cee1e also orders proposal comparisons by the owner journal's event sequence. Graph version counters belong to individual selection lines and cannot order sibling snapshots. Independent exact evidence reads, full identity verification, and TaskId checks remain intact. The registered-store regression proposal_comparisons_follow_journal_order_across_selection_lines accepts chronological comparisons with equal or decreasing local counters, verifies the exact added dependency relation, and refuses reversed or identical event sequences.

Validation: canonical Bazel rustfmt_check_2024 targets for both tracedecay-contracts and tracedecay-rusqlite-runtime passed, and git diff --check passed. A focused local //crates/tracedecay-rusqlite-runtime:rusqlite_suite attempt on the preceding integrated head stopped while compiling tracedecay-contracts__dev: the compiler action exited unsuccessfully without a Rust diagnostic. Zero runtime tests executed in that local attempt. Hosted CI run 45985733601 for published head d4b371c7 passed all 181 Linux test targets (119 executed, 62 cached). In the completed fleet job, //crates/tracedecay-rusqlite-runtime:rusqlite_suite freshly passed in 175.6 seconds, covering all three new registered-store regressions. Clippy, repository gates, feature gates, dashboard, benchmark harness checks, and the Linux aggregate also passed. Windows validation is running. The original suite counts above predate these follow-ups.

Work's covered_prefix stopped at the first journal event outside the
request's selection, so one repository-scoped event permanently froze
every later no-Git mutation under SelectionCoverageIncomplete. The
authorization rules forbid widening the selection, so there was no remedy.

Each scope set is now its own version line over the one owner journal.
An event carries the relation scopes it was admitted under, and its
published version is keyed by that scope set, so a graph version is only
ever read together with the line it belongs to. A reader folds the events
native to its selection plus the narrower events that are still its base,
and skips the rest, so an unrelated scoped event neither advances nor
breaks the line it does not belong to.

Line membership is decided by the event's scope set, never by its version
number: versions are per-line counters, so two lines both produce version
2 and a version match proves nothing about which line an event is on. A
narrower event is a line's base only until that line folds an event of its
own; after that it is a sibling written against a head the line has moved
past.

A change that genuinely depends on an entity only another line holds fails
the graph's own validation as an unknown task, which names no hidden
entity. Optimistic concurrency is per line, so two writers on one line
still conflict while an event on another line does not stale either.

A journal written before version lines were keyed by scope set is refused
as a typed reset rather than shimmed.

Removes WorkGraphSelectionCoverageV1 and SelectionCoverageIncomplete, with
no remaining caller, and regenerates the dashboard schema, decoders, types
and TypeScript SDK from the canonical generators.

Refs #4215
@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d4b371c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

ScriptedAlchemy and others added 2 commits November 27, 2026 01:44
An earlier release installed the Work product journal into every
registered store, the profile authority included, although only a
project's session store hosts Work. Refusing that earlier shape whenever
the table existed turned an upgrade into a reset of the whole profile
authority, losing its project registry, accounting and remote-deletion
records for tables nothing ever wrote.

An earlier-shape journal holding no row records no Work, so its tables
are now replaced by the current shape and the store keeps serving, the
same settlement the session temporal schema gives an empty earlier
schema. A journal holding any row stays the typed reset and is left
exactly as found; no row is converted.

Refs #4215

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A selection naming the project and its repository covers both the
repository line and the no-Git line. When both advanced from the same
base, its fold applied one sibling and then refused the other, which
still expected the shared base, so the combined read and its first write
were unavailable for good.

A line that holds no event is now rooted on its widest narrower line that
holds one, the newest of equally wide ones, and a line that holds events
ends at its own last one. Readers fold exactly the chain that head ends
at, paired with each event's publication by line and sequence, so no
hidden or sibling event is ever folded or paired.

Graph versions are per-line counters, so the event draft now carries the
exact verified head it was written against, and the writer matches the
head's journal sequence and recovered digest inside the transaction
rather than a version number another line can also publish.

The writer no longer decodes and replays the owner's whole journal. It
reads the line head from a per-line index, folds only the line's events
since its checkpoint, counts checkpoint distance in the line's own
events, and hands the recovered graph to attempt admission instead of
folding it twice. A sequence index on publications keeps the invalidation
triggers from scanning the owner's history on every append.

Refs #4215

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@ScriptedAlchemy
ScriptedAlchemy merged commit 5e5d59f into master Nov 27, 2026
18 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.

Redesign Work scope selection so unrelated scoped events do not freeze current work

1 participant