Repository navigation
OpenConceptLab/ocl_online#424 | A write checkpoint lets the capability policy keep content read-only - #1007
Conversation
…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
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.
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
|
Replies to Codex pass 1, fixed in a182d26.
|
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.
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
|
Replies to Codex pass 2, fixed in 597fd82.
|
snyaggarwal
left a comment
There was a problem hiding this comment.
Review (high effort, not verified by running). Most severe first.
publishlets other field edits through (core/capabilities/writes.py:41). A PUT or PATCH counts aspublishwhenever its body makes a private repository viewable, so every other field in that body rides on thepublishanswer.- Example: PATCH
{"public_access": "View", "name": "X", "extras": {...}}on content the policy keeps read-only. A policy that allowspublishsaves the whole edit. - A second PATCH that sets
public_accessback toNoneis then aneditof public content. - Suggest: only call it
publishwhenpublic_accessis the only change, or give the policy both facts.
- Example: PATCH
- #985 (isolated source versions) skips the check.
IsolatedVersionCommit.get_rejectionandpreflightreplace HEAD's content and check onlyhead.has_edit_access. Once both PRs merge, that path never asks the policy. They also conflict inBaseResourceImporter.__init__(isolatedvspolicy). Whichever merges second needs the check inget_rejection. - Expansions aren't asked (
core/collections/views.py:867, 946, 984). Expansion POST and DELETE, andre-evaluate/, still useHasAccessToVersionedObject. They change what a collection version resolves to, so$expandanswers differently. They look like writes;CanEditConceptDictionaryVersionwould cover them. - A run's PATCH can be refused partway through (
core/map_projects/views.py:348).AutomatchRunViewupdates go throughChecksWrites. If a policy's answer for a project changes during a run, for example because the policy ranks projects byupdated_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. - 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. - The policy is asked once per import line (
core/importers/models.py:126). Nothing is cached per repository, and package-import rows andsave_fhir_resourceeach make a new policy. Caching by (repository id, action), as the hierarchy pass already does withwritable_by_source_id, would make it one call per repository. - The overrides endpoint now takes any capability (
core/capabilities/views.py:220). This widens the existingcore/capabilitiesoverrides debt (OpenConceptLab/ocl_online#532). Could the extension mechanism be agreed there first?
Policy-side details are on the private PR.
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.
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
|
Replies to Codex pass 3, fixed in 784b5bf.
|
…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
Simplification review (claude subagent, commit 784b5bf)8 items. Applied in ee1bdec (
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"
}
]
} |
Adversarial pass (fresh Claude subagent, both halves, this PR at 784b5bf)No P0. Its findings on this PR's checkpoint:
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
Codex check of commits 597fd82..ee1bdec (codex-cli 0.169.0)Verdict: 3 findings: 1 P1, 2 P2.
Replies (fixed in 99213dc;
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. |
…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
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.
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.
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
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
|
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.
Replies:
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"
}
]
} |
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.
Replies:
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"
}
]
} |
…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
Item 7 done as (c), and the PR is up to date with master
|
|
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": []
} |
…in a source the capability policy keeps read-only
…f a read-only source is refused before anything changes - IsolatedVersionCommit.get_rejection, which preflight and run share, asks the capability policy about an edit of HEAD. preflight raises the WriteRefused, with the policy's body, before any line imports; run returns it before HEAD's hierarchy or codes change. - BulkImportParallelRunner files a refused version under permission_denied with the policy's body, as BulkImportInline does, instead of under others with no reason. - A version that rolls back reports nothing dropped: HEAD kept those codes. - add_references returns a refusal as its own item, so no expression's error can be read as one. - An import's hierarchy asks the policy only about the sources its children are in. - CanAdministerParentDictionary asks about an edit of the repository whatever the view, as CanEditParentDictionary does (CanAdministerDictionaryContent was the same permission without that). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…d up front reports the refusal in its result preflight still raises the WriteRefused, and each runner catches it and reports it as it reports a refused line, instead of failing the task with the body only in its traceback. Nothing imports. - BulkImportInline and BulkImportParallelRunner list the version line under permission_denied, with the capability policy's body as its errors. - The archive Importer returns a summary with one failure, whose message ends with the body as JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
Codex review, pass 1 (codex-cli 0.169.0, commit d2e687b)Scope: the commits answering the Nov 23 review, Verdict: findings (1 P1)
Response: F1.1 fixed in 315df17. 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
Codex review, pass 2 (codex-cli 0.169.0, commit 315df17)Scope: Verdict: findings (1 P1)
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 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
Codex review, pass 3 (codex-cli 0.169.0, commit 11f1b09)Scope: Verdict: findings (1 P1)
Response: F3.1 fixed in 5c9b0ae: Simplification review (Claude subagent, at 11f1b09): two optional items, neither taken. S1 suggested parenthesising the conditional that picks 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"
}
]
} |
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": []
} |
Adversarial pass (Claude subagent, read-only,
|
snyaggarwal
left a comment
There was a problem hiding this comment.
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, whichpreflightandrunshare, asks about an edit of HEAD, andrunreturns 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_deniedwith the body. - Both rollback paths clear
dropped. add_referencesreturns the refusal as its own item, the hierarchy import asks only about its children's sources, andCanAdministerParentDictionaryasks about an edit, asCanEditParentDictionarydoes.
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.
…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
…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>
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)returnsNone(allow) or the refusal body.contentis the repository row written (a Source or Collection: its HEAD, or the version a write changes, which keeps its ownpublic_access) or a MapProject.actionisedit,delete(a HEAD or a map project: the whole of it) orpublish(a write'spublic_accessvalue makes a repository row others can't view viewable by them; a version only under a viewable HEAD). A FHIR update is always anedit. Any other change to a map project, itspublic_accessincluded, is anedit.GroupLimitPolicyinherits the default, which returnsNone.capabilities.E004also 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.CanEditConceptDictionaryandCanEditConceptDictionaryVersion, through a newChecksWritesbase: repository and version update and delete (latest/andHEAD/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 throughCanEditParentDictionaryandCanAdministerParentDictionary, always asedit.updates_head), and neverpublish(applies_public_access = False). Package import updates likewise.$clonetarget; 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.$compareand$changelog; creating a repository;writes_content = False: processing flags, the references preview, client configs, an AutoMatch run's progress updates, so a run allowed to start can finish);IsAdminUser: a mapping's hard delete, a concept or mapping version's DELETE, the hierarchy amend route);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.pylint -j0 core/gives 10.00 with no messages.🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV