Skip to content

test(BA-7809): add scenario tests for the resource policy adapter - #14507

Closed
jopemachine wants to merge 6 commits into
mainfrom
doc/BA-7809-resource-policy-scenarios
Closed

test(BA-7809): add scenario tests for the resource policy adapter#14507
jopemachine wants to merge 6 commits into
mainfrom
doc/BA-7809-resource-policy-scenarios

Conversation

@jopemachine

@jopemachine jopemachine commented Sep 11, 2026

Copy link
Copy Markdown
Member

Resolves BA-7809

Summary

  • Write api/adapters/resource_policy/KNOWLEDGE.md for the keypair, user and project policies and transcribe it into tests/scenario/bai_scenario/manager/resource_policy/ — 83 rows over 6 modules, every public adapter call (17 calls, 20 wirings) reached.
  • One adapter carries three policies of the same shape, so components/resource_policy.py holds one class per policy family — the seed that lays one, the calls that read and write one, the places its node has — and each row is written once and run against every family it applies to. Rows a single family owns (unlimited slot, priority cap, keypair-owner filter, reading one's own policy) name it.
  • Seeds added: a project policy under a name of its own (the pinned one is what every personal project looks for), a keypair laid under an existing user, and the nullable limits the editing rows clear.

Behaviours the rows pin, worth a reviewer's eye:

  • A name nobody has is refused as cannot resolve, not not found — for the superadmin too. The lookup hides whether the name exists from everyone, so this adapter has no not-found row.
  • Clearing a nullable limit clears it; clearing a non-nullable one is read as omitted and leaves the value as it was.
  • Purge has no conflict check; a policy still referenced by a keypair, user or project is stopped by the foreign key, so the refusal is the repository's constraint-violation error, as is a duplicate name or an out-of-range priority cap on create.
  • Reading one's own policy is guarded by READ at the caller's own scope, not merely narrowed to it. Among several keys the default-marked one names the keypair policy; an inactive default key yields to an active one; no active key finds nothing.

Test plan

  • python3 scripts/knowledge/check.py passes
  • test-scenario on CI: 83 scenarios, 0 failing
  • report.md generated from the CI run's scenarios.jsonl with scripts/scenario-report.py --split and committed

🤖 Generated with Claude Code

https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD

jopemachine and others added 2 commits September 11, 2026 11:12
Replace the TODO stub in api/adapters/resource_policy/KNOWLEDGE.md with the
scenarios the adapter guarantees for the keypair, user and project policies:
the superadmin role on create and search, the name lookup that refuses a
missing name and an unreachable one the same way, the database constraints
that answer for duplicate names, out-of-range priority caps and policies
still referenced, and the caller's own scope on reading one's own policy.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD
@github-actions github-actions Bot added the size:L 100~500 LoC label Sep 11, 2026
jopemachine and others added 2 commits September 11, 2026 11:16
Rename the search section, say "resolve" for the name lookup, name the
constraint-violation refusals as the repository's, and rewrite the sentences
that read awkwardly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD
Transcribe api/adapters/resource_policy/KNOWLEDGE.md into
tests/scenario/bai_scenario/manager/resource_policy: 83 rows over six modules,
every public adapter call reached. One component class per policy family
carries what tells the three apart — the seed, the calls, the node's fields —
so each row is written once and run against each family it applies to.

Seeds: a named project policy nobody's personal project looks for, a keypair
laid under an existing user, and the nullable limits the editing rows clear.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD
@github-actions github-actions Bot added size:XL 500~ LoC and removed size:L 100~500 LoC labels Sep 11, 2026
Generated from the CI run with scripts/scenario-report.py --split. Name the
type parameters of the policy families after what they carry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD
@jopemachine jopemachine changed the title doc(BA-7809): fill the resource policy adapter scenarios test(BA-7809): add scenario tests for the resource policy adapter Sep 11, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vFCmtPMD6GLPBJxJoFroD
@jopemachine

Copy link
Copy Markdown
Member Author

Split into a stack of three, one per policy: #14515 (project) → #14516 (keypair) → #14517 (user). Same content, same rows.

@jopemachine
jopemachine deleted the doc/BA-7809-resource-policy-scenarios branch September 11, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant