Skip to content

OpenConceptLab/ocl_online#365 | The write checkpoint asks make_private when a repository row is saved as private - #1009

Merged
snyaggarwal merged 36 commits into
masterfrom
ocl_online-365-private-gate
Nov 23, 2026
Merged

snyaggarwal merged 36 commits into
masterfrom
ocl_online-365-private-gate

Conversation

@paynejd

@paynejd paynejd commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Part of OpenConceptLab/ocl_online#365. Stacked on #1007 (base ocl_online-424-write-checkpoint), whose write checkpoint it extends; retarget to master once #1007 merges. Design: ocl_online#365 issuecomment-7008529914.

Also carries part of OpenConceptLab/ocl_online#698 (5f1d7ab): a FHIR update never makes a private HEAD viewable. That fix ships only when #1007 and then this PR merge. The rest of #698 stays open, and nothing here closes it: taking the values a FHIR resource omits from HEAD rather than from the resolved release.

What changes

  • A fourth write action, make_private, on CapabilityPolicy.get_write_refusal(user, content, action). It's asked whenever a repository row is saved as one others can't view by its own public_access:
    • a new private repository;
    • a HEAD or version that others could view by its own public_access and is changed to private;
    • a private row that moves to another owner (no route allows that today; the check is one comparison).
  • Where: ConceptContainerModel.persist_new and persist_changes ask before saving, so every path that saves a repository row asks:
    • REST create, and PUT/PATCH on the repository, …/HEAD/, …/{version}/ and …/latest/;
    • bulk-import and package-import source and collection lines;
    • FHIR updates whose resolved release is private. A FHIR create is always public, since a FHIR resource carries no access.
  • A refusal is WriteRefused, the 403 with the policy's body that OpenConceptLab/ocl_online#424 | A write checkpoint lets the capability policy keep content read-only #1007 added (an OperationOutcome on FHIR routes, with the body's values as its issues). An import line, or a package resource, fails with the body in the report, and the rest of the import goes on.
  • A FHIR update never makes a private HEAD viewable (Codex passes 2 and 3; part of OpenConceptLab/ocl_online#698). CodeSystem, ConceptMap and ValueSet updates save the resolved release's values onto HEAD, its public_access included.
    • Now a private HEAD keeps its own access.
    • A private release's access still goes onto a viewable HEAD, with its other values, so nothing private becomes viewable. That saves HEAD as private, so it asks make_private.
  • Not asked: creating a repository others can view; a new version, which takes its HEAD's access; saving a row that was private already; making a row viewable (publish, as before).
  • The default policy allows it, so nothing changes for anyone until a policy refuses.

Tests

core/capabilities/tests/test_make_private.py uses a stub policy that refuses make_private. It covers:

  • REST create for user- and organization-owned sources and collections, refused with the body and nothing saved, and created when allowed;
  • every update route for HEADs and versions, including a version under a private HEAD (it keeps its own access);
  • rows already private, rows made viewable, and new versions, which aren't asked;
  • FHIR updates of all three types: a private HEAD stays private (this fails on all three without the fix), and a private release onto a viewable HEAD is refused, by REST and in a package;
  • import lines, refused with the body while the rest import.

makes_private has its own table of cases. The whole suite runs 3,405 tests OK (2 skipped), and pylint -j0 core/ exits 0.

Review

Codex passes are posted below with replies.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi

paynejd and others added 19 commits November 19, 2026 00:25
…y policy keep content read-only

CapabilityPolicy.get_write_refusal(user, content, action) is asked once a user's own
access allows a write to a repository (its HEAD) or a map project. The action is
edit, delete (the whole repository or map project) or publish (a private repository
becomes viewable by others). It returns None to allow the write, or a body that is
sent as a 403 (WriteRefused). The default policy refuses nothing.

Checked: repository and map project writes through CanEditConceptDictionary (and
concept, mapping, name, extra and reference writes through their repository),
version create/update/delete, both $clone targets, bulk import lines (a refused line
is reported as permission denied with the body), package-import updates, and
cross-repository hierarchy updates (skipped when refused). Processing flags, the
references preview, client configs, exports and expansions are not checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVrPPnDZrZdP6cZdwk
…ritten, and writes stay in the repository checked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVrPPnDZrZdP6cZdwk
…rsion, and default expansions and queued reference adds are checked

Codex pass 2 on #1007, and the other half's pass 3:
- A write to a version is asked about that version, which keeps its own
  public_access, not about its HEAD. Making a private version viewable is
  `publish`; deleting a version is still an edit.
- `short_code` is read-only on the version serializers, so a version update
  never moves it to another repository.
- Re-evaluating a version's default expansion, and creating an expansion that
  becomes its default, are edits of the version.
- The reference-add task asks again when it runs, and returns the refusal.
- The latest-version routes classify from the row they resolve.
- A DELETE's body is never read.
- Linking a parent's new version to the children it already has isn't asked
  about: the system keeps those links current (reverts the pass 1 change,
  which hid such children from the parent's children).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
… they write, a version keeps its repository on every route, and external export changes are checked

Codex pass 3 on #1007:
- A FHIR update (API or package import) is asked about the HEAD it saves
  onto, whichever row the URL or canonical URL resolves (`updates_head` on
  the CodeSystem, ConceptMap and ValueSet detail views).
- A version keeps its repository on every route: the create-or-update
  serializers take a mnemonic from the body only for a new row or a HEAD,
  which covers the repository detail route with `?version=`. This replaces
  the read-only `short_code` from the last commit.
- Making a version viewable is `publish` only while its HEAD is viewable;
  under a private HEAD it stays hidden, so it's an edit.
- Uploading or removing an external export is an edit of the version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
…te tests repeat, and a guard that only skipped a cheap policy, cut

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
…s decided from the stored row, and publishing follows how a version is viewed

Codex check of 597fd82..ee1bdec on #1007:
- Whether a row may take a new mnemonic is decided from the stored row,
  before the body's version label applies.
- `makes_viewable` follows `is_publicly_viewable`: without an active HEAD, a
  version is viewable by its own access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
…s an edit of its version, a started run can finish, and an import asks once per repository

- Expansion POST and DELETE and re-evaluate/ use CanEditConceptDictionaryVersion, so each is an edit of the version,
  default or not. The two default-only checks are gone; the processing route still isn't asked.
- AutomatchRunView sets writes_content = False: its PATCH takes only a run's lifecycle fields and changes no project
  content, so a run that was allowed to start can record its progress and finish. Starting a run is still asked.
- BatchWriteRefusals asks the capability policy once per user, saved repository row and action. BulkImportInline's
  lines and hierarchy pass share one, and so do the rows of a package file. An import line never changes the access
  of an existing row, so an answer holds for the batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…swer can change during a run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…tays one takes a new mnemonic, and a batch's answers expire after a minute

Codex check of ee1bdec..60d9e65 on #1007:
- FC.1: a stored row takes the body's mnemonic only when it is a HEAD before and after the body applies. A HEAD
  that the body relabels as a version keeps its repository, as a version relabelled HEAD already did; this covers
  the repository route and FHIR ValueSet updates, which both prepare the row here.
- FC.2: BatchWriteRefusals asks again once an answer is a minute old, so a change in the policy's answer reaches a
  long import within the minute instead of at its end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…n is about the row as stored now

Codex check of 60d9e65..59642d9 on #1007, FC.3: a batch keeps the rows it loaded, so once
an answer expired, the policy was asked about a row whose access may have changed since (a source made public during
an import was still refused). BatchWriteRefusals now asks about the row as stored now, one query per repository a
minute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…cks the question asked after an answer expires

Codex check of 59642d9..85795a9 on #1007, FC.5: the test only exercised the first question.
It now asks, makes the row public, lets the answer expire and checks that the second question is about the public row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…e write checkpoint

Conflicts: CapabilityPolicy keeps both default hooks (check_new_member from master, get_write_refusal here) and the
start-up check tests both signatures; core/common/permissions.py imports both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…epository's capabilities again

Reverts the change that let the per-user overrides route take any capability in the capabilities table, with its
test. A deployment that adds its own capabilities serves its own route for them, through OCL_EXTRA_URLCONFS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…ring says what isn't asked

A map project's public_access change is an edit; publish is for repository rows. Not asked: staff-only routes,
deleting an owner (its repositories go without asking about each), and a queued write when it runs, except a
reference add.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
… says import lines are asked in the worker, and export uploads are asked

FC.10: a bulk import's lines are asked in the worker as it writes them, not when the import is queued. FC.11:
uploading or removing an external export is an edit of its version; generating and downloading one aren't asked.
FC.12: publish is the change that makes a row others can't view viewable, whatever blank value it held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
… says which writes a worker asks about, and that a FHIR update is an edit

FC.13: a parent's new version in another repository is asked in the hierarchy worker, as import lines are. FC.14:
publish is a write that sets public_access; a FHIR update is always an edit. FC.15: the docstring no longer states
the import batch's cache, which covers only the rows BatchWriteRefusals checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
…ent's new version to its children isn't asked, and publish is the value a write sends

FC.16: the docstring's not-asked list names linking a parent's new version to the children it already has. FC.17:
publish is a write whose public_access value makes the row viewable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
…e whenever a repository row is saved as private

A capability policy can now refuse making a repository private: creating a private repository, or changing a
repository or version that others could view by its own public_access to private (or moving a private one to
another owner). ConceptContainerModel.persist_new and persist_changes ask it before saving, so the REST routes,
import lines and FHIR writes all ask, and a refusal is the WriteRefused 403 with the policy's body. An import line
or a package resource fails with that body; the rest of the import goes on. The default policy allows it. New
versions take their HEAD's access and aren't asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
@paynejd
paynejd requested a review from snyaggarwal November 19, 2026 12:21
…hecks the body's values reach the OperationOutcome

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit 236c1bb)

Verdict: 2 findings: 1 P1, 1 P2.

  • P1 core/capabilities/tests/test_make_private.py:224: FHIR 403 responses flatten the policy's structured refusal body; the HTTP test checks only that the response is an OperationOutcome.
  • P2 core/common/models.py:1374: a concurrent update can make a repository private without asking, since the comparison and the save are separate.

Replies (c47e76b; the module's 14 tests OK, pylint exit 0):

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "full",
    "commit": "236c1bbd",
    "verdict": "findings",
    "prior": [],
    "findings": [
        {
            "id": "F1.1",
            "severity": "P1",
            "tag": null,
            "file": "core/capabilities/tests/test_make_private.py",
            "line": 224,
            "claim": "FHIR 403 responses flatten the policy's structured refusal body. The HTTP test checks only that the response is an OperationOutcome.",
            "scenario": "A CodeSystem update would copy a private release's access onto a public HEAD. When the policy refuses with an error_code and a numeric code of 3, the FHIR handler turns both fields into issue text, including the string \"3\". The client loses the original response structure and types.",
            "action": "Preserve the complete policy payload in the FHIR 403 while keeping a valid OperationOutcome, and assert that payload in the HTTP test.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "F1.2",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 1374,
            "claim": "A concurrent update can make a repository private without asking the policy because the state comparison and save are separate.",
            "scenario": "One request renames a private collection. After it reads the stored row, a second request publishes the collection. The rename still compares two private snapshots, skips make_private, and saves its stale private access over the newly public row.",
            "action": "Lock the stored row when reading its current access and hold the lock through the policy check and save. Add a regression test for concurrent publishing and editing.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

…ass 2: a FHIR update keeps HEAD's own access

A FHIR resource carries no access, but CodeSystem, ConceptMap and ValueSet updates saved the resolved release's
public_access onto HEAD: a public release made a private HEAD public, and a private one made a public HEAD private.
With make_private asked, an owner whose policy refuses it couldn't make such a HEAD private again. HEAD now keeps its
own access, and the new version takes it, as any new version does. So no FHIR write is asked make_private, and the
import's catch of a refused FHIR save is dropped again. Partial for ocl_online#698 (its first two criteria).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.169.0, commit c47e76b)

Verdict: 1 new finding, P1. Pass 1's F1.1 and F1.2 marked unresolved (answered below).

  • P1 core/common/models.py:1374: a FHIR update copies a public release's access onto a private HEAD, which publishes it, and the new question can then stop its owner from making it private again.

Replies (c3e9790; whole suite 3,404 OK, pylint exit 0):

  • F2.1 P1, fixed: CodeSystem, ConceptMap and ValueSet updates now leave HEAD's own public_access as it was, since a FHIR resource carries none. The new version takes HEAD's access, as any new version does. That's the first two criteria of OpenConceptLab/ocl_online#698, which this commit references without closing. A new test checks both directions on all three resource types: it fails on all six cases without the fix.
  • F1.1, moot now: with HEAD's access kept, no FHIR write saves a row as private, so none is asked make_private. The test and the import's catch for a refused FHIR save are gone again. FHIR refusals from the base PR's checkpoint keep their OperationOutcome shape, as before.
  • F1.2 P2, accepted as in pass 1: the whole-row save's lost update predates this PR, and the stale request is itself asked about writing to a private row.
findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "c47e76bc",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "unresolved"
        },
        {
            "id": "F1.2",
            "status": "unresolved"
        }
    ],
    "findings": [
        {
            "id": "F2.1",
            "severity": "P1",
            "tag": null,
            "file": "core/common/models.py",
            "line": 1374,
            "claim": "An ordinary FHIR update can publish an existing private repository, and the new checkpoint can block its owner from restoring privacy.",
            "scenario": "A source has a private HEAD and an older release whose own access is View. The policy allows edits and refuses make_private. An owner updates the CodeSystem through FHIR without supplying an access setting. The serializer copies the release's View access onto HEAD, making the source public. Before this change the owner could restore None through the REST API. That update now returns 403 and leaves the source public.",
            "action": "Preserve the stored private HEAD access when a FHIR update uses a version with public access. Add a regression test that allows the FHIR edit while refusing make_private and verifies that HEAD stays private.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

…ass 3: a FHIR update only keeps a private HEAD private

c3e9790 kept HEAD's access on every FHIR update, but the update still takes the resolved release's other values:
a private release's description and the like went onto a HEAD others can view. Now a FHIR update never makes a
private HEAD viewable (a public release's access isn't copied onto it), and a private release's access still goes
onto a viewable HEAD with its other values, which asks make_private, as before. The import's catch of a refused
FHIR save, and the base PR's test expectation, are back. Taking every omitted value from HEAD stays with
ocl_online#698.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 3 (codex-cli 0.169.0, commit c3e9790)

Verdict: 1 new finding, P1. It marks F2.1's fix regressed and F1.2 unresolved; F1.1 resolved.

  • P1 core/code_systems/serializers.py:429: keeping HEAD's access on every FHIR update lets a private release's other values (its description, say) go onto a HEAD others can view, and into the new version. ConceptMap and ValueSet do the same.

Replies (5f1d7ab; whole suite 3,405 OK, pylint exit 0):

  • F3.1, fixed by narrowing c3e9790: a FHIR update still takes the resolved release's values for whatever the resource omits. Taking those from HEAD instead is OpenConceptLab/ocl_online#698's third criterion, a wider change to FHIR updates. So the rule here is now that a FHIR update never makes a private HEAD viewable:
    • A private HEAD keeps its own access, whatever the release's. That's F2.1's case, still fixed.
    • A private release's access still goes onto a viewable HEAD, together with its other values, as before this PR. That saves HEAD as private, so the update is asked make_private, and a refusal is a 403 OperationOutcome with the body's values as its issues. Nothing private becomes viewable either way.
    • Tests cover each direction on CodeSystem, ConceptMap and ValueSet. The first fails on all three without the fix. The import's catch of a refused FHIR save, and the base PR's test expectation, are back.
  • F1.2: accepted, as in pass 1.

Pass 3 is the last of the three. Next come the simplification review and a check of the later commits.

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "c3e97902",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "resolved"
        },
        {
            "id": "F1.2",
            "status": "unresolved"
        },
        {
            "id": "F2.1",
            "status": "regressed"
        }
    ],
    "findings": [
        {
            "id": "F3.1",
            "severity": "P1",
            "tag": null,
            "file": "core/code_systems/serializers.py",
            "line": 429,
            "claim": "The FHIR update preserves HEAD's public access but can copy private release metadata into public HEAD and the new public version. ConceptMap and ValueSet use the same update pattern.",
            "scenario": "A public repository has a private release with a description that differs from HEAD's. An editor submits a FHIR update that resolves to that release and omits the optional description. The serializer inherits the private description from the release, saves it onto public HEAD, and carries it into the new public version. Anonymous readers can then see it.",
            "action": "When a FHIR update resolves to a private release under a public HEAD, take omitted fields from HEAD and apply the fields supplied in the request. Add a regression test with distinct descriptions that checks what anonymous readers see on HEAD and the new version.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

…nt, two tests folded into the route tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Simplification review (fresh Claude subagent, commit 5f1d7ab)

Four items. Applied in fca40ff; the module's 55 tests and the base PR's pass, and pylint exits 0.

  • S1 shrink, applied: the FHIR comment is written once, on CodeSystem. ConceptMap and ValueSet point to it.
  • S2 dup-test, applied: the unit test of a version under a private HEAD is gone. The REST version test covers it.
  • S3 dup-test, applied: the user-owned test is folded into the HEAD route test as a third repository.
  • S4 yagni, declined: it proposed one WriteRefused handler where the line's result is formed. The bulk loop has no catch around source and collection lines, so moving it there would change that loop for every line type. The two process() catches are four lines each.

A Codex check of the commits since pass 3 (c3e9790..fca40ff) follows.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Adversarial pass (fresh Claude subagent, both halves: this PR at fca40ff's tree and the private rule)

No P0, P1 or P2. Four P3s, recorded and not fixed (one is about the private half, answered there):

  • P3: makes_private's "moves to another owner" clause can't be reached today, since the update serializers' fields exclude every owner field. It stays: if a route that moves a repository is ever added, the move gets asked about the destination. That route would also need its own permission check on the destination owner.
  • P3: import lines ask make_private once per private line, not through BatchWriteRefusals. Each answer is about a new row, which the batch wouldn't cache anyway.
  • P3: a blank public_access counts as private here, while some list filters show it. That's an older inconsistency, and the checkpoint errs on the side of asking.

Checked clean:

  • Every path that saves a repository row's public_access goes through persist_new or persist_changes: the REST and FHIR serializers, the import lines, the FHIR package path and import_lookup_values. Nothing bulk-updates repository access outside migrations, and no route clones, transfers or reactivates a repository.
  • A new version always takes HEAD's access, so creating a version can't make a row private. A version made private later is asked by its own access on every route, under a private HEAD too.
  • A create always takes the URL's owner, so no API path stores both owner fields.
  • The FHIR rule holds: a private HEAD stays private, and a viewable HEAD that takes a private release's access is asked.
  • A single PUT can't both publish and re-privatize a row.
  • The ask comes after full_clean and before anything is saved, and import callers catch it.
  • No commercial wording is in this PR's code, tests or messages.

The full write-up is in the review archive. A Codex check of the commits since pass 3 follows.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits c3e9790..fca40ff (codex-cli 0.169.0)

Verdict: clean. No findings on 5f1d7ab (a FHIR update keeps a private HEAD private) or fca40ff (the simplification cuts).

Where this PR stands: Codex passes 1 to 3, the simplification review, the adversarial pass and this check are all posted above. No P0 or P1 is open. Accepted: pass 1's F1.2 (a lost update between reading and saving a row, which predates this PR) and the adversarial P3s. Ready for @snyaggarwal's review once #1007 has his OK.

final.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "final",
    "commit": "fca40ff1",
    "verdict": "clean",
    "prior": [],
    "findings": []
}

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 4 (codex-cli 0.169.0, commit 4869a42)

A new round after the requested changes at fca40ff. 4869a42 fixes both of those P1s; this pass reviewed it.

Verdict: 3 findings: 1 P1, 2 P2. Earlier findings: F1.1, F2.1 and F3.1 resolved; F1.2 marked unresolved (answered below).

  • F4.1 P1 core/value_sets/serializers.py:220: a ValueSet update saves HEAD a second time, when it adds the resource's references (Collection.add_references()). That save comes after the lock and writes the whole row it holds, so a write that made HEAD private in between is overwritten, and the new version copies HEAD's access.
  • F4.2 P2 core/sources/serializers.py:174: a HEAD that takes a blank release's access still shows in anonymous repository lists, because those lists exclude only the stored value None.
  • F4.3 P2 core/common/models.py:2023: if queuing the index task fails at commit, Django skips the transaction's later callbacks, such as a new version's seed task.

Replies (f78d6ff; whole suite 3,410 + 648 OK, pylint clean):

  • F4.1, fixed: add_references() now saves only updated_by and updated_at, since its callers have already saved the collection's other values. A references PUT can no longer overwrite a concurrent change of access either. None of the three FHIR updates saves HEAD's whole row again after persist_changes(): CodeSystem and ConceptMap save only concepts and mappings, and the new version copies HEAD's access while HEAD is locked (update_version_data()). New test: test_a_value_set_update_s_references_keep_a_head_made_private_after_head_was_saved.
  • F4.2, accepted: the API can't store a blank access (PublicAccessField takes only View or None), and production has no blank sources or collections. The lists' exclude(public_access='None') was already in place, and is used in about ten places, the concept and mapping lists among them. Before this PR, the same update made HEAD View, fully public; now it's hidden everywhere except those lists.
  • F4.3, fixed: the callback is robust=True, so a failed enqueue is logged and the other callbacks still run. New test: test_a_failed_index_enqueue_doesn_t_stop_the_transaction_s_other_callbacks.
  • F1.2: the FHIR case of a lost update is what 4869a42's row lock fixes. A REST write that saves a stale whole row still loses a concurrent change, as it did before this PR; that's general, not FHIR's.
pass4.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "4869a421",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "resolved"
        },
        {
            "id": "F1.2",
            "status": "unresolved"
        },
        {
            "id": "F2.1",
            "status": "resolved"
        },
        {
            "id": "F3.1",
            "status": "resolved"
        }
    ],
    "findings": [
        {
            "id": "F4.1",
            "severity": "P1",
            "tag": null,
            "file": "core/value_sets/serializers.py",
            "line": 220,
            "claim": "A ValueSet update can still make a concurrently privatized HEAD public.",
            "scenario": "A FHIR update of a public ValueSet includes a new compose reference. After persist_changes releases its lock, a REST update makes HEAD private and commits. Collection.add_references then calls self.save() on the stale collection, restoring View. Version creation reads that republished HEAD and gives the new version View too.",
            "action": "Limit the reference update to the HEAD fields it actually changes so it cannot overwrite public_access. Add a regression test with the privacy change occurring between the first HEAD save and reference persistence.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "F4.2",
            "severity": "P2",
            "tag": null,
            "file": "core/sources/serializers.py",
            "line": 174,
            "claim": "Copying blank access from a release onto HEAD leaves the updated repository metadata visible in REST lists.",
            "scenario": "The policy allows a FHIR update sourced from a blank-access release. The update copies the release's metadata and blank access onto a previously public HEAD. An anonymous REST list request still returns the repository's name and canonical URL because the database-backed source and collection lists exclude only the literal None access value.",
            "action": "Use the model's public-access predicate in the database-backed repository lists and test anonymous list visibility after an allowed update from a blank-access release.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "F4.3",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 2023,
            "claim": "A failed search-index enqueue after commit can prevent version seeding from being queued.",
            "scenario": "With ES_SYNC enabled, an asynchronous version creation registers the index callback before the seeding callback. If publishing the index task raises after retries, Django stops running the remaining non-robust callbacks. The request fails after the version and its processing marker have committed, leaving a version whose members were never seeded.",
            "action": "Isolate deferred index enqueue failures from later commit callbacks. Test that the seeding callback is still attempted when the preceding index enqueue raises.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes. I reviewed the full discussion against f78d6ff1.

  • Resolved — the two P1s from my previous review. The serializers now preserve the resolved release’s blank access through preparation, and the FHIR save rereads and locks HEAD before deciding what access to retain. The ValueSet follow-up (F4.1) also limits the references save to the audit fields, so it preserves a concurrent visibility change.
  • Still open — F4.2 (P2). Blank access reaches storage through the bulk and package import paths. Anonymous lists still treat a blank HEAD as public. The inline comment proposes a canonical stored value and a test of the actual list response.
  • Resolved in a transaction — F4.3. A failed generic index enqueue no longer prevents later commit callbacks. The inline comment flags the separate behavior change for autocommit saves.
  • Earlier findings. F1.1 retains the existing FHIR OperationOutcome contract, with assertions for the refusal values. F2.1 and F3.1 are covered by the current FHIR guards for explicit private access, with the blank-access listing case tracked above. F1.2 remains a known REST lost-update case. The new lock covers FHIR writes.

Verification was by source and test review. The author reports passing tests and lint. GitHub Pylint was still running when I checked this revision.

Comment thread core/common/models.py
Comment on lines +1364 to +1365
if keep_private and not original_repo.public_can_view:
obj.public_access = original_repo.public_access

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Store canonical private access before saving HEAD. The current test checks public_can_view, but the anonymous source and collection list querysets exclude only ACCESS_TYPE_NONE. The bulk and package importers pass public_access directly into the model, where blank is allowed, so this can happen through supported imports even though PublicAccessField rejects blank. A FHIR update can copy release metadata onto a blank HEAD that still appears in those lists.

With ACCESS_TYPE_NONE imported, normalize the selected value before computing the access-change flag and checking policy.

Suggested change
if keep_private and not original_repo.public_can_view:
obj.public_access = original_repo.public_access
if keep_private and not original_repo.public_can_view:
obj.public_access = original_repo.public_access
if obj.public_access == '':
obj.public_access = ACCESS_TYPE_NONE

Apply the same normalization in persist_new for import-created HEADs. Extend the blank-release regression to verify that the repository is absent from an anonymous list after the FHIR write.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6fa582b, as you suggested. persist_new and persist_changes both store a blank access as None through one small method, store_blank_access_as_none(). In persist_changes that happens after the keep_private decision, and before the access-change flag and the make_private check. So a blank import line and a FHIR update from a blank release both store None, and the save signal passes None on to the concepts and mappings too.

Tests, each failing on f78d6ff:

  • test_a_blank_release_the_policy_allows_leaves_head_and_the_new_version_private now checks the anonymous sources/ or collections/ list: the repository is listed before the FHIR write and absent after it, for CodeSystem, ConceptMap and ValueSet.
  • test_a_blank_access_line_is_stored_as_private: a bulk import line with a blank access is stored as None, asks make_private, and stays out of the anonymous list.
  • test_an_edit_that_sends_no_access_keeps_a_blank_row_private now expects None after a REST edit.

Comment thread core/common/models.py Outdated
Comment on lines +2024 to +2025
transaction.on_commit(
lambda: handle_save.apply_async(args, queue='indexing', permanent=False), robust=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve index enqueue error reporting for autocommit saves. Django runs on_commit immediately when there is no transaction. With robust=True it logs a final broker error and the write returns successfully, silently dropping the index update. This affects every model using this signal, including ordinary REST writes. Keep robustness when deferring inside a transaction so later callbacks still run. Preserve the existing error propagation for autocommit and add a test of that path.

Suggested change
transaction.on_commit(
lambda: handle_save.apply_async(args, queue='indexing', permanent=False), robust=True)
connection = transaction.get_connection(using=instance._state.db) # pylint: disable=protected-access
connection.on_commit(
lambda: handle_save.apply_async(args, queue='indexing', permanent=False),
robust=connection.in_atomic_block,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6fa582b with your suggestion: robust=connection.in_atomic_block. Deferred inside a transaction, a failed enqueue is logged and the later callbacks still run. Under autocommit it runs at once, and the broker's error reaches the write, as before this PR.

New test: IndexEnqueueUnderAutocommitTest (a transaction test case, so there's no surrounding atomic block) checks that the error propagates. It fails on f78d6ff. The in-transaction test still checks that later callbacks run.

… HEAD lock takes no key; an index enqueue is robust only inside a transaction

Review of #1009 at f78d6ff, and Codex pass 5:
- A blank access is private (public_can_view), but the database-backed anonymous lists exclude only None, and bulk and package imports can store a blank. persist_new and persist_changes now store a blank as None, before the access-change flag and the make_private check. Tests read the anonymous list after a FHIR update from a blank release and after a blank import line.
- The index enqueue is robust only when it's deferred inside a transaction, so later callbacks still run. Under autocommit it runs at once and its error reaches the write, as before f78d6ff. A transaction test covers that path.
- The FHIR update locks HEAD FOR NO KEY UPDATE: it still makes a concurrent write to HEAD wait, but a concurrent child write's foreign-key check doesn't, so the two can't deadlock (Codex F5.2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXZaRJn7QiL3warvW2
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 5 (codex-cli 0.169.0, commit f78d6ff)

Verdict: 3 findings, all P2. Earlier findings: F4.1 resolved; F4.2 unresolved; F4.3 marked regressed by its own fix. F1.2 unresolved (the REST case only, as before).

  • F5.1 P2 core/sources/serializers.py:174: a blank access copied onto HEAD also goes onto its concepts and mappings, which the anonymous concept and mapping lists still show, because they exclude only None.
  • F5.2 P2 core/common/models.py:1363: HEAD's FOR UPDATE lock can deadlock with a concurrent concept edit, whose foreign-key check on the source waits for that lock while the update waits for the concept row.
  • F5.3 P2 core/common/models.py:2025: robust=True also logs and drops a failed index enqueue under autocommit, so an ordinary write reports success with a stale search index.

Replies (6fa582b; whole suite 3,412 + 648 OK, pylint clean):

  • F5.1 and F4.2, fixed as the review at f78d6ff asked: persist_new and persist_changes store a blank access as None, before the access-change flag and the make_private check. HEAD is stored as None, so the save signal also gives its concepts and mappings None, which every list reads as private. New tests read the anonymous list after a FHIR update from a blank release, and after a blank import line.
  • F5.2, fixed: the lock is select_for_update(no_key=True). It still makes a concurrent write to HEAD wait, but a foreign-key check (FOR KEY SHARE) doesn't wait on it. The lock test now expects FOR NO KEY UPDATE.
  • F5.3 and F4.3, fixed as the review at f78d6ff asked: the callback is robust only when it's deferred inside a transaction (robust=connection.in_atomic_block). Under autocommit it runs at once, and the broker's error reaches the write, as before this PR. New transaction test: test_a_failed_index_enqueue_under_autocommit_reaches_the_write.
pass5.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "f78d6ff1",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "resolved"
        },
        {
            "id": "F1.2",
            "status": "unresolved"
        },
        {
            "id": "F2.1",
            "status": "resolved"
        },
        {
            "id": "F3.1",
            "status": "resolved"
        },
        {
            "id": "F4.1",
            "status": "resolved"
        },
        {
            "id": "F4.2",
            "status": "unresolved"
        },
        {
            "id": "F4.3",
            "status": "regressed"
        }
    ],
    "findings": [
        {
            "id": "F5.1",
            "severity": "P2",
            "tag": null,
            "file": "core/sources/serializers.py",
            "line": 174,
            "claim": "Copying a blank release's access onto HEAD also leaves its concepts and mappings visible in anonymous REST lists.",
            "scenario": "A native JSON import can store blank access because it bypasses PublicAccessField. A release can inherit that blank access before HEAD is published. If the policy later allows a FHIR update from that release, the source save signal propagates the blank access to its concepts and mappings. The database-backed /concepts/ and /mappings/ lists exclude only the literal None value, so they can return content from the now-private source, including concepts added by the FHIR update.",
            "action": "Use the model's public-access predicate in the affected database-backed lists, or normalize blank access to the canonical private value when saving it. Test anonymous repository and child lists after an allowed update from a blank release.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "F5.2",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 1363,
            "claim": "The FHIR HEAD lock can deadlock with a concurrent concept edit.",
            "scenario": "A concept edit locks its existing concept row while creating a new version. A concurrent CodeSystem update makes HEAD private, takes FOR UPDATE on the source, and waits to propagate access to the locked concept row. The concept edit needs a foreign-key lock on that same source before its new version can commit. PostgreSQL aborts one of the writes.",
            "action": "Take a no-key-update lock for the access decision and keep it through the save. Verify with a PostgreSQL concurrency test that the source save and a concept edit can both commit.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "F5.3",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 2025,
            "claim": "A failed index enqueue can now leave a repository searchable after the API reports that making it private succeeded.",
            "scenario": "An owner renames a public collection and makes it private in one REST update. If the broker rejects the indexing enqueue after retries, the robust callback logs the failure and the API returns success. The old Elasticsearch document still admits anonymous search hits, and search hydrates those IDs from the database without rechecking access. A search for the old name can return the newly private collection's current metadata until it is reindexed.",
            "action": "Recheck current repository access when materializing search hits. Keep failed indexing enqueues retryable while allowing later commit callbacks to run.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

…k HEAD is stored as None

- F6.1: a new version copies HEAD's access, so a HEAD stored blank before blanks were stored as None gave its new version a blank, which the anonymous lists show. persist_new_version now stores it as None, as persist_new and persist_changes do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qXZaRJn7QiL3warvW2
@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 6 (codex-cli 0.169.0, commit 6fa582b)

The last pass of this round. Verdict: 2 findings, both P2. Earlier findings: every pass 4 and pass 5 finding resolved, and F1.1, F2.1 and F3.1 too. F1.2 is still unresolved: it's the REST lost update, which the lock doesn't cover, as your review at f78d6ff noted.

  • F6.1 P2 core/common/models.py:1455: a new version copies HEAD's access, so a HEAD stored blank before this PR gives its new version a blank access, which the anonymous lists show.
  • F6.2 P2 core/common/models.py:2034: if the index enqueue fails inside the FHIR update's transaction, the robust callback lets the update succeed with HEAD's old, public search document. Search results are loaded from the database by id without checking access, so its new metadata can show in an anonymous search until HEAD is reindexed.

Replies (a614e85; whole suite 3,412 + 648 OK, pylint clean):

  • F6.1, fixed: persist_new_version stores a blank as None after copying HEAD's access, as persist_new and persist_changes do. test_a_new_version_takes_its_head_s_access_and_is_not_asked now covers a blank HEAD as well, and fails on 6fa582b.
  • F6.2, accepted: your review at f78d6ff asked to keep the enqueue robust inside a transaction, so later callbacks such as a version's seed task still run. A failed enqueue leaves a stale search document after any indexed write, and did before this PR too. Checking access when search results are loaded is a search-wide change, which I've passed to the driver as a possible follow-up.
pass6.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "6fa582b1",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "resolved"
        },
        {
            "id": "F1.2",
            "status": "unresolved"
        },
        {
            "id": "F2.1",
            "status": "resolved"
        },
        {
            "id": "F3.1",
            "status": "resolved"
        },
        {
            "id": "F4.1",
            "status": "resolved"
        },
        {
            "id": "F4.2",
            "status": "resolved"
        },
        {
            "id": "F4.3",
            "status": "resolved"
        },
        {
            "id": "F5.1",
            "status": "resolved"
        },
        {
            "id": "F5.2",
            "status": "resolved"
        },
        {
            "id": "F5.3",
            "status": "resolved"
        }
    ],
    "findings": [
        {
            "id": "F6.1",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 1455,
            "claim": "Version creation still writes blank access, which anonymous repository lists treat as public.",
            "scenario": "An owner creates v2 from a legacy source or collection HEAD whose public_access is blank. The new version inherits the blank. A database-backed anonymous repository list filtered by version=v2 returns its metadata because the list excludes only rows stored as 'None'.",
            "action": "Normalize the inherited access after copying it from the locked HEAD and before saving the version. Add a regression test against the anonymous list response.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "F6.2",
            "severity": "P2",
            "tag": null,
            "file": "core/common/models.py",
            "line": 2034,
            "claim": "A successful FHIR update can leave newly private HEAD metadata visible in anonymous search after a failed index enqueue.",
            "scenario": "A ValueSet update copies a private release onto a previously public HEAD. The database commit succeeds, the HEAD index enqueue fails, and the robust callback lets the request finish successfully. Elasticsearch still marks HEAD public, and the search result loader fetches and serializes the current database row by ID without checking its access. The updated private metadata remains searchable until HEAD is reindexed.",
            "action": "Keep the callback robust and verify repository visibility against the current database row before returning Elasticsearch hits. Test an anonymous search with a stale public document for a private HEAD.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Simplification review, round 2 (fresh Claude subagent, commit 6fa582b)

It reviewed fca40ff..6fa582b and proposed three optional cuts, all low confidence. I declined all three, so there's no commit from this review.

  • S1, shrink, declined: it proposed writing out store_blank_access_as_none() at its two call sites. The method keeps persist_changes within pylint's statement limit, and states the rule once; it's now used in three places (a614e85). The suggested if not obj.public_access would also turn None into 'None'.
  • S2, shrink, declined: it proposed moving validation, the access-change flag and check_make_private outside the locked block. The flag and the policy question have to read the locked row and the access decided under the lock, the order your review at f78d6ff asked for. The lock is held for one row's save.
  • S3, dup-test, declined: it proposed folding the blank import test and the blank REST edit test together. They test different paths (persist_new and persist_changes), and share little setup.

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Adversarial pass, round 2 (fresh Claude subagent, fca40ff..a614e85)

A read-only review of how this round's commits decide who can see a repository. It was given the code and the goal, not my conclusions.

No P0, and no P1 from these commits. It confirmed that the FHIR lock holds: a concurrent write to HEAD waits for the save, and the post-lock read is current. A refusal or an IntegrityError rolls back, the tasks queued after the save run outside the lock, and the new-version path copies the locked HEAD's access.

Recorded, with no change in this PR:

  • P1, predates this PR: the REST lost update that your review at f78d6ff records as a known case, and that pass 1's F1.2 also found. A REST write that sends no access still saves the access it read. I've suggested a follow-up to the driver.
  • P2: a HEAD deleted between a FHIR update's read and its lock now fails with an error instead of being saved back. CodeSystem and ConceptMap updates already did, since the source path read the stored row unguarded.
  • P2: when a FHIR update changes HEAD's access, the cascade to its concepts and mappings runs while HEAD is locked. I found no concept or mapping write that also updates the source row in one transaction, which is what a deadlock would need; counts are updated in a separate task.
  • P2: a FHIR update from a private release makes a public HEAD private (and asks make_private). That's this PR's round-1 behaviour, from OpenConceptLab/ocl_online#698.
  • P2: the same point as Codex's F6.2: a failed enqueue inside a transaction can leave a stale search document.
  • P2: rows stored blank before this PR stay blank until they're next saved. Production has no blank sources or collections. A data migration for any blank concepts or mappings would need its own plan.
  • P3: add_references() no longer saves other in-memory changes a future caller might make; the current callers save them first. A blank row's first edit cascades None to its children.

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 6fa582b..a614e85 (codex-cli 0.169.0)

Verdict: clean. No findings on a614e85 (a new version of a blank HEAD is stored as None).

Where this PR stands: your two P1s from fca40ff and your two P2s from f78d6ff are fixed. This round ran Codex passes 4 to 6 (posted above), the simplification review, the adversarial pass and this check. No P0 or P1 from this PR is open. Accepted:

  • F6.2: a stale search document after a failed enqueue inside a transaction;
  • F1.2: the REST lost update, which predates this PR;
  • the adversarial P2s and P3s above.

The whole suite passes at a614e85 (3,412 + 648), and pylint is clean.

final.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "final",
    "commit": "a614e852",
    "verdict": "clean",
    "prior": [],
    "findings": []
}

snyaggarwal and others added 8 commits November 23, 2026 08:13
…in a source the capability policy keeps read-only
…f a read-only source is refused before anything changes

- IsolatedVersionCommit.get_rejection, which preflight and run share, asks the capability policy about an edit of
  HEAD. preflight raises the WriteRefused, with the policy's body, before any line imports; run returns it before
  HEAD's hierarchy or codes change.
- BulkImportParallelRunner files a refused version under permission_denied with the policy's body, as
  BulkImportInline does, instead of under others with no reason.
- A version that rolls back reports nothing dropped: HEAD kept those codes.
- add_references returns a refusal as its own item, so no expression's error can be read as one.
- An import's hierarchy asks the policy only about the sources its children are in.
- CanAdministerParentDictionary asks about an edit of the repository whatever the view, as CanEditParentDictionary
  does (CanAdministerDictionaryContent was the same permission without that).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…d up front reports the refusal in its result

preflight still raises the WriteRefused, and each runner catches it and reports it as it reports a refused line,
instead of failing the task with the body only in its traceback. Nothing imports.
- BulkImportInline and BulkImportParallelRunner list the version line under permission_denied, with the capability
  policy's body as its errors.
- The archive Importer returns a summary with one failure, whose message ends with the body as JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…d up front counts the lines submitted and the one processed

Each runner's result now gives the lines submitted as its total and the refused version line as the one line
processed. A seeding parallel import counts the version line in its total too, which its parts don't hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…el import's saved progress counts its version line

The progress BulkImportParallelRunner saves on its task counted only its parts, which never hold the version line,
so an import refused up front ended at 0 of 2, and a seeding import one short of its total. It now counts the
version line's outcome too, as its result does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…5c9b0ae

One conflict, in core/common/models.py: the branch's store_blank_access_as_none() and
the isolated versions' apply_version_metadata_to_head() were added at the same spot.
Both are kept. A new version still takes HEAD's access after HEAD takes the version
line's metadata, which never includes its access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTwySjW7bPFSitB8J7
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits a614e85..eab632e (codex-cli 0.169.0)

Verdict: clean. No findings.

It reviewed only the merge of the base branch at 5c9b0ae (eab632e), asking whether the merge broke either checkpoint: the read-only edit refusal (now asked about HEAD before an import that seeds a version imports any line) or this PR's make_private ask, including the persist_changes(keep_private=True) row lock and blank access stored as None. It also looked for any new path from the base branch or master that saves a repository row's access without going through persist_new or persist_changes.

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "final",
    "commit": "eab632e9",
    "verdict": "clean",
    "prior": [],
    "findings": []
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Base branch merged at its final head (5c9b0ae)

eab632e merges ocl_online-424-write-checkpoint at 5c9b0ae (the round that answered the review of #1007, plus master). It's a merge, not a rebase, so the commits you reviewed keep their ids.

One conflict, in core/common/models.py: this PR's store_blank_access_as_none() and master's apply_version_metadata_to_head() (isolated versions) were added at the same place. I kept both. In persist_new_version_in_transaction the order is now: lock HEAD, apply_version_metadata_to_head(head), update_version_data(head), store_blank_access_as_none(), save. A new version still takes HEAD's access, and the metadata a version line copies onto HEAD has no access field, so the version isn't asked make_private. Everything else merged on its own. git diff 5c9b0ae9 eab632e9 is the same change this PR made before (git diff 68f22a6f a614e852).

Both checkpoints still apply. The read-only refusal (now asked about HEAD before an import that seeds a version imports any line) and this PR's make_private ask, including the persist_changes(keep_private=True) row lock, are unchanged. Nothing new from the base branch or master saves a repository row's access outside persist_new or persist_changes.

Checks on eab632e:

  • CI's pylint -j0 core/: 10.00/10
  • core.capabilities (this PR's test_make_private and the base's test_writes): 171 tests OK
  • Whole suite, as CI runs it: 3,550 tests OK (2 skipped) without ES, 658 OK with ES
  • Codex check of the merge: clean (comment above)

@paynejd
paynejd requested a review from snyaggarwal November 23, 2026 04:18
Base automatically changed from ocl_online-424-write-checkpoint to master November 23, 2026 04:44
…nt's squash merge

Master now holds the write checkpoint as one squashed commit (86ca658)
plus the release search change. Seven files conflicted because both
sides had added the write checkpoint's lines. Each resolves to master's
version of those lines with this branch's own changes on top: a
three-way merge of each file using the write checkpoint's final head
(5c9b0ae) as the base merges cleanly. This branch's diff against
master is now line for line its diff against 5c9b0ae.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qUbSx2byXLH6U3Cyye
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits eab632e..9a65844 (codex-cli 0.169.0)

Verdict: clean. No findings.

It reviewed only the merge of master at 86ca658 (this PR's base branch, now squash-merged as #1007, plus #1010), asking whether the merge broke the read-only write checkpoint or this PR's make_private checkpoint, and whether #1010's new code (the release public_access signal, seeding in one transaction, the import indexer) saves a repository row's access outside persist_new/persist_changes or relies on a blank access.

findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "9a658445",
  "verdict": "clean",
  "prior": [],
  "findings": []
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Master merged after #1007's squash merge (9a65844)

9a65844 merges master at 86ca658, which holds #1007 as one squashed commit, plus #1010. It's a merge, not a rebase, so the commits you reviewed keep their ids. The PR now targets master and is mergeable.

Seven conflicts (core/capabilities/constants.py, policy.py, tests/test_writes.py, writes.py, core/collections/serializers.py, core/importers/importer.py, core/sources/serializers.py), all from #1007's lines being on both sides: real commits here, a squash on master. Each file merged cleanly as a three-way merge with #1007's final head (5c9b0ae) as the base, so #1007's lines are master's version and this PR's lines sit on top. The squash on master changes the same lines as #1007's branch did.

The diff against master is only this PR's change: git diff origin/master...HEAD has the same changed lines, in the same 14 files, as git diff 5c9b0ae9 eab632e9 (what this PR added on top of #1007 before).

Checks on 9a65844:

  • CI's pylint -j0 core/: exit 0
  • core.capabilities, core.importers, core.sources, core.collections (without ES): 957 tests OK
  • Whole suite, as CI runs it: 3,564 tests OK (2 skipped) without ES, 672 OK with ES
  • Codex check of the merge: clean (comment above)

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 9a65844. Both P2s from my review at f78d6ff are fixed as your replies describe:

  • A blank access is stored as None (store_blank_access_as_none()) in persist_new, persist_changes (after the keep_private decision and before the access-change flag and make_private) and, from Codex's F6.1, persist_new_version. So an import line or a FHIR write from a blank release stays out of the anonymous lists, and the tests check the list response.
  • The index enqueue is robust only inside a transaction, so an enqueue error under autocommit reaches the write again, with IndexEnqueueUnderAutocommitTest.
  • The lock is now select_for_update(no_key=True). It still makes a concurrent write to HEAD wait for the FHIR save, and it no longer blocks writes that only reference the row, such as a concept saved under that source.

The two merges keep this PR's change as it was. git diff 86ca658c 9a658445 matches git diff 5c9b0ae9 eab632e9 line for line, so the conflicts from #1007's squash merge were resolved to the same code. It merges cleanly with master now that #1023 and #1024 are in, and only Collection.add_references() shares a file with them, in a function neither touches. Master's build with #1007, #1010, #1023 and #1024 passes the full suite. I haven't run the tests locally.

Fine to leave as accepted: F1.2 (a REST write that sends no access saves the access it read, which predates this PR), F6.2 (a failed enqueue inside a transaction leaves a stale search document, as any indexed write can), and the adversarial pass's P2s and P3s.

Nit (PR body): it still says this is stacked on #1007 and should be retargeted once #1007 merges. The test count (3,405) is also from before the merges.

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.

2 participants