Skip to content

#882 feat: readable record ownership, and owned_by_dataset (v0.81.0) - #891

Merged
gregoryfoster merged 4 commits into
mainfrom
feat/882-ownership
Nov 26, 2026
Merged

gregoryfoster merged 4 commits into
mainfrom
feat/882-ownership

Conversation

@gregoryfoster

Copy link
Copy Markdown
Member

Part 2 of 2 for #882. Stacked on #889 (base feat/882-reason-code). Merge #889 first; GitHub then retargets this PR to main. Design doc: docs/plans/2026-11-25-reason-code-ownership-design.md. Decisions: operator comments 7172492503, 7175854705 and 7177148696.

What changes

Ownership on reads, relative to the calling key

  • AssignmentDetail.ownership covers the tenure: start_date, end_date, is_current.
  • OrgDetail.parent_ownership covers parent_id, the only org column the gate guards.
  • Both answer self | other | none | dataset, typed as the Ownership enum in the spec.
  • Served on getAssignment, getOrg and batchGetOrgs. These three now take require_key for the key id.
  • dataset comes first. A subscribed dataset's in-scope producer_crosswalk anchor means its nightly apply reverts any observation write, whoever holds source_key_id.
  • ETag: make_etag(id, updated_at, *relative) gives "<id>-<ms>-<ownership>". Two keys never share a validator, and the ETag changes when a dataset starts owning a row, though updated_at doesn't. The batch ETags still equal getOrg's.

Writes the apply would revert (owned_by_dataset, a new ObservationReasonCode)

  • Refused before the source_key_id gate:
    • an id-addressed assignment update or retract;
    • an id-addressed reparent.
  • An identical assertion never claims a dataset row: Provenance cannot be claimed by an identical id-addressed observation — no-op precedes the COALESCE #478's claim stops there.
  • Skipped, not refused, and listed in unapplied (operator, 2026-11-25), so the rest of the observation lands:
    • the natural-key close-enrichment;
    • the write-if-null parent fill. Re-asserting the parent the org already holds is agreement, not a skip.

The principle and its guard

  • OBSERVATIONS.md § Record ownership: a source_key_id gate exists exactly where the observation API can overwrite or remove a value, and who created a row is not who may overwrite it.
  • tests/core/test_source_key_gates.py declares each of the 7 tables that carry the column as a gate or a stamp, and fails on a new one or on a gate for people or roles.

Docs

  • API_ASSIGNMENTS, API_ORGS: the new fields and refusals.
  • PUBLIC_API: the code table, unapplied, the ETag format.
  • CONVENTIONS: make_etag.

Release: v0.81.0, with the client regenerated.

Verification

  • Pre-commit unit tier: passed.
  • New tests/api/public/test_record_ownership.py: 20 integration tests, all passed.
  • Related integration modules (orgs, assignments, observations, conditional GET, observation writers and resolver, dataset ownership): 510 passed.
  • scripts/pre-ship.sh: passed.
  • The full -m integration suite was not run here, by the operator's direction (Tests: cut commit-hook and suite wall-clock; integration runs only when asked #890). PR 1's full run, on the shared base, was 5609 passed.

Known limits:

  • dataset uses the overlay's anchor scope. An anchored org whose dataset emits no parent row still reads dataset, and a parent fill there is skipped. Accepted in the design.
  • List rows carry no ownership, because a collection ETag can't be per-key.

🤖 Generated with Claude Code

gregoryfoster and others added 4 commits November 26, 2026 00:37
AssignmentDetail.ownership and OrgDetail.parent_ownership answer
self | other | none | dataset relative to the calling key (getAssignment,
getOrg, batchGetOrgs). `dataset` comes first: a subscribed dataset's in-scope
crosswalk anchor means its nightly apply reverts any observation write,
whoever holds source_key_id. The detail ETag folds the value
(make_etag(..., *relative)), so two keys never share a validator and a dataset
adopting a row moves it. The three reads take require_key for the key id.

Writes the apply would revert: an id-addressed assignment update or retract,
or an id-addressed reparent, is refused `owned_by_dataset` before the
source_key_id gate; an identical assertion never claims a dataset row; the
natural-key close-enrichment and the write-if-null parent fill are skipped and
listed in `unapplied` (operator, 2026-11-25).

The principle is in OBSERVATIONS.md § Record ownership, held by
tests/core/test_source_key_gates.py: a gate exists exactly where the API can
overwrite or remove, and every source_key_id column is declared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te, as what ignores the stamp

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hout IF NOT EXISTS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ip is a closed set (CR 2)

OBSERVATIONS.md and PUBLIC_API.md were already over the 10,000-token doc
budget, and #882 added 900 and 1,084 tokens to them. The reason-code table,
the one-name paragraph and the Record ownership section move to
docs/PRODUCER_CONTRACT.md, reached from both. The growth falls to 65 and 397.
The new doc also says Ownership's four values are a closed set (the second half
of CR 2). The guard, the docstrings and API_ASSIGNMENTS point at the new doc;
the client is regenerated, as ObservationReasonCode's docstring is in the spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from feat/882-reason-code to main November 26, 2026 01:39
@gregoryfoster
gregoryfoster merged commit 717098b into main Nov 26, 2026
1 check passed
@gregoryfoster
gregoryfoster deleted the feat/882-ownership branch November 26, 2026 01:39
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