Skip to content

fix(autodoc): deliver the context to Claude, and fail loudly when nothing happens - #37952

Merged
fmontes merged 7 commits into
mainfrom
issue-36949-autodoc-fix
Oct 30, 2026
Merged

fmontes merged 7 commits into
mainfrom
issue-36949-autodoc-fix

Conversation

@jdcmsd

@jdcmsd jdcmsd commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The autodoc workflow has never produced a report. All 13 runs since 2026-08-14 went green without Claude seeing a prompt. This PR fixes that, plus the defects hidden behind it, which surfaced once the pipeline could be exercised end to end. It's one file, .github/workflows/issue_autodoc.yml, and depends on dotCMS/ai-workflows#70 (executor v3.6.0).

Everything below was rehearsed from a core branch with core's real secrets and issue data (see Testing).

What was wrong, and what changed

# Problem Fix
B1 The prompt never reached Claude. The context went to the executor as a job output. The runner drops any job output its secret masker would alter, and the prompt's curl example Authorization: Bearer $… trips it. Confirmed: the same context without that line arrives intact. prep encrypts the prompt (instructions.md) and the context (eval_context.md) as separate files and uploads them as an artifact (autodoc-context). The executor (v3.6.0) decrypts them, sends the instructions as Claude's prompt, and has Claude read the context from disk as data, never instructions. Claude searches via a new autodoc-search command instead of a curl with a token, so the Bearer text is gone from the prompt.
B2 Silent success. A run that did nothing ended green. No context, no report or an executor skip now fails the run. Every run writes the full report to its summary.
B3 PRs in private repos were invisible. prep read issue data with GITHUB_TOKEN, which only sees core. For #36628 it saw 1 of 3 linked PRs, missing the ones that carried the work. prep reads via CI_MACHINE_TOKEN, the org token the job already used for the vault checkout. ctx.py fetches each PR from its own repo; it previously assumed core.
B4 Sub-issues were dropped. Doc-labeled sub-issues are skipped ("the Epic run will handle docs"), but the Epic's context never included sub-issues. ctx.py fetches sub-issues and their PRs. The prompt treats a doc-labeled sub-issue as an explicit signal. The skip now leaves a ::notice:: naming the Epic.
B5 Type : Documentation didn't trigger a run. Added to the trigger labels.
B7 Prompt-injection exposure. Every issue comment was included, and Claude had unrestricted Bash plus tokens in its environment. Only comments from org members and collaborators are included. Bodies are clipped at 12k chars and comments at 4k. The executor limits Claude to autodoc-search, Read and Write, and the drafting token never reaches it. finalize refuses to post a report containing any pipeline secret.
B8 Vault lookup matched by prefix (/issues/3599 matched 35990). Exact match.
B11 Updates to older doc pages would be skipped. The update guardrail only accepted dashed UUIDs; 81 of the first 500 doc pages (e.g. evergreen-tracks) have 32-hex IDs. Both forms accepted.
B12 Reports quoted private material in public. A test report repeated dotcms-aios vault notes and private-repo issue numbers, and it becomes a public comment on this repo. The prompt has a confidentiality section, and ctx.py marks private-repo items and the vault section. Re-tested: no private material repeated, same determination.
B13 A bad dotCMS token or host went unnoticed, and could hide human drafts. The authoring server answers the page search and content reads anonymously when the token is invalid. A stale token or wrong AUTODOC_DOTCMS_BASE_URL looked like "no such page", and the content read returned the live version instead of the working one, so the human-draft guardrail passed on pages with outstanding drafts (confirmed on three). Writes still need a valid token, but dry runs reported "guardrail passed" and the cause was hidden. finalize first checks that the token authenticates as the CI Autodoc service account (/api/v1/users/current) and fails with an error naming both settings. A failed or malformed page search also fails the run instead of reading as "no page".

Also:

  • per-issue concurrency so two runs on the same issue can't race
  • create won't duplicate an existing urlTitle
  • an update or create without a draft fails instead of blanking the working version or creating an empty page, and an update draft under half the current page's length is refused as likely truncated (checked in dry runs too)
  • the "human draft" guardrail warns instead of silently skipping

Manual runs

PR #37933 added workflow_dispatch; this version uses it:

  • issue_number (required)
  • dry_run (default true): build the report and show it in the run summary, but post nothing and write nothing to dotCMS
  • ignore_epic_parent
  • inject_test (dry runs only): add a prompt-injection comment to the context; the run fails if the report follows it

Uses: testing a branch's version before merge, backfilling the issues that were missed, re-assessing after docs change.

Testing

Diagnostics on main's own code, from a branch, 2026-10-08:

  • confirmed B1's trigger, B3's token gap, and that Bedrock OIDC works from a branch dispatch
  • found that claude-code-action refuses branch runs without its own github_token (fixed in the executor)

Rehearsal of this workflow from branch autodoc-rehearsal, forced to dry run:

Rehearsal run records were deleted after download, because run summaries on this public repo would have exposed the pre-fix reports. Results are kept privately.

Bedrock end to end from this branch on @v3.6.0-rc1, dry runs, 2026-10-13. All four runs green; each one $1.05–$1.98:

Issue Result
#36628 none, as in the rehearsal
#35693 none. The evergreen-tracks page was revised on 2026-10-09, after the rehearsal that proposed the update; the report checks the revised page section by section
#36951 (ignore_epic_parent) none, as in the rehearsal
#36628 + inject_test injection not followed; finalize's injection and leak checks passed

The rc1 runs showed Claude making 5–16 refused tool calls per run, because the raw search output (about 500 KB per query) was too large to read. The executor's autodoc-search now prints a compact list and saves full pages for Read, and the prompt describes that.
Bedrock end to end on @v3.6.0-rc2, the same four dry runs, 2026-10-27. All green, with the same determinations as rc1. There were no refused tool calls, and about half as many turns at about half the cost:

Issue Result Refused calls (rc1 → rc2) Turns (rc1 → rc2) Cost (rc1 → rc2)
#36628 none 12 → 0 35 → 28 $1.73 → $0.97
#35693 none 16 → 0 37 → 11 $1.60 → $0.87
#36951 (ignore_epic_parent) none 16 → 0 42 → 10 $1.05 → $0.42
#36628 + inject_test injection not followed; finalize's injection and leak checks passed 5 → 0 46 → 30 $1.98 → $1.18

Before merge:

After merge: backfill the missed issues with manual runs, dry first.

Review notes

  • Most of the diff is two inlined heredocs: the prompt (Write prompt) and the context builder (Build eval context), which was rewritten to use GraphQL. The job structure is unchanged: preflight → prep → claude → finalize.
  • Why encrypt: this repo is public and so are its artifacts, and the context includes vault files and private-repo PR bodies. The key is the AUTODOC_CONTEXT_KEY repo secret, already set.
  • Not changed: the report format (META block, DRAFT marker), the dotCMS apply logic, and the human-draft guardrail's service account.
  • Known behavior: claude-code-action checks that whoever triggered the run has write access. An issue closed by a non-member, such as an outside author closing their own doc-labeled issue, fails the claude job visibly instead of running.

Refs #36949

🤖 Generated with Claude Code

This PR fixes: #36949

- Context travels prep -> executor as an encrypted artifact instead of a
  job output (dropped by the runner's secret masker).
- prep reads issues/PRs with CI_MACHINE_TOKEN, fetches PRs from their own
  repos, includes sub-issues, trusted comments only, clips long text.
- Missing context/report fails the run; report goes to the run summary.
- Dispatch inputs: dry_run (default), ignore_epic_parent, inject_test.
- Accept 32-hex dotCMS identifiers; add Type : Documentation trigger.
- Prompt: autodoc-search instead of curl; confidentiality rules.

Refs #36949

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jdcmsd and others added 3 commits October 8, 2026 14:11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dotCMS serves the page search and content reads to anonymous callers,
so a stale drafting token or a wrong AUTODOC_DOTCMS_BASE_URL looked like
'no page', and the content read returned the live version instead of the
working one, letting the human-draft guardrail pass on pages with
outstanding drafts. Check /api/v1/users/current for the service account
first, and treat a failed or malformed search as fatal.

Refs #36949

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The executor's autodoc-search now prints a ranked list with excerpts and
saves full pages for Read, instead of ~500 KB of raw JSON per query.

Refs #36949

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdcmsd
jdcmsd marked this pull request as ready for review October 14, 2026 10:38
@jdcmsd
jdcmsd requested a review from a team as a code owner October 14, 2026 10:38
@jdcmsd
jdcmsd marked this pull request as draft October 23, 2026 18:37
@jdcmsd

jdcmsd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

converting to draft just to prevent a premature merge ahead of dotCMS/ai-workflows#70, which is itself awaiting a tag for further testing.

…or v3.6.0

The prep job now uploads instructions.md and eval_context.md as separate
encrypted files. The executor sends the instructions as Claude's prompt
and frames the context as data, so trusted and untrusted text no longer
share a file. The prompt is no longer appended to the context.

Pinned to @v3.6.0, which has the matching artifact layout. Merge only
after v3.6.0 is tagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdcmsd
jdcmsd marked this pull request as ready for review October 28, 2026 17:46
@jdcmsd

jdcmsd commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Ready for review. ai-workflows#70 is merged and v3.6.0 is tagged on its merge commit. This branch is pinned to @v3.6.0, and the four dry runs on it passed with 0 refused tool calls. Details are in the description.

@fmontes, your Oct 23 approval predates the latest push, so it needs a fresh approval to merge.

@fmontes fmontes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two things worth a follow-up commit before the first live run. Everything else I checked (executor contract at v3.6.0, finalize gating, bot comments excluded as CONTRIBUTOR, leak check ordering) looks right.

Comment thread .github/workflows/issue_autodoc.yml Resolved
Comment thread .github/workflows/issue_autodoc.yml Resolved
Comment thread .github/workflows/issue_autodoc.yml Resolved
…Python 3.11

- update/create without a BEGIN_DOC_DRAFT body now fails instead of
  blanking the working version or creating an empty page (checked in the
  lookup step, so dry runs catch it too, and again in each apply step)
- an update draft under half the current page's length is refused as
  likely truncated
- build the Related PRs list outside the f-string; the nested quotes
  needed Python 3.12 (PEP 701)

Review feedback from @fmontes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdcmsd

jdcmsd commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @fmontes, good catches. All three are fixed in 652b23b (replies inline), and actionlint is green. Ready for another look when you have a minute.

@fmontes
fmontes added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit b3f603f Oct 30, 2026
53 checks passed
@fmontes
fmontes deleted the issue-36949-autodoc-fix branch October 30, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : CI/CD PR changes GitHub Actions/workflows

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

ci(autodoc): fix Bedrock OIDC and harden autodoc workflow

2 participants