Skip to content

Declare the ideation cross-reference projection's Status once, in one shared place - #985

Merged
brettheap merged 4 commits into
mainfrom
fix/793-cross-reference-status-single-source
Sep 12, 2026
Merged

brettheap merged 4 commits into
mainfrom
fix/793-cross-reference-status-single-source

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-2 (openXfactory-2)

What

ideation/cross-reference.md must carry Status: projection — it is rewritten in place from the YAML on every run, so it has no captured state to be immutable against (docs/document-lifecycle.md; declare-generated-projection-status, 2026-08-28, commit fc788825, which changed that very line from Status: record).

Two code paths produce that file's content and each declared the value independently:

  • scripts/render-ideation-cross-reference.py::render_markdown typed the literal "Status: projection";
  • scripts/doc_health/ideation_readiness.py::_render_markdown — the write path every nightly/packet run actually takes, reused by doc_health/derive_possibles.py::persist — does not render at all. It delegates to whichever copy of the standalone renderer the OPENXFACTORY_ROOT env var (CI's .openxfactory-pin/) or the ancestor walk happens to resolve. A consuming repository pinned before fc788825 therefore still emitted Status: record.

That is the disagreement openxFactory #785 hit; it worked around it by re-rendering the landed .md with the standalone renderer by hand.

How

One source of truth, scripts/projection_header.py — placed beside scripts/output_boundary.py, in neither package, for the same reason that one is (doc_health must not import from ideation_dashboard; persist() already reaches this directory for its boundary, so nothing new travels with the vendored module):

  • PROJECTION_STATUS = "projection" / STATUS_LINE = f"Status: {PROJECTION_STATUS}" — declared once;
  • apply_status_line(markdown) — stamps that line onto a projection whose vintage the caller cannot vouch for.

Both paths now emit the header from it: the renderer appends STATUS_LINE, and the delegating path stamps STATUS_LINE onto whatever the resolved renderer returned. Neither can emit another value, whichever snapshot is reachable. Already-correct output is returned byte-identical.

How verified

  • tests/doc-health/test_cross_reference_projection_status.py (new): the real ideation/cross-reference.yaml rendered through both paths in one process is byte-identical; the header line is pinned to Status: projection; a simulated pre-fc788825 pin emitting Status: record is corrected by _render_markdown and by persist() on disk, with the rest of the body untouched; correct output is passed through unchanged.
  • python3 -m pytest -q tests/doc-health -k 'cross_reference or ideation or derive_possibles or readiness'
  • python3 scripts/doc-health.py --single-repo . --family ideation-routing — no new findings.
  • OPENSPEC_TELEMETRY=0 openspec validate --all --strict — failure set equal to origin/main's.

ideation/cross-reference.md is not regenerated here: a fresh render of the committed YAML through the changed renderer is byte-identical to the committed file, so the projection needs no update.

refs #793

🤖 Generated with Claude Code

Summary by Sourcery

Centralize and enforce the ideation cross-reference projection status across all rendering and persistence paths.

Bug Fixes:

  • Ensure the ideation cross-reference projection always emits the canonical Status: projection header, including when a stale pinned renderer is used.

Enhancements:

  • Centralize the projection status declaration and normalize delegated renderer output while preserving already-correct content unchanged.

Tests:

  • Add coverage for agreement between direct and delegated rendering, stale renderer correction, persistence, import fallback behavior, idempotence, and header/body handling.

…agree with it

The ideation cross-reference `.md` must carry `Status: projection`
(docs/document-lifecycle.md; declare-generated-projection-status,
2026-08-28). Two paths produce that file and each declared the value
independently: the standalone renderer typed the literal, while
doc_health's persist() does not render at all — it delegates to whichever
copy of that renderer OPENXFACTORY_ROOT or the ancestor walk resolves, so
a consuming repository pinned before fc78882 still emitted
`Status: record`.

The value now lives once, in scripts/projection_header.py beside
output_boundary.py: the renderer appends STATUS_LINE, and the delegating
path stamps STATUS_LINE onto whatever the resolved renderer returned.
Neither can emit another value, whichever snapshot is reachable.

refs #793

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 23:13
@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR introduces a package-independent shared projection-header module and uses it to canonicalize the cross-reference status in both the direct renderer and delegated doc-health write path, preventing stale pinned renderers from emitting Status: record; regression tests cover consistency, correction, persistence, and byte preservation.

File-Level Changes

Change Details Files
Centralize the projection status declaration and enforce it across both rendering paths.
  • Add shared PROJECTION_STATUS and STATUS_LINE constants.
  • Add a header-stamping helper that preserves canonical output and repairs stale or missing status headers.
  • Apply the shared status line in the standalone renderer and to output returned by resolved renderer copies.
scripts/projection_header.py
scripts/render-ideation-cross-reference.py
scripts/doc_health/ideation_readiness.py
Add regression coverage for renderer consistency and stale pinned-renderer correction.
  • Verify both paths produce byte-identical output with Status: projection.
  • Exercise correction of stale Status: record output through readiness and persistence paths.
  • Verify already-correct output and body content remain unchanged.
tests/doc-health/test_cross_reference_projection_status.py

Possibly linked issues


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

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

Address the header-scan body-corruption risk and add regression coverage for the normalization helper.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Centralizes the ideation cross-reference projection status and normalizes output across rendering paths.

Changes:

  • Adds shared projection status constants and normalization.
  • Updates standalone and delegated renderers to use the canonical status.
  • Preserves already-correct output byte-for-byte.
File summaries
File Summary
scripts/render-ideation-cross-reference.py Uses the shared projection status.
scripts/projection_header.py Defines and applies status normalization. Moderate: limit header scanning to avoid rewriting body lines. Nit (3 votes): add regression coverage for normalization cases.
scripts/doc_health/ideation_readiness.py Stamps delegated renderer output with the canonical status.
Review details

Suppressed comments (1)

scripts/projection_header.py:53

  • _HEADER_SCAN_LINES extends past the five-line header, so if a resolved renderer omits Status: and its body contains a legitimate Status: ... line within the first 12 lines, the loop rewrites that body line instead of using the insertion path. That breaks the documented guarantee that the body is untouched; limit the scan to the actual header block or stop at the first body section.
_HEADER_SCAN_LINES = 12
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • 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 scripts/projection_header.py Resolved
Both paths render the real index in ONE process and must come out
byte-identical, so drift goes red here rather than months later in a
repository whose pin happens to be stale. A deliberately stale renderer —
PR #785's condition, reconstructed — is held to the declared status through
_render_markdown and through persist() on disk, and proven to change
nothing else about the projection.

refs #793

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 23:17

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

Resolve the renderer import risk and fix the failing overly broad test assertion.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

scripts/render-ideation-cross-reference.py:34

  • Because this module is also loaded by path from OPENXFACTORY_ROOT in ideation_readiness._render_markdown, a bare from projection_header import STATUS_LINE can resolve an unrelated/stale projection_header already on the caller's sys.path; the sibling fallback is only used when the import raises. In that mixed-checkout case the standalone renderer can still emit the wrong status, defeating the single-source guarantee. Load projection_header.py from Path(__file__).resolve().parent unconditionally (or verify the imported module's __file__) before reading STATUS_LINE.
try:
    from projection_header import STATUS_LINE
except ImportError:  # pragma: no cover - this file loaded BY PATH (doc_health's
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

…urce text

A substring scan for `Status:` over a whole file is answered by prose, and
by prose that is true and should stay: a renderer explaining which status it
emits will name it. The forbidden thing is a second EXECUTABLE copy of the
value, so the check now reads string constants out of the tree with
docstrings excluded — the same parsed-not-grepped instrument
test_import_direction.py uses, and for the same reason. The declaration
itself is held to composing its line from PROJECTION_STATUS.

refs #793

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 23:28

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 import-resolution and moderate header-window findings remain.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

scripts/projection_header.py:53

  • The normalizer introduces a second header-window constant (12), but the repository's canonical status readers use doc_health.corpus.STATUS_SCAN_LINES = 15 (scripts/doc_health/corpus.py:111-221). If a resolved renderer places a valid Status: header on real line 13–15, this loop treats it as missing, inserts a second Status: projection, and leaves the old value in the output. Please use a header/body boundary or otherwise align this neutral helper with the established 15-line contract so the stale-status correction cannot fail for a valid header layout.
#: How far into the document a `Status:` line is still a HEADER line. The
#: projection's header block is five lines; anything further down belongs to the
#: rendered body (cluster sections, member tables) and is not ours to rewrite.
_HEADER_SCAN_LINES = 12
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

doc_health is vendored, so the bare import of the declaration is the
ordinary route but not a guaranteed one. _projection_stamp() falls back to
reading the sibling file beside THIS module's own tree — never the
renderer's, which is resolved from OPENXFACTORY_ROOT and may be any
vintage, that being the defect itself.

The suite's conftest puts this checkout's scripts/ on the path, which is
what would mask the case, so the new test closes that route with a None
entry in sys.modules and holds the stamp over a deliberately stale
renderer regardless.

refs #793

Lane: openxfactory-2
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 23:39

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.

🔵 Needs a closer look

Address the vendored-helper fallback and header normalization issues, including early body status and CRLF preservation.

Review details

Suppressed comments (3)

scripts/doc_health/ideation_readiness.py:1326

  • This fallback still assumes that the newly added projection_header.py is copied beside every vendored ideation_readiness.py. A consumer can have the updated vendored module without that sibling; then exec_module() raises FileNotFoundError before _render_markdown can preserve its documented fail-open None result, turning an unreachable renderer into a lane crash. Make the helper an explicit part of the vendored surface, or handle its absence without breaking the existing skip behavior.
        path = Path(__file__).resolve().parents[1] / "projection_header.py"

scripts/projection_header.py:75

  • The first Status: line in the first 12 lines is not necessarily a header line. If a resolved renderer omits the header but emits an early body line such as Status: record, this code rewrites body content and never inserts a header; an already-canonical body line is treated as sufficient too. That contradicts the helper's documented body-preservation guarantee, so replacement should be anchored to the projection's actual header position/boundary and covered with an early-body-status case.
    for i, line in enumerate(lines[:_HEADER_SCAN_LINES]):
        if line.startswith(_STATUS_PREFIX):
            if line == STATUS_LINE:
                return markdown
            lines[i] = STATUS_LINE
            return "\n".join(lines)

scripts/projection_header.py:75

  • split("\n") leaves the \r on CRLF lines, so an already-canonical Status: projection\r\n is not equal to STATUS_LINE; this branch rewrites it and drops the \r, violating the documented byte-identical pass-through. Make the scan line-ending-aware by preserving each line terminator, and add a CRLF regression case.
    lines = markdown.split("\n")
    for i, line in enumerate(lines[:_HEADER_SCAN_LINES]):
        if line.startswith(_STATUS_PREFIX):
            if line == STATUS_LINE:
                return markdown
            lines[i] = STATUS_LINE
            return "\n".join(lines)
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

Copy link
Copy Markdown

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

@brettheap
brettheap merged commit f07c7a0 into main Sep 12, 2026
13 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-2 (openXfactory-2)
LANDED — lane openxfactory-2 (openXfactory-2), 2026-09-12T00:28:03Z, PR #985 → f07c7a0 (no Rule 6 window)
Brett Heap ${WORD_WHEN:-2026-09-11, in session, multi-choice SELECTION}, verbatim: "Land all when green, including #989 after its fix". --squash --admin at head b896c39 (code-owner review cannot clear on a self-authored PR; admin merge on his word, B2 pattern).

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