Skip to content

OpenConceptLab/ocl_online#424 | A write checkpoint lets the capability policy keep content read-only - #1007

Merged
snyaggarwal merged 25 commits into
masterfrom
ocl_online-424-write-checkpoint
Nov 23, 2026
Merged

snyaggarwal merged 25 commits into
masterfrom
ocl_online-424-write-checkpoint

Conversation

@paynejd

@paynejd paynejd commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Part of OpenConceptLab/ocl_online#424.

A write checkpoint: the capability policy can keep content read-only and refuse writes to it, with a body it sends. The default policy refuses nothing, so oclapi2 behaves as before unless a deployment configures a policy that uses it. Two fixes found on the way apply under any policy: a version update can no longer move a version to another repository, and a version create always lands on the repository in the URL.

What changes

  • CapabilityPolicy.get_write_refusal(user, content, action) returns None (allow) or the refusal body.
    • content is the repository row written (a Source or Collection: its HEAD, or the version a write changes, which keeps its own public_access) or a MapProject.
    • action is edit, delete (a HEAD or a map project: the whole of it) or publish (a write's public_access value makes a repository row others can't view viewable by them; a version only under a viewable HEAD). A FHIR update is always an edit. Any other change to a map project, its public_access included, is an edit.
    • GroupLimitPolicy inherits the default, which returns None. capabilities.E004 also checks this method's signature.
  • WriteRefused(UsageRefused): a 403 that sends the policy's body as it is.
  • core/capabilities/writes.py: get_write_target, get_own_write_action, makes_viewable, get_write_refusal, check_write.
  • Where it's asked, only after the user's own access allows the write:
    • CanEditConceptDictionary and CanEditConceptDictionaryVersion, through a new ChecksWrites base: repository and version update and delete (latest/ and HEAD/ included), version create, extras, logo, references, source $clone, map project and log writes, and starting an AutoMatch run. Concept, mapping, name, description and extras writes go through CanEditParentDictionary and CanAdministerParentDictionary, always as edit.
    • FHIR CodeSystem, ConceptMap and ValueSet updates, asked about the HEAD they save onto (updates_head), and never publish (applies_public_access = False). Package import updates likewise.
    • The concept $clone target; bulk import lines that write to an existing repository (a refused line is reported with the body, and the rest goes on; one policy serves a batch, which keeps its answer for a saved repository row and action a minute; a FHIR resource in an import is asked each time); a parent's new version in another repository during hierarchy updates.
    • Every expansion write (creating, deleting or re-evaluating one), as an edit of its collection version. Uploading or removing an external export.
    • The reference-add task asks again when it runs, as the collection may have become read-only while it was queued.
  • Never asked:
    • reads, generating and downloading exports, $compare and $changelog; creating a repository;
    • views that write no content (writes_content = False: processing flags, the references preview, client configs, an AutoMatch run's progress updates, so a run allowed to start can finish);
    • linking a parent's new version to the children it already has (the system keeps those current);
    • routes only staff may use (IsAdminUser: a mapping's hard delete, a concept or mapping version's DELETE, the hierarchy amend route);
    • deleting an owner (an organization, by its route or an import line, or a user, by staff), which deletes its repositories without asking about each.
  • Queued writes: writes a worker makes on its own (a bulk import's lines, a parent's new version in another repository during a hierarchy update) are asked in the worker. Other queued writes are asked when they're requested, and only a reference add asks again when it runs; deleting a repository, an async concept delete and an expansion's re-evaluation run as they were allowed.

Review

Codex passes 1–3, a simplification review, an adversarial pass and Codex checks of the later commits are posted below, each with replies. Sunny's reviews are answered in replies below.

Tests

  • core/capabilities/tests/test_writes.py: the default refuses nothing; a stub policy that refuses gets a 403 with its body on every path above, with the expected action and content, and leaves the content unchanged; every expansion write is asked; reads, exports and processing are never asked; an import batch keeps its answer per repository row and action; bulk and package imports are refused per line; a version never moves to another repository.
  • CI at 5c9b0ae: Tests and Pylint passed. Locally at 5c9b0ae, the full suite passed (3,528 tests without the search tag, 658 with it), and pylint -j0 core/ gives 10.00 with no messages.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit 359f7b3)

Verdict: 6 findings: 4 P1, 2 P2. Fixes follow in the next push, with one reply line per finding.

  • P1 core/sources/views.py:269: Version creation can write to a different repository from the one the checkpoint approved.
  • P1 core/common/permissions.py:103: FHIR updates can be classified as publication even though the serializer ignores the visibility change.
  • P1 core/importers/importer.py:581: CodeSystem and ConceptMap updates can resolve a different HEAD after the checkpoint.
  • P1 core/capabilities/writes.py:32: The delete action follows the view class even when the resolved row is a release.
  • P2 core/concepts/models.py:755: Hierarchy propagation still writes parent links onto children in read-only sources.
  • P2 core/capabilities/writes.py:35: A malformed visibility value crashes private repository updates before serializer validation.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "359f7b398f425516818c58bdd421b9cb37ecc6e4",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "core/sources/views.py",
      "line": 269,
      "claim": "Version creation can write to a different repository from the one the checkpoint approved.",
      "scenario": "An owner has a writable repository and a read-only repository in the same namespace. A version-create request targets the writable repository, but the body names the read-only repository as its mnemonic. The source and collection views pass that body value to create_version, which resolves the other HEAD and creates a release there without checking it.",
      "action": "Bind version creation to the HEAD loaded and checked by the view. Reject conflicting repository identity fields and cover both source and collection releases.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P1",
      "tag": null,
      "file": "core/common/permissions.py",
      "line": 103,
      "claim": "FHIR updates can be classified as publication even though the serializer ignores the visibility change.",
      "scenario": "A private CodeSystem, ConceptMap, or ValueSet and its selected release are both private. A FHIR update includes a visibility field alongside valid content changes. The checkpoint classifies the raw field as publish, and a policy that permits publication lets the update through. The FHIR serializer ignores the visibility field and writes the content changes while the repository stays private.",
      "action": "Classify FHIR updates as edits. On routes that support publishing, grant the publish action only when validated data will change the HEAD's visibility.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.3",
      "severity": "P1",
      "tag": null,
      "file": "core/importers/importer.py",
      "line": 581,
      "claim": "CodeSystem and ConceptMap updates can resolve a different HEAD after the checkpoint.",
      "scenario": "A package's canonical URL resolves to a writable source, but the resource ID names a read-only source under the same owner. The importer checks the writable source. The CodeSystem and ConceptMap update serializers then replace the mnemonic before resolving HEAD, so they can overwrite the read-only source and copy the writable source's visibility onto it. The same serializer path is used by FHIR API updates.",
      "action": "Capture the authorized HEAD before applying resource fields, reject a conflicting resource ID, and regression-test the real package import and FHIR update paths.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.4",
      "severity": "P1",
      "tag": null,
      "file": "core/capabilities/writes.py",
      "line": 32,
      "claim": "The delete action follows the view class even when the resolved row is a release.",
      "scenario": "An owner deletes a read-only FHIR repository that has a release newer than HEAD. The inherited detail view selects the newest release, but the checkpoint reports a whole-repository delete. A policy that allows whole-repository deletion therefore lets the owner remove an individual release. In the other direction, the explicit OCL HEAD detail route reports edit even when it deletes or publishes the actual HEAD.",
      "action": "Classify the action from the resolved target and the operation the handler will perform. Check release deletion as an edit, and cover deletion and publication through the explicit HEAD route.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.5",
      "severity": "P2",
      "tag": null,
      "file": "core/concepts/models.py",
      "line": 755,
      "claim": "Hierarchy propagation still writes parent links onto children in read-only sources.",
      "scenario": "A writable source contains a parent concept that already has a child in a read-only source. When another child is attached to that parent, hierarchy processing creates a new parent version and adds it to the existing read-only child's stored parent links without checking the child's source. The parent-version worker can make the same unchecked write.",
      "action": "Apply the write checkpoint to each destination source before propagating links onto its child concepts. Preserve the prior links for children whose sources refuse the edit.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.6",
      "severity": "P2",
      "tag": null,
      "file": "core/capabilities/writes.py",
      "line": 35,
      "claim": "A malformed visibility value crashes private repository updates before serializer validation.",
      "scenario": "With the default policy, an authorized update to a private source or collection sends a nonzero JSON number for public_access. The new classifier calls lower() on the number before invoking the policy, so the request raises AttributeError instead of returning the serializer's field-level 400.",
      "action": "Use validated visibility data for action classification or guard the raw value's type. Add a default-policy API test that expects the field-level 400.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Replies to Codex pass 1, fixed in a182d26. core.capabilities runs 124 tests and the wider run 2,915, all OK; pylint -j0 core/ gives 10.00. Each new test was also run against 359f7b3, where every one failed.

  • P1 version create writes another repository: fixed. The source and collection version-create views now set mnemonic and id from the URL after the body, so the version always lands on the repository that was checked. This also closes the same cross-repository write under the default policy.
  • P1 FHIR update classified as publish: fixed. A new view flag, applies_public_access, is off on the CodeSystem, ConceptMap and ValueSet detail views, so their writes are never publish.
  • P1 FHIR and package updates resolve another HEAD: fixed. A CodeSystem or ConceptMap update whose resource id differs from the repository being updated is refused with a 400 on id, before HEAD is resolved. That covers the FHIR API PUT and the package-import update, which share the path. ValueSet wasn't affected.
  • P1 delete follows the view, not the object: fixed. The action is decided from the object actually written. delete and publish happen only for a repository's HEAD or a map project; a write to a release is edit. …/HEAD/ on the version detail views now classifies like the repository route. Bulk-import delete lines are classified the same way.
  • P2 hierarchy links on children in refused repositories: fixed in set_parent_concepts_from_uris, create_new_versions_for_removed_parents and process_hierarchy_for_new_parent_concept_version. A refused child stays linked to the parent's earlier version.
  • P2 a non-string public_access is a 500: fixed. It's never publish, so the serializer returns its 400.
  • Also, from the other half's review: the staff capability override endpoint now resolves any capability in the capabilities table by name, and returns 404 when there's none. A test covers it.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: 6 findings: 3 P1, 3 P2. Pass 1: F1.1–F1.4 and F1.6 resolved; F1.5's fix regressed (see F2.2). Fixes follow in the next push, with one reply line per finding.

  • P1 core/sources/serializers.py:494: A version update can move a release into a repository the checkpoint never approved.
  • P1 core/concepts/models.py:759: The hierarchy fix hides existing children from the parent's current hierarchy.
  • P1 core/collections/views.py:946: Rebuilding a default expansion can rewrite saved collection membership without a checkpoint.
  • P2 core/common/tasks.py:186: Queued reference additions can write after a collection becomes read-only.
  • P2 core/sources/views.py:305: The latest-version route can classify publication of a HEAD as an edit.
  • P2 core/common/permissions.py:100: Bodyless delete operations now require parsing any supplied body, even under the default policy.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "a182d267",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F1.3",
      "status": "resolved"
    },
    {
      "id": "F1.4",
      "status": "resolved"
    },
    {
      "id": "F1.5",
      "status": "regressed"
    },
    {
      "id": "F1.6",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "F2.1",
      "severity": "P1",
      "tag": null,
      "file": "core/sources/serializers.py",
      "line": 494,
      "claim": "A version update can move a release into a repository the checkpoint never approved.",
      "scenario": "An org member edits a release of a public source and supplies the mnemonic of a private, read-only source in the same org as its `short_code`. If the destination has no release with that version label, the serializer changes the saved row's mnemonic and the release appears in the read-only source. Collection version updates use the same writable alias.",
      "action": "Bind the repository identity on source and collection version updates to the checked object, or check the destination before allowing a move. Test both serializers through their version endpoints.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.2",
      "severity": "P1",
      "tag": null,
      "file": "core/concepts/models.py",
      "line": 759,
      "claim": "The hierarchy fix hides existing children from the parent's current hierarchy.",
      "scenario": "A child in a read-only source links to the latest version of a parent in a writable source. After the parent gets a new version, the child keeps its old link. The parent's `/children/` query looks only at its HEAD and new latest version, so the child disappears from that response while the child's `/parents/` response still shows the parent.",
      "action": "Preserve current hierarchy reads for links from a child's current version to an older parent version, while keeping historical reads version-specific. Extend the regression test to assert both API directions.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.3",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/views.py",
      "line": 946,
      "claim": "Rebuilding a default expansion can rewrite saved collection membership without a checkpoint.",
      "scenario": "A read-only private collection has a default expansion with an unpinned reference to a source that has since changed. An org member posts to `re-evaluate/`. The worker rebuilds the default membership and can update the saved reference's concept and mapping links when expansion locking is enabled. Creating an expansion can also set the collection's default when auto-expansion is enabled and no default exists.",
      "action": "Check `edit` before rebuilding or assigning a default expansion that changes saved collection content. Preserve expansion reads and ad hoc evaluation.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.4",
      "severity": "P2",
      "tag": null,
      "file": "core/common/tasks.py",
      "line": 186,
      "claim": "Queued reference additions can write after a collection becomes read-only.",
      "scenario": "A user queues a reference addition while a private collection is writable. The collection becomes read-only before the worker starts. The worker reloads the collection and saves the references using the decision made at submission, so the write succeeds after that.",
      "action": "Recheck the current write policy in the worker before adding references. Return the refusal body through the task result and the synchronous response.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.5",
      "severity": "P2",
      "tag": null,
      "file": "core/sources/views.py",
      "line": 305,
      "claim": "The latest-version route can classify publication of a HEAD as an edit.",
      "scenario": "An existing private HEAD is marked released and is the row selected by `/latest/`. The owner submits a visibility change that would make it public. The source and collection latest-version views always ask for `edit`, so a policy that permits publication still refuses the request.",
      "action": "Classify the latest-version update from the resolved row. Ask for `publish` when the selected row is HEAD and the update makes it public.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.6",
      "severity": "P2",
      "tag": null,
      "file": "core/common/permissions.py",
      "line": 100,
      "claim": "Bodyless delete operations now require parsing any supplied body, even under the default policy.",
      "scenario": "An authorized client sends a repository or map-project DELETE with an informational `text/plain` body. The endpoint previously ignored the body. The new permission check accesses `request.data` before classifying the action, so DRF returns 415 and the deletion fails.",
      "action": "Classify DELETE without accessing `request.data`. Read the body only for updates whose action depends on visibility.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

The posted JSON words F2.4's scenario neutrally; the archived copy is verbatim.

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Replies to Codex pass 2, fixed in 597fd82. core.capabilities runs 128 tests and the wider run 3,324 (no ES), all OK; pylint -j0 core/ gives 10.00 with no messages. Each new test was also run against a182d26, where every one failed.

  • F1.5 / F2.2 P1 the hierarchy fix hides children: fixed by reverting F1.5's fix. Linking a parent's new version to the children it already has isn't asked about: the system keeps those links current when a writable repository changes, and holding them back hid the children from the parent's /children/. F1.5 is accepted on that ground. A parent's own new version in a refused repository is still not written, as in 359f7b3.
  • F2.1 P1 a version update moves a release: fixed. short_code is read-only on the source and collection version serializers, so a version update never changes its repository, under any policy. Tested for both.
  • F2.3 P1 rebuilding a default expansion: fixed. Re-evaluating a version's default expansion, and creating an expansion that becomes the version's default, are edits of the version. Re-evaluating another expansion, and creating one that isn't the default, aren't asked about.
  • F2.4 P2 a queued reference add: fixed. The task asks again when it runs and returns the refusal as its result; when it ran in-process, the view sends it as the 403.
  • F2.5 P2 the latest-version route: fixed. Both latest-version views classify from the row they resolve, so making it viewable is publish.
  • F2.6 P2 a DELETE with a body that doesn't parse: fixed. A DELETE's body is never read.
  • Also, from the other half's review: 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, and deleting a version is still an edit. get_write_target returns the row written.

@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.

Review (high effort, not verified by running). Most severe first.

  1. publish lets other field edits through (core/capabilities/writes.py:41). A PUT or PATCH counts as publish whenever its body makes a private repository viewable, so every other field in that body rides on the publish answer.
    • Example: PATCH {"public_access": "View", "name": "X", "extras": {...}} on content the policy keeps read-only. A policy that allows publish saves the whole edit.
    • A second PATCH that sets public_access back to None is then an edit of public content.
    • Suggest: only call it publish when public_access is the only change, or give the policy both facts.
  2. #985 (isolated source versions) skips the check. IsolatedVersionCommit.get_rejection and preflight replace HEAD's content and check only head.has_edit_access. Once both PRs merge, that path never asks the policy. They also conflict in BaseResourceImporter.__init__ (isolated vs policy). Whichever merges second needs the check in get_rejection.
  3. Expansions aren't asked (core/collections/views.py:867, 946, 984). Expansion POST and DELETE, and re-evaluate/, still use HasAccessToVersionedObject. They change what a collection version resolves to, so $expand answers differently. They look like writes; CanEditConceptDictionaryVersion would cover them.
  4. A run's PATCH can be refused partway through (core/map_projects/views.py:348). AutomatchRunView updates go through ChecksWrites. If a policy's answer for a project changes during a run, for example because the policy ranks projects by updated_at, the Mapper's progress or finish PATCH gets a 403 and the run never closes. Consider exempting updates to a run that has already started.
  5. The hierarchy splits on a refused child (core/concepts/models.py:759, 791). When a parent gets a new version, children in a refused repository keep linking to the old parent version, so the new version loses those children in browse and $cascade. Linking a child to its parent's new version doesn't change the child's repository content, so it may not need asking.
  6. The policy is asked once per import line (core/importers/models.py:126). Nothing is cached per repository, and package-import rows and save_fhir_resource each make a new policy. Caching by (repository id, action), as the hierarchy pass already does with writable_by_source_id, would make it one call per repository.
  7. The overrides endpoint now takes any capability (core/capabilities/views.py:220). This widens the existing core/capabilities overrides debt (OpenConceptLab/ocl_online#532). Could the extension mechanism be agreed there first?

Policy-side details are on the private PR.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: 5 findings: 4 P1, 1 P2. Earlier findings: all resolved except F1.5 (accepted on pass 2) and F2.1, which F3.2 extends to the repository detail route. This was the last pass; fixes follow, with one reply line per finding, then a Codex check of the later commits.

  • P1 core/capabilities/writes.py:38: A release edit is classified as publication even when its private HEAD keeps it hidden.
  • P1 core/sources/serializers.py:403: The repository detail route still lets an update move a release into a read-only repository.
  • P1 core/code_systems/serializers.py:423: FHIR updates check the selected release even though they write the HEAD and create a new version.
  • P1 core/repos/mixins.py:62: External export attachments can be replaced or removed from read-only releases.
  • P2 core/common/tasks.py:488: Queued expansion rebuilds and concept hard deletes still run after the repository becomes read-only.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "597fd824",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F1.3",
      "status": "resolved"
    },
    {
      "id": "F1.4",
      "status": "resolved"
    },
    {
      "id": "F1.5",
      "status": "unresolved"
    },
    {
      "id": "F1.6",
      "status": "resolved"
    },
    {
      "id": "F2.1",
      "status": "unresolved"
    },
    {
      "id": "F2.2",
      "status": "resolved"
    },
    {
      "id": "F2.3",
      "status": "resolved"
    },
    {
      "id": "F2.4",
      "status": "resolved"
    },
    {
      "id": "F2.5",
      "status": "resolved"
    },
    {
      "id": "F2.6",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "F3.1",
      "severity": "P1",
      "tag": null,
      "file": "core/capabilities/writes.py",
      "line": 38,
      "claim": "A release edit is classified as publication even when its private HEAD keeps it hidden.",
      "scenario": "An owner of read-only content updates a private release under a private HEAD, changing its description and setting `public_access` to `View`. The checkpoint receives `publish` and allows the write, although the release remains private because its HEAD is private.",
      "action": "Classify a release update as `publish` only when the resulting visibility lets others view it. Cover the case where both the release and HEAD are private.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.2",
      "severity": "P1",
      "tag": null,
      "file": "core/sources/serializers.py",
      "line": 403,
      "claim": "The repository detail route still lets an update move a release into a read-only repository.",
      "scenario": "An editor updates a public source through its detail URL with `?version=v1`. That selects release `v1`, but the route uses `SourceDetailSerializer`, which still accepts `id` and `short_code` as the repository mnemonic. Naming a private read-only source owned by the same account moves the release there if that source has no `v1`. The checkpoint only saw the original public release. Collections have the same path.",
      "action": "Keep the repository identity immutable whenever an update resolves to a release, including on detail routes that select a release through the query string.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.3",
      "severity": "P1",
      "tag": null,
      "file": "core/code_systems/serializers.py",
      "line": 423,
      "claim": "FHIR updates check the selected release even though they write the HEAD and create a new version.",
      "scenario": "A repository has a public HEAD and a private latest release. Once its private content is read-only, a FHIR PUT with the matching resource ID and a new version is refused based on the private release. The serializer would have updated the public HEAD and inserted a new version without saving over the existing release. The same applies to ConceptMap and ValueSet.",
      "action": "Check the HEAD the FHIR serializer will write for both API and package updates. Preserve its visibility explicitly so the selected release's access cannot be copied onto HEAD as a side effect.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.4",
      "severity": "P1",
      "tag": null,
      "file": "core/repos/mixins.py",
      "line": 62,
      "claim": "External export attachments can be replaced or removed from read-only releases.",
      "scenario": "After a private release becomes read-only, its owner can upload a replacement file to an existing external export key or delete the attachment. Both operations change saved release content, and deletion removes the stored file. Neither operation asks the checkpoint.",
      "action": "Check `edit` on the release before replacing or removing an attachment. Keep attachment downloads and generated exports available.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.5",
      "severity": "P2",
      "tag": null,
      "file": "core/common/tasks.py",
      "line": 488,
      "claim": "Queued expansion rebuilds and concept hard deletes still run after the repository becomes read-only.",
      "scenario": "An editor queues a default expansion rebuild or an asynchronous hard delete of a HEAD-only concept while the private repository is writable. The repository becomes read-only before the worker starts. The worker still rewrites the saved expansion members or deletes the concept because only the request checked the policy.",
      "action": "Carry the initiating user into these tasks and recheck `edit` against the current repository row before writing. Report the refusal in the task result and clear the expansion's processing flag.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

The posted JSON words three scenarios neutrally; the archived copy is verbatim.

… 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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Replies to Codex pass 3, fixed in 784b5bf. core.capabilities runs 130 tests and the wider run 3,326 (no ES), all OK; pylint -j0 core/ gives 10.00 with no messages. Each new test was also run against 597fd82, where every one failed.

  • F3.1 P1 publish under a private HEAD: fixed. Making a version viewable is publish only while its HEAD is viewable; under a private HEAD the version stays hidden, so the write is an edit.
  • F3.2 P1 the detail route with ?version= moves a release: fixed at the source. The source and collection create-or-update serializers take a mnemonic from the body only for a new row or a HEAD, so no route can move a version to another repository. That replaces F2.1's read-only short_code.
  • F3.3 P1 FHIR updates checked the selected release: fixed. The CodeSystem, ConceptMap and ValueSet detail views set updates_head, so a PUT or PATCH is asked about the HEAD it saves onto; a DELETE is still asked about the row it deletes. The package import asks about the HEAD of the row its canonical URL matched. The release's access being copied onto HEAD by a FHIR update is older than this PR, and not a way to write read-only content: left as it is.
  • F3.4 P1 external export attachments: fixed. Uploading or removing one is an edit of the version; downloads and generated exports aren't asked about.
  • F3.5 P2 queued expansion rebuilds and hard deletes: accepted. Neither task carries the user who asked, and a write queued just before content becomes read-only that finishes just after is the same as one made just before. The reference add (F2.4) rechecks because it already carried the user.

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Simplification review (claude subagent, commit 784b5bf)

8 items. Applied in ee1bdec (core.capabilities and core.concepts 315 tests OK without ES; pylint 10.00, no messages):

  • S1 yagni core/common/permissions.py:85 (writes_content flag): not applied. The flag sits on the view that knows its writes change no content; swapping each of those views to another permission class spreads that knowledge across get_permissions overrides and shared mixins.
  • S2 shrink core/code_systems/views.py:42 (flags onto the FHIR mixin): not applied. The mixin also serves FHIR list and create views; the flags belong next to the three detail views they describe.
  • S3 yagni core/importers/models.py:117 (drop the shared policy): not applied. A bulk import asks once per line, and one policy per batch keeps that cheap whatever a policy does when it's made.
  • S4 shrink core/importers/models.py:318 (walrus): not applied. Style only.
  • S5 dup-test test_writes.py:177: applied. The route tests show which object reaches the policy.
  • S6 dup-test test_writes.py:488: not applied. It's the one test that a refusal of one repository doesn't refuse another.
  • S7 delete core/capabilities/views.py:219: not applied. It's the fix for the other half's pass 2 P1: staff couldn't set the per-account override that undoes read-only, which the ticket requires.
  • S8 delete core/concepts/models.py:734: applied.

A Codex check of the commits after pass 3 follows, after the adversarial pass.

simplify.json
{
    "reviewer": "claude subagent",
    "perspective": "simplify",
    "mode": "full",
    "commit": "784b5bfd",
    "verdict": "findings",
    "prior": [],
    "findings": [
        {
            "id": "S1",
            "severity": null,
            "tag": "yagni",
            "file": "core/common/permissions.py",
            "line": 85,
            "claim": "The `writes_content` view flag (getattr in ChecksWrites, plus 3 views that set it: ResourceClientConfigsView, ConceptContainerProcessingMixin, CollectionReferencesPreview, CollectionVersionExpansionProcessingView) exists only to turn the checkpoint off for views that were given CanEditConceptDictionary. CanEditConceptDictionary has no behaviour beyond HasPrivateAccess, so those views can simply use the non-checking class.",
            "action": "Have those views return HasPrivateAccess() (or keep CanEditConceptDictionary only where a write is real) in get_permissions/edit_permission_class; delete the `writes_content` attribute lines, the getattr condition and the docstring sentence about it.",
            "lines_delta": -8,
            "confidence": "medium"
        },
        {
            "id": "S2",
            "severity": null,
            "tag": "shrink",
            "file": "core/code_systems/views.py",
            "line": 42,
            "claim": "The same two flags (`applies_public_access = False`, `updates_head = True`) with identical comments are repeated on the CodeSystem, ConceptMap and ValueSet update views.",
            "action": "Set the two flags once on FhirViewMixin (or FhirReadMixin) and delete the six lines and three duplicate comments from the three views.",
            "lines_delta": -4,
            "confidence": "medium"
        },
        {
            "id": "S3",
            "severity": null,
            "tag": "yagni",
            "file": "core/importers/models.py",
            "line": 117,
            "claim": "The `policy=` argument is threaded through 6 importer constructors and 8 call sites, and ImporterSubtask builds a shared instance, only to avoid calling get_capability_policy() (a plain import_string(...)() ) once per line. Nothing in the repo shows a policy that is costly to build.",
            "action": "Drop the `policy` parameter and self.policy plumbing; Importer.get_write_refusal calls get_write_refusal(self.user, target, action) with policy=None (it already builds one). Same in Concept.can_write_hierarchy_of and the bulk-import `can_write` helper: drop the `policy` argument and the `policy = get_capability_policy()` locals.",
            "lines_delta": -22,
            "confidence": "low"
        },
        {
            "id": "S4",
            "severity": null,
            "tag": "shrink",
            "file": "core/importers/models.py",
            "line": 318,
            "claim": "The 4-line `refusal = self.get_write_refusal(x); if refusal is not None: return refusal` block is pasted about 10 times across the importers.",
            "action": "Use `if refusal := self.get_write_refusal(x): return refusal` (WriteRefused is an exception instance so it is truthy; or keep `is not None` in the walrus). Removes a line per site and the `too-many-return-statements` pylint disables stay as is.",
            "lines_delta": -10,
            "confidence": "medium"
        },
        {
            "id": "S5",
            "severity": null,
            "tag": "dup-test",
            "file": "core/capabilities/tests/test_writes.py",
            "line": 177,
            "claim": "test_the_target_is_the_repository_row_or_the_map_project asserts get_write_target's return values directly; every route test already proves a repository row or map project reaches the policy and a concept or org does not (calls list in the route tests).",
            "action": "Delete the test; the ReadOnlyPolicy.calls assertions in the route tests cover the behavior.",
            "lines_delta": -10,
            "confidence": "medium"
        },
        {
            "id": "S6",
            "severity": null,
            "tag": "dup-test",
            "file": "core/capabilities/tests/test_writes.py",
            "line": 488,
            "claim": "test_a_writable_repository_is_written (PUT to the source while only the collection is read-only) repeats test_a_write_goes_ahead plus a calls assertion that test_repository_update_is_an_edit already makes.",
            "action": "Delete it, or fold its one extra check (a different read-only repo doesn't block this one) into test_repository_update_is_an_edit.",
            "lines_delta": -7,
            "confidence": "low"
        },
        {
            "id": "S7",
            "severity": null,
            "tag": "delete",
            "file": "core/capabilities/views.py",
            "line": 219,
            "claim": "get_capability_id switching from CAPABILITY_ID_BY_NAME to a Capability table lookup (plus the new test_any_capability_in_the_table_can_be_overridden) has nothing to do with the write checkpoint or ticket 424.",
            "action": "Move it to its own ticket/PR and drop it from this diff (views.py hunk, its import and the test in core/capabilities/tests/tests.py).",
            "lines_delta": -17,
            "confidence": "medium"
        },
        {
            "id": "S8",
            "severity": null,
            "tag": "delete",
            "file": "core/concepts/models.py",
            "line": 734,
            "claim": "`and parent_concepts` added to `if create_parent_version` only skips building a policy when there are no parents; it is a micro-guard whose only purpose is the policy local from S3.",
            "action": "Revert to `if create_parent_version:` (nothing replaces it; with S3 applied the policy local is gone anyway).",
            "lines_delta": -1,
            "confidence": "low"
        }
    ]
}

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Adversarial pass (fresh Claude subagent, both halves, this PR at 784b5bf)

No P0. Its findings on this PR's checkpoint:

  • Every write route checked: every POST, PUT, PATCH and DELETE in core/*/views.py and the mixins reaches ChecksWrites or an explicit check_write: concepts, mappings, names, extras, logos, references, versions, clones, FHIR updates, importer lines, hierarchy writes and map projects. Owner fields can't move a repository; staff are never refused; reads, exports and processing flags aren't asked.
  • P2 non-default expansions can be created or re-evaluated on a refused collection version without asking. Accepted: a non-default expansion doesn't change what the version holds (pass 2's F2.3 kept ad hoc evaluation open on purpose).
  • P3 a release DELETE is an edit, so a policy that allows deleting a whole repository doesn't thereby allow deleting one release. As designed on pass 1 (F1.4); noted on the private ticket.
  • P3 the resolved-repo-updates DELETE soft-deletes an expansion without asking; it's older than this PR and is a delete.
  • The rest was about the private policy and is answered on the private ticket.

A Codex check of the commits after pass 3 (597fd82..ee1bdec) follows.

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 597fd82..ee1bdec (codex-cli 0.169.0)

Verdict: 3 findings: 1 P1, 2 P2.

  • P1 core/common/permissions.py:87: A FHIR update can make a public repository private by copying access from the version it resolves.
  • P2 core/sources/serializers.py:166: The mnemonic guard checks whether the row is HEAD after applying the incoming version label.
  • P2 core/capabilities/writes.py:49: The classifier treats publishing a version without an active HEAD as an edit.

Replies (fixed in 99213dc; core.capabilities 131 OK, the wide run 3,327 with one thread-timing test in core.capacity (untouched here) failing under parallel load and passing alone; each new test fails against ee1bdec):

  • FC.1 P1 a FHIR update copies the resolved release'"'"'s access onto HEAD: not fixed here. Under the default policy it behaves exactly as on master: a FHIR update has always copied the latest release'"'"'s public_access onto HEAD. It doesn'"'"'t write content the checkpoint refuses (the HEAD it saves onto is asked about, since 784b5bf); it makes content private, which is a separate rule. It needs its own ticket, asked for on the private ticket.
  • FC.2 P2 the HEAD check runs after the incoming version label: fixed. Whether a row may take a new mnemonic is decided from the stored row, before the body applies.
  • FC.3 P2 a version without an active HEAD: fixed. makes_viewable follows is_publicly_viewable: a version is published when it becomes viewable, which without an active HEAD means its own access.
final.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "final",
    "commit": "ee1bdec7",
    "verdict": "findings",
    "prior": [],
    "findings": [
        {
            "id": "FC.1",
            "severity": "P1",
            "tag": null,
            "file": "core/common/permissions.py",
            "line": 87,
            "claim": "A FHIR update can make a public repository private by copying access from the version it resolves.",
            "scenario": "An owner of read-only private content updates a CodeSystem whose HEAD is public and whose selected release is private. The new check allows the edit based on HEAD. The serializer then copies the release's private access onto HEAD and creates a private version. Existing public releases become hidden. The package import has the same behavior when it matches the private release.",
            "action": "Preserve the destination HEAD's public_access in all three FHIR update serializers before saving HEAD or creating the new version. Assert that both rows retain public access in the API and package-import regression tests.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.2",
            "severity": "P2",
            "tag": null,
            "file": "core/sources/serializers.py",
            "line": 166,
            "claim": "The mnemonic guard checks whether the row is HEAD after applying the incoming version label.",
            "scenario": "An owner updates a named version through its version endpoint with a HEAD label and an unused short code. The serializer treats the row as HEAD and accepts the short code, moving the version out of the original repository and saving it as a new HEAD. The collection serializer has the same ordering.",
            "action": "Evaluate whether the stored row is HEAD before applying request fields. Reject a named version's transition to HEAD and test that both its label and repository stay intact.",
            "lines_delta": null,
            "confidence": "high"
        },
        {
            "id": "FC.3",
            "severity": "P2",
            "tag": null,
            "file": "core/capabilities/writes.py",
            "line": 49,
            "claim": "The classifier treats publishing a version without an active HEAD as an edit.",
            "scenario": "A HEAD rename leaves a private version under the old mnemonic. Once the owner's private content is read-only, they set that version's access to View through the repository detail route with a version query parameter. The new classifier causes a 403. The API's visibility rule would make the version publicly viewable because it has no active HEAD.",
            "action": "Align publish classification with the repository visibility rule for versions without an active HEAD. Keep coverage for versions whose active HEAD is private.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

The posted JSON words two scenarios neutrally; the archived copy is verbatim.

@paynejd
paynejd marked this pull request as ready for review November 19, 2026 06:56
@paynejd
paynejd requested a review from snyaggarwal November 19, 2026 06:56
paynejd and others added 4 commits November 19, 2026 02:24
…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits ee1bdec..60d9e65 (codex-cli 0.169.0, commit 60d9e65)

This covers 99213dc, the fixes for the last check that hadn't been checked yet, and the review fixes 897da1b and 60d9e65.

Verdict: 2 findings, both P1.

  • P1 core/collections/serializers.py:171: The source and collection serializers now accept a mnemonic change when an update turns a HEAD into a version.
  • P1 core/capabilities/writes.py:77: Bulk and package imports reuse write decisions after the policy's answer changes.

Replies. Both are fixed in 59642d9. The whole suite runs 3,331 OK (2 skipped), and pylint is 10.00 with exit 0. Each new test fails against 60d9e65.

  • FC.1 P1, a HEAD relabelled as a version takes a new mnemonic: fixed. A stored row takes the body's mnemonic only when it is a HEAD both before and after the body applies; a new row always takes it. This covers the repository route and FHIR ValueSet updates, since both prepare the row in prepare_object. Test: test_a_row_takes_a_new_mnemonic_only_as_a_head_that_stays_one.
    • The ValueSet case where the HEAD stays a HEAD and a different id renames it is how master already behaves. That write stays in the row the checkpoint asked about. CodeSystem and ConceptMap updates refuse another id; a ValueSet update doesn't. I've asked for a separate ticket for it.
  • FC.2 P1, a batch keeps answers after the policy's answer changes: fixed. BatchWriteRefusals asks again once an answer is a minute old, so a change reaches a long import within the minute. A batch still asks a handful of times, not once per line. Test: test_a_batch_asks_again_once_an_answer_is_a_minute_old.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "60d9e655",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "FC.1",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/serializers.py",
      "line": 171,
      "claim": "The source and collection serializers now accept a mnemonic change when an update turns a HEAD into a version.",
      "scenario": "An editor changes a public HEAD's mnemonic to that of a read-only repository under the same owner and supplies an unused version label. The checkpoint approves the original public HEAD, then the save attaches the row to the read-only repository as a version. A ValueSet package update can also silently rename an existing HEAD when it matches by canonical URL and supplies a different FHIR ID, leaving prior releases under the old mnemonic.",
      "action": "For an existing row, apply mnemonic changes only if both the stored and requested versions are HEAD. Cover the REST update and the ValueSet package import in regression tests.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "FC.2",
      "severity": "P1",
      "tag": null,
      "file": "core/capabilities/writes.py",
      "line": 77,
      "claim": "Bulk and package imports reuse write decisions after the policy's answer changes.",
      "scenario": "An import checks a private repository just before the scheduled cutoff. Later rows for that repository still write after the cutoff even though the policy would now refuse them. The same cache keeps refusing later rows if an account override restores write access during the import.",
      "action": "Ask the policy for each write using current inputs. Add a regression test in which the policy's answer changes between two rows for the same repository.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Replies to Sunny's review (at 597fd82)

Thanks, Sunny. One line of answer per item, then detail. Fixes are in 897da1b and 60d9e65 (a docstring), plus 59642d9, 85795a9 and 25bfeb5 from the Codex checks posted on this PR. The whole suite runs 3,332 OK (2 skipped), and pylint -j0 core/ is 10.00 with exit 0.

  1. publish carries other field edits: not changed here; the gate for the step after is OpenConceptLab/ocl_online#365.

    • TBv3's repository edit form PUTs the whole object, every field and not only public_access (RepoCreate.jsx, service.put(payload)). A rule of "publish only when public_access is the only key" would refuse the owner's own way out through TBv3.
    • Comparing each field to the stored value instead is fragile: JSON fields, extras, and nulls against blanks would make an unchanged field look changed.
    • A body that publishes and edits ends where a publish followed by an edit ends, and both of those are allowed. The step that matters comes after that, and it's covered by OpenConceptLab/ocl_online#365. More detail is on the private PR.
  2. OpenConceptLab/ocl_online#655 | Isolated source versions #985 skips the check: agreed. Whichever PR merges second adds it. That PR adds get_write_refusal to IsolatedVersionCommit.get_rejection and resolves the BaseResourceImporter.__init__ conflict (isolated there, write_refusals here). I haven't touched OpenConceptLab/ocl_online#655 | Isolated source versions #985's branch.

  3. Expansions aren't asked: agreed and fixed. Expansion POST and DELETE and re-evaluate/ now use CanEditConceptDictionaryVersion, so each is an edit of the collection version, default or not. The two default-only checks from 597fd82 are gone. The processing route still isn't asked (writes_content = False), as it only clears a flag. Test: test_every_expansion_write_is_an_edit_of_the_version.

  4. A run's PATCH can be refused partway through: fixed. AutomatchRunView sets writes_content = False. Its PATCH takes only lifecycle fields (completed_rows, failed_rows, completion_status, completed_at), so a run that was allowed to start can record its progress and finish. Starting a run is still asked. Test: test_a_started_run_records_its_progress_and_finishes_without_being_asked.

  5. The hierarchy splits on a refused child: already reverted in 597fd82. Linking children to a parent's new version isn't asked about. Test: test_a_parent_s_new_version_is_linked_to_children_in_read_only_repositories.

  6. One policy call per import line: fixed.

    • A new BatchWriteRefusals (core/capabilities/writes.py) asks once per user, saved repository row and action.
    • BulkImportInline shares one across its lines and its hierarchy pass, which replaces the pass's own policy. A package file's rows share one through ResourceImporter.
    • An import line never changes the access of a row that exists (source and collection lines only create), so an answer is kept until it is a minute old (59642d9). After that it is asked again about the row as stored now (85795a9), so a change in the answer reaches a long import within the minute. A new version isn't saved yet, so it's asked each time.
    • A FHIR resource is asked once, as it is one repository.
    • Tests: test_a_batch_asks_once_per_repository_and_action, test_a_batch_asks_again_once_an_answer_is_a_minute_old, test_an_answer_asked_again_is_about_the_row_as_stored_now and test_the_rows_of_a_package_file_share_their_answers.
  7. The overrides endpoint takes any capability: your call; I haven't reverted it. It was the fix for the private PR's pass 2 P1: staff couldn't set an override for a capability the private layer adds, and the ticket needs that override for a per-account exception. The options:

    • (a) Keep it here. The endpoint takes any capability in the capabilities table and stays staff-only.
    • (b) Revert it here, and agree on the extension mechanism on OpenConceptLab/ocl_online#532 first. Until then, staff could make such an override only from the Django shell, because UserCapabilityOverride isn't registered in Django admin.
    • (c) Revert it here, and the private package serves its own staff route for its capabilities' overrides through OCL_EXTRA_URLCONFS, which core already loads. This needs that setting in the deployment.

    I recommend (c): public code stays as it was and the mechanism already exists. The cost is one small route on the private PR plus the deployment setting. Tell me which one you want and I'll make it.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 60d9e65..59642d9 (codex-cli 0.169.0, commit 59642d9)

Verdict: FC.1 resolved. FC.2 still open by Codex's reading, plus 1 new finding, a P2.

  • P2 core/capabilities/writes.py:84: Rechecking an expired answer can refuse bulk writes to a repository that is already public.

Replies:

  • FC.2, an answer can still be up to a minute old: kept, deliberately. Codex wants every line asked with current inputs. That is the one-call-per-line cost Sunny's item 6 asked to remove. A minute bounds how long a changed answer takes to reach a long import. A single API request already checks once and then writes.
  • FC.3 P2, a re-check is asked about the row the batch loaded: fixed in 85795a9. A batch keeps the rows it loaded (get_cached_parent_source), so an expired answer was re-asked about a row whose access may have changed since. Now the answer is asked about the row as stored now, at one query per repository a minute. Test: test_an_answer_asked_again_is_about_the_row_as_stored_now, which fails against 59642d9. The whole suite runs 3,332 OK (2 skipped), and pylint is 10.00 with exit 0.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "59642d96",
  "verdict": "findings",
  "prior": [
    {"id": "FC.1", "status": "resolved"},
    {"id": "FC.2", "status": "unresolved"}
  ],
  "findings": [
    {
      "id": "FC.3",
      "severity": "P2",
      "tag": null,
      "file": "core/capabilities/writes.py",
      "line": 84,
      "claim": "Rechecking an expired answer can refuse bulk writes to a repository that is already public.",
      "scenario": "A bulk concept or mapping import starts on a private source before the cutoff and caches the source row. The owner makes the source public while the import runs. After the cutoff and cache expiry, the policy sees the old private row and refuses later lines even though the source is public. Those lines were allowed before this commit.",
      "action": "Use the current repository row when recomputing an expired answer. Add a bulk import regression test that makes the source public between checks.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commit 85795a9 (codex-cli 0.169.0, commit 85795a9)

Verdict: 2 new findings, both P2. Codex still counts FC.2 as open (answered above), and marks FC.3 as regressed through FC.4.

  • P2 core/capabilities/writes.py:85: The refresh lets bulk import resume after a source is published, but newly imported concepts and mappings still inherit private access from the cached source.
  • P2 core/capabilities/tests/test_writes.py:627: The new regression test exercises only the first policy lookup.

Replies:

  • FC.4 P2, later lines keep the access of the source the batch loaded: accepted, not fixed here. This comes from the batch's own cache of the parent source (get_cached_parent_source), which this PR doesn't touch. Master behaves the same: an import that runs while its source is made public saves its later lines with the access it loaded. The checkpoint now matches master there instead of refusing those lines, so FC.3 is resolved for what it covers.
  • FC.5 P2, the test only exercised the first question: fixed in 25bfeb5. The test now asks, makes the stored row public, lets the answer expire, and checks that the second question is about the public row. It fails when the refresh is removed. core.capabilities runs 136 OK, and pylint is 10.00 with exit 0. 25bfeb5 changes only a test and hasn't been through Codex.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "85795a91",
  "verdict": "findings",
  "prior": [
    {
      "id": "FC.2",
      "status": "unresolved"
    },
    {
      "id": "FC.3",
      "status": "regressed"
    }
  ],
  "findings": [
    {
      "id": "FC.4",
      "severity": "P2",
      "tag": null,
      "file": "core/capabilities/writes.py",
      "line": 85,
      "claim": "The refresh lets bulk import resume after a source is published, but newly imported concepts and mappings still inherit private access from the cached source.",
      "scenario": "A bulk import caches a private source and receives a refusal. The owner publishes the source while the batch is running. After expiry, the policy sees the public source and permits the next line. The importer saves the new concept or mapping with the cached source's private access and reports success. Anonymous global listings omit the new resource.",
      "action": "Use the refreshed source for both the policy check and bulk import persistence. Add a test that publishes the source between import lines and checks the new resource's stored access.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "FC.5",
      "severity": "P2",
      "tag": null,
      "file": "core/capabilities/tests/test_writes.py",
      "line": 627,
      "claim": "The new regression test exercises only the first policy lookup.",
      "scenario": "If the first lookup refreshes the row but the expiry path passes the stale instance, the new test still passes. The existing expiry test changes the policy's response without changing the stored row, so it also passes while FC.3 returns.",
      "action": "Prime the cache, change the stored access, advance the mocked clock to expiry, and assert that the second policy call receives the updated access.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

paynejd and others added 2 commits November 19, 2026 02:55
…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
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Item 7 done as (c), and the PR is up to date with master

  • Item 7, the overrides route: reverted (60c3184). The route takes only this repository's capabilities again: core/capabilities/views.py matches master, and the test for the wider behaviour is gone. A deployment that adds its own capabilities serves its own staff route for them through OCL_EXTRA_URLCONFS. The detail is on the private PR.
  • Master merged in (98707dc), so the PR is mergeable again. I merged rather than rebased so the commits cited in the review comments above stay valid; the squash merge folds it away. Three files conflicted:
  • Tests: the whole suite runs 3,390 OK (2 skipped), and pylint -j0 core/ is 10.00 with exit 0.

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits afe3ee0..a69e2dd (codex-cli 0.169.0, commit a69e2dd)

Verdict: clean, no findings. Earlier: FC.16 resolved, FC.17 resolved.

findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "a69e2dd0",
  "verdict": "clean",
  "prior": [
    {
      "id": "FC.16",
      "status": "resolved"
    },
    {
      "id": "FC.17",
      "status": "resolved"
    }
  ],
  "findings": []
}

Comment thread core/importers/models.py Resolved
Comment thread core/importers/models.py Resolved
Comment thread core/importers/models.py Resolved
Comment thread core/collections/views.py Resolved
Comment thread core/concepts/models.py Resolved
Comment thread core/concepts/permissions.py Resolved
paynejd and others added 2 commits November 22, 2026 22:14
…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
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Scope: the commits answering the Nov 23 review, 351dc8c0..d2e687b1.

Verdict: findings (1 P1)

  • F1.1 (P1) core/importers/models.py:637: a refusal raised by preflight escaped all three import tasks as an exception, so the task failed and the policy's body survived only as traceback text.

Response: F1.1 fixed in 315df17. preflight still raises; each runner catches the WriteRefused and reports it as it reports a refused line, with nothing imported: BulkImportInline and BulkImportParallelRunner list the version line under permission_denied with the body as errors, and the archive Importer returns a summary with one failure ending in the body as JSON. test_a_seeded_version_of_a_read_only_source_is_refused_before_any_line_imports now checks the inline and parallel results, and test_a_seeded_version_archive_of_a_read_only_source_reports_the_refusal the archive's.

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "full",
    "commit": "d2e687b1",
    "verdict": "findings",
    "prior": [],
    "findings": [
        {
            "id": "F1.1",
            "severity": "P1",
            "tag": null,
            "file": "core/importers/models.py",
            "line": 637,
            "claim": "A preflight refusal escapes all three import tasks as a Celery exception, so the task API loses the structured policy body.",
            "scenario": "An authorized editor submits a valid seeded import for a source that is already read-only when the worker starts. Preflight raises before any writes, but the task is marked FAILURE and the refusal is available only as exception text. The inline and parallel result handlers never add a permission_denied entry, and the archive task never produces a report containing the refusal. The new tests stop at the importer constructor or call the commit directly, so they miss the queued result.",
            "action": "Keep raising WriteRefused in preflight and handle it at the queued import boundaries. Preserve its body in the task API, including permission_denied with errors for inline and parallel imports. Test the polled result for a source that is read-only before the worker starts.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

…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
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Scope: 351dc8c0..315df17e. F1.1: resolved.

Verdict: findings (1 P1)

  • F2.1 (P1) core/importers/models.py:1611: after an up-front refusal the counts didn't add up: the inline result said 0 of 2 processed, the parallel one 1 of 0, the archive one 0 of 0.

Response: F2.1 fixed in 11f1b09. Each runner's result gives the lines submitted as its total and the refused version line as the one line processed; the refusal tests check (2, 1) for inline, parallel and archive. A seeding parallel import also counts the version line in its total, which its parts don't hold. The archive's refusal result moved into Importer.get_refused_result to keep run within Pylint's statement limit.

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "315df17e",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "resolved"
        }
    ],
    "findings": [
        {
            "id": "F2.1",
            "severity": "P1",
            "tag": null,
            "file": "core/importers/models.py",
            "line": 1611,
            "claim": "A preflight refusal records a version-line outcome but leaves the import's processed and total counts inconsistent.",
            "scenario": "Submit one concept and one source-version line targeting a read-only source. The inline result reports 0 of 2 processed with one denial. The parallel result reports 1 of 0 processed with one denial. The archive result reports 0 of 0 processed with one failure. Each result contains an outcome for the version line.",
            "action": "Preserve the submitted line count and count the refused version as one processed line in all three results. Leave skipped lines unprocessed and assert the final counts in the refusal tests.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

…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
@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

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

Scope: 351dc8c0..11f1b09f. F1.1: resolved. F2.1: resolved.

Verdict: findings (1 P1)

  • F3.1 (P1) core/importers/models.py:1612: after an up-front refusal, the parallel runner's saved task progress counted only its child tasks, so it showed 0 of 2 processed while its detailed result showed 1 of 2.

Response: F3.1 fixed in 5c9b0ae: get_completed_progress counts the seeded version line's outcome too, as json_result does. That also brings a normal seeding run to N of N; its version line is committed by the main runner, never in a part. The refusal test now runs the parallel runner with a task record and checks the saved summary (it failed before the fix with 0 of 2). A Codex check of 11f1b09f..5c9b0ae9 follows.

Simplification review (Claude subagent, at 11f1b09): two optional items, neither taken. S1 suggested parenthesising the conditional that picks errors in commit_isolated_version: the same expression. S2 suggested dropping the test's assertion on what the policy is asked, which is the contract every other test in test_writes.py pins, and the direct preflight raise the review asked for.

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "verify",
    "commit": "11f1b09f",
    "verdict": "findings",
    "prior": [
        {
            "id": "F1.1",
            "status": "resolved"
        },
        {
            "id": "F2.1",
            "status": "resolved"
        }
    ],
    "findings": [
        {
            "id": "F3.1",
            "severity": "P1",
            "tag": null,
            "file": "core/importers/models.py",
            "line": 1612,
            "claim": "The parallel import status reports zero processed lines after preflight refuses the version line.",
            "scenario": "Submit a concept and a version line targeting a read-only source through the parallel importer. Preflight records one denial and schedules no parts. The completed task's API summary shows 0 of 2 processed because progress counts only child tasks and hierarchy work. The detailed result shows 1 of 2 processed.",
            "action": "Count the refused version line when saving task progress. Extend the regression test to run the parallel importer with a task record and assert the saved summary as well as the detailed result.",
            "lines_delta": null,
            "confidence": "high"
        }
    ]
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 11f1b09..5c9b0ae (codex-cli 0.169.0)

F3.1: resolved. Verdict: clean, no findings.

findings.json
{
    "reviewer": "codex-cli 0.169.0",
    "perspective": "defects",
    "mode": "final",
    "commit": "5c9b0ae9",
    "verdict": "clean",
    "prior": [
        {
            "id": "F3.1",
            "status": "resolved"
        }
    ],
    "findings": []
}

@paynejd

paynejd commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Adversarial pass (Claude subagent, read-only, 351dc8c0..5c9b0ae9)

Asked to find a way for a user with ordinary edit access to write to content the policy refuses through the changed paths (seeded-version imports, reference adds, hierarchy imports, CanAdministerParentDictionary), or anything now refused that shouldn't be. No P0 or P1.

  • P3, predates this range: a batch keeps the policy's answer up to a minute, so lines of one long import can still land just after a source turns read-only; a seeded version's commit asks again, fresh, before it changes HEAD. This is the documented bound.
  • P3, predates this range: a hierarchy import links a child in a writable source to a parent in a read-only one; only the child's source is asked, as on the per-line path. That matches the docstring (child links aren't asked).
  • Checked clean: version and content lines naming different sources are rejected; a HEAD the import creates; the policy is asked only after edit access; nothing imports after an up-front refusal in any runner; WriteRefused isn't caught as a validation error; 2-, 3- and 4-item add_references results; nothing newly refused for writable sources or reads.

@paynejd
paynejd requested a review from snyaggarwal November 23, 2026 03:51

@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 5c9b0ae. All six comments from the 351dc8c review are fixed as your replies describe, and I checked each against the code:

  • A seeded version's source is asked about before any line imports: get_rejection, which preflight and run share, asks about an edit of HEAD, and run returns the refusal before its transaction. Each of the three runners reports it with the policy's body and counts that add up, as your Codex passes 1–3 worked out.
  • The parallel commit files a later refusal under permission_denied with the body.
  • Both rollback paths clear dropped.
  • add_references returns the refusal as its own item, the hierarchy import asks only about its children's sources, and CanAdministerParentDictionary asks about an edit, as CanEditParentDictionary does.

The two P3s in your adversarial pass are the documented bounds, so I agree with leaving them.

CI is green at 5c9b0ae, and the branch merges cleanly with master, which now has #1010. #1010 doesn't touch the write checks. I haven't run the tests locally.

Nit (PR body, not blocking): the Tests section still says the suite passed at 60c3184 and that the later commits change only a docstring. d2e687b to 5c9b0ae change code, so that line should point at 5c9b0ae's CI run.

@snyaggarwal
snyaggarwal merged commit 86ca658 into master Nov 23, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-424-write-checkpoint branch November 23, 2026 04:44
paynejd added a commit that referenced this pull request Nov 23, 2026
…1007) into ocl_online-718-query-collection-version

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
snyaggarwal added a commit that referenced this pull request Nov 23, 2026
…e when a repository row is saved as private (#1009)

* OpenConceptLab/ocl_online#424 | A write checkpoint lets the capability 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

* OpenConceptLab/ocl_online#424 | Write checks classify by the object written, 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

* OpenConceptLab/ocl_online#424 | A version write is asked about the version, 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

* OpenConceptLab/ocl_online#424 | FHIR updates are asked about the HEAD 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

* OpenConceptLab/ocl_online#424 | Simplification review: a test the route 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

* OpenConceptLab/ocl_online#424 | Final check fixes: a version's move is 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

* OpenConceptLab/ocl_online#424 | Review fixes: every expansion write is 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

* OpenConceptLab/ocl_online#424 | A test says only that the policy's answer can change during a run

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

* OpenConceptLab/ocl_online#424 | Codex check fixes: only a HEAD that stays 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

* OpenConceptLab/ocl_online#424 | Codex check fix: an answer asked again 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

* OpenConceptLab/ocl_online#424 | Codex check fix: the refresh test checks 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

* OpenConceptLab/ocl_online#424 | The overrides route takes only this repository'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

* OpenConceptLab/ocl_online#424 | Sunny's follow-up: the policy's docstring 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

* OpenConceptLab/ocl_online#424 | Codex check of 565a2ff: the docstring 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

* OpenConceptLab/ocl_online#424 | Codex check of d70869f: the docstring 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

* OpenConceptLab/ocl_online#424 | Codex check of afe3ee0: linking a parent'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

* OpenConceptLab/ocl_online#365 | The write checkpoint asks make_private 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

* OpenConceptLab/ocl_online#365 | Codex pass 1: the FHIR refusal test checks 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

* OpenConceptLab/ocl_online#365 OpenConceptLab/ocl_online#698 | Codex pass 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

* OpenConceptLab/ocl_online#365 OpenConceptLab/ocl_online#698 | Codex pass 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

* OpenConceptLab/ocl_online#365 | Simplification review: one FHIR comment, 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

* OpenConceptLab/ocl_online#365 | A FHIR update keeps a blank release private and decides HEAD's access under a row lock

Review of #1009 at fca40ff:
- A stored row keeps its own access when a write sends none, a blank (private) one included. prepare_object() turned a blank into View, so a FHIR update copied a blank release onto a viewable HEAD as View, and a REST edit made a blank row public as an edit.
- persist_changes(keep_private=True) reads the stored row FOR UPDATE in a transaction held through the save, and keeps the row's access when it's private. The CodeSystem, ConceptMap and ValueSet updates pass it instead of reading HEAD before the save, so a concurrent write that makes HEAD private isn't overwritten. The tasks persist_changes queues go after that transaction.
- The search index task a save queues goes on commit, so it reads the row as committed: outside a transaction it goes at once, as before.

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

* OpenConceptLab/ocl_online#365 | Codex pass 4: adding a ValueSet's references saves only who changed it; a failed index enqueue doesn't stop other commit callbacks

- F4.1: a FHIR ValueSet update saved HEAD again in Collection.add_references(), after the lock, with the whole row it held in memory, so a write that made HEAD private in between was overwritten. add_references() now saves only updated_by and updated_at: its callers have saved the collection's other values.
- F4.3: the index task queued on commit is a robust callback, so a failed enqueue is logged and the transaction's other callbacks, such as a new version's seed task, still run.

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

* OpenConceptLab/ocl_online#365 | A blank access is stored as None; the 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

* OpenConceptLab/ocl_online#365 | Codex pass 6: a new version of a blank 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

* OpenConceptLab/ocl_online#424 | an import's hierarchy links no child in a source the capability policy keeps read-only

* OpenConceptLab/ocl_online#424 | Review of 351dc8c: a seeded version of 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

* OpenConceptLab/ocl_online#424 | Codex pass 1 (F1.1): an import refused 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

* OpenConceptLab/ocl_online#424 | Codex pass 2 (F2.1): an import refused 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

* OpenConceptLab/ocl_online#424 | Codex pass 3 (F3.1): a seeding parallel 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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Sunny Aggarwal <sny.aggarwal@gmail.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.

2 participants