Skip to content

§ 4.4 code half: the lifecycle engine reads its vocabulary, terminal statuses and immutability point from a registered DomainProfile (RULING C2; ASK-4 5634195861) - #14

Merged
brettheap merged 22 commits into
mainfrom
build/section-4-4-domain-profile-engine
Sep 11, 2026
Merged

brettheap merged 22 commits into
mainfrom
build/section-4-4-domain-profile-engine

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

#13 landed on main as 01357c8 (the BUILD slice 2b ratchet), per the sequencing note on openxFactory#656 (comment 5634218589). It shared no file with #13 — #13 touched pyproject.toml and tests/test_dependency_direction.py, neither of which this PR edits — which is why it was authored before #13 landed and lands after.

What this is

§ 4.4 of split-opendox-two-layer-product, the code half at openXdox-code: the lifecycle engine stops carrying one domain's words and reads its status vocabulary, terminal statuses and immutability point from a registered domain profile.

PARAMETERIZE, do not ship one domain's words (RULING C2). The lifecycle engine reads its status vocabulary, transitions, authorities and immutability point from a domain profile. A hardcoded status word is a defect under domain-mapping-declaration. — tasks.md § 4.4

RULING C2 (openxFactory#656, 2026-09-04T17:47Z) is that openXdox is the domain-mapping CORE, parameterized by a profile a descendant supplies — "a clinician using MedxDox never sees the word 'requirement'". It was not: openxFactory's own Status: taxonomy lived as literals inside the domain-neutral openxdox package, which is verbatim the failure domain-mapping-declaration names ("openxFactory's own vocabulary is treated as neutral … the placement is refused under RULING C2").

Citations. RULING C2 (5547049745-adjacent packet text, openspec/changes/split-opendox-two-layer-product/tasks.md § 4.4 / design.md / specs/domain-mapping-declaration/spec.md); ASK-2 5628886636 (the lazy proxy, and the sequencing); ASK-4 5633855878 (the questions) RULED at 5634195861 ("ASK-4: recommendations on all five, proceed"); the sequencing note 5634218589; this lane's CLAIM 5634255209. Design note and schema: opensoft/openXdox-spec docs/domain-profile-design-note.md + contracts/schemas/domain-profile.schema.yaml (#8, 446a13f5).

The RULED shape, and where each ruling lands

ASK-4 RULED where it is in this diff
Q1 carriage BOTH — YAML canonical, dataclass the runtime form DomainProfile + load(path_or_mapping)
Q2 schema home openXdox-spec the schema is NOT vendored; load() checks the fields the ENGINE consumes and refuses naming the field
Q3 v1 depth vocabulary + immutability point ENFORCED; transitions/authorities DECLARED only require_status() / is_immutable() enforce; Transition.authority is parsed, typed and unread
Q4 terminal_statuses per KIND DomainProfile.terminal_statuses(kind)
Q5 one registration, two accessors one register() once at process start; current() here, profile_openxfactory at openDox-code (§ 4.3, held)

Resolve by ROLE, never by word. STAGED_STATUS was never "the string staged" — it is "the status this domain's documents carry while ORGANIZED". The profile declares a neutral role: per status, and the engine asks profile.status("organized"). A descendant whose organized status is spelled triaged works with no engine change. Ambiguity is refused naming both candidates, never resolved by declaration order.

Refusal, not a default. With nothing registered, current() raises DomainProfileNotRegistered quoting the registration call. There is no fallback to the words this package used to hardcode — that fallback is exactly how these literals would have survived § 4.4 invisibly, and it is the permissive answer domain-mapping-declaration refuses twice.

The registration contract the openxFactory half must honour

import openxdox.domain_profile as domain_profile

domain_profile.register(domain_profile.load("<path to the domain profile YAML>"))
  • Exact module: openxdox.domain_profile (src/openxdox/domain_profile.py).
  • Exact call: register(load(<path>)), ONCE, at process start, by the descendant's own adapter and by nothing in the neutral packages. openxdox never imports openxFactory; the direction the carve removed stays removed.
  • Refusal message when it is not made — DomainProfileNotRegistered:

    no domain profile is registered, so this engine has no status vocabulary, no terminal statuses and no immutability point. openXdox is the domain-mapping CORE and ships NO domain's words (RULING C2, openxFactory#656): the descendant that drives it registers its own profile at process start with openxdox.domain_profile.register(openxdox.domain_profile.load(<profile.yaml>)) and the neutral package never registers one for it. This is a refusal, not a missing default: falling back to a vocabulary here is the defect domain-mapping-declaration names.

  • What the profile must DECLARE for this engine. A demote transition (its to: is the status the engine flips returning outlines to, and the kind: token every transition manifest and declared-origin record carries; its declaring kind's proposed status is what returning change artifacts are flipped to), and a kind declaring the promote-to-staging act whose terminal_statuses are the states a candidate may not be promoted from. A profile missing either makes the corresponding verb raise ProfileLookupError — a reportable gap in the declaration, named, rather than a silent wrong answer. The vendored fixture carries both, and its header says so.
  • Q5's second accessor. current() also consults opendox.domain_profile when this leg's registry is empty — late, optional, and only in the lawful direction (openXdox pins openDox, RULED OQ-2) — so the one host registration Q5 rules can serve both legs once § 4.3's profile_openxfactory proxy lands. A delegation, never a default: with neither registry holding a profile the refusal stands.
  • Import stays side-effect-free. Nothing resolves a profile at import time. gate_console.STAGED_STATUS / .DRAFT_STATUS survive as module attributes via PEP 562 __getattr__, resolved on first ACCESS, so an importer that never drives the lifecycle never needs a profile.

The seventeen sites, re-swept live on main 5333b125

Seventeen occurrences over fifteen lines — the design note's count, verified by re-sweep in this branch and asserted by tests/test_no_hardcoded_status_words.py.

# site (pre-change) literal axis accessor it now reads
1 gate_console.py:167 DRAFT_STATUS = "draft" lifecycle / vocabulary _draft_status() → current().status("proposed") (module attr kept via __getattr__)
2 gate_console.py:171 STAGED_STATUS = "staged" lifecycle / vocabulary _staged_status() → current().status("organized") (module attr kept via __getattr__)
3 gate_console.py:826 DRAFT_STATUS lifecycle / vocabulary _draft_status()
4 gate_console.py:903 STAGED_STATUS lifecycle / vocabulary _staged_status()
5 gate_console.py:968 "kind": "staged" transitions / destination _demote_destination() → current().destination_status("demote")
6 gate_console.py:1012 DRAFT_STATUS lifecycle / vocabulary _draft_status()
7 gate_console.py:1151 ("rejected", …) lifecycle / terminal statuses current().terminal_statuses("register-possible")
8 gate_console.py:1151 (…, "superseded") lifecycle / terminal statuses same call, same tuple
9 gate_console.py:1339 DRAFT_STATUS (first) lifecycle / vocabulary _draft_status()
10 gate_console.py:1339 DRAFT_STATUS (second) lifecycle / vocabulary _draft_status()
11 gate_console.py:1351 STAGED_STATUS lifecycle / vocabulary _staged_status()
12 gate_console.py:1374 STAGED_STATUS lifecycle / vocabulary _staged_status()
13 gate_console.py:1487 DRAFT_STATUS lifecycle / vocabulary _draft_status()
14 gate_console.py:1569 DRAFT_STATUS lifecycle / vocabulary _draft_status()
15 gate_console.py:1651 "kind": "staged" transitions / destination _demote_destination()
16 generator.py:349 != "staged" transitions / destination _declared_origin_kind() → current().destination_status("demote")
17 generator.py:367 return "staged", … transitions / destination _declared_origin_kind()
18 gate_console.py:1550 f"# {topic}\n\nStatus: staged\n" lifecycle / vocabulary _staged_status()

FINDING: it is EIGHTEEN occurrences over SIXTEEN lines, not seventeen over fifteen

tests/test_no_hardcoded_status_words.py failed on its first run against a tree in which all seventeen named sites had already been migrated, at gate_console.py:1550 on main:

readme.write_text(f"# {plan.staging_topic}\n\nStatus: staged\n" + note, ...)

— the README a demote writes for a staging topic that does not have one. The design note's live sweep looked for the bare token "staged" and for the constant STAGED_STATUS; here the word is embedded in a longer f-string, so neither pattern saw it. It is the same defect and it is migrated on the same accessor as the fragment beside it. The count for the record is eighteen occurrences over sixteen lines. This is the argument for a guard over a careful reading, in one line of evidence — and it is why the guard is in the required check rather than in a commit message.

One disposition worth naming, because it departs from the design note's column heading. The note's migration table files sites 5/15/16/17 under the artifact kinds axis and calls site 5 "the destination kind of the demote transition". The token those four sites actually read and write is staged — the demote transition's declared to: status — while the profile's destination_kind for demote is staging-topic, the artifact kind. Reading destination_kind there would have changed the bytes in every transition manifest, declared-origin record and execution receipt in the corpus. So the engine reads destination_status("demote") (→ staged, byte-identical), and destination_kind("demote") (→ staging-topic) is carried on the profile as declared data for the later slice that enforces transitions. Nothing from the note is dropped; the axis it named is on the object, and the site reads the field that preserves behaviour.

By role, by act — never by a name this package writes down. A status is asked for by neutral ROLE; a KIND is asked for through the ACT that operates on it (kind_declaring("demote"), kind_declaring("promote-to-staging")) rather than by writing governance-document or register-possible into a neutral module, because a descendant calls its governed prose and its candidate register something else. What the engine keeps is its OWN verb list — demote and promote-to-staging are the gate console's API surface, not status words. test_the_engine_names_no_artifact_kind_of_any_domain guards that too.

Disclosed, and deliberately not migrated: two register words remain. _PROMOTABLE_STATE = "latent" (gate_console.py:1135) and state == "picked" (:1154) are the possibles register's own vocabulary. ASK-4 Q4 ruled the TERMINAL pair into terminal_statuses and scoped nothing else, and the fixture's register-possible lifecycle declares both words with neutral roles, so migrating them is a one-line follow-on whenever the register's vocabulary slice is taken. They are named here rather than swept in silently, and they are outside the nine-word taxonomy this PR's guard asserts is gone.

Tests

validate now runs the two new suites beside the existing shape assertions, on exactly the grounds test_dependency_direction.py joined under § 4.1: both are shape assertions authored HERE, not carved suites. The guard PARSES the two engine modules with ast and never imports them; the profile suite imports openxdox.domain_profile alone — yaml and the standard library, no doc_health, no carved module. Neither un-narrows RULED Q-L8 (b′).

  • tests/test_no_hardcoded_status_words.py — the C2 guard. Zero literals of the nine-word taxonomy (plus the register's rejected) survive in either module, dict KEYS excluded ({"record": …} is a field name, not a status claim) and f-string parts included — which is what found site 18. It also asserts each module still reads the profile (a module that neither hardcodes a word nor reads a profile has not been parameterized, it has been emptied), that nothing resolves a profile at MODULE level, and that no artifact KIND of any domain is named either.
  • tests/test_domain_profile.py — the loader (every required field refused BY NAME; referential integrity of immutability_point.status, transitions.from/to and terminal_statuses against the declared vocabulary; forward tolerance of fields a later schema revision adds), role resolution and its ambiguity refusal, a descendant spelling its organized status triaged resolving with no engine change, per-kind terminal_statuses, the immutability point including the never-freezing regenerated case and its required reason, and registration / late resolution / the refusal — asserting the refusal message leaks no domain word, and asserting in a FRESH interpreter that import registers nothing.
  • conftest.py at the repository root makes the HOST's registration at test-process start, unconditionally and never behind a try/except: a suite that silently ran with no profile is a suite in which this slice's refusal looks like a passing test. Process start is where a host registers, and this is it.
  • tests/test_leg_shape.py and tests/test_dependency_direction.py are untouched — the two files openXdox-code Lower the openDox back-import ratchet to ZERO at import time after BUILD slice 2b, and guard the values openDox now owns #13 owns are pyproject.toml and tests/test_dependency_direction.py, and neither is edited here. No back-import is added: domain_profile.py imports yaml (a declared runtime dependency, already on IMPORT_TIME_ALLOWED) and stdlib only.

Figures. validate's own command — python -m pytest -q tests/test_leg_shape.py tests/test_dependency_direction.py tests/test_domain_profile.py tests/test_no_hardcoded_status_words.py --noconftest — 83 passed locally: the 24 that pass on main, unchanged, plus 59 new (49 profile + 10 guard). The carved suites under tests/ remain uncollectable in this leg for the pre-existing reasons validate.yml records (RULED Q-L8 (b′)): doc_health and scripts/proposal-support.py are openxFactory's, unvendored and not on PyPI. Their collection errors are identical on main and on this branch.

Not in this PR

  • The real profile instance and its registration at openxFactory. It shares files with PR-2 openxFactory#940 and follows it. This half ships the contract, the refusal and the accessors; it ships no domain's words.
  • § 4.3 (openDox-code cli.py / serve.py) — shares files with BUILD slice 2b and stays held.
  • Enforcing transitions or authorities — RULED Q3: declared only in v1.

Refs opensoft/openXfactory#656.

🤖 Generated with Claude Code

Summary by Sourcery

Parameterize the lifecycle engine with a registered domain profile and enforce refusal of hardcoded or undeclared domain vocabulary.

New Features:

  • Add a domain-profile loader and runtime model for domain-specific status vocabularies, lifecycle metadata, terminal statuses, transitions, authorities, and immutability points.
  • Parameterize lifecycle and generator behavior through registered profile roles, acts, and destination kinds instead of hardcoded domain terminology.
  • Provide explicit registration, late resolution, validation, lookup errors, and refusal behavior when no profile is available.

Bug Fixes:

  • Remove hardcoded lifecycle and register status words from gate-console and generator paths, including embedded status text written to generated files.
  • Prevent malformed or incomplete profiles from being silently accepted through missing-field defaults, ambiguous roles, invalid references, duplicate declarations, or invalid immutability settings.

Enhancements:

  • Preserve backward-compatible gate-console status attributes while resolving them lazily from the registered profile.
  • Support per-kind terminal statuses, destination-role resolution, forward-compatible profile fields, and non-freezing regenerated artifacts.

CI:

  • Extend the validation workflow with domain-profile and hardcoded-status guard suites.

Tests:

  • Add comprehensive domain-profile loader, validation, registration, delegation, lifecycle accessor, and immutability tests.
  • Add AST-based guards ensuring engine modules contain no hardcoded domain status words or artifact kinds and do not resolve profiles at import time.
  • Add a vendored profile fixture and process-start test registration setup.

…4 Q1/Q3/Q4/Q5)

openXdox is the domain-mapping CORE, parameterized by a profile a descendant
supplies (RULING C2, openxFactory#656 2026-09-04T17:47Z). It shipped one
domain's words instead: openxFactory's own `Status:` taxonomy as literals in
`gate_console.py` and `generator.py`, which is verbatim the failure
`domain-mapping-declaration` names. This is the object those literals will read
instead; no engine site moves in this commit.

The shape is RULED, not invented — ASK-4, Brett Heap, comment 5634195861
("recommendations on all five, proceed"), against the design note and schema at
openXdox-spec (#8, 446a13f5):

* Q1 BOTH — the YAML is canonical, `DomainProfile` is the runtime form, and
  `load()` is the one place a malformed profile is refused rather than at
  twenty call sites.
* Q2 the schema stays at openXdox-spec and is NOT vendored: `load()` checks the
  fields this ENGINE consumes, which is a narrower promise than a copy free to
  drift from its home.
* Q3 v1 ENFORCES the vocabulary (`require_status`) and the immutability point
  (`is_immutable`); transitions and authorities are parsed, typed and readable
  and nothing here refuses an undeclared move — stated rather than implied.
* Q4 `terminal_statuses` is PER KIND.
* Q5 ONE registration (`register()`), late resolution (`current()`), and a
  refusal — `DomainProfileNotRegistered`, quoting the exact registration call —
  when nothing is registered. There is NO fallback to the words this package
  used to hardcode: that fallback is how the literals would have survived this
  refactor invisibly, and it is the permissive default the capability refuses.

Resolve by ROLE, never by word: `status("organized")`, not `statuses["staged"]`,
so a descendant whose organized status is spelled `triaged` needs no engine
change. Ambiguity is refused naming both candidates, never resolved by order.

`current()` also consults `opendox.domain_profile` when this leg's registry is
empty — late, optional, and only in the lawful direction (openXdox pins
openDox) — so the ONE host registration Q5 rules can serve both legs once § 4.3
lands. A delegation, never a default: with neither registry holding a profile,
the refusal stands.

The fixture is a vendored copy of openXdox-spec's worked example carrying the
CORRECTED taxonomy: nine statuses including `projection`, out of band and NOT
immutable, plus a `projection` kind declaring `addenda: regenerated` with the
required `note` (retraction 5633989351; openXdox-spec #11). An out-of-band
never-freezing status loads, and `immutability_point` stays required and
enforced for every kind that does freeze.

Refs opensoft/openXfactory#656

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 12:18
@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR parameterizes the lifecycle engine around a registered domain profile: profiles are parsed into immutable runtime objects, resolved only when accessed, and used for vocabulary, terminal-status, transition-destination, and immutability decisions instead of shipping domain-specific status words. It also adds a corrected, hermetic engineering profile fixture for exercising the contract and forward-compatible profile shape.

Sequence diagram for late domain profile registration and lifecycle access

sequenceDiagram
    participant Host as Descendant adapter
    participant Profile as openxdox.domain_profile
    participant Engine as Lifecycle engine
    participant Upstream as opendox.domain_profile

    Host->>Profile: load(profile_yaml)
    Profile-->>Host: DomainProfile
    Host->>Profile: register(DomainProfile)
    Engine->>Profile: current()
    Profile-->>Engine: registered DomainProfile
    Engine->>Profile: status(role)
    Profile-->>Engine: domain status word
    Engine->>Profile: terminal_statuses(kind)
    Profile-->>Engine: per-kind terminal statuses
    Engine->>Profile: is_immutable(kind, status)
    Profile-->>Engine: immutability decision
Loading

State diagram for profile resolution and refusal

stateDiagram-v2
    [*] --> Unregistered
    Unregistered --> Registered: register(load(profile))
    Registered --> Registered: current()
    Unregistered --> UpstreamLookup: current()
    UpstreamLookup --> Registered: upstream profile available
    UpstreamLookup --> Refused: no profile available
    Refused --> Registered: register(load(profile))
Loading

File-Level Changes

Change Details Files
Introduces a validated, immutable domain-profile runtime model and late-bound process registration.
  • Adds frozen dataclasses for lifecycle vocabularies, artifact kinds, transitions, authorities, acts, evidence, gates, and truth stores.
  • Loads profiles from YAML paths or mappings with required-field, type, referential-integrity, role-ambiguity, transition, and immutability validation.
  • Enforces per-kind status membership, terminal-status lookup, role-based status resolution, transition destinations, and immutability semantics, including never-freezing regenerated projections.
  • Provides register/current/unregister accessors with no default vocabulary, a detailed not-registered refusal, and optional late upstream delegation.
src/openxdox/domain_profile.py
Provides a hermetic domain-profile fixture representing the corrected openxFactory engineering taxonomy.
  • Declares artifact kinds, per-kind vocabularies and terminal statuses, transitions, immutability points, acts, gates, evidence classes, authorities, and truth-store metadata.
  • Covers the ninth projection status and regenerated non-freezing lifecycle shape used by forward-tolerance tests.
tests/fixtures/openxfactory-engineering-profile.yaml

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

brettheap and others added 2 commits September 11, 2026 08:19
…16-17 of 17)

Both `"staged"` literals in the declared-origin reader — the `kind:` test and
the marker it returns — were openxFactory's own word inside the domain-neutral
package. They now read `_declared_origin_kind()`, the status the profile
declares the `demote` transition lands on.

One accessor serves this reader and the manifest `gate_console.py` writes,
which is the point rather than a convenience: the record the forward gate
writes and the record the reverse gate reads have to agree, and they now agree
BY CONSTRUCTION instead of by two literals that happened to match.

Resolved late, per call. Importing `openxdox.generator` still registers
nothing and resolves nothing.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…es 1-15 of 17)

The status words this module carried were openxFactory's own taxonomy inside
the domain-neutral package — the defect `domain-mapping-declaration` names. All
fifteen occurrences here now resolve through the registered profile:

* `DRAFT_STATUS` / `STAGED_STATUS` stop being constants and become
  `_draft_status()` / `_staged_status()`. `gate_console.STAGED_STATUS` and
  `.DRAFT_STATUS` still work for any importer, through a module-level
  `__getattr__` (PEP 562) resolved on first ACCESS — so `import
  openxdox.gate_console` still registers nothing, resolves nothing and refuses
  nothing, and an importer that never drives the lifecycle never needs a
  profile.
* the two `"kind": "staged"` record literals (the transition manifest's
  destination and the execution receipt's) read `_demote_destination()`, the
  status the profile declares the `demote` transition lands on — the same
  accessor `generator.py`'s declared-origin reader uses, so the record the
  forward gate writes and the record the reverse gate reads agree by
  construction.
* `("rejected", "superseded")` reads `terminal_statuses(...)` — RULED ASK-4 Q4,
  per KIND, because those two words are the possibles REGISTER's vocabulary and
  not the document spine's.

BY ROLE, BY ACT, NEVER BY A NAME THIS PACKAGE WRITES DOWN. A kind is named
through the act that operates on it (`kind_declaring("demote")`,
`kind_declaring("promote-to-staging")`) rather than by writing
`governance-document` or `register-possible` into a neutral module: a
descendant calls its governed prose and its candidate register something else.
What the engine keeps is its OWN verb list — `demote` and
`promote-to-staging` are the gate console's API surface, not status words —
and it looks the domain's words up by them. `MedxDox` needs no engine change.

The vendored fixture gains the `register-possible` kind the source example
itself says it would gain "when the register's own vocabulary is declared".
The engine now asks for that vocabulary, so a fixture without it would prove
the accessor against a profile no real host could supply. The openxFactory half
must declare it.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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

Lifecycle integration is unwired, with unresolved validation, registration, and test-coverage findings.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a YAML-backed DomainProfile loader and registry, plus an engineering-domain profile fixture, for lifecycle vocabulary, terminal statuses, and immutability rules. Lifecycle consumers and focused tests remain unwired.

Changes:

  • Adds profile parsing, validation, lookup, immutability, and registration APIs.
  • Adds an engineering-domain YAML fixture.
File summaries
File Review findings
src/openxdox/domain_profile.py Critical (3): Lifecycle consumers remain hardcoded and unwired. Moderate (2): Non-freezing immutability checks bypass vocabulary validation. Moderate (3): Malformed scalar fields can raise raw TypeError. Nit (2): Focused regression tests are missing. Moderate (2): Duplicate registration silently overwrites the profile. Nit (1): Missing-field diagnostics misstate the gates requirement. Moderate (1): Upstream accessor errors are swallowed. Moderate (1): Non-boolean YAML values are coerced. Moderate (1): Duplicate artifact kinds are accepted.
tests/fixtures/openxfactory-engineering-profile.yaml Nit (2): Fixture is unused; registration and focused tests are missing.
Review details

Suppressed comments (4)

src/openxdox/domain_profile.py:790

  • The missing-field diagnostic says that acts and gates are both mandatory and that none of the axes is optional, but the profile contract makes gates optional when acts name an inline gate and this loader intentionally omits it from REQUIRED_TOP_LEVEL. When another field is missing, this message therefore reports a requirement the loader does not enforce; align the diagnostic with the actual contract.
    """
    origin: str | None = None
    if isinstance(source, Mapping):
        raw: Any = source

src/openxdox/domain_profile.py:892

  • Catching every exception from the upstream accessor converts real upstream defects—such as a malformed registration or an accessor bug—into None, after which this leg raises the misleading DomainProfileNotRegistered. Handle only the upstream 'not registered' condition and let unexpected failures propagate so configuration errors are diagnosable.
def is_registered() -> bool:
    """Has a profile been registered here, without resolving or refusing?"""
    return _registered is not None

src/openxdox/domain_profile.py:546

  • bool(...) coerces malformed YAML instead of validating it: human_only: "false" and contradiction_legal: "false" are loaded as True. These flags are persisted in the runtime profile, and human_only will affect authority semantics, so reject non-boolean values rather than silently changing behavior.
    src/openxdox/domain_profile.py:837
  • lifecycle_for() returns the first matching lifecycle, but the loader only checks that each kind exists; duplicate artifact_kind entries are accepted. A malformed profile with two lifecycle declarations for one kind will therefore silently select one for status, terminal_statuses, and is_immutable, making behavior declaration-order dependent. Validate uniqueness before returning the profile.
        artifact_kinds=tuple(
            _artifact_kind(v, i)
            for i, v in enumerate(_as_sequence(data["artifact_kinds"], "artifact_kinds"))),
        lifecycle=tuple(
            _lifecycle(v, i)
  • Files reviewed: 4/4 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Copilot AI review requested due to automatic review settings September 11, 2026 12:22
…ENTH site

THE GUARD FOUND ONE THE SWEEP MISSED. `tests/test_no_hardcoded_status_words.py`
parses `gate_console.py` and `generator.py` with `ast` and asserts ZERO status
words of the nine-word taxonomy, plus the register's terminal pair, survive as
literals. It failed on first run at `gate_console.py:1550` (on `main`):

    readme.write_text(f"# {plan.staging_topic}\n\nStatus: staged\n" + note, ...)

— the README a demote writes for a staging topic that has none. The design
note's live sweep counted SEVENTEEN occurrences over fifteen lines and did not
see this one, because it looked for the bare token `"staged"` and for the
constant `STAGED_STATUS`, and here the word is EMBEDDED in a longer f-string.
It is migrated on the same accessor as the fragment it sits beside. **The count
is EIGHTEEN occurrences over SIXTEEN lines.** This is the argument for a guard
over a careful reading, in one line of evidence.

The guard also asserts what a zero-literal count cannot see on its own: that
each module still READS the profile (a module that neither hardcodes a word nor
reads a profile has not been parameterized, it has been emptied); that nothing
resolves a profile at MODULE level (late by contract, so an importer that never
drives the lifecycle never needs one); and that no ARTIFACT KIND of any domain
is named either — a kind's name is a domain's word too, reached through
`kind_declaring(<act>)`. It is a source sweep, not an import, so it runs
without `doc_health` and keeps working whatever the BUILD arc does to the rest
of the suite.

`conftest.py` at the repository root makes the HOST's registration at
test-process start, unconditionally and never behind a try/except: a suite that
silently ran with no profile would be a suite in which the refusal this slice
installs looks like a passing test. That is not a test convenience standing in
for the contract — process start is where a host registers, and this is it.

`tests/test_domain_profile.py` covers the loader (every required field refused
BY NAME, referential integrity against the declared vocabulary, forward
tolerance of fields a later schema revision adds), role resolution and its
ambiguity refusal, per-kind `terminal_statuses`, the immutability point
including the never-freezing `regenerated` case and its required reason, and
registration / late resolution / the refusal — asserting the refusal message
leaks no domain word, and asserting in a FRESH interpreter that import
registers nothing.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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

Unresolved critical and moderate issues affect registration, validation, custom vocabularies, and test coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (8)

Previously missed (1) — in code that hasn't changed since the last review.

src/openxdox/domain_profile.py:568

  • bool() coerces invalid YAML values instead of refusing them: for example, human_only: "false" becomes True. That silently changes authority semantics in the runtime profile; enforce that supplied values are actual booleans and raise DomainProfileInvalid otherwise.

src/openxdox/domain_profile.py:576

  • This helper assumes every non-string value is iterable; a malformed profile such as terminal_statuses: 3 reaches enumerate(value) and leaks a raw TypeError instead of the documented DomainProfileInvalid refusal. Reject non-list/tuple values before enumerating them.
    if value is None:
        return ()
    if isinstance(value, str):
        raise DomainProfileInvalid(f"{where}: expected a list of strings, got a string")
    return tuple(_text(v, f"{where}[{i}]") for i, v in enumerate(value))

src/openxdox/domain_profile.py:879

  • The documented registration contract is ONCE, but a later call silently replaces _registered. That lets the vocabulary change midway through a process and makes records produced before and after the call disagree; reject a second registration (leaving unregister() as the explicit test/teardown escape hatch).
    if not isinstance(profile, DomainProfile):
        raise TypeError(
            "register() takes a DomainProfile; build one with "
            "openxdox.domain_profile.load(<profile.yaml>)")
    _registered = profile

src/openxdox/domain_profile.py:417

  • The never_freezes early return skips the vocabulary check, so is_immutable("projection", "not-a-declared-status") returns False instead of refusing the out-of-vocabulary status. Validate status against order before handling never_freezes so this path enforces the same closed vocabulary as every other kind.
        if point.never_freezes:
            return False

src/openxdox/domain_profile.py:474

  • This accessor aggregates transitions across kinds and only checks that their destination status strings agree. If two artifact kinds declare the same act and happen to use the same destination status, it silently returns a value even though kind_declaring() defines that situation as ambiguous and refuses it; a manifest can therefore resolve an act without a unique kind. Enforce the single declaring kind before returning the destination status.
        rows = self.transitions_for(act)
        return self._one(rows, act, "to", tuple(sorted({t.to for t in rows})))

src/openxdox/gate_console.py:1213

  • Although this hunk moves terminal states into the profile, promotability_refusal() still hardcodes the same register kind's latent and picked status ids (and the fallback message repeats latent). Those ids are explicitly declared in the new register-possible vocabulary, so a descendant that renames them still cannot promote or refuse entries correctly. Resolve the promotable and picked roles through the declared kind as well.
        if state in _terminal_register_states():

src/openxdox/generator.py:72

  • The profile is consulted here only for the origin token, while _document_exclusion_reason() still compares every document status against the module-level LIFECYCLE_STATUSES = TAXONOMY. A descendant profile that calls its organized state triaged will be dropped from every snapshot as unrecognized, so custom vocabularies do not work through the generator; make that validation consult the registered profile as well.
from . import domain_profile

tests/fixtures/openxfactory-engineering-profile.yaml:31

  • This fixture refers to tests/test_domain_profile.py, but that test file is not present in the checkout (and the advertised test_no_hardcoded_status_words.py guard is absent too). The new loader, registration refusal, and hardcoded-word protections therefore have no corresponding coverage in this PR; add the promised suites or remove these claims.
# `tests/test_domain_profile.py` asserts both halves of that sentence.
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/openxdox/gate_console.py Resolved
Copilot AI review requested due to automatic review settings September 11, 2026 12:28
brettheap and others added 2 commits September 11, 2026 08:30
`tests/test_domain_profile.py` and `tests/test_no_hardcoded_status_words.py`
join `test_leg_shape.py` and `test_dependency_direction.py` in the required
check, on exactly the grounds `test_dependency_direction.py` joined under
§ 4.1: both are SHAPE assertions authored HERE, not carved suites. The guard
PARSES the two engine modules with `ast` and never imports them; the profile
suite imports `openxdox.domain_profile` alone — `yaml` and the standard
library, no `doc_health`, no carved module. Neither un-narrows RULED Q-L8 (b'):
the carved suites stay out until the BUILD arc makes them runnable.

A guard that does not run is a comment. "A hardcoded status word is a defect
under `domain-mapping-declaration`" (tasks.md § 4.4), and the literals § 4.4
removes were the OBVIOUS way to write the code while the engine and its one
domain shared a repository — they will be the obvious way again the next time
someone adds a status-bearing step. A defect class that recurs by default
belongs in a required check.

`unregistered_profile` moves from `tests/conftest.py` into the test module that
uses it, because `validate` invokes pytest with `--noconftest` and a suite in
that invocation may not depend on a conftest being collected. It restores
whatever was registered, so a run that DID come through the root `conftest.py`
— the host's process-start registration — is left as it was found.

Local: `python -m pytest -q tests/test_leg_shape.py
tests/test_dependency_direction.py tests/test_domain_profile.py
tests/test_no_hardcoded_status_words.py --noconftest` -> 83 passed
(24 unchanged from main + 59 new).

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1. `is_immutable()` checked the vocabulary AFTER the never-freezes arm, so
   `is_immutable("projection", "typo")` answered `False` — handing a typo the
   same answer as a lawful projection and dropping the vocabulary enforcement
   RULED ASK-4 Q3 for a whole class of kinds. The membership check now runs
   first, for every kind.

2. `_tuple_of_text` rejected only strings, so a malformed scalar
   (`terminal_statuses: 1`) reached `enumerate()` and surfaced as a raw
   `TypeError` from inside the loader — the one thing `load()` promises not to
   do. Every shape that is not a list of strings is now refused by name.

3. `register()` silently overwrote a previous registration, which is not what
   "ONE registration" (RULED ASK-4 Q5) means. A second, DIFFERING registration
   now raises `AlreadyRegistered` naming `unregister()`; re-registering the
   same object stays a no-op, so an idempotent host start-up is not punished.
   Swapping the vocabulary under a running engine would leave half a process
   reading words the other half had stopped using, with nothing reporting it.

Findings 4-7 of the round were raised against the first commit, before the
engine sites, the suites and the registration existed; they are answered on
their threads with the commits that closed them.

Local: validate's own command -> 88 passed.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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

Unresolved moderate issues remain in profile validation, registration, and hardcoded status handling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (9)

src/openxdox/domain_profile.py:667

  • terminal_statuses is an engine-consumed per-kind declaration, but data.get(...) makes a missing field indistinguishable from an explicitly empty list. A profile that omits it therefore loads with no terminal states, so promotability_refusal() cannot reject terminal register entries; require the field while still allowing an explicit [] for kinds such as projection.
    if duplicates:

src/openxdox/domain_profile.py:576

  • _tuple_of_text assumes any non-string value is iterable. A scalar YAML value therefore raises a raw TypeError, while a mapping with string keys is silently accepted as those keys, instead of consistently raising DomainProfileInvalid for malformed known fields. Validate the container type before calling enumerate() and reject mappings.
    return value


def _opt_text(mapping: Mapping[str, Any], key: str) -> str | None:
    value = mapping.get(key)

src/openxdox/domain_profile.py:417

  • The never_freezes branch returns before validating status, so is_immutable("projection", "typo") returns False instead of raising ProfileLookupError. That bypasses the promised vocabulary enforcement for the non-freezing kind; perform the membership check before this early return.

    def is_immutable(self, kind: str, status: str) -> bool:
        """Has an artifact of `kind` at `status` passed its immutability point?

src/openxdox/domain_profile.py:879

  • register() silently replaces _registered, even though the contract and this function's docstring require one host registration at process start. A second adapter or accidental late registration can switch the vocabulary mid-process and make subsequent lifecycle results use a different profile; reject a second registration, while retaining unregister() for explicit teardown/test isolation.
            raise DomainProfileInvalid(

src/openxdox/domain_profile.py:564

  • Known optional string fields are silently dropped when they have the wrong type. In particular, transitions[].act: 123 becomes act=None, changing a declared transition into an unacted row and deferring the failure until a later lookup instead of rejecting the profile at load time. Preserve None only for an absent field and raise DomainProfileInvalid for present non-string values.
    items = list(value)
    if not items:

src/openxdox/domain_profile.py:858

  • The loader only checks lifecycle kinds for membership in the declared-kind set; it never rejects two lifecycle rows for the same kind. Such a profile loads, but lifecycle_for() returns the first row, so status, terminal-state, and immutability lookups silently depend on declaration order instead of refusing an ambiguity.
        basis=_tuple_of_text(data.get("basis"), f"{where}.basis"),
        artifact_kinds=tuple(
            _artifact_kind(v, i)
            for i, v in enumerate(_as_sequence(data["artifact_kinds"], "artifact_kinds"))),
        lifecycle=tuple(

src/openxdox/generator.py:368

  • The new demote lookup does not cover the later _cluster_lineage path, which still compares poss.get("state") == "picked" (line 913). picked is a declared register-possible lifecycle status in the profile fixture, so a domain that renames it will silently lose those change-lineage edges even though this module now claims to read the vocabulary from the profile. Use a profile-derived register state here as well.
    if origin.get("kind") != _declared_origin_kind():

tests/test_no_hardcoded_status_words.py:48

  • The C2 guard omits latent, picked, and promoted, although the fixture declares them as statuses of register-possible and gate_console.py still embeds latent/picked. It can therefore report zero hardcoded lifecycle words while those domain-specific IDs remain in the engine; include the complete register vocabulary in the sweep or otherwise assert that these states are profile-resolved.
TAXONOMY_WORDS = frozenset({
    "brainstorm", "staged", "draft", "ratified", "standard",
    "superseded", "retired", "record", "projection",
})

tests/test_no_hardcoded_status_words.py:120

  • The f-string guard only detects a literal part equal to a watched word or containing the exact Status: <word> prefix. A future hardcoded value such as f"state={value}: draft" therefore passes the C2 guard, even though draft is still embedded in the generated text. Scan every literal JoinedStr part with a token-boundary check (while keeping any intentional documentation exclusions explicit).
        for part in node.values
        if isinstance(part, ast.Constant) and isinstance(part.value, str)
        for word in WATCHED_WORDS
        if f"Status: {word}" in part.value or part.value.strip() == word
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/gate_console.py Resolved
Copilot AI review requested due to automatic review settings September 11, 2026 12:34
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

Figures

validate (the required check) — run 34599499292, conclusion success, head a4bda011. SonarCloud: pass. Its pytest step now runs four files:

python -m pytest -q tests/test_leg_shape.py tests/test_dependency_direction.py \
                    tests/test_domain_profile.py tests/test_no_hardcoded_status_words.py \
                    --noconftest

Locally, that exact command: 88 passed — the 24 that pass unchanged on main, plus 64 new (52 profile cases, 12 guard cases).

The whole tree, branch against main, same interpreter, same installed dependency set, both with openxFactory's scripts/ reachable so the carved suites can be collected at all:

failed passed skipped errors
main (5333b125) 943 1563 8 181
this branch 943 1627 8 181

Identical failure and error counts; +64 passed, all of them this PR's own. Nothing this slice touches moves a single existing result in either direction, which is the behaviour claim the migration rests on.

Those 943 failures and 181 errors are the leg's PRE-EXISTING state, not a regression and not something this PR is entitled to fix: the carved suites need openxFactory's doc_health and scripts/proposal-support.py, which this leg neither vendors nor can install (RULED Q-L8 (b′) — .github/workflows/validate.yml records the narrowing in full, and tests/test_dependency_direction.py enumerates the same reach). Making them runnable is BUILD-arc work (§ 3.5/3.6). The measurement above is worth what it is worth precisely because both sides were measured the same way.

Review

Copilot round 1: 7 threads, 7 answered, 0 unresolved. Three were substantive and are fixed in a4bda01, each with a regression case:

  1. is_immutable() checked the vocabulary AFTER the never-freezes arm, so an undeclared status on a regenerated kind answered False instead of refusing — the vocabulary enforcement RULED under ASK-4 Q3, dropped for a whole class of kinds. The membership check now runs first, for every kind.
  2. _tuple_of_text let a malformed scalar reach enumerate() and surface as a raw TypeError from inside the loader — the one thing load() promises not to do.
  3. register() silently overwrote a previous registration, which is not what "ONE registration" (ASK-4 Q5) means. A second, differing registration now raises AlreadyRegistered naming unregister(); re-registering the same object stays a no-op.

The other four were raised against the first commit — which deliberately added the module and moved no engine site — and are answered on their threads with the commits that closed them.

Still DRAFT, and still held

Lands only after openXdox-code #13 (BUILD slice 2b ratchet), per the sequencing note openxFactory#656 comment 5634218589. No file overlap with #13.

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

Unresolved critical and moderate validation and lifecycle-resolution issues remain.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (8)

Previously missed (2) — in code that hasn't changed since the last review.

src/openxdox/domain_profile.py:863

  • This expression does not validate a present gates value before iterating it. A profile with gates: 1 raises a raw TypeError from enumerate, while gates: {} or gates: 0 is treated as if the optional field were omitted; both violate the loader's single DomainProfileInvalid refusal path. Validate the optional array's type explicitly, allowing only omission or a list of gate mappings.
    tests/test_no_hardcoded_status_words.py:120
  • The f-string guard only matches Status: <word> or a literal part equal to the word. A new hardcoded status such as f"state=draft" would pass even though the docstring says f-string parts are swept and this guard is meant to prevent the defect from returning. Scan every JoinedStr constant with token boundaries (rather than only this exact header format).

src/openxdox/domain_profile.py:577

  • _opt_text silently turns any present non-string into None. For example, transitions[].act: 123 loads as an act-less transition, so kind_declaring("demote") fails later instead of load() raising its promised DomainProfileInvalid; the same loss affects other consumed optional fields. Reject non-None non-strings instead of dropping them.
def _opt_text(mapping: Mapping[str, Any], key: str) -> str | None:
    value = mapping.get(key)
    return value if isinstance(value, str) and value.strip() else None

src/openxdox/domain_profile.py:581

  • bool(...) coerces malformed YAML values instead of validating them: a quoted human_only: "false" becomes True, even though the profile schema declares this field as boolean. Reject non-boolean values so a malformed profile cannot silently change authority semantics.
def _flag(mapping: Mapping[str, Any], key: str) -> bool:
    return bool(mapping.get(key, False))

src/openxdox/domain_profile.py:684

  • The transition validation checks only from and to; it never verifies that t.authority names one of profile.authorities. A typo such as authority: gate-ator therefore loads as a supposedly valid declaration even though the schema describes every transition authority as resolving to the authority axis, and the inconsistency is only discovered by a later lookup. Validate these references during load() without adding actor-enforcement behavior.
    for i, t in enumerate(transitions):
        if t.to not in ids:
            raise DomainProfileInvalid(
                f"{where}.transitions[{i}].to: {t.to!r} is not in this kind's "
                f"declared vocabulary {ids}")

src/openxdox/domain_profile.py:818

  • A file containing invalid UTF-8 fails in read_text() with UnicodeDecodeError, which is neither OSError nor yaml.YAMLError, so load() leaks a raw exception instead of using its documented DomainProfileInvalid refusal path. Include UnicodeError in this handler so all unreadable/malformed profile files are reported consistently.
            raw = yaml.safe_load(path.read_text(encoding="utf-8"))
        except OSError as exc:

tests/test_no_hardcoded_status_words.py:147

  • This removes whole FunctionDef/ClassDef nodes before walking the tree, but decorators, default arguments, and annotations are evaluated at module import time. A declaration such as def f(value=domain_profile.current()) would therefore evade the assertion despite violating the late-resolution contract. Exclude only function bodies while still inspecting those import-time subexpressions.
    module_level = [n for n in tree.body
                    if not isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef))]
    calls = [
        node.lineno
        for stmt in module_level
        for node in ast.walk(stmt)
        if isinstance(node, ast.Call)
        and isinstance(node.func, ast.Attribute)
        and node.func.attr in {"current", "load", "register"}

tests/test_no_hardcoded_status_words.py:168

  • This assertion only searches raw source text, so the existing explanatory comments/docstrings containing domain_profile satisfy it even if all executable profile calls are removed. That makes the guard unable to detect the lifecycle module being emptied—the failure mode its docstring describes. Inspect the AST for an actual domain_profile call (as the two modules currently use) instead of checking the source substring.
    text, _tree = _module_source(module)
    assert "domain_profile" in text, (
        f"{module} names no domain profile at all; § 4.4 parameterizes this "
        "module, it does not empty it")
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/gate_console.py Resolved
brettheap and others added 5 commits September 11, 2026 14:40
…g it

Copilot review thread on PR #14 (src/openxdox/domain_profile.py:568):
`_flag()` returned `bool(mapping.get(key, False))`, so a malformed YAML
value such as `human_only: "false"` — a non-empty string, truthy in
Python — silently became `True` instead of being refused. That changes
authority metadata rather than reporting the malformed field, breaking
`load()`'s promise to refuse a malformed profile once, on the way in,
naming the field.

`_flag()` now takes the loader's `where` context, accepts only an actual
`bool` (or an absent key, keeping its False default), and raises
DomainProfileInvalid naming `{where}.{key}` for anything else. Its three
call sites (`Status.contradiction_legal`, `Status.excluded_from_conversion`,
`Authority.human_only`) pass `where` through.

Regression cases in tests/test_domain_profile.py: a string/int/list/mapping
value is refused by name (parametrized, including the motivating
`"false"` case), an absent key still defaults to False, an actual bool
still loads, and the same helper backing a Status flag is covered too.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…le entry

Copilot review thread on PR #14 (src/openxdox/domain_profile.py:882):
load() checked that every lifecycle's artifact_kind was DECLARED in
artifact_kinds, but not that either was declared only ONCE.
`{k.id for k in profile.artifact_kinds}` is a set — a repeated
artifact_kinds[].id was silently absorbed with no error — and
lifecycle_for() returns the first matching entry, so a second lifecycle
for an already-used kind loaded with no effect: its vocabulary,
immutability point and transitions were parsed and then silently
discarded.

load() now refuses both shapes explicitly, by name, before returning the
profile: a duplicate artifact_kinds[].id, and a second lifecycle entry
for a kind already seen. Both are refused once, on the way in, on the
same footing as every other malformed shape this loader enforces.

Regression cases in tests/test_domain_profile.py: a duplicated
artifact_kinds entry is refused, and a duplicated lifecycle entry for
governance-document is refused.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… own word

Copilot review thread on PR #14 (src/openxdox/gate_console.py:214):
_demote_destination() called domain_profile.destination_status(DEMOTE_ACT),
which reads the demote transition's `to:` spelling — a word the loader
validates only against the SOURCE kind's vocabulary
(governance-document). The artifact that actually gets created is a
DIFFERENT kind (destination_kind(act), staging-topic), and this
function's result is written as that artifact's own Status: header and
as the demotion manifest's destination.kind token. A descendant profile
whose staging-topic spells "organized" differently from
governance-document's `to:` word would have this code write the wrong
status into the new document; the two words agree only by coincidence
in openxFactory's own fixture.

generator._declared_origin_kind() read the identical
domain_profile.destination_status("demote") for the same underlying
reason (its own docstring says "one accessor serves both" this reader
and the gate_console manifest, so the forward gate's write and the
reverse gate's read "agree BY CONSTRUCTION"). Fixing gate_console.py
alone would have broken that documented invariant for any descendant
where the two words diverge, so both call sites move together.

domain_profile.py gains destination_role_status(act, role): resolves
`status(role, kind=destination_kind(act))` — the DESTINATION kind's own
word for the role — rather than the source kind's transition spelling.
Both _demote_destination() and _declared_origin_kind() now call it with
("organized" role), so they agree by construction rather than by two
call sites that happen to resolve the same way today.

Regression cases in tests/test_domain_profile.py: a profile where the
staging-topic kind renames its organized status away from
governance-document's `to: staged` proves destination_role_status
resolves via the destination kind, and a same-fixture case proves no
regression when the words agree.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…file too

Copilot review thread on PR #14 (src/openxdox/gate_console.py:1214):
the terminal-state migration (RULED ASK-4 Q4) left promotability_refusal's
other two register-possible words hardcoded — `_PROMOTABLE_STATE = "latent"`
and a literal `state == "picked"` check — so a descendant renaming either
word would still be stuck reading openxFactory's own spelling for these
two, even though terminal_statuses is already parameterized.

Sweeping the same word across both engine modules found a THIRD site:
generator._cluster_lineage also carried a hardcoded `"picked"` literal
when reading a possible's claim on a cluster. Left alone, it would have
defeated the gate_console fix's purpose the moment a descendant renamed
the word — the two modules would disagree about what "picked" means.

gate_console.py gains _promotable_register_state() and
_picked_register_state(), resolving through
`status(<role>, kind=kind_declaring(PROMOTE_TO_STAGING_ACT))` the same
way `_terminal_register_states()` already does; promotability_refusal
and its message text now read through them instead of the literals.
generator.py gains its own _picked_register_state() (the same
composition, using the act's own string since generator.py does not
import gate_console's constants) and _cluster_lineage reads it instead
of the literal.

tests/test_no_hardcoded_status_words.py's AST guard gains
REGISTER_OTHER_WORDS = {"latent", "picked"}, enforcing the fix the same
way REGISTER_TERMINAL_WORDS already enforces the terminal pair — "the
defect class needs a test, not a memory" (this file's own docstring).

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 11, 2026 18:47

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

Moderate validation and regression-guard gaps remain in domain_profile.py and test_no_hardcoded_status_words.py.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (3)

src/openxdox/domain_profile.py:864

  • This diagnostic says gates is one of the required fields and that none of the listed axes is optional, but gates is intentionally optional in the profile contract and is omitted from REQUIRED_TOP_LEVEL. When another field is missing, the error gives the wrong remediation; clarify that gates may be omitted when acts name them inline.
            f"{where}: required field(s) {missing} missing. A domain profile "
            "declares all five axes of `domain-mapping-declaration` — artifact "
            "kinds, lifecycle, acts and gates, evidence classes, promoting "
            "authorities — plus its truth store; none of them is optional.")

src/openxdox/domain_profile.py:594

  • _opt_text silently turns a present non-string (including null) into None. A malformed declaration such as act: 123 or destination_kind: 123 is therefore loaded as if the field were omitted and only fails or misbehaves later, contrary to the loader's one-time field validation. Reject invalid present values and preserve None only for omitted optional fields.
def _opt_text(mapping: Mapping[str, Any], key: str) -> str | None:
    value = mapping.get(key)
    return value if isinstance(value, str) and value.strip() else None

tests/test_no_hardcoded_status_words.py:149

  • The AST guard removes every FunctionDef/ClassDef subtree before walking it, so it misses import-time expressions in decorators, default arguments, or class bodies. A future def f(value=domain_profile.current()) would execute current() during import while this required test passes. Inspect those definition-time expressions, or verify a fresh import with no registration instead of excluding the subtrees.
    module_level = [n for n in tree.body
                    if not isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef))]
  • Files reviewed: 9/9 changed files
  • Comments generated: 7
  • Review effort level: Lite

Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread tests/test_no_hardcoded_status_words.py Resolved
Comment thread tests/test_no_hardcoded_status_words.py Resolved
brettheap and others added 2 commits September 11, 2026 14:59
Second-round Copilot review thread on PR #14 (src/openxdox/domain_profile.py:500,
raised against the first round's own destination_role_status): destination_kind()
built its comparison set as
`{t.destination_kind for t in rows if t.destination_kind}` — filtering out
rows with no declared destination_kind BEFORE comparing. If one `demote`
transition named a destination kind and another said nothing at all, the
filtered set held only the declared value, `_one()` saw no disagreement, and
destination_role_status() (added in the first round) would resolve a
destination vocabulary that not every matching transition actually declared.

destination_kind() now checks the unfiltered declarations first: if some
rows name a destination_kind and others don't, it refuses by name rather
than silently keeping the declared subset. The existing agree/disagree/
absent-everywhere cases (`_one()`) are unchanged.

Regression case in tests/test_domain_profile.py:
test_destination_kind_refused_when_only_some_transitions_declare_it removes
destination_kind from one of governance-document's two demote transitions
and asserts the loader refuses rather than silently answering with the one
row that still declares it.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Second-round Copilot review thread on PR #14 (src/openxdox/domain_profile.py:705):
when `addenda` is `regenerated`, the loader checked only that a non-empty
`note` was present; it never checked that the immutability point's own
status actually has role `out-of-band`. A profile could therefore declare
an ordinary spine status such as `ratified` (role `ratified`) as
"regenerated", and `is_immutable()` would answer `False` for it at every
status, silently bypassing v1's immutability enforcement for a status this
domain otherwise treats as part of its normal progression.

`_lifecycle()` now looks up the immutability point's own status in the
kind's vocabulary whenever `never_freezes` is true, and refuses unless that
status's declared role is `out-of-band`. openxFactory's own `projection`
kind (role `out-of-band`) is unaffected.

Regression case in tests/test_domain_profile.py:
test_regenerated_is_refused_unless_the_status_is_out_of_band declares
`ratified` (role `ratified`) as regenerated, with its required note
present, and asserts the loader still refuses it.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
brettheap and others added 5 commits September 11, 2026 15:00
…via .get()

Second-round Copilot review thread on PR #14 (src/openxdox/domain_profile.py:719):
`terminal_statuses` is required by the profile contract even when the
declared list is empty (openxFactory's own `projection` kind declares
`terminal_statuses: []` rather than omitting the key), but the loader read
it with `data.get("terminal_statuses")`, which treats a missing key and an
explicit empty list identically — both reach `_tuple_of_text` as `None`
and both become `()`. A profile that omitted the declaration entirely
loaded exactly as if it had explicitly said "no terminal states", instead
of being refused for skipping a required field.

`_lifecycle()` now reads it through `_require`, which distinguishes an
absent (or explicit `null`) key from a present-but-empty list; the latter
still loads as `()`, the former is refused by name.

Regression case in tests/test_domain_profile.py:
test_an_omitted_terminal_statuses_is_refused_not_defaulted_to_empty deletes
the key entirely and asserts the loader refuses rather than silently
defaulting to no terminal states.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… types

Second-round Copilot review thread on PR #14 (src/openxdox/domain_profile.py:866):
`bool` is a subclass of `int` in Python and `True == 1`, so
`data["schema_version"] != SCHEMA_VERSION` let `schema_version: true` pass
as schema version 1 — a malformed profile with the wrong type accepted by
an equality comparison that does not check the type. The same comparison
also accepts a numerically-equal float (`1.0 == 1`).

The check now requires an actual `int`, explicitly rejecting `bool` first
(since `isinstance(True, int)` is also true), before comparing the value
to `SCHEMA_VERSION`.

Regression case in tests/test_domain_profile.py:
test_a_non_int_schema_version_is_refused_even_when_equal_by_coincidence,
parametrized over `True`, `False`, `"1"` and `1.0`.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Second-round Copilot review thread on PR #14 (src/openxdox/domain_profile.py:923):
the post-construction validation checked lifecycle kinds and duplicate
ids, but never the cross-axis references a transition or an act carries.
An id declared on one axis and consumed on another was never checked
against what that OTHER axis actually declares: a transition could name
an undeclared `authority`, `act`, or `destination_kind` and still load,
`kind_declaring()` could select an act no `acts:` entry names at all, and
an act's `gate`/`target_kind`/`requires_evidence` could point at nothing.
A typo loaded cleanly and surfaced only if some caller happened to look
that exact id up later.

load() now validates, before returning the profile: every transition's
`authority` is a declared Authority id; every transition's `act` (when
present) is a declared Act id; every transition's `destination_kind`
(when present) is a declared artifact kind; every act's `gate` is a
declared Gate id; every act's `target_kind` (when present) is a declared
artifact kind; every id in an act's `requires_evidence` is a declared
EvidenceClass id.

`gates` is the one axis `REQUIRED_TOP_LEVEL` does not name, so the `gate`
check applies only when the profile declares any gates at all — a
gate-less profile is not held to a reference it never made. The other
five checked axes (authorities, acts, evidence_classes, artifact_kinds,
and lifecycle transitions/acts themselves) are all required and therefore
never empty in a validly constructed profile.

Six refusal regression cases in tests/test_domain_profile.py (one per
reference checked) plus one confirming the deliberate gates exemption
when the axis is omitted entirely.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…andalone tokens

Second-round Copilot review thread on PR #14 (tests/test_no_hardcoded_status_words.py:129):
the f-string sweep only recognized two narrow shapes — the literal
substring "Status: <word>", or a part that IS just the word and nothing
else. A literal such as f"status={state} (staged)" is a longer Constant
part that matches neither, despite the test's own docstring claiming it
sweeps every f-string part.

The sweep now matches each watched word as a STANDALONE TOKEN
(`\bword\b` via `_STANDALONE_WORD_RE`) anywhere in a literal part — a
strict superset of the two shapes it replaces, so nothing that used to
trip this test stops tripping it. Word-boundary matching alone would
also flag prose already in gate_console.py that merely shares a word with
the taxonomy ("the record's provenance", "gate-action record",
".ratification-record.yaml", "draft workspace", "the ratified state");
those seven lines are named individually in a new PROSE_EXEMPT set, each
with its own justification, rather than silently narrowing the match back
down. generator.py has no such lines today.

The sweep logic is factored into `_f_string_offenders()` so it can be
proven against a synthetic snippet, independent of what the two real
modules currently contain:
test_the_f_string_sweep_catches_a_word_embedded_in_a_longer_literal
reproduces the review's own motivating example and asserts it is now
caught; test_the_f_string_sweep_still_catches_the_original_two_shapes
confirms no regression on what the test already recognized;
test_the_f_string_sweep_does_not_flag_a_word_embedded_in_a_longer_word
confirms `unstaged` does not trip `staged`.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…n, not seventeen

Second-round Copilot review thread on PR #14 (tests/test_no_hardcoded_status_words.py:215):
test_the_seventeen_sites_are_gone_and_the_count_is_recorded's name,
docstring and assertion message all still stated the design note's
ORIGINAL sweep count — seventeen occurrences over fifteen lines — while
the migrated source and this guard's own docstring establish eighteen
over sixteen: a first-round review on this same PR caught the eighteenth
site (gate_console.py:1550 on main, a status word embedded in a longer
f-string — exactly the class this guard's own f-string sweep exists to
catch) and it was corrected in the same commit that added this guard
(6c877a9), but this one test's recorded baseline was never updated to
match. Its failure diagnostics would report the wrong count to a future
reader.

Renamed to test_the_eighteen_sites_are_gone_and_the_count_is_recorded;
docstring and assertion message now state eighteen over sixteen and
explain where the corrected number comes from. The assertion logic itself
was already correct (total == 0) and is unchanged.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 11, 2026 19:10

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

Unresolved moderate findings remain in profile validation, registry integration, generator behavior, and guard coverage.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (7)

Previously missed (1) — in code that hasn't changed since the last review.

tests/test_no_hardcoded_status_words.py:125

  • This literal scan only matches string constants whose entire value equals a watched word. A future ordinary write such as readme.write_text("Status: staged\\n") is a longer ast.Constant and is neither checked here nor covered by the f-string scan, so the required guard can miss a new hardcoded status write. Scan relevant ordinary string literals too, with audited prose exclusions, and add a regression case.

src/openxdox/domain_profile.py:1100

  • Catching Exception here converts any failure inside the upstream registry—such as a broken profile or programming error—into the local 'no profile' refusal, hiding the real failure and making a valid upstream registration indistinguishable from an absent one. Catch only the upstream's expected absence/not-registered case and let unexpected errors propagate.
    try:
        candidate = getter()
    except Exception:      # noqa: BLE001 — an upstream refusal is "not here"
        return None
    return candidate if isinstance(candidate, DomainProfile) else None

src/openxdox/domain_profile.py:1114

  • This refusal docstring repeats the outdated seventeen-literal count even though the corrected migration count is eighteen. Update it with the same eighteen-site figure so the public explanation of why the fallback is forbidden does not contradict the guard's recorded baseline.
    There is no fallback to the words this package used to hardcode. That
    fallback is precisely how the seventeen literals would have survived § 4.4
    invisibly, and it is the permissive default `domain-mapping-declaration`
    refuses.

src/openxdox/domain_profile.py:1100

  • _upstream() only returns a candidate when it is an instance of this leg's DomainProfile, but the shared opendox.domain_profile registry deliberately stores an opaque host module/object. The Q5 contract therefore cannot be satisfied by the documented call above: registering via openxdox.domain_profile.register(...) leaves OpenDox's registry empty, while registering the host object in opendox is discarded here unless it is this exact class. Align the one-registration seam/type contract and test both accessors before relying on this delegation.
        candidate = getter()
    except Exception:      # noqa: BLE001 — an upstream refusal is "not here"
        return None
    return candidate if isinstance(candidate, DomainProfile) else None

src/openxdox/generator.py:72

  • Importing the profile here only parameterizes origin and register lookups; _document_exclusion_reason() still validates every document against LIFECYCLE_STATUSES = TAXONOMY. A valid descendant profile that spells its organized status triaged will therefore be excluded as unrecognized, and generation can proceed without a registered profile using the old vocabulary. Route this validation through the registered profile so generator behavior honors the same vocabulary and refusal contract.
from . import domain_profile

tests/test_no_hardcoded_status_words.py:241

  • This assertion searches the raw source text, and both engine modules already mention domain_profile in docstrings/comments. Removing every executable profile access would therefore still pass this guard, despite the test claiming to catch an emptied module. Parse the AST and require an actual domain_profile call/reference instead of a substring match.
    text, _tree = _module_source(module)
    assert "domain_profile" in text, (
        f"{module} names no domain profile at all; § 4.4 parameterizes this "
        "module, it does not empty it")

tests/test_no_hardcoded_status_words.py:89

  • These exemptions are keyed only by the current JoinedStr line number. Inserting or deleting lines can move a new status-bearing f-string onto one of these exempt numbers and silently disable the guard, while moving existing prose off the number creates a false failure. Key the exemption to stable source text/AST content (or another source span that verifies the expected expression), not just a line number.
PROSE_EXEMPT: frozenset[tuple[str, int]] = frozenset({
    ("gate_console.py", 315),   # "the record's provenance names one of" (OutputBoundary refusal prose)
    ("gate_console.py", 319),   # the same sentence's other raise site
    ("gate_console.py", 829),   # "gate-action record " — the audit-record noun, not a status
    ("gate_console.py", 1066),  # "'Returned drafts' record" / "returned draft proposals" — README/INDEX prose
    ("gate_console.py", 1675),  # "draft workspace" / "draft ideas" / "draft-proposal convention" — prose
    ("gate_console.py", 1848),  # ".ratification-record.yaml" — a filename, not a written status
    ("gate_console.py", 1851),  # "the ratified state" — prose
})
  • Files reviewed: 9/9 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
Comment thread src/openxdox/domain_profile.py Resolved
brettheap and others added 4 commits September 11, 2026 16:16
…ep count

The docstring said the migration moved seventeen occurrences over
fifteen lines and that those seventeen sites now read this module.
tests/test_no_hardcoded_status_words.py already records the corrected
number: eighteen occurrences over sixteen lines (a first-round review
caught the eighteenth site, gate_console.py:1550 on main, which the
design note's original sweep missed). Update the docstring's three
mentions (lines 15, 19, 1112) to the same eighteen/sixteen the guard
and the migrated source agree on. The two other 'seventeen' mentions
in the tree (gate_console.py:1648-1649, test_no_hardcoded_status_words.py
lines 10/277) are left as-is: both describe the design note's ORIGINAL
undercount as history, not the current total, and are already accurate.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…d of dropping it

`value if isinstance(value, str) ... else None` silently converted
EVERY non-string present value to absence: a malformed
`transition.act: 123` or `destination_kind: 42` loaded as if the field
had been omitted, which is indistinguishable from a legitimate None to
every cross-axis check that reads it (`kind_declaring()`,
`destination_role_status()`, and `load()`'s own referential-integrity
checks below), letting the malformed value bypass validation entirely
rather than being refused.

`_opt_text(mapping, key, where)` now returns None only for an absent
key or an explicit null; any other present value is routed through
`_text()`, which already refuses a non-string (or empty-after-strip)
value by name for every REQUIRED field in this module — the same
promise, extended to the optional ones. All eighteen call sites now
pass their local `where` so the refusal names the field.

Verified against the fixture profile: `transition.act = 123` and
`transition.destination_kind = 42` now raise DomainProfileInvalid
naming the field, while a genuinely omitted `act` key still loads as
None. 122 local tests (test_leg_shape, test_dependency_direction,
test_domain_profile, test_no_hardcoded_status_words) pass unchanged.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ormed one

`data.get("gates") or []` treated ANY falsey present value the same as
a missing key: `gates: false`, `gates: 0`, `gates: ""` all silently
became `[]`, exactly like an omitted `gates` key does, because `gates`
is the one axis the loader's own comment already documents as legally
absent. That let a malformed declaration load as "no gates were
declared", which then also skipped the act.gate cross-axis check
below (guarded by `if declared_gates`), silently letting an arbitrary
`act.gate` value through validation.

Added `_opt_sequence(mapping, key, where)`, next to `_as_sequence`:
returns `[]` only for an absent key or an explicit null, and otherwise
requires the present value to actually be a list — but, unlike
`_as_sequence`, does NOT refuse a present-but-empty list, since for
this one optional axis "no entries" and "key absent" are the same
declaration. `gates=` in `load()` now calls it instead of the `or []`
idiom.

Verified against the fixture profile: `gates: false`, `gates: 0`, and
`gates: ""` now all raise DomainProfileInvalid naming `gates`, while an
explicit `gates: []` and a deleted `gates` key both still load exactly
as before (matching
tests/test_domain_profile.py::test_gate_reference_is_not_checked_when_the_profile_declares_no_gates).
122 local tests pass unchanged.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… refuse a duplicate id

The four `declared_*` set comprehensions each collapse a duplicate id
with no error, and `act()`/`authority()` return the FIRST matching
entry. A profile could therefore declare two entries with the same id
but different metadata for any of these four axes and load cleanly:
the cross-axis referential-integrity checks just below would validate
against whichever entry happened to load, and every later
`profile.act(...)`/`profile.authority(...)` lookup would silently
return the first one and ignore the second — order-dependent behavior
a malformed profile should never produce.

`artifact_kinds` and each kind's `vocabulary` (both above, already
landed) refuse a duplicate id the same way; this closes the same gap
for the remaining four axes with one loop, immediately before the
`declared_authorities`/`declared_acts`/`declared_evidence`/
`declared_gates` sets are built.

Verified against the fixture profile: appending a duplicate entry to
`acts`, `gates`, `evidence_classes`, or `authorities` now raises
DomainProfileInvalid naming the axis and the repeated id in each case;
the unmodified fixture still loads. 122 local tests pass unchanged.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 11, 2026 20:20
@sonarqubecloud

Copy link
Copy Markdown

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

One critical and seven moderate findings remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (7)

Previously missed (1) — in code that hasn't changed since the last review.

tests/test_no_hardcoded_status_words.py:241

  • This companion guard only checks whether the raw source contains the text domain_profile. Both engine modules already contain that name in comments/docstrings, so deleting the actual import and every runtime profile lookup would still pass and the parameterization could regress silently. Check the AST for an actual profile call/reference instead of searching source text.

src/openxdox/domain_profile.py:939

  • This missing-field diagnostic says gates is one of the required axes and that none is optional, but REQUIRED_TOP_LEVEL omits gates and _opt_sequence() deliberately accepts an absent gates axis. A profile missing another required field is therefore told to add an optional field; describe the five required fields and state that gates is optional.
        raise DomainProfileInvalid(
            f"{where}: required field(s) {missing} missing. A domain profile "
            "declares all five axes of `domain-mapping-declaration` — artifact "
            "kinds, lifecycle, acts and gates, evidence classes, promoting "
            "authorities — plus its truth store; none of them is optional.")

src/openxdox/domain_profile.py:1155

  • The Q5 delegation turns every exception raised by opendox.domain_profile.current() into local DomainProfileNotRegistered. A registered upstream profile that is malformed, or an upstream import/runtime failure, will therefore be misreported as “nothing is registered” and hide the actionable error. Treat only the documented not-registered condition as absence and let other failures propagate.
    try:
        candidate = getter()
    except Exception:      # noqa: BLE001 — an upstream refusal is "not here"
        return None
    return candidate if isinstance(candidate, DomainProfile) else None

src/openxdox/gate_console.py:2380

  • Removing these globals breaks from openxdox.gate_console import *: this module has no __all__, so star imports enumerate module.__dict__, and PEP 562 __getattr__/__dir__ do not make DRAFT_STATUS or STAGED_STATUS appear there. That contradicts the stated backward compatibility for the previously public constants; add an explicit __all__ containing the existing public globals plus both late attributes (or another star-import compatibility mechanism).
def __getattr__(name: str):
    resolver = _LATE_ATTRIBUTES.get(name)
    if resolver is None:
        raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
    return resolver()


def __dir__() -> list[str]:
    return sorted(list(globals()) + list(_LATE_ATTRIBUTES))

tests/test_no_hardcoded_status_words.py:89

  • _f_string_offenders exempts each JoinedStr by line, but current source has additional prose nodes at gate_console.py:320 (record's provenance), :1067 (returned draft proposals), :1678 (draft ideas/draft-proposal), and :1854 (ratified state). The set lists :319, :1066, :1675, and :1851 instead for several of these, so the required validate command reports existing prose as offenders; exempt the actual audited nodes.
    ("gate_console.py", 1066),  # "'Returned drafts' record" / "returned draft proposals" — README/INDEX prose
    ("gate_console.py", 1675),  # "draft workspace" / "draft ideas" / "draft-proposal convention" — prose
    ("gate_console.py", 1848),  # ".ratification-record.yaml" — a filename, not a written status
    ("gate_console.py", 1851),  # "the ratified state" — prose
})

tests/test_no_hardcoded_status_words.py:125

  • The literal guard only matches a Constant whose entire value is one watched word, while the second pass only visits JoinedStr nodes. A normal string containing a status word (including an adjacent-literal concatenation) becomes a non-exact ast.Constant and passes both tests even though it can write a domain status. Scan all string-literal forms with the standalone-token rule, while retaining audited prose exclusions, so the required guard cannot be bypassed outside f-strings.
    found = [
        (node.lineno, node.value)
        for node in ast.walk(tree)
        if isinstance(node, ast.Constant)
        and isinstance(node.value, str)
        and node.value in WATCHED_WORDS
        and id(node) not in keys
    ]

tests/test_no_hardcoded_status_words.py:89

  • PROSE_EXEMPT is keyed only by (module, lineno). Inserting or removing code above one of these f-strings shifts the line numbers; the original prose then becomes a false positive, and a new f-string that lands on an exempt line can be silently skipped, allowing a hardcoded status through the required guard. Key each exemption to the expected source segment or AST shape and assert that the exempt node still matches before excluding it.
PROSE_EXEMPT: frozenset[tuple[str, int]] = frozenset({
    ("gate_console.py", 315),   # "the record's provenance names one of" (OutputBoundary refusal prose)
    ("gate_console.py", 319),   # the same sentence's other raise site
    ("gate_console.py", 829),   # "gate-action record " — the audit-record noun, not a status
    ("gate_console.py", 1066),  # "'Returned drafts' record" / "returned draft proposals" — README/INDEX prose
    ("gate_console.py", 1675),  # "draft workspace" / "draft ideas" / "draft-proposal convention" — prose
    ("gate_console.py", 1848),  # ".ratification-record.yaml" — a filename, not a written status
    ("gate_console.py", 1851),  # "the ratified state" — prose
})
  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/openxdox/generator.py Resolved
@brettheap
brettheap marked this pull request as ready for review September 11, 2026 20:32

@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 6 days and 5 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit 3840c16 into main Sep 11, 2026
4 checks passed
brettheap added a commit that referenced this pull request Sep 12, 2026
…egistered DomainProfile, not doc_health's TAXONOMY (RULING C2; § 4.4 follow-up) (#16)

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

§ 4.4 follow-up on RULING C2 (register item from #14's landing, #656 comment
5640381252): generator.py's exclusion check read its status vocabulary from
a module-level LIFECYCLE_STATUSES = TAXONOMY imported from doc_health — a
hardcoded status source and part of the declared doc_health cross-column
reach. _document_exclusion_reason now reads the registered DomainProfile
(profile.statuses for the kind that declares the demote act, the same
kind-derivation idiom the module already uses), refusing with
DomainProfileNotRegistered when nothing is registered — refusal, not a
default. Four tests: every declared status accepted, an undeclared one
rejected, refusal before registration, and a renamed status word needing
no engine change. The AST literal guard and the doc_health reach table are
unmoved (a name-to-name assignment was never a counted literal; the module
still imports doc_health.corpus for corpus scanning, which stays a register
item). Copilot's one thread — the pinned snapshot schema's lifecycle_status
enum still mirrors doc_health's taxonomy — verified as no live regression
(today's profile vocabulary equals the enum byte for byte) and recorded as a
BUILD-arc register item under openXdox-spec's governance. CI's four-file
validate: 122 passed at e23aa1a.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 13, 2026
…bytes as package data, the assembly seam (#18)

Lane: openxfactory-4-opendox-extraction

Refs opensoft/openXfactory#656 (stays OPEN). CLAIM: 5648073924.

**§ 3.4 slice S5, leg A — the gate loop leaves openDox's bundle and becomes a
contribution openXdox supplies.** openDox-spec `docs/front-end-package-boundary.md`
§ 5 row S5 @ `7d12428c`; the contract is openXdox-spec
`docs/gate-loop-view-contract.md` @ `d73767b7`, whose § 8 Q1–Q12 were RULED by
Brett Heap on 2026-09-12 at opensoft/openXfactory#656 — comments `5648044785`
(Q5, Q1, Q3), `5648049748` (Q2, Q4, Q7, Q8), `5648065587` (Q9–Q12), with the
counterpart-Q6 correction at `5649094228`.

SIX ViewBindings, not four: `gate.js:mountGateBar`, `gate-lens.js:mountLensGate`,
`gate-projects.js:mountProjectCommissions`, `dispose.js:mountRefusalPanel`,
`swb-create.js:mountCreateAffordance` and `swb-session.js:mountSessionAffordances`
— slice S4's two new class-B modules say in their own headers that they leave the
bundle here, and leaving them would have left their `gate.lens` / `gate.projects`
entries in openDox's CORE arm. Every binding names a **`shell`** region, so RULED
Q1's generic `dom` mount pass never reaches them; RULED Q3's ONE signature
`mount(host, snapshot, ctx)` is applied to all six and **the gate bar's declared
exception ends here**; RULED Q2's `exports` namespace names `isGateBearing` and
`firstEditTransport`; RULED Q4's `requires` are dotted `/capabilities` paths,
argued per binding; RULED Q8 makes `page-overlay` the declared page-level host, so
no `document.body` survives in `dispose.js`; RULED Q12's four computed routes are
declared as their LITERALS. Seventeen routes in all — § 1.2(c)'s thirteen constants
plus Q12's four — every one under this column's own `serve_gate.ACTIONS_GATE_PREFIX`.

RULED Q5's assembly seam: `openxdox.web_assets.install_view_modules(web_dir)` copies
the six modules into the one `<web_dir>/views/` that `opendox.serve.build_server`
serves, shipped as `[tool.setuptools.package-data]`, with
`serve_views.ViewModuleRoutesExtension` as the fallback. It REFUSES rather than
creating a `web_dir` or a `views/` that is not there — a bundle with no openDox in
it is an assembly error, not a partial install to continue past.

**Pairs with opensoft/openDox-code#20** (the shell half). Neither leg lands alone:
the shell stops shipping these six modules in the same act that this column starts
shipping them.

**The annotation this leg was owed has LANDED FIRST, as RULING Q-L1 requires:**
opensoft/openXfactory#1023 → `ee251d6c54b7e16728f2648c71faa90d6be76496`, carrying the
FOUR RE-DESTINATIONS under the form RULED Q6 (`gate.js`, `dispose.js`,
`swb-create.js`, `swb-session.js` from `opendox_code` to `openxdox_code`, each row's
own `destination` untouched), the seven `created:` admissions this column needed, and
sixteen declared-edit entries over eleven rows. Measured from that landed main against
this head: `verify-carve-arrival.py --destination openxdox_code --phase B` answers
**OK — 96 rows arrived, 9 digests verified, 83 declared-edit rows within their lines,
123 files with NONE undeclared, 4 rows RE-DESTINED HERE (RULED Q6), 22 declared
admissions used** — once the three PRE-EXISTING `arrival-undeclared-edit` rows that
predate this slice (`gate_console.py`, `generator.py`, `tests/ideation-dashboard/
test_generator.py`, openXdox-code #14's § 4.4 code half and #16's RULING-C2 follow-up)
are remedied in a SCRATCH manifest, never the repository's. They are listed, not
absorbed, and they still owe an annotation of their own.

Register, carried forward rather than passed over:
* **The `opendox` pin bump is owed.** This leg pins `opendox @ a99eba03`, which
  predates the view registry, so the three materialization assertions SKIP — never
  fail — until the pin names an openDox carrying § 3.4 slice S5.
* **`profile_openxfactory.py` owes one line** at openxFactory: `VIEW_EXTENSIONS =
  view_extensions.VIEW_EXTENSIONS` beside its `ROUTE_EXTENSIONS` tuple. The
  assembly's act, not this leg's.
* **The gate column's transport-failure handling is a defect this slice cannot take.**
  Copilot found, correctly, that a rejected `fetch` escapes the write path in four of
  the six modules; four of those are ARRIVED files whose flagged lines are
  byte-identical to the carve commit, and normalizing a rejection into
  `{ok: false, message}` is new BEHAVIOUR, which is in none of RULING OQ-1's three
  declared-edit classes. RULED BY THE LANE, 2026-09-13: out of S5's scope. Five
  threads resolved on that word and REGISTERED on #656 for a later declared act.
* **RULED Q7's CSS extraction is owed** for the same reason: "a stylesheet block
  leaves for another leg" is in none of OQ-1's three classes.

Copilot rounds 1–3, all fifteen threads answered and resolved. The sharpest finding
was its own correction of this PR's first shape: `gate.dispose` declared
`requires: ["actions.gate"]`, which made `resolveView` answer `null` on every HOSTED
intent plane and deleted the refusal tray the declaration was meant to describe —
fixed at `2ca488a` with a test that states the reason. Round 3 took two more: a built
`firstEditTransport` now keeps the model it validated instead of reading the
module-level install (it is the one export reached through the REGISTRY rather than a
mount, so it outlives the call that built it, and a second mount would have shaped one
editor's Save with another's model), and `tests/test_gate_console.py`'s three
expectations were repointed to `src/opendox/cli.py` — lines the carve row already
declares at `[58, 1627, 1785, 1786]`, so no new declaration was owed.

Gate evidence: destination gate above; `validate` SUCCESS at `7b86350a` (run
34727512041), the one required check; 15 review threads / 0 unresolved; Sourcery
review skipped (budget) = advisory.
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