Skip to content

§ 4.5 slice 1: the role-and-authority projection (design § D4 machinery 6) - #10

Merged
brettheap merged 1 commit into
mainfrom
build/section-4-5-role-authority-projection
Sep 11, 2026
Merged

brettheap merged 1 commit into
mainfrom
build/section-4-5-role-authority-projection

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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#656 comment 5628886636 — "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:

  1. Transcribes the ALREADY-RATIFIED Hermes-level role table from docs/roles-and-authority.md (opensoft/openxFactory) — PO, PM, CA, PA, Merge Council, Merge Master — as data, never invented.
  2. Joins it, at request time, to the SAME primitives every core route already reaches through self (route_extension.py's own "SAME PRIMITIVES are REACHABLE" guarantee: the resolved actor, the capability dict, the loopback verdict).
  3. Renders one JSON projection replacing the bare console-token/loopback pair, with the resolved actor identity redacted off-loopback (mirroring serve_projection._serve_index's own "belt and braces on the hosted plane" redaction, not a new gating philosophy).
  4. Deliberately does NOT hardcode the domain-specific labels design § D4 names ("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 future domain-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.py already 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 exact GET /projections/role-authority binding, handled by a RoleAuthorityRoutes mixin 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.py proves the binding: conforms structurally to route_extension.RouteExtension; registers through collect_bindings alone 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 via resolve_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_projection reaches doc_health at import time via snapshot_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 to main — no back-imports added, nothing under MUST_CONSUME_OPENDOX touched.

Arrival

OK …/xdox: openxdox_code (opensoft/openXdox-code) at opensoft/openxFactory@b075fd91dc8f
(opendox-carve-0), phase B — 92 row(s) arrived, 9 digest(s) verified, 81 declared-edit
row(s) within their lines, 4 unapplied; 6 of 6 declared replica(s) verified; 102 file(s)
under scripts, src/openxdox, tests with none undeclared (1 scaffold, 0 replica, 5
created); scaffold admissions checked against 3487e476d782
exit=0

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-model contracts, no new data model, a route contribution through the § 2.4 seam, and tests (openXdox-code's own pytest, plus the seam-conformance suite — no separate validate-roles* script exists under openxFactory/scripts/, checked before assuming none did).

Two deliberate scope decisions, flagged rather than silently taken:

  • No openXdox-spec requirement 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.yml is NOT extended to run the two new test files, even though they pass cleanly without doc_health in this environment — RULING Q-L8 (b′) scoped validate down 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:

  • Add a role-and-authority projection that exposes the neutral Hermes role table together with request actor, capability, console-presence, and loopback information.
  • Add a read-only GET endpoint at /projections/role-authority with off-loopback actor redaction and optional caller-supplied domain labels.

Enhancements:

  • Provide a pure, domain-neutral projection API without introducing a new authority data model.
  • Add route-extension seam support for composition alongside the existing gate and projection routes.

Tests:

  • Add unit and seam-conformance coverage for projection rendering, capability flattening, redaction, route registration, dispatch, and route compatibility.

…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>
Copilot AI lite review requested due to automatic review settings September 11, 2026 03:47
@brettheap
brettheap marked this pull request as ready for review September 11, 2026 03:48
@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

This 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 request

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Adds a pure role-and-authority projection built from the ratified neutral Hermes-level role table and existing request primitives.
  • Transcribes six neutral authority layers without introducing a new data model.
  • Supports optional caller-provided domain labels while keeping the shared model domain-neutral.
  • Projects actor, console-token presence, loopback status, capability grants, and authority layers into JSON-ready data.
  • Flattens truthy nested capability leaves into stable, sorted dotted-path grants.
  • Redacts actor identity off-loopback while preserving diagnostic status fields.
src/openxdox/role_authority_projection.py
Exposes the projection through the existing route-contribution seam without wiring it into the live application composition point.
  • Adds an exact GET /projections/role-authority RouteBinding.
  • Implements a mixin handler that reads actor, capabilities, and loopback from self and serves JSON, including HEAD behavior through the existing server primitive.
  • Keeps the extension structurally independent of core route implementations.
src/openxdox/role_authority_projection.py
Adds comprehensive unit coverage for projection behavior and route-seam conformance.
  • Tests neutral-layer transcription, label injection, JSON serialization, capability flattening, projection construction, redaction, and handler output.
  • Verifies structural RouteExtension conformance, standalone binding collection, handler resolution, GET/HEAD matching, prefix separation, and assembly beside existing route extensions.
  • Marks existing-column assembly tests as environment-dependent skips when doc_health is unavailable.
tests/test_role_authority_projection.py
tests/test_role_authority_projection_seam.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit 4f98e77 into main Sep 11, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.capabilities is the full capability payload, not just the grant map: the existing serve adds actor, refresh, and (when available) console_token alongside actions. Walking it wholesale emits entries such as actor, refresh.binding, and console_token as capability_grants, so the projection reports metadata as grants. Restrict this call to the actions mapping (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_name and decides strings 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,
Comment on lines +43 to +48
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")
brettheap added a commit that referenced this pull request Sep 11, 2026
…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>
brettheap added a commit that referenced this pull request Sep 11, 2026
…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>
brettheap added a commit that referenced this pull request Sep 11, 2026
`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>
brettheap added a commit that referenced this pull request Sep 11, 2026
…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>
brettheap added a commit that referenced this pull request Sep 11, 2026
…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>
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