Repository navigation
§ 4.5 slice 1: the role-and-authority projection (design § D4 machinery 6) - #10
Conversation
…ery 6) Design § D4 names the gap directly: "clinician of record, licensed professional, launch approver; the contracts exist and the workbench shows only a per-serve console token and a loopback verdict." This is the projection that closes it — a pure rendering surface over the already-ratified roles-authority-model neutral role table (Hermes-level roles: PO/PM/CA/PA/Merge Council/Merge Master), joined at request time to the same primitives every core route already reaches through self (route_extension.py's own reachability guarantee): the resolved actor, the capability dict, and the loopback verdict. No new data model, and no domain words hardcoded here: RULING C2 (task 4.4) refuses shipping one domain's vocabulary inside this shared, domain-neutral package, so domain-specific labels (e.g. "clinician of record") are accepted only via an optional caller-supplied mapping, defaulting to the neutral role table alone. The route contribution (RoleAuthorityProjectionExtension.routes() -> RouteBinding) matches the shape serve_gate.py/serve_projection.py already use; task 4.3's composition-point wiring (RULED ASK-2: a lazy proxy) is a separate, still-open box this slice does not depend on. New files only: src/openxdox/role_authority_projection.py, plus unit tests (pure logic + a fake-handler-double test of the redaction rule) and a seam-conformance suite proving the binding registers through route_extension and assembles beside the two existing § 2.4 columns without collision (two of those seam tests skip in this environment, same as every other doc_health-dependent carved module, per § 4.1's own documented, BUILD-arc-gated reachability gap). tests/test_leg_shape.py + tests/test_dependency_direction.py --noconftest: 24 passed, unchanged from main (no back-imports added). Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Reviewer's GuideThis slice introduces a domain-neutral role-and-authority JSON projection that combines the ratified six-role table with existing per-request actor, capability, and loopback primitives, exposes it as an independently testable route contribution, and validates both pure rendering behavior and route-seam compatibility. Live composition wiring, the evidence surface, and the workbench remain outside this PR. Sequence diagram for the role-and-authority projection requestsequenceDiagram
participant Client
participant Route as RoleAuthorityRoutes
participant Projection as project
participant View as SessionAuthorityView
participant Server as _serve_bytes
Client->>Route: GET /projections/role-authority
Route->>Projection: project(actor, capabilities, loopback)
Projection->>Projection: _flatten_truthy_grants(capabilities)
Projection->>Projection: layers(domain_labels)
Projection-->>Route: SessionAuthorityView
Route->>View: as_json(reveal_actor=loopback)
View-->>Route: JSON projection
Route->>Server: _serve_bytes(body, JSON_CTYPE, head_only)
Server-->>Client: Role, authority, session facts
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 1 hour and 16 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
|
There was a problem hiding this comment.
🟡 Changes recommended
Correct token-presence reporting and narrow the seam-test skip handling before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds the first §4.5 role-and-authority projection slice, including neutral role data, projection rendering, and route-seam integration.
Changes:
- Adds
GET /projections/role-authority. - Supports actor redaction and optional domain labels.
- Adds projection and route-seam tests.
File summaries
| File | Summary | Review notes |
|---|---|---|
src/openxdox/role_authority_projection.py |
Projection model, rendering, handler, and route extension. | Token presence is inferred from actor presence and should use the actual token state. |
tests/test_role_authority_projection.py |
Projection behavior tests. | Canonical role tuples should be asserted completely. |
tests/test_role_authority_projection_seam.py |
Route registration, dispatch, and composition tests. | Restrict ModuleNotFoundError skips to the documented doc_health case. |
Review details
Suppressed comments (2)
src/openxdox/role_authority_projection.py:220
self.capabilitiesis the full capability payload, not just the grant map: the existing serve addsactor,refresh, and (when available)console_tokenalongsideactions. Walking it wholesale emits entries such asactor,refresh.binding, andconsole_tokenascapability_grants, so the projection reports metadata as grants. Restrict this call to theactionsmapping (or otherwise filter to grant booleans).
capability_grants=_flatten_truthy_grants(capabilities),
tests/test_role_authority_projection.py:38
- This only pins role IDs and non-empty text, so the
role_nameanddecidesstrings that form the canonical projection can be changed or mistyped while the suite still passes. Since this module claims to transcribe the ratified Hermes table, assert the complete six tuples (or compare with a canonical fixture) to catch drift.
def test_neutral_layers_are_the_six_hermes_level_roles_in_document_order() -> None:
# Transcribed from docs/roles-and-authority.md's "Hermes-Level Roles"
# table, in its own row order.
role_ids = [role_id for role_id, _name, _decides in NEUTRAL_LAYERS]
assert role_ids == ["PO", "PM", "CA", "PA", "Merge Council", "Merge Master"]
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| invented here.""" | ||
| resolved_actor = actor if actor else None | ||
| return SessionAuthorityView( | ||
| console_token_present=resolved_actor is not None, |
| except ModuleNotFoundError as exc: | ||
| pytest.skip( | ||
| f"existing § 2.4 contribution column not importable in this " | ||
| f"environment ({exc!r}) — doc_health reachability is BUILD-arc " | ||
| "work (§ 3.5/3.6), not this slice's to fix; this test will " | ||
| "assert for real once that lands") |
…de (design § D4 machinery 4) (#11) § 4.5 slice 2 of split-opendox-two-layer-product, on Brett Heap's ruling ASK-3 "projection → evidence surface → workbench" (opensoft/openXfactory#656 comment 5628886636; CLAIM 5632730583): the EVIDENCE-AND-PROVENANCE SURFACE at openXdox-code — design § D4 machinery (4) names the gap ("a chart citation, a ledger tie-out and an attribution chain are ONE machinery over different nouns … nothing renders it"). Adds `src/openxdox/evidence_provenance_surface.py` (+258): `project()` takes an already-parsed `xfactory_derived_model_conformance` document (schema `contracts/schemas/xfactory-derived-model-conformance.schema.yaml`) and renders, per family / per `role: model` member, the schema's three provenance sub-fields (`evidence_field`, `assumption_register_field`, `invented_facts_field`) under the declared `form` — realizing `governed-derived-model`'s second structural invariant, quoted: "A conforming model object SHALL tag every fact with provenance — an evidence trace with source references, or a declared assumption in a required assumption register — and a domain MAY instead forbid assumptions entirely by declaring the assumptions-forbidden form". No new data model; no conformance verdict computed (the schema's deep checks live only in `scripts/validate-derived-models.py`, "never copied" — honoured). One `GET /projections/evidence` `RouteBinding` through the § 2.4 seam via `EvidenceProvenanceSurfaceExtension.routes()`; the seam test proves structural conformance and assembly beside slice 1's `RoleAuthorityProjectionExtension` (2 bindings) and beside the full four-column set (6 bindings, order-insensitive, zero `RouteBindingError`). New files only (+762/−0): the module, a unit suite, a seam suite — 29 tests (27 pass, 2 skip pending `doc_health`, § 4.1's cited gap); with slice 1's 34: 61 passed / 4 skipped; required `test_leg_shape` + `test_dependency_direction` unchanged at 24 — no back-imports. Arrival phase B OK, every row figure identical to the landed baseline (92 / 9 / 81 / 4 unapplied / 6 of 6), created files 5 → 8 (all declared). `validate` run 34588736762 success (fix round 17fa62b: both seam suites now skip ONLY on the cited `doc_health` gap and re-raise any other `ModuleNotFoundError` — the one Copilot thread, resolved; `validate` run 34590155148 success); SonarCloud passed; 0 threads. **4.5 STAYS OPEN — 2 of 3; the model/scenario workbench (design § D4 machinery (5), the "centre of gravity") remains.** Register: openXdox root `code` pin now owes a bump past both #10 and this (batched with slice 2b's openXdox-code landing); an openXdox-spec requirement row is owed at 4.5's full tick. Refs opensoft/openXfactory#656. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ign § D4 machinery 5) (#12) § 4.5 slice 3 of split-opendox-two-layer-product, on Brett Heap's ruling ASK-3 "projection → evidence surface → workbench" (opensoft/openXfactory#656 comment 5628886636; CLAIM 5633537301): the MODEL/SCENARIO WORKBENCH at openXdox-code — design § D4 machinery (5), the "centre of gravity". Adds `src/openxdox/model_scenario_workbench.py` (+404): `project()` takes an already-parsed `xfactory_derived_model_conformance` document and renders one bench station per family — the model member and the optional scenario member, `scope` + `isolation_boundary`, the truth store joined to each member's `truth_store_access` binding, `output_status_field` beside `HYPOTHESIS_OUTPUT_STATUSES`, and the `promoting_authority` — rendering the declaration without re-deriving any conformance judgment (the schema's deep checks live only in `scripts/validate-derived-models.py`, "never copied" — honoured) and without re-rendering provenance (machinery (4)'s, slice 2). One `GET /projections/workbench` `RouteBinding` through the § 2.4 seam via `ModelScenarioWorkbenchExtension.routes()`, reading the same `derived_model_conformance` attribute slice 2 established; the seam suite proves structural conformance and assembly beside `RoleAuthorityProjectionExtension` + `EvidenceProvenanceSurfaceExtension` and beside the full column set (order-insensitive, zero `RouteBindingError`). New files only (+1082/−0): the module, a unit suite (23), a seam suite (12) — 35 tests (33 pass, 2 skip only on the cited `doc_health` gap, § 4.1, re-raising any other `ModuleNotFoundError`); required `test_leg_shape` + `test_dependency_direction` unchanged at 24 — no back-imports. Arrival phase B exit 0, every figure identical to main except created files 8 → 11 (all declared). `validate` run 34593278586 success; SonarCloud success; 1 Copilot thread (suites landed after the module's first commit) answered and resolved. **4.5 = 3 of 3 at openXdox-code; the openXdox-spec requirement row is owed before the tick.** Register: openXdox root `code` pin owes one bump past #10/#11/#12 (batched with slice 2b's openXdox-code landing). Refs opensoft/openXfactory#656. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`e07e3de8` was that pull request's head when this branch was cut; two review rounds have landed on it since (`cc1d806b`). The census this file records is MEASURED through the pin, so a stale one means `validate` here proves the table against a tree nobody is reviewing any more. The two commits since are test additions and carry no census change — the table is unchanged, and that is the claim this bump lets CI check rather than assert. Still a HEAD sha, which is right for review and wrong for `main`: the lane re-pins to the MERGE sha before this lands. Refs opensoft/openXfactory#656 Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…2b landed) The ratchet table is measured through the pin; #10 landed on openDox-code main as 0f1f2e59e31b8304979f18d8af7108b0f82899fb, so the pin names the commit main carries rather than the pull request's head. Lane: openxfactory-4-opendox-extraction Refs opensoft/openXfactory#656 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ILD slice 2b, and guard the values openDox now owns (#13) Lane: openxfactory-4-opendox-extraction Refs opensoft/openXfactory#656 The openXdox half of BUILD slice 2b, landed in the same window as openDox-code #10 (0f1f2e59) because the ratchet refuses an unrecorded FALL exactly as it refuses a rise. Two moves that are one act: pyproject.toml pins opendox at #10's merge sha on openDox-code main, and OPENDOX_BACK_IMPORTS records the import-time reaches at zero over the five modules (branch_session.py, cli.py, serve.py to 0; serve_project.py and serve_workbench.py already there) with the 19 deferred reaches unchanged — the table is measured through the pin. The drift guard holds openXdox's spelling of the three values openDox now owns as default arguments (defaults.py at the leg) equal to openDox's, so the two copies cannot part silently. The 13-line openDox→openXdox inversion the census named (5626260214) reads 0 import-time / 19 deferred; the deferred reaches are § 4.3/§ 4.5 injection's business, not this arc's. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>



Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)
§ 4.5 slice 1 of
split-opendox-two-layer-product: the role-and-authority projection (design § D4 machinery (6)), RULED to launch first among 4.5's three named features (ASK-3,opensoft/openxFactory#656comment5628886636— "contracts already exist... no ruling needed").Refs opensoft/openXfactory#656
What it renders
Design § D4 names the gap in one sentence: "clinician of record, licensed professional, launch approver; the contracts exist and the workbench shows only a per-serve console token and a loopback verdict." This PR adds
src/openxdox/role_authority_projection.py, a pure rendering surface that:docs/roles-and-authority.md(opensoft/openxFactory) — PO, PM, CA, PA, Merge Council, Merge Master — as data, never invented.self(route_extension.py's own "SAME PRIMITIVES are REACHABLE" guarantee: the resolved actor, the capability dict, the loopback verdict).serve_projection._serve_index's own "belt and braces on the hosted plane" redaction, not a new gating philosophy)."clinician of record"etc.) —roles-authority-model's own first requirement binds the neutral model to stay "without any single domain's execution roles, group names, or tooling," and task 4.4's RULING C2 refuses exactly this failure one column over. Domain labels are accepted only via an optional caller-supplied mapping (a futuredomain-mapping-declaration"promoting authorities" axis, task 4.4, not yet built), defaulting to the neutral table alone.No new data model: every field is either transcribed from the ratified doc or lifted verbatim off primitives
serve_gate.py/serve_projection.pyalready consume the same way.Seam
A route contribution matching
serve_gate.py/serve_projection.py's existing shape exactly:RoleAuthorityProjectionExtension.routes() -> tuple[route_extension.RouteBinding, ...], one exactGET /projections/role-authoritybinding, handled by aRoleAuthorityRoutesmixin method (_handle_role_authority_projection) that will resolve through the MRO once task 4.3's composition point (RULED ASK-2: a lazy proxy) wires it in — a separate, still-open box this slice does not depend on or block on.tests/test_role_authority_projection_seam.pyproves the binding: conforms structurally toroute_extension.RouteExtension; registers throughcollect_bindingsalone and assembled beside the two existing § 2.4 columns (GateRoutesExtension,ProjectionRoutesExtension) in both declaration orders, with no collision; the handler name resolves to a real callable viaresolve_handlers;match()dispatches both GET and HEAD to it. Two of these tests (the "assembles beside the two existing columns" pair) skip in this environment with a cited reason —openxdox.serve_projectionreachesdoc_healthat import time viasnapshot_registry, which § 4.1's own second clause already names as lawful-but-not-yet-reachable here (BUILD-arc work, § 3.5/3.6, not this slice's). They will assert for real the day that lands.Tests
tests/test_role_authority_projection.py(26 tests) +tests/test_role_authority_projection_seam.py(8 tests): 34 passed, 2 skipped (python -m pytest -q tests/test_role_authority_projection.py tests/test_role_authority_projection_seam.py --noconftest, the two skips cited above).Required suite unaffected:
python -m pytest -q tests/test_leg_shape.py tests/test_dependency_direction.py --noconftest→ 24 passed, identical tomain— no back-imports added, nothing underMUST_CONSUME_OPENDOXtouched.Arrival
The three new files (
src/openxdox/role_authority_projection.py,tests/test_role_authority_projection.py,tests/test_role_authority_projection_seam.py) are each named on the command line with--allow-created— new modules only, nothing inside any existing row's declared lines touched.Tick judgment — 4.5 stays OPEN
Task 4.5's box names three independent features: the model/scenario workbench (L/XL), the evidence-and-provenance surface (M), and the role-and-authority projection (S). This PR meets only the third. The box does not tick: the workbench and the evidence surface remain unbuilt, per RULING ASK-3's own launch order (this slice → evidence surface → workbench).
Within this slice's own scope, everything the BRIEF SKELETON named is met: a rendering/query surface over the existing
roles-authority-modelcontracts, no new data model, a route contribution through the § 2.4 seam, and tests (openXdox-code's ownpytest, plus the seam-conformance suite — no separatevalidate-roles*script exists underopenxFactory/scripts/, checked before assuming none did).Two deliberate scope decisions, flagged rather than silently taken:
openXdox-specrequirement row is added in this PR — out of this slice's stated BUILD scope; a follow-up if the lane wants the requirement declared before the box ticks..github/workflows/validate.ymlis NOT extended to run the two new test files, even though they pass cleanly withoutdoc_healthin this environment — RULING Q-L8 (b′) scopedvalidatedown to shape-assertions-only pending the BUILD arc, and widening that scope is not this slice's call to make unilaterally.Collision discipline
New files only. Untouched:
pyproject.toml(BUILD slice 2b's opendox pin),tests/test_dependency_direction.py,gate_console.py's constants.🤖 Generated with Claude Code
Summary by Sourcery
Add the role-and-authority projection surface and its route contribution as the first independently deliverable feature of the § 4.5 work.
New Features:
/projections/role-authoritywith off-loopback actor redaction and optional caller-supplied domain labels.Enhancements:
Tests: