Skip to content

OpenConceptLab/ocl_online#785 | A capability policy can add to the refusal of a map project - #1118

Open
paynejd wants to merge 2 commits into
masterfrom
OpenConceptLab/ocl_online-785-complete-refusal
Open

paynejd wants to merge 2 commits into
masterfrom
OpenConceptLab/ocl_online-785-complete-refusal

Conversation

@paynejd

@paynejd paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member

Linked Issue

Advances OpenConceptLab/ocl_online#785

What this changes

A capability policy can now add to the refusal of a new map project.

A policy builds the body of its own refusals, so it can add keys to them. This refusal is one oclapi2 builds itself, so a policy couldn't. CapabilityPolicy.complete_refusal(user, capability_id, body, owner=None) is the checkpoint for that: check_map_project_capacity() asks it for the body it sends, both in the permission and again under the row locks.

By default the body goes out as it is, so with the default policy every response is the same as before.

How it was checked

Two new tests with a policy that adds a key: a personal project refused by the permission, and an organization's project whose last place is taken between the two checks. The tests of core.map_projects and core.capabilities pass, and Pylint is clean.

Order

It can be released before or after the other parts of OpenConceptLab/ocl_online#785: a policy that doesn't define the method gets the default, and one that does is simply asked.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qVzyaMUV7QSvivXit7

paynejd and others added 2 commits December 3, 2026 01:07
…fusal of a map project

oclapi2 builds this refusal itself, so a policy had no way to add to its
body, as it can to its own. By default the body goes out as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVzyaMUV7QSvivXit7
…r an organization's project, is tested too

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

paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: findings, 1 finding.

  • F1.1 P2 tests.py:370 The new test covers the permission refusal with the same user as actor and owner. It leaves the refusal under the row locks and the distinct-owner argument untested.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "5e199e96",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P2",
      "tag": null,
      "file": "core/map_projects/tests/tests.py",
      "line": 370,
      "claim": "The new test covers the permission refusal with the same user as actor and owner. It leaves the refusal under the row locks and the distinct-owner argument untested.",
      "scenario": "Two authorized requests to create a project under the same organization pass the permission check while one slot remains. After the first request takes that slot, the second must return a 403 completed by the policy with the organization as owner. The test starts at capacity on a personal route, so it would still pass if the locked check skipped completion or the hook received the actor in place of the organization.",
      "action": "Add an organization-scoped POST test with a policy that reports available capacity on the first check and exhausted capacity on the second. Assert that the 403 includes the policy's contribution and that the hook received the acting user and the organization as separate arguments.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Pass 1 (commit 79bdfaa):

  • F1.1 (P2), fixed. A second test creates a project under an organization, with the last place taken between the two checks. The refusal under the locks carries what the policy added, and the policy gets the acting user and the organization.

@paynejd

paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

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

Verdict: clean.

Earlier: F1.1 resolved

findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "79bdfaab",
  "verdict": "clean",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    }
  ],
  "findings": []
}

@paynejd

paynejd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Simplification review (a fresh Claude subagent, commit 79bdfaa)

Verdict: clean.

findings.json
{
  "reviewer": "claude subagent",
  "perspective": "simplify",
  "mode": "full",
  "commit": "79bdfaab",
  "verdict": "clean",
  "prior": [],
  "findings": []
}

@paynejd
paynejd marked this pull request as ready for review December 3, 2026 07:01
@paynejd
paynejd requested a review from snyaggarwal December 3, 2026 07:01

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: approve. Merge order for OpenConceptLab/ocl_online#785: this one first, then OpenConceptLab/ocl_online_api#133, then OpenConceptLab/oclmap#146. Each part falls back on its own, so any order is safe. This order just lets the create refusal carry the notice as soon as the Mapper starts asking for one.

Open core: clean. complete_refusal() is a replaceable checkpoint. oclapi2 builds only its existing neutral body (detail, error_code, limit, used), and by default it sends that body unchanged. No limit or upgrade wording is composed here, and the test policy adds only a neutral added key. This makes the existing debt easier to move, and it doesn't add to it.

Contract check across the three PRs:

  • The body keeps error_code: mapper_projects_limit_reached and gains only what the policy adds. The private implementation adds notice/quota/links in the shape oclmap's getNotice() already reads for the other refusals.
  • The no-access case (limit: null) passes through unchanged. Both the permission and the re-check under the row locks go through check_map_project_capacity(), so both refusals get the same treatment, and the second new test covers the organization owner.
  • On an open install the default returns the body as it is, so the response is the same as on master.

Nothing blocking. One optional note for later, not this PR: the checkpoint covers only this refusal. The other refusals oclapi2 builds itself in the Mapper views can go through it when they move under ocl_online#532.

Codex's F1.1 (untested lock path and distinct owner) is fixed in 79bdfaa. CI is green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants