Repository navigation
OpenConceptLab/ocl_online#365 | The write checkpoint asks make_private when a repository row is saved as private - #1009
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
…ritten, and writes stay in the repository checked Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVrPPnDZrZdP6cZdwk
…rsion, and default expansions and queued reference adds are checked Codex pass 2 on #1007, and the other half's pass 3: - A write to a version is asked about that version, which keeps its own public_access, not about its HEAD. Making a private version viewable is `publish`; deleting a version is still an edit. - `short_code` is read-only on the version serializers, so a version update never moves it to another repository. - Re-evaluating a version's default expansion, and creating an expansion that becomes its default, are edits of the version. - The reference-add task asks again when it runs, and returns the refusal. - The latest-version routes classify from the row they resolve. - A DELETE's body is never read. - Linking a parent's new version to the children it already has isn't asked about: the system keeps those links current (reverts the pass 1 change, which hid such children from the parent's children). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
… they write, a version keeps its repository on every route, and external export changes are checked Codex pass 3 on #1007: - A FHIR update (API or package import) is asked about the HEAD it saves onto, whichever row the URL or canonical URL resolves (`updates_head` on the CodeSystem, ConceptMap and ValueSet detail views). - A version keeps its repository on every route: the create-or-update serializers take a mnemonic from the body only for a new row or a HEAD, which covers the repository detail route with `?version=`. This replaces the read-only `short_code` from the last commit. - Making a version viewable is `publish` only while its HEAD is viewable; under a private HEAD it stays hidden, so it's an edit. - Uploading or removing an external export is an edit of the version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
…te tests repeat, and a guard that only skipped a cheap policy, cut Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
…s decided from the stored row, and publishing follows how a version is viewed Codex check of 597fd82..ee1bdec on #1007: - Whether a row may take a new mnemonic is decided from the stored row, before the body's version label applies. - `makes_viewable` follows `is_publicly_viewable`: without an active HEAD, a version is viewable by its own access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV61RJpyxhpxCo3dkV
…s an edit of its version, a started run can finish, and an import asks once per repository - Expansion POST and DELETE and re-evaluate/ use CanEditConceptDictionaryVersion, so each is an edit of the version, default or not. The two default-only checks are gone; the processing route still isn't asked. - AutomatchRunView sets writes_content = False: its PATCH takes only a run's lifecycle fields and changes no project content, so a run that was allowed to start can record its progress and finish. Starting a run is still asked. - BatchWriteRefusals asks the capability policy once per user, saved repository row and action. BulkImportInline's lines and hierarchy pass share one, and so do the rows of a package file. An import line never changes the access of an existing row, so an answer holds for the batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…swer can change during a run Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…tays one takes a new mnemonic, and a batch's answers expire after a minute Codex check of ee1bdec..60d9e65 on #1007: - FC.1: a stored row takes the body's mnemonic only when it is a HEAD before and after the body applies. A HEAD that the body relabels as a version keeps its repository, as a version relabelled HEAD already did; this covers the repository route and FHIR ValueSet updates, which both prepare the row here. - FC.2: BatchWriteRefusals asks again once an answer is a minute old, so a change in the policy's answer reaches a long import within the minute instead of at its end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…n is about the row as stored now Codex check of 60d9e65..59642d9 on #1007, FC.3: a batch keeps the rows it loaded, so once an answer expired, the policy was asked about a row whose access may have changed since (a source made public during an import was still refused). BatchWriteRefusals now asks about the row as stored now, one query per repository a minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…cks the question asked after an answer expires Codex check of 59642d9..85795a9 on #1007, FC.5: the test only exercised the first question. It now asks, makes the row public, lets the answer expire and checks that the second question is about the public row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…e write checkpoint Conflicts: CapabilityPolicy keeps both default hooks (check_new_member from master, get_write_refusal here) and the start-up check tests both signatures; core/common/permissions.py imports both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…epository's capabilities again Reverts the change that let the per-user overrides route take any capability in the capabilities table, with its test. A deployment that adds its own capabilities serves its own route for them, through OCL_EXTRA_URLCONFS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWBUrfYtCosXndVvLm
…ring says what isn't asked A map project's public_access change is an edit; publish is for repository rows. Not asked: staff-only routes, deleting an owner (its repositories go without asking about each), and a queued write when it runs, except a reference add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
… says import lines are asked in the worker, and export uploads are asked FC.10: a bulk import's lines are asked in the worker as it writes them, not when the import is queued. FC.11: uploading or removing an external export is an edit of its version; generating and downloading one aren't asked. FC.12: publish is the change that makes a row others can't view viewable, whatever blank value it held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
… says which writes a worker asks about, and that a FHIR update is an edit FC.13: a parent's new version in another repository is asked in the hierarchy worker, as import lines are. FC.14: publish is a write that sets public_access; a FHIR update is always an edit. FC.15: the docstring no longer states the import batch's cache, which covers only the rows BatchWriteRefusals checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
…ent's new version to its children isn't asked, and publish is the value a write sends FC.16: the docstring's not-asked list names linking a parent's new version to the children it already has. FC.17: publish is a write whose public_access value makes the row viewable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVzATyCCKXRfX4hhci
…e whenever a repository row is saved as private A capability policy can now refuse making a repository private: creating a private repository, or changing a repository or version that others could view by its own public_access to private (or moving a private one to another owner). ConceptContainerModel.persist_new and persist_changes ask it before saving, so the REST routes, import lines and FHIR writes all ask, and a refusal is the WriteRefused 403 with the policy's body. An import line or a package resource fails with that body; the rest of the import goes on. The default policy allows it. New versions take their HEAD's access and aren't asked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
…hecks the body's values reach the OperationOutcome Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
Codex review, pass 1 (codex-cli 0.169.0, commit 236c1bb)Verdict: 2 findings: 1 P1, 1 P2.
Replies (c47e76b; the module's 14 tests OK, pylint exit 0):
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "236c1bbd",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/capabilities/tests/test_make_private.py",
"line": 224,
"claim": "FHIR 403 responses flatten the policy's structured refusal body. The HTTP test checks only that the response is an OperationOutcome.",
"scenario": "A CodeSystem update would copy a private release's access onto a public HEAD. When the policy refuses with an error_code and a numeric code of 3, the FHIR handler turns both fields into issue text, including the string \"3\". The client loses the original response structure and types.",
"action": "Preserve the complete policy payload in the FHIR 403 while keeping a valid OperationOutcome, and assert that payload in the HTTP test.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 1374,
"claim": "A concurrent update can make a repository private without asking the policy because the state comparison and save are separate.",
"scenario": "One request renames a private collection. After it reads the stored row, a second request publishes the collection. The rename still compares two private snapshots, skips make_private, and saves its stale private access over the newly public row.",
"action": "Lock the stored row when reading its current access and hold the lock through the policy check and save. Add a regression test for concurrent publishing and editing.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…ass 2: a FHIR update keeps HEAD's own access A FHIR resource carries no access, but CodeSystem, ConceptMap and ValueSet updates saved the resolved release's public_access onto HEAD: a public release made a private HEAD public, and a private one made a public HEAD private. With make_private asked, an owner whose policy refuses it couldn't make such a HEAD private again. HEAD now keeps its own access, and the new version takes it, as any new version does. So no FHIR write is asked make_private, and the import's catch of a refused FHIR save is dropped again. Partial for ocl_online#698 (its first two criteria). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
Codex review, pass 2 (codex-cli 0.169.0, commit c47e76b)Verdict: 1 new finding, P1. Pass 1's F1.1 and F1.2 marked unresolved (answered below).
Replies (c3e9790; whole suite 3,404 OK, pylint exit 0):
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "c47e76bc",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "unresolved"
},
{
"id": "F1.2",
"status": "unresolved"
}
],
"findings": [
{
"id": "F2.1",
"severity": "P1",
"tag": null,
"file": "core/common/models.py",
"line": 1374,
"claim": "An ordinary FHIR update can publish an existing private repository, and the new checkpoint can block its owner from restoring privacy.",
"scenario": "A source has a private HEAD and an older release whose own access is View. The policy allows edits and refuses make_private. An owner updates the CodeSystem through FHIR without supplying an access setting. The serializer copies the release's View access onto HEAD, making the source public. Before this change the owner could restore None through the REST API. That update now returns 403 and leaves the source public.",
"action": "Preserve the stored private HEAD access when a FHIR update uses a version with public access. Add a regression test that allows the FHIR edit while refusing make_private and verifies that HEAD stays private.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…ass 3: a FHIR update only keeps a private HEAD private c3e9790 kept HEAD's access on every FHIR update, but the update still takes the resolved release's other values: a private release's description and the like went onto a HEAD others can view. Now a FHIR update never makes a private HEAD viewable (a public release's access isn't copied onto it), and a private release's access still goes onto a viewable HEAD with its other values, which asks make_private, as before. The import's catch of a refused FHIR save, and the base PR's test expectation, are back. Taking every omitted value from HEAD stays with ocl_online#698. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
Codex review, pass 3 (codex-cli 0.169.0, commit c3e9790)Verdict: 1 new finding, P1. It marks F2.1's fix regressed and F1.2 unresolved; F1.1 resolved.
Replies (5f1d7ab; whole suite 3,405 OK, pylint exit 0):
Pass 3 is the last of the three. Next come the simplification review and a check of the later commits. findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "c3e97902",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "unresolved"
},
{
"id": "F2.1",
"status": "regressed"
}
],
"findings": [
{
"id": "F3.1",
"severity": "P1",
"tag": null,
"file": "core/code_systems/serializers.py",
"line": 429,
"claim": "The FHIR update preserves HEAD's public access but can copy private release metadata into public HEAD and the new public version. ConceptMap and ValueSet use the same update pattern.",
"scenario": "A public repository has a private release with a description that differs from HEAD's. An editor submits a FHIR update that resolves to that release and omits the optional description. The serializer inherits the private description from the release, saves it onto public HEAD, and carries it into the new public version. Anonymous readers can then see it.",
"action": "When a FHIR update resolves to a private release under a public HEAD, take omitted fields from HEAD and apply the fields supplied in the request. Add a regression test with distinct descriptions that checks what anonymous readers see on HEAD and the new version.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…nt, two tests folded into the route tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi
Simplification review (fresh Claude subagent, commit 5f1d7ab)Four items. Applied in fca40ff; the module's 55 tests and the base PR's pass, and pylint exits 0.
A Codex check of the commits since pass 3 (c3e9790..fca40ff) follows. |
Adversarial pass (fresh Claude subagent, both halves: this PR at fca40ff's tree and the private rule)No P0, P1 or P2. Four P3s, recorded and not fixed (one is about the private half, answered there):
Checked clean:
The full write-up is in the review archive. A Codex check of the commits since pass 3 follows. |
Codex check of commits c3e9790..fca40ff (codex-cli 0.169.0)Verdict: clean. No findings on 5f1d7ab (a FHIR update keeps a private HEAD private) or fca40ff (the simplification cuts). Where this PR stands: Codex passes 1 to 3, the simplification review, the adversarial pass and this check are all posted above. No P0 or P1 is open. Accepted: pass 1's F1.2 (a lost update between reading and saving a row, which predates this PR) and the adversarial P3s. Ready for @snyaggarwal's review once #1007 has his OK. final.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "fca40ff1",
"verdict": "clean",
"prior": [],
"findings": []
} |
Codex review, pass 4 (codex-cli 0.169.0, commit 4869a42)A new round after the requested changes at fca40ff. 4869a42 fixes both of those P1s; this pass reviewed it. Verdict: 3 findings: 1 P1, 2 P2. Earlier findings: F1.1, F2.1 and F3.1 resolved; F1.2 marked unresolved (answered below).
Replies (f78d6ff; whole suite 3,410 + 648 OK, pylint clean):
pass4.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "4869a421",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "unresolved"
},
{
"id": "F2.1",
"status": "resolved"
},
{
"id": "F3.1",
"status": "resolved"
}
],
"findings": [
{
"id": "F4.1",
"severity": "P1",
"tag": null,
"file": "core/value_sets/serializers.py",
"line": 220,
"claim": "A ValueSet update can still make a concurrently privatized HEAD public.",
"scenario": "A FHIR update of a public ValueSet includes a new compose reference. After persist_changes releases its lock, a REST update makes HEAD private and commits. Collection.add_references then calls self.save() on the stale collection, restoring View. Version creation reads that republished HEAD and gives the new version View too.",
"action": "Limit the reference update to the HEAD fields it actually changes so it cannot overwrite public_access. Add a regression test with the privacy change occurring between the first HEAD save and reference persistence.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F4.2",
"severity": "P2",
"tag": null,
"file": "core/sources/serializers.py",
"line": 174,
"claim": "Copying blank access from a release onto HEAD leaves the updated repository metadata visible in REST lists.",
"scenario": "The policy allows a FHIR update sourced from a blank-access release. The update copies the release's metadata and blank access onto a previously public HEAD. An anonymous REST list request still returns the repository's name and canonical URL because the database-backed source and collection lists exclude only the literal None access value.",
"action": "Use the model's public-access predicate in the database-backed repository lists and test anonymous list visibility after an allowed update from a blank-access release.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F4.3",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 2023,
"claim": "A failed search-index enqueue after commit can prevent version seeding from being queued.",
"scenario": "With ES_SYNC enabled, an asynchronous version creation registers the index callback before the seeding callback. If publishing the index task raises after retries, Django stops running the remaining non-robust callbacks. The request fails after the version and its processing marker have committed, leaving a version whose members were never seeded.",
"action": "Isolate deferred index enqueue failures from later commit callbacks. Test that the seeding callback is still attempted when the preceding index enqueue raises.",
"lines_delta": null,
"confidence": "high"
}
]
} |
snyaggarwal
left a comment
There was a problem hiding this comment.
Verdict: Request changes. I reviewed the full discussion against f78d6ff1.
- Resolved — the two P1s from my previous review. The serializers now preserve the resolved release’s blank access through preparation, and the FHIR save rereads and locks HEAD before deciding what access to retain. The ValueSet follow-up (F4.1) also limits the references save to the audit fields, so it preserves a concurrent visibility change.
- Still open — F4.2 (P2). Blank access reaches storage through the bulk and package import paths. Anonymous lists still treat a blank HEAD as public. The inline comment proposes a canonical stored value and a test of the actual list response.
- Resolved in a transaction — F4.3. A failed generic index enqueue no longer prevents later commit callbacks. The inline comment flags the separate behavior change for autocommit saves.
- Earlier findings. F1.1 retains the existing FHIR
OperationOutcomecontract, with assertions for the refusal values. F2.1 and F3.1 are covered by the current FHIR guards for explicit private access, with the blank-access listing case tracked above. F1.2 remains a known REST lost-update case. The new lock covers FHIR writes.
Verification was by source and test review. The author reports passing tests and lint. GitHub Pylint was still running when I checked this revision.
| if keep_private and not original_repo.public_can_view: | ||
| obj.public_access = original_repo.public_access |
There was a problem hiding this comment.
[P2] Store canonical private access before saving HEAD. The current test checks public_can_view, but the anonymous source and collection list querysets exclude only ACCESS_TYPE_NONE. The bulk and package importers pass public_access directly into the model, where blank is allowed, so this can happen through supported imports even though PublicAccessField rejects blank. A FHIR update can copy release metadata onto a blank HEAD that still appears in those lists.
With ACCESS_TYPE_NONE imported, normalize the selected value before computing the access-change flag and checking policy.
| if keep_private and not original_repo.public_can_view: | |
| obj.public_access = original_repo.public_access | |
| if keep_private and not original_repo.public_can_view: | |
| obj.public_access = original_repo.public_access | |
| if obj.public_access == '': | |
| obj.public_access = ACCESS_TYPE_NONE |
Apply the same normalization in persist_new for import-created HEADs. Extend the blank-release regression to verify that the repository is absent from an anonymous list after the FHIR write.
There was a problem hiding this comment.
Done in 6fa582b, as you suggested. persist_new and persist_changes both store a blank access as None through one small method, store_blank_access_as_none(). In persist_changes that happens after the keep_private decision, and before the access-change flag and the make_private check. So a blank import line and a FHIR update from a blank release both store None, and the save signal passes None on to the concepts and mappings too.
Tests, each failing on f78d6ff:
test_a_blank_release_the_policy_allows_leaves_head_and_the_new_version_privatenow checks the anonymoussources/orcollections/list: the repository is listed before the FHIR write and absent after it, for CodeSystem, ConceptMap and ValueSet.test_a_blank_access_line_is_stored_as_private: a bulk import line with a blank access is stored asNone, asksmake_private, and stays out of the anonymous list.test_an_edit_that_sends_no_access_keeps_a_blank_row_privatenow expectsNoneafter a REST edit.
| transaction.on_commit( | ||
| lambda: handle_save.apply_async(args, queue='indexing', permanent=False), robust=True) |
There was a problem hiding this comment.
[P2] Preserve index enqueue error reporting for autocommit saves. Django runs on_commit immediately when there is no transaction. With robust=True it logs a final broker error and the write returns successfully, silently dropping the index update. This affects every model using this signal, including ordinary REST writes. Keep robustness when deferring inside a transaction so later callbacks still run. Preserve the existing error propagation for autocommit and add a test of that path.
| transaction.on_commit( | |
| lambda: handle_save.apply_async(args, queue='indexing', permanent=False), robust=True) | |
| connection = transaction.get_connection(using=instance._state.db) # pylint: disable=protected-access | |
| connection.on_commit( | |
| lambda: handle_save.apply_async(args, queue='indexing', permanent=False), | |
| robust=connection.in_atomic_block, | |
| ) |
There was a problem hiding this comment.
Done in 6fa582b with your suggestion: robust=connection.in_atomic_block. Deferred inside a transaction, a failed enqueue is logged and the later callbacks still run. Under autocommit it runs at once, and the broker's error reaches the write, as before this PR.
New test: IndexEnqueueUnderAutocommitTest (a transaction test case, so there's no surrounding atomic block) checks that the error propagates. It fails on f78d6ff. The in-transaction test still checks that later callbacks run.
… HEAD lock takes no key; an index enqueue is robust only inside a transaction Review of #1009 at f78d6ff, and Codex pass 5: - A blank access is private (public_can_view), but the database-backed anonymous lists exclude only None, and bulk and package imports can store a blank. persist_new and persist_changes now store a blank as None, before the access-change flag and the make_private check. Tests read the anonymous list after a FHIR update from a blank release and after a blank import line. - The index enqueue is robust only when it's deferred inside a transaction, so later callbacks still run. Under autocommit it runs at once and its error reaches the write, as before f78d6ff. A transaction test covers that path. - The FHIR update locks HEAD FOR NO KEY UPDATE: it still makes a concurrent write to HEAD wait, but a concurrent child write's foreign-key check doesn't, so the two can't deadlock (Codex F5.2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXZaRJn7QiL3warvW2
Codex review, pass 5 (codex-cli 0.169.0, commit f78d6ff)Verdict: 3 findings, all P2. Earlier findings: F4.1 resolved; F4.2 unresolved; F4.3 marked regressed by its own fix. F1.2 unresolved (the REST case only, as before).
Replies (6fa582b; whole suite 3,412 + 648 OK, pylint clean):
pass5.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "f78d6ff1",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "unresolved"
},
{
"id": "F2.1",
"status": "resolved"
},
{
"id": "F3.1",
"status": "resolved"
},
{
"id": "F4.1",
"status": "resolved"
},
{
"id": "F4.2",
"status": "unresolved"
},
{
"id": "F4.3",
"status": "regressed"
}
],
"findings": [
{
"id": "F5.1",
"severity": "P2",
"tag": null,
"file": "core/sources/serializers.py",
"line": 174,
"claim": "Copying a blank release's access onto HEAD also leaves its concepts and mappings visible in anonymous REST lists.",
"scenario": "A native JSON import can store blank access because it bypasses PublicAccessField. A release can inherit that blank access before HEAD is published. If the policy later allows a FHIR update from that release, the source save signal propagates the blank access to its concepts and mappings. The database-backed /concepts/ and /mappings/ lists exclude only the literal None value, so they can return content from the now-private source, including concepts added by the FHIR update.",
"action": "Use the model's public-access predicate in the affected database-backed lists, or normalize blank access to the canonical private value when saving it. Test anonymous repository and child lists after an allowed update from a blank release.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F5.2",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 1363,
"claim": "The FHIR HEAD lock can deadlock with a concurrent concept edit.",
"scenario": "A concept edit locks its existing concept row while creating a new version. A concurrent CodeSystem update makes HEAD private, takes FOR UPDATE on the source, and waits to propagate access to the locked concept row. The concept edit needs a foreign-key lock on that same source before its new version can commit. PostgreSQL aborts one of the writes.",
"action": "Take a no-key-update lock for the access decision and keep it through the save. Verify with a PostgreSQL concurrency test that the source save and a concept edit can both commit.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F5.3",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 2025,
"claim": "A failed index enqueue can now leave a repository searchable after the API reports that making it private succeeded.",
"scenario": "An owner renames a public collection and makes it private in one REST update. If the broker rejects the indexing enqueue after retries, the robust callback logs the failure and the API returns success. The old Elasticsearch document still admits anonymous search hits, and search hydrates those IDs from the database without rechecking access. A search for the old name can return the newly private collection's current metadata until it is reindexed.",
"action": "Recheck current repository access when materializing search hits. Keep failed indexing enqueues retryable while allowing later commit callbacks to run.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…k HEAD is stored as None - F6.1: a new version copies HEAD's access, so a HEAD stored blank before blanks were stored as None gave its new version a blank, which the anonymous lists show. persist_new_version now stores it as None, as persist_new and persist_changes do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXZaRJn7QiL3warvW2
Codex review, pass 6 (codex-cli 0.169.0, commit 6fa582b)The last pass of this round. Verdict: 2 findings, both P2. Earlier findings: every pass 4 and pass 5 finding resolved, and F1.1, F2.1 and F3.1 too. F1.2 is still unresolved: it's the REST lost update, which the lock doesn't cover, as your review at f78d6ff noted.
Replies (a614e85; whole suite 3,412 + 648 OK, pylint clean):
pass6.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "6fa582b1",
"verdict": "findings",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "unresolved"
},
{
"id": "F2.1",
"status": "resolved"
},
{
"id": "F3.1",
"status": "resolved"
},
{
"id": "F4.1",
"status": "resolved"
},
{
"id": "F4.2",
"status": "resolved"
},
{
"id": "F4.3",
"status": "resolved"
},
{
"id": "F5.1",
"status": "resolved"
},
{
"id": "F5.2",
"status": "resolved"
},
{
"id": "F5.3",
"status": "resolved"
}
],
"findings": [
{
"id": "F6.1",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 1455,
"claim": "Version creation still writes blank access, which anonymous repository lists treat as public.",
"scenario": "An owner creates v2 from a legacy source or collection HEAD whose public_access is blank. The new version inherits the blank. A database-backed anonymous repository list filtered by version=v2 returns its metadata because the list excludes only rows stored as 'None'.",
"action": "Normalize the inherited access after copying it from the locked HEAD and before saving the version. Add a regression test against the anonymous list response.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F6.2",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 2034,
"claim": "A successful FHIR update can leave newly private HEAD metadata visible in anonymous search after a failed index enqueue.",
"scenario": "A ValueSet update copies a private release onto a previously public HEAD. The database commit succeeds, the HEAD index enqueue fails, and the robust callback lets the request finish successfully. Elasticsearch still marks HEAD public, and the search result loader fetches and serializes the current database row by ID without checking its access. The updated private metadata remains searchable until HEAD is reindexed.",
"action": "Keep the callback robust and verify repository visibility against the current database row before returning Elasticsearch hits. Test an anonymous search with a stale public document for a private HEAD.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Simplification review, round 2 (fresh Claude subagent, commit 6fa582b)It reviewed fca40ff..6fa582b and proposed three optional cuts, all low confidence. I declined all three, so there's no commit from this review.
|
Adversarial pass, round 2 (fresh Claude subagent, fca40ff..a614e85)A read-only review of how this round's commits decide who can see a repository. It was given the code and the goal, not my conclusions. No P0, and no P1 from these commits. It confirmed that the FHIR lock holds: a concurrent write to HEAD waits for the save, and the post-lock read is current. A refusal or an IntegrityError rolls back, the tasks queued after the save run outside the lock, and the new-version path copies the locked HEAD's access. Recorded, with no change in this PR:
|
Codex check of commits 6fa582b..a614e85 (codex-cli 0.169.0)Verdict: clean. No findings on a614e85 (a new version of a blank HEAD is stored as Where this PR stands: your two P1s from fca40ff and your two P2s from f78d6ff are fixed. This round ran Codex passes 4 to 6 (posted above), the simplification review, the adversarial pass and this check. No P0 or P1 from this PR is open. Accepted:
The whole suite passes at a614e85 (3,412 + 648), and pylint is clean. final.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "a614e852",
"verdict": "clean",
"prior": [],
"findings": []
} |
…in a source the capability policy keeps read-only
…f a read-only source is refused before anything changes - IsolatedVersionCommit.get_rejection, which preflight and run share, asks the capability policy about an edit of HEAD. preflight raises the WriteRefused, with the policy's body, before any line imports; run returns it before HEAD's hierarchy or codes change. - BulkImportParallelRunner files a refused version under permission_denied with the policy's body, as BulkImportInline does, instead of under others with no reason. - A version that rolls back reports nothing dropped: HEAD kept those codes. - add_references returns a refusal as its own item, so no expression's error can be read as one. - An import's hierarchy asks the policy only about the sources its children are in. - CanAdministerParentDictionary asks about an edit of the repository whatever the view, as CanEditParentDictionary does (CanAdministerDictionaryContent was the same permission without that). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…d up front reports the refusal in its result preflight still raises the WriteRefused, and each runner catches it and reports it as it reports a refused line, instead of failing the task with the body only in its traceback. Nothing imports. - BulkImportInline and BulkImportParallelRunner list the version line under permission_denied, with the capability policy's body as its errors. - The archive Importer returns a summary with one failure, whose message ends with the body as JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…d up front counts the lines submitted and the one processed Each runner's result now gives the lines submitted as its total and the refused version line as the one line processed. A seeding parallel import counts the version line in its total too, which its parts don't hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…el import's saved progress counts its version line The progress BulkImportParallelRunner saves on its task counted only its parts, which never hold the version line, so an import refused up front ended at 0 of 2, and a seeding import one short of its total. It now counts the version line's outcome too, as its result does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTC2WYPcA7oaxHvFsC
…5c9b0ae One conflict, in core/common/models.py: the branch's store_blank_access_as_none() and the isolated versions' apply_version_metadata_to_head() were added at the same spot. Both are kept. A new version still takes HEAD's access after HEAD takes the version line's metadata, which never includes its access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTwySjW7bPFSitB8J7
Codex check of commits a614e85..eab632e (codex-cli 0.169.0)Verdict: clean. No findings. It reviewed only the merge of the base branch at 5c9b0ae (eab632e), asking whether the merge broke either checkpoint: the read-only edit refusal (now asked about HEAD before an import that seeds a version imports any line) or this PR's findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "eab632e9",
"verdict": "clean",
"prior": [],
"findings": []
} |
Base branch merged at its final head (5c9b0ae)eab632e merges One conflict, in Both checkpoints still apply. The read-only refusal (now asked about HEAD before an import that seeds a version imports any line) and this PR's Checks on eab632e:
|
…nt's squash merge Master now holds the write checkpoint as one squashed commit (86ca658) plus the release search change. Seven files conflicted because both sides had added the write checkpoint's lines. Each resolves to master's version of those lines with this branch's own changes on top: a three-way merge of each file using the write checkpoint's final head (5c9b0ae) as the base merges cleanly. This branch's diff against master is now line for line its diff against 5c9b0ae. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUbSx2byXLH6U3Cyye
Codex check of commits eab632e..9a65844 (codex-cli 0.169.0)Verdict: clean. No findings. It reviewed only the merge of master at 86ca658 (this PR's base branch, now squash-merged as #1007, plus #1010), asking whether the merge broke the read-only write checkpoint or this PR's findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "9a658445",
"verdict": "clean",
"prior": [],
"findings": []
} |
Master merged after #1007's squash merge (9a65844)9a65844 merges master at 86ca658, which holds #1007 as one squashed commit, plus #1010. It's a merge, not a rebase, so the commits you reviewed keep their ids. The PR now targets master and is mergeable. Seven conflicts ( The diff against master is only this PR's change: Checks on 9a65844:
|
snyaggarwal
left a comment
There was a problem hiding this comment.
Approving at 9a65844. Both P2s from my review at f78d6ff are fixed as your replies describe:
- A blank access is stored as
None(store_blank_access_as_none()) inpersist_new,persist_changes(after thekeep_privatedecision and before the access-change flag andmake_private) and, from Codex's F6.1,persist_new_version. So an import line or a FHIR write from a blank release stays out of the anonymous lists, and the tests check the list response. - The index enqueue is robust only inside a transaction, so an enqueue error under autocommit reaches the write again, with
IndexEnqueueUnderAutocommitTest. - The lock is now
select_for_update(no_key=True). It still makes a concurrent write to HEAD wait for the FHIR save, and it no longer blocks writes that only reference the row, such as a concept saved under that source.
The two merges keep this PR's change as it was. git diff 86ca658c 9a658445 matches git diff 5c9b0ae9 eab632e9 line for line, so the conflicts from #1007's squash merge were resolved to the same code. It merges cleanly with master now that #1023 and #1024 are in, and only Collection.add_references() shares a file with them, in a function neither touches. Master's build with #1007, #1010, #1023 and #1024 passes the full suite. I haven't run the tests locally.
Fine to leave as accepted: F1.2 (a REST write that sends no access saves the access it read, which predates this PR), F6.2 (a failed enqueue inside a transaction leaves a stale search document, as any indexed write can), and the adversarial pass's P2s and P3s.
Nit (PR body): it still says this is stacked on #1007 and should be retargeted once #1007 merges. The test count (3,405) is also from before the merges.
Part of OpenConceptLab/ocl_online#365. Stacked on #1007 (base
ocl_online-424-write-checkpoint), whose write checkpoint it extends; retarget tomasteronce #1007 merges. Design: ocl_online#365 issuecomment-7008529914.Also carries part of OpenConceptLab/ocl_online#698 (5f1d7ab): a FHIR update never makes a private HEAD viewable. That fix ships only when #1007 and then this PR merge. The rest of #698 stays open, and nothing here closes it: taking the values a FHIR resource omits from HEAD rather than from the resolved release.
What changes
make_private, onCapabilityPolicy.get_write_refusal(user, content, action). It's asked whenever a repository row is saved as one others can't view by its ownpublic_access:public_accessand is changed to private;ConceptContainerModel.persist_newandpersist_changesask before saving, so every path that saves a repository row asks:…/HEAD/,…/{version}/and…/latest/;WriteRefused, the 403 with the policy's body that OpenConceptLab/ocl_online#424 | A write checkpoint lets the capability policy keep content read-only #1007 added (an OperationOutcome on FHIR routes, with the body's values as its issues). An import line, or a package resource, fails with the body in the report, and the rest of the import goes on.public_accessincluded.make_private.publish, as before).Tests
core/capabilities/tests/test_make_private.pyuses a stub policy that refusesmake_private. It covers:makes_privatehas its own table of cases. The whole suite runs 3,405 tests OK (2 skipped), andpylint -j0 core/exits 0.Review
Codex passes are posted below with replies.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qTiRsArGHHF2m8aQBi