Skip to content

Cap the doc-health nightly's regression-issue body (fixes the red finalize since 2026-09-05) - #1121

Merged
brettheap merged 2 commits into
mainfrom
fix/doc-health-regression-issue-body-cap
Sep 21, 2026
Merged

brettheap merged 2 commits into
mainfrom
fix/doc-health-regression-issue-body-cap

Conversation

@brettheap

@brettheap brettheap commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-1

Status: draft — do not land. Lands on Brett Heap's word.

The bug

opensoft/xFactory's doc-health-nightly (consuming
.github/workflows/doc-health-reusable.yml@main from this repo) has
concluded failure on every scheduled run since ~2026-09-05, always at
finalize / "Open regression issue (one per run, contract regression
rule)". The step wrote one bullet per new critical/error finding straight
into issue-body.md with no size cap, and once the regression list grew
past GitHub's 65536-character createIssue limit, gh issue create
failed. Decisive log line (run 35299844095, 2026-09-18 03:07:12Z):

GraphQL: Body is too long (maximum is 65536 characters) (createIssue)
##[error]Process completed with exit code 1.

The step then exits 1, reddening the whole finalize job at a
housekeeping step, hiding any real red elsewhere in the job. The last
issue it managed to open is opensoft/xFactory#236 (2026-09-04); no
regression issue has opened since.

What changed

.github/workflows/doc-health-reusable.yml, two steps:

  1. "Run doc-health suite" — right after new-findings.json is
    written, a new inline block writes the FULL, unabridged findings list
    to new-findings.md:

    python3 - "$RUN_DATE" <<'PY'
    import json, sys
    sys.path.insert(0, "openxFactory/scripts")
    from doc_health.regression_issue_body import render
    run_date = sys.argv[1]
    findings = json.load(open("new-findings.json"))
    _, full_list_md = render(findings, run_date, cap_bytes=60000)
    open("new-findings.md", "w").write(full_list_md)
    PY
    

    This has to happen here, not inside "Open regression issue" itself:
    that step is conditional (if: new_count != '0') and sits near the
    end of a very long finalize job, well after "Upload report
    artifact" already ran — too late for anything it writes to reach that
    artifact. "Upload report artifact"'s path: is broadened from a
    single file to a list so it now collects new-findings.md too:

    path: |
      ${{ steps.run.outputs.report_out }}
      new-findings.md
    

    So nothing found is ever lost, even when the issue body itself is
    capped.

  2. "Open regression issue (one per run, contract regression rule)"
    (step name and if: unchanged; env: still only GH_TOKEN) — the
    body is now built by the same renderer, capped at 60000 UTF-8 bytes
    (bytes, not characters: bytes upper-bound characters for any UTF-8
    string, so 60000 bytes is always safely under the 65536-character
    GitHub limit), and gh issue create is guarded so a create failure
    can never fail finalize again:

    gh issue create \
      --title "doc-health regressions ${{ steps.run.outputs.run_date }}" \
      --body-file issue-body.md \
      --repo "${{ github.repository }}" \
      || echo "::warning::doc-health: could not open the regression issue (see log); the report and artifacts are unaffected"
    

    mirroring the sibling "Supersede stale regression issues" step's
    stated posture ("Every gh call is guarded so this step can never fail
    the nightly").

The cap/render logic is extracted into
scripts/doc_health/regression_issue_body.py
(render(findings, run_date, cap_bytes=60000) -> (issue_body, full_list_md)) rather than kept purely inline, precisely because both
call sites above need it.

Tests

New tests/doc-health/test_regression_issue_body_cap.py, 11 tests:

  • test_open_regression_issue_step_name_and_condition_unchanged
  • test_open_regression_issue_step_calls_the_extracted_renderer_with_the_cap
  • test_gh_issue_create_is_guarded_so_a_failure_cannot_fail_finalize
  • test_run_doc_health_suite_writes_new_findings_md_before_the_upload_step
  • test_upload_report_artifact_step_collects_new_findings_md_too
  • test_render_returns_a_body_under_the_default_cap_for_a_small_list
  • test_render_caps_a_large_list_and_names_the_full_count_and_omission (5000 synthetic findings)
  • test_render_body_bytes_never_exceed_a_small_cap_either
  • test_render_raises_when_cap_bytes_cannot_even_hold_the_skeleton
  • test_render_empty_findings_list_is_well_formed
  • test_module_default_cap_is_60000_matching_githubs_65536_character_limit

Worth flagging: the first version of render()'s byte-budget reservation
undercounted the blank-line separators between sections and could exceed
its own cap at small cap_bytes values — test_render_body_bytes_never_exceed_a_small_cap_either
(50 findings, caps 1000–3000 bytes) caught it during development. Fixed by
measuring the fixed header/count/omitted-line overhead directly off the
same assembly function instead of hand-deriving it, so the reservation
cannot drift out of sync with what gets assembled.

Validation run

  • python3 -m pytest tests/doc-health -q → 1908 passed, 7 pre-existing
    warnings (unrelated tarfile deprecation notice), 0 failed. Run twice
    (before and after the rebase below) with the same result.
  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/doc-health-reusable.yml'))"
    → exits 0, no output (parses clean).
  • actionlint .github/workflows/doc-health-reusable.yml → 9 findings,
    same 9 (identical file:code/message set, normalized for line-number
    shift) as origin/main before this change — all pre-existing shellcheck
    style/info notes elsewhere in the file (SC2129/SC2086/SC2012/SC2015);
    zero new findings.
  • python3 scripts/validate-code-surface.py . → exit 0: "code_surface: 46
    active proposals, 46 declaring — 7 none, 31 a repository list, 8 named
    by the register, 0 outside the grammar. … code_surface validation
    passed (every active declaration's head is admitted)."
    This change
    touches no openspec/changes/ proposal, so no code_surface:
    declaration was demanded.

Merge-cleanliness proof

PR #1111 (realize/citation-report-r2) merged into main while this
branch was in progress (89d7975d9, 2026-09-18T20:03:40Z), inserting a
"Citation remainder report" step immediately after "Upload report
artifact" — the same step this fix also touches. An initial scratch-worktree
git merge --no-commit --no-ff origin/main against that landed state
produced one conflict, purely mechanical: both sides touch the
path: ${{ steps.run.outputs.report_out }} line as their anchor (this fix
rewrites it into a path: | list; #1111 inserts its new step right after
it), with no overlap in intent. Resolved by rebasing this branch onto
current origin/main — combining this fix's expanded path: block with
#1111's citation-remainder steps unchanged — then re-running the full
validation above against the rebased tree (all green, no new actionlint
findings). A second scratch-worktree git merge --no-commit --no-ff origin/main against the rebased branch returned "Already up to date"
(exit 0): this branch now carries current origin/main as an ancestor, so
it merges cleanly.

Not done

Nothing outstanding from the brief.

Lands on Brett Heap's word.

Refs #1118.
Lane: openxfactory-1

🤖 Generated with Claude Code

Summary by Sourcery

Keep doc-health nightly finalization green when regression findings exceed GitHub's issue-body limit while retaining the full findings list in artifacts.

Bug Fixes:

  • Prevent oversized doc-health regression issue bodies from failing nightly finalization by capping rendered content below GitHub's issue limit and making issue creation non-fatal.

Enhancements:

  • Preserve the complete regression findings list in the uploaded report artifact while using the shared renderer for both artifact and issue output.

Tests:

  • Add workflow and renderer coverage for byte limits, truncation reporting, artifact collection, and guarded issue creation.

… failed create from failing finalize

doc-health-nightly's `finalize` job has reddened every scheduled run since
~2026-09-05 at "Open regression issue" (#1118): the
step wrote one bullet per new critical/error finding straight into
issue-body.md with no size cap, and once the regression list grew past
GitHub's 65536-character createIssue limit, `gh issue create` failed
(decisive log, run 35299844095: "GraphQL: Body is too long (maximum is
65536 characters) (createIssue)"), exiting 1 and reddening the job. The
last issue it managed to open is opensoft/xFactory#236 (2026-09-04).

Extracts the rendering into scripts/doc_health/regression_issue_body.py
(`render(findings, run_date, cap_bytes=60000) -> (issue_body, full_list_md)`)
because the fix needs the same rendering in two places in one job run:
"Open regression issue" is conditional and sits near the end of a long
`finalize` job, but "Upload report artifact" -- which now also carries
new-findings.md, the full unabridged list, so nothing found is ever lost
even when the issue body itself is capped -- runs much earlier, right
after new-findings.json is produced. Both call sites pass cap_bytes=60000
explicitly (bytes, not characters -- bytes upper-bound characters for any
UTF-8 string, so a 60000-byte cap is always safely under the 65536-
character GitHub limit).

`gh issue create` is now guarded with `|| echo "::warning::..."`, mirroring
the sibling "Supersede stale regression issues" step's stated posture:
"Every gh call is guarded so this step can never fail the nightly."

Adds tests/doc-health/test_regression_issue_body_cap.py: structural checks
on the workflow (step name/if/env unchanged, the cap constant and guard
present, new-findings.md written before and collected by "Upload report
artifact") plus unit tests on render() itself, including 5000 synthetic
findings forcing truncation and small-cap edge cases that caught a real
off-by-N bug in the byte-budget reservation during development.

Lane: openxfactory-1
Co-Authored-By: Claude Sonnet 5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The fix prevents oversized doc-health regression issue bodies from reddening nightly finalization by rendering them under a 60000-byte limit and making issue creation non-fatal, while uploading an unabridged findings list as an artifact. Rendering is shared in a dedicated module and covered by workflow-structure and edge-case tests.

File-Level Changes

Change Details Files
Cap and centralize regression issue-body rendering while preserving the complete findings list.
  • Extract shared rendering into render() with a 60000 UTF-8-byte cap, truncation counts, and explicit handling for unsatisfiable small caps.
  • Generate new-findings.md immediately after findings are produced and upload it alongside the existing report.
  • Build issue-body.md through the shared renderer and guard gh issue create so housekeeping failures cannot fail finalize.
.github/workflows/doc-health-reusable.yml
scripts/doc_health/regression_issue_body.py
Add regression coverage for workflow wiring, artifact preservation, failure handling, and byte-budget edge cases.
  • Verify the issue step contract, renderer invocation, guarded issue creation, and artifact path ordering.
  • Test default and small-cap byte limits, truncation metadata, full-list preservation, empty findings, and skeleton-size failures.
tests/doc-health/test_regression_issue_body_cap.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

One new test performs thousands of large-string substring scans in a loop, which is unnecessarily expensive and could slow or destabilize CI.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR fixes the doc-health reusable workflow’s nightly finalize job failing at the housekeeping step that opens a regression issue when the issue body exceeds GitHub’s 65,536-character limit. It introduces a capped issue-body renderer (byte-based), preserves the full unabridged findings list in uploaded artifacts, and guards gh issue create so issue-creation failures no longer fail the job.

Changes:

  • Add scripts/doc_health/regression_issue_body.py to render a capped regression issue body while also producing the full findings markdown list for artifacts.
  • Update .github/workflows/doc-health-reusable.yml to (a) write new-findings.md early enough to be included in the report artifact, (b) cap the issue body via the extracted renderer, and (c) make gh issue create non-fatal.
  • Add tests/doc-health/test_regression_issue_body_cap.py with workflow-structure assertions and unit tests for byte-cap correctness and truncation behavior.
File summaries
File Description
tests/doc-health/test_regression_issue_body_cap.py Adds structural tests for the workflow wiring plus unit tests for cap/truncation behavior of the renderer.
scripts/doc_health/regression_issue_body.py New shared renderer that enforces a UTF-8 byte cap for the issue body while preserving a full findings list for artifacts.
.github/workflows/doc-health-reusable.yml Wires the renderer into the nightly, uploads new-findings.md, caps issue bodies, and guards issue creation to keep finalize green.
Review details
  • 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.

…substring searches

tests/doc-health/test_regression_issue_body_cap.py::test_render_caps_a_large_list_and_names_the_full_count_and_omission
looped `for i in range(5000): assert f"fragment-{i:05d}.md" in full`,
doing 5000 individual substring searches over the large `full_list_md`
string (quadratic in the number of findings). Replace it with a single
regex pass: extract every `fragment-\d{5}.md` id from `full` with
re.findall, collect them into a set, and compare that set to the
expected `{f"fragment-{i:05d}.md" for i in range(5000)}` for exact
equality. This is linear in len(full) and, as a set comparison, also
catches any unexpected extra id that the naive per-id loop would have
missed.

python3 -m pytest tests/doc-health/test_regression_issue_body_cap.py -q
still passes all 11 tests; the flagged test's own runtime drops from
0.61s to 0.04s (full file: 2.25s -> 1.09s).

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 18, 2026 20:40

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

It modifies a reusable GitHub Actions workflow that affects nightly operational behavior across repositories, so it warrants final human review despite strong test coverage.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

Copy link
Copy Markdown

@brettheap

Copy link
Copy Markdown
Contributor Author

Brett Heap, 2026-09-21T20:32Z, in the lane session (verbatim): "land #1121 when green" — the landing word for this pull request (the nightly's regression-issue body cap, #1118). Recorded here so the Rule 6 LANDING line can cite it. Marking ready and landing when the gates read green.

Lane: openxfactory-1

@brettheap
brettheap marked this pull request as ready for review September 21, 2026 20:32
@brettheap

Copy link
Copy Markdown
Contributor Author

FREEZE — lane openxfactory-1, session 393ade52-a921-4dd9-9dc5-224ebc056651, 2026-09-21T20:32Z: head 1f425f6d is the landing candidate; no further pushes to fix/doc-health-regression-issue-body-cap. Gates read: six required checks GREEN at this head, main's newest decided pytest-suite (b0329d65) GREEN, 0 open review threads, no closing keyword. Word: Brett Heap "land #1121 when green" (comment 5767105481). Rule 6 LANDING follows.

Lane: openxfactory-1

@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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/doc-health-reusable.yml" line_range="2258-2259" />
<code_context>
+          # reuses the same renderer for its own capped issue-body.md.
+          python3 - "$RUN_DATE" <<'PY'
+          import json, sys
+          sys.path.insert(0, "openxFactory/scripts")
+          from doc_health.regression_issue_body import render
+          run_date = sys.argv[1]
+          findings = json.load(open("new-findings.json"))
</code_context>
<issue_to_address>
**issue (bug_risk):** The workflow imports `doc_health.regression_issue_body` from `openxFactory/scripts`, but this module is added to the reusable-workflow repository and the caller's `openxFactory` submodule is pinned independently. When the nightly consumes this workflow at `@main` before the caller advances that submodule pin, both inline Python blocks raise `ModuleNotFoundError`, so the suite/finalize job fails before the guarded issue creation can help.

**Triggers:** When a caller repository has not yet updated its pinned `openxFactory` submodule to a commit containing `regression_issue_body.py`.

**Suggested fix:** Either import the module from the workflow repository's checked-out path guaranteed to contain this commit, or update/enforce the caller submodule pin together with the workflow change and add a compatibility fallback.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if the renderer or workflow wiring is wrong, a regression issue could be created with an incomplete or misleading body, and reverting would not remove that already-persisted issue; however, the full findings remain in the artifact and the issue is bounded and manually repairable.

Blocking findings: .github/workflows/doc-health-reusable.yml:2259


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +2258 to +2259
sys.path.insert(0, "openxFactory/scripts")
from doc_health.regression_issue_body import render

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The workflow imports doc_health.regression_issue_body from openxFactory/scripts, but this module is added to the reusable-workflow repository and the caller's openxFactory submodule is pinned independently. When the nightly consumes this workflow at @main before the caller advances that submodule pin, both inline Python blocks raise ModuleNotFoundError, so the suite/finalize job fails before the guarded issue creation can help.

Triggers: When a caller repository has not yet updated its pinned openxFactory submodule to a commit containing regression_issue_body.py.

Suggested fix: Either import the module from the workflow repository's checked-out path guaranteed to contain this commit, or update/enforce the caller submodule pin together with the workflow change and add a compatibility fallback.

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

LANDING — lane openxfactory-1, session 393ade52-a921-4dd9-9dc5-224ebc056651@Eagle, 2026-09-21T20:33:23Z, PR #1121 into opensoft/openxFactory main

Guard at 2026-09-21T20:33:28Z on head 1f425f6d15efbd482321de802d61340d3243ce82: six required checks SUCCESS (lane-line, openspec-cli-pin, pytest-suite, release-tag-gate, signed-execution-chain-gate, wallet-validation); closingIssuesReferences = []; 0 unresolved threads; main's newest decided pytest-suite = success; no other-lane open LANDING into opensoft/openxFactory main (who --landing). mergeStateStatus BLOCKED = the code-owner-review ruleset that never clears on the author's own account; admin merge on Brett Heap's recorded word (FIX #1118 doc-health nightly regression-issue body cap; Brett Heap 2026-09-21 land #1121 when green (comment 5767105481)). Merge = merge commit.

@brettheap
brettheap merged commit 80c68da into main Sep 21, 2026
16 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1 (openXfactory-1)

LANDED — lane openxfactory-1, session 393ade52-a921-4dd9-9dc5-224ebc056651@Eagle, 2026-09-21T20:33:38Z, PR #1121 into opensoft/openxFactory main → 80c68da

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