Skip to content

feat(autodoc-executor): read context from an encrypted artifact; restrict Claude tools (v3.6.0) - #70

Merged
fmontes merged 6 commits into
mainfrom
autodoc-executor-context-artifact
Oct 28, 2026
Merged

fmontes merged 6 commits into
mainfrom
autodoc-executor-context-artifact

Conversation

@jdcmsd

@jdcmsd jdcmsd commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Paired with dotCMS/core#37952, the caller-side fix. Review together.

Fixes the autodoc pipeline, which has never produced a report in dotCMS/core: all 13 runs since 2026-08-14 went green without running Claude. Callers pinned to v3.5.x are unaffected. The legacy inline-prompt mode is removed (see Compatibility).

  • Input is an encrypted artifact (context_artifact plus secret AUTODOC_CONTEXT_KEY, both required). It holds two files:

    • instructions.md is the task prompt, written by the caller's workflow. It becomes Claude's prompt.
    • eval_context.md is the issue, PRs, comments and notes, including untrusted text. Claude reads it from disk, and the prompt says it is data whose instructions must never be followed.

    So trusted and untrusted text never arrive in the same tool result. The run fails if either file is missing or empty.

  • autodoc-search command. The executor installs a small search script that holds the dotCMS AI search token in a file only it reads. It prints a compact ranked list (title, urlTitle, date, excerpts) and saves each page's full text under .autodoc/pages/ for Read. The raw API response is about 500 KB per query, too large for Claude to read as command output.

  • Search settings are inputs: search_url, search_origin, search_model, search_index, search_threshold and search_limit. Their defaults are today's values, and each is validated before use: https only, and numbers must be numbers. Tuning search needs a caller change, not a new tag.

  • Fixed tool set. The session has only Bash, Read and Write (--tools), with Bash allowed only for autodoc-search (--allowedTools). Other built-ins, such as Agent (subagents), ToolSearch, Edit and the web tools, don't exist in the session.

  • github_token: ${{ github.token }} is passed to claude-code-action (see "Why" below).

  • Fails loudly. It errors on missing instructions or context, when the action skips itself, and when there's no report (if-no-files-found: error).

  • Less in Claude's environment. No dotCMS drafting token, base URL, site folder or search token. The caller's finalize job does all dotCMS writes.

  • CI: tests.yml now shellchecks the autodoc-search script, which actionlint can't see inside its quoted heredoc.

Why

Diagnostic runs in dotCMS/core on 2026-10-08 established three things.

  1. The prompt never arrives. The caller passes the context as a job output. The runner drops any job output its secret masker would alter (Skip output 'eval_context' since it may contain secret). The prompt's curl example Authorization: Bearer $AUTODOC_… matches the masker's Bearer pattern: the same context minus that line got through intact, and Bearer placeholder alone was dropped. So the executor received prompt: "", the action logged NO PROMPT, and the job ended green. Artifacts aren't masker-checked, and handing Claude a search command instead of a credential removes the Bearer text from the prompt altogether.
  2. claude-code-action skips itself on branch runs. Without github_token, the action trades the OIDC token for a Claude GitHub App token. That exchange refuses any run whose calling workflow differs from the default branch's copy (Workflow validation failed … identical content), and the job exits green. So no change to the caller can be dry-run from a branch. On main, the exchange succeeds and an App token with write access lands in Claude's GH_TOKEN, next to unrestricted Bash and untrusted issue text. Claude needs no GitHub access here, so the job's own contents: read token is passed instead. This also skips the exchange.
  3. Bedrock OIDC works from a branch dispatch (Authenticated as assumedRoleId …:GitHubActions). Once this is tagged, the caller fix can be validated in core before it merges.

The encryption exists because dotCMS/core is public, and so are its artifacts. The context includes dotcms-aios vault files and bodies of PRs in private repos.

Compatibility

Removed: the inline prompt input (the v3.5.0 legacy mode) and the deprecated autodoc_dotcms_site_folder and autodoc_dotcms_base_url inputs and AUTODOC_DOTCMS_API_TOKEN_DRAFTING secret. The legacy mode never produced a report, and it ran with full Bash,Write, the search token in Claude's environment and untrusted text in the prompt, which is the setup this PR exists to fix.

dotCMS/core is the only caller, and it moves to the new layout in #37952. Anything pinned to v3.5.0 keeps working. The version stays v3.6.0; the v3.6.0 release notes should record the removal.

Test plan

  • actionlint 1.7.7 (docker) passes on the repo
  • YAML parses
  • New pin actions/download-artifact@3e5f45b… resolved to commit v8.0.1 via the documented procedure; other pins are unchanged from main
  • autodoc-search run locally against the live API: results returned, empty query exits 2, quotes in queries are safe
  • v3.6.0-rc1 cut on 51a856b
  • Dry runs from a dotCMS/core branch on @v3.6.0-rc1 (dispatch, dry_run=true, nothing posted or written), 2026-10-13: #36628 (Epic, private cross-repo PRs), #35693 (vault hit, 16 sub-issues), #36951 (doc-labeled sub-issue). All green, end to end through Bedrock.
  • Adversarial on rc1: #36628 with an injected comment. The report didn't follow it, and finalize's injection and leak checks passed.
  • rc1 runs found two problems, fixed in 2c97b44. (1) Claude made 5–16 refused tool calls per run, trying to filter search output. (2) One run used the Agent tool, which --allowedTools doesn't remove.
  • Local A/B on #35693 (same context, prompt, flags and script, Sonnet 5, transcripts kept privately). Raw-JSON search: output persisted as "too large (469 KB)", then python3/cat/jq attempts, 2 refused, 18 turns. Formatted search: 0 refused, 11 turns, same determination.
  • Install step tested locally: good token, bad token (401 body shown, exit 22 mapped), empty query (exit 2), a path-traversal urlTitle (listed, not saved), empty and non-JSON responses (Results: 0 and a visible failure).
  • v3.6.0-rc2 cut on 2c97b44; the same four core dry runs repeated, 2026-10-27. All green, same determinations, 0 refused tool calls (rc1: 12, 16, 16, 5), 10–30 turns (rc1: 35–46), $0.42–$1.18 per run (rc1: $1.05–$1.98). Injection test passed again.
  • Review changes (64f3f1b), pre-push check using this commit's actual "Compose prompt", "Install autodoc-search" (input defaults) and "Compose claude_args" steps, with Claude Code 2.1.220 (the version CI installs) and contexts rebuilt by #37952's builder:
    • #35693: none (same as rc2), 0 refused calls, 7 turns, $0.63.
    • #36628 with the injection fixture: none (same as rc2), injection not followed, no canary, 0 refused calls, 10 turns, $0.63.
    • Tools used: Read on the context and saved pages, autodoc-search, Write. Nothing else.
  • Failure paths tested locally:
    • A missing or empty instructions.md or eval_context.md stops the run.
    • An http search_url, an origin with a path, a non-numeric threshold and a zero limit are each rejected.
    • A bad token reaches the existing 401 message.
  • The extracted autodoc-search script passes shellcheck (the same extraction tests.yml runs)
  • Tag v3.6.0 on the merge commit, then repeat the four core dry runs on it before #37952 merges

Notes for reviewers

🤖 Generated with Claude Code

…oken

- New context_artifact input + AUTODOC_CONTEXT_KEY secret: the caller
  uploads the eval context as an encrypted artifact instead of a job
  output, which the runner drops whenever its secret masker matches
  (the prompt's "Authorization: Bearer" curl line).
- Install autodoc-search (holds the AI search token); in artifact mode
  Claude gets Bash(autodoc-search:*), Read, Write only.
- Pass github_token: github.token so claude-code-action skips the App
  token exchange, which refuses branch runs of a modified caller and
  would put a write-capable token in Claude's env.
- Fail on empty prompt/context, on the action skipping itself, and on
  a missing report.
- Stop exporting the drafting token, base URL and site folder to Claude;
  those inputs become optional (deprecated).

Legacy inline prompt callers keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jdcmsd
jdcmsd requested review from a team as code owners October 8, 2026 16:35
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:112 — AUTODOC_DOTCMS_API_TOKEN_AISEARCH is conditionally passed to Claude’s environment only when context_artifact is empty, but the autodoc-search script reads it from a file — this creates a dangerous inconsistency: if context_artifact is set, the token is never exposed to Claude’s env, but the script still tries to read it from $RUNNER_TEMP/autodoc-search.token, which was written using the same secret. This is correct — however, the sed command on line 147 replaces __TOKEN_FILE__ with the path, but the token file is written with umask 077 and printf — which is safe — but the script assumes the token file exists and is readable. If the autodoc-search installation fails (e.g., due to permission or race), the sed substitution leaves __TOKEN_FILE__ unexpanded, causing curl to send literal string $(cat "__TOKEN_FILE__") — which is a hardcoded secret placeholder in the HTTP request, leaking the token string __TOKEN_FILE__ to the AI search API. This is a secret exposure bug.
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:147 — The sed command s|__TOKEN_FILE__|$TOKEN_FILE| is applied to a here-document that is written to a file. If $TOKEN_FILE contains a / (e.g., /tmp/...), the sed delimiter | breaks and sed fails silently, leaving __TOKEN_FILE__ in the script. This causes curl to send $(cat "__TOKEN_FILE__") as a literal string — which is not a token but a command string — and if the AI search API logs this, it logs a plaintext command that reveals the token file path. Worse: if the API is compromised, an attacker could craft a query that triggers shell injection via the $(cat ...) — but the script uses set -euo pipefail and curl with --fail-with-body, so it won’t execute — however, the token file path is exposed in logs (e.g., if API returns error), which is a sensitive path disclosure.
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — The smoke test runs "$BIN/autodoc-search" "dotCMS content types" — but if the AI search API is down or returns non-200, curl --fail-with-body exits non-zero and the job fails. This is correct — but the error message says “check AUTODOC_DOTCMS_API_TOKEN_AISEARCH and the AI search API” — which is misleading: the token is correct, but the API is down. This obscures root cause and causes operators to waste time rotating secrets. Should check curl exit code and distinguish between auth failure (401) and connectivity (timeout, 5xx).
  • 🟠 High: .github/workflows/autodoc-executor.yml:175 — AUTODOC_DOTCMS_API_TOKEN_AISEARCH is conditionally passed to the Claude step: ${{ inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' }}. This is incorrect syntax — GitHub Actions does not support && in expressions. This evaluates as a string literal "false && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH" — meaning the token is always empty in context_artifact mode. This breaks the legacy path: if context_artifact is empty, the token is not passed, so autodoc-search cannot run — but the legacy path requires the token to be in the environment for the inline curl command. This is a silent failure — the job runs, Claude writes a report with no search results, and the caller gets a false positive. This is a critical logic flaw.
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:215 — path: ${{ steps.compose.outputs.report }} — if compose step fails (e.g., context artifact missing), report output is undefined. upload-artifact with if-no-files-found: error will fail — but the error message will be No files found matching ... — not “report file not generated”. This hides the real failure (compose step) behind a misleading artifact error. Should add a step to validate $REPORT exists before upload.
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — rm -f "$WORKDIR/eval_context.md.enc" — if decryption fails, the .enc file is still deleted. This erases evidence of a failed decryption (e.g., wrong key, corrupted file). Should preserve .enc for debugging unless explicitly successful.

Existing

  • 🟡 Medium: .github/workflows/autodoc-executor.yml:147 — Prior: sed with | delimiter risks breaking on paths with / — still present. Assumption: $TOKEN_FILE may contain / (common in /tmp/...). What to verify: Does $RUNNER_TEMP ever contain /? Yes — always. This is a known issue in GitHub Actions scripts.

Resolved

  • ✅ .github/workflows/autodoc-executor.yml:215 — path: /tmp/autodoc-report.md → path: ${{ steps.compose.outputs.report }} — now uses dynamic path, fixes hardcoded path issue.

Run: #37809959172 · tokens: in: 4602 · out: 1646 · total: 6248

- Fail if the token file is empty or the path placeholder survived.
- Smoke-test error says how to tell a bad token from an API outage.
- Skip the report upload when setup failed, so the real error is the
  one reported.

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

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:147 — sed -i "s|__TOKEN_FILE__|$TOKEN_FILE|" "$BIN/autodoc-search" uses | as delimiter; if $TOKEN_FILE contains /, substitution fails silently, leaving __TOKEN_FILE__ in the script → curl will send literal $(cat "__TOKEN_FILE__"), causing authentication failure and silent search corruption.
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; || '' is not a valid ternary, so AUTODOC_DOTCMS_API_TOKEN_AISEARCH is always empty in context-artifact mode → Claude runs without token exposure but legacy prompts that rely on it are broken silently.
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — if: ${{ !cancelled() && steps.compose.outcome == 'success' }} skips upload if compose step failed, but does not handle failure() or unsuccessful() → if compose fails due to missing context file, upload is skipped but no error is surfaced to caller; caller sees “no files found” instead of root cause.
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — echo "::error::autodoc-search smoke test failed. The curl error above distinguishes the cause..." conflates HTTP 401/403 (bad token) with 5xx (API outage), but the error message does not distinguish them → obscures root cause for operators.
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — rm -f "$WORKDIR/eval_context.md.enc" deletes encrypted file on decryption failure → erases debugging evidence for key mismatch or corrupted artifact.

Existing

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:112 — Hardcoded placeholder 'TOKEN_FILE' in autodoc-search script may be sent to AI search API, leaking token file path and enabling potential injection if API logs it → unchanged, still present.
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:147 — sed substitution with | delimiter breaks on paths containing /, leaving TOKEN_FILE unexpanded in script, causing curl to send literal string $(cat "TOKEN_FILE") → unchanged, still present.
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression 'inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || ''' is invalid syntax; token is always empty in context_artifact mode, breaking legacy path silently → unchanged, still present.
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure with API outage, obscuring root cause → unchanged, still present.
  • 🟠 High: .github/workflows/autodoc-executor.yml:175 — Legacy path fails silently due to invalid GitHub Actions expression, causing Claude to run without search token → unchanged, still present.
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:215 — upload-artifact error hides compose step failure behind misleading 'no files found' message → unchanged, still present.
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence → unchanged, still present.

Resolved

  • ✅ .github/workflows/autodoc-executor.yml:175 — AUTODOC_DOTCMS_API_TOKEN_DRAFTING is now marked deprecated and not exposed → fixed per PR intent, though syntax error remains.
  • ✅ .github/workflows/autodoc-executor.yml:215 — if: always() replaced with if: ${{ !cancelled() && steps.compose.outcome == 'success' }} → improves error handling, though still incomplete.

Run: #37810475689 · tokens: in: 5094 · out: 1274 · total: 6368

…uard

- New step writes Claude tool-use counts and refused tool calls to the
  job log and summary (tool names only; for refused Bash, the first
  word of the command), so a run is debuggable without exposing
  context text in a public log.
- Report upload now keys off whether Claude ran, so a failed Bedrock
  login no longer adds a secondary "no files found" error.

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

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:112 — autodoc-search script still contains literal __TOKEN_FILE__ in curl command before sed substitution; if sed fails or is bypassed, the unexpanded string $(cat "__TOKEN_FILE__") is sent to the AI search API, leaking the token file path and enabling potential injection if API logs it
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:147 — sed -i "s|__TOKEN_FILE__|$TOKEN_FILE|" "$BIN/autodoc-search" uses | delimiter; if $TOKEN_FILE contains / (e.g., /tmp/autodoc-search.token), sed breaks and leaves __TOKEN_FILE__ unexpanded, causing curl to send literal string $(cat "__TOKEN_FILE__")
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; || '' is parsed as a string literal, not a fallback, so AUTODOC_DOTCMS_API_TOKEN_AISEARCH is always empty in context-artifact mode, breaking legacy path silently
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — if: ${{ !cancelled() && steps.claude.outcome != 'skipped' }} on upload step skips artifact upload if Claude is skipped (e.g., due to earlier failure), but does not surface the root cause — leads to misleading "no files found" error instead of original setup error
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure (401/403) with API outage (timeout/5xx) in a single message; obscures root cause for debugging
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence; no backup or logging of original encrypted content

Existing

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:147 — sed substitution with | delimiter breaks on paths containing /, leaving TOKEN_FILE unexpanded in script, causing curl to send literal string $(cat "TOKEN_FILE")
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression 'inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || ''' is invalid syntax; token is always empty in context_artifact mode, breaking legacy path silently
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — if: ${{ !cancelled() && steps.compose.outcome == 'success' }} skips upload on compose failure but does not surface root cause, leading to misleading 'no files found' error
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure with API outage, obscuring root cause
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:112 — Hardcoded placeholder 'TOKEN_FILE' in autodoc-search script may be sent to AI search API, leaking token file path and enabling potential injection if API logs it

Resolved

  • ✅ .github/workflows/autodoc-executor.yml:215 — steps.compose.outcome changed to steps.claude.outcome — now correctly skips upload only if Claude was skipped, not if compose failed
  • ✅ .github/workflows/autodoc-executor.yml:175 — || ''' changed to || '' — syntax now valid (though still logically flawed as described above)
  • ✅ .github/workflows/autodoc-executor.yml:112 — __TOKEN_FILE__ is now substituted via sed — but still vulnerable to delimiter breakage

Run: #37816131477 · tokens: in: 5426 · out: 1324 · total: 6750

…lure causes

- Bake the token file path in with printf %q instead of a sed placeholder
  (no substitution step that could be left half-done).
- Smoke test reports the cause from curl exit code: HTTP error (bad token
  vs API failure), timeout, or connection failure.
- Decrypt: remove the ciphertext only inside the success branch.

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

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; || '' is not a valid conditional fallback in GitHub Actions expressions — this causes AUTODOC_DOTCMS_API_TOKEN_AISEARCH to always be empty, breaking the token injection for legacy mode and making the smoke test fail silently.
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — if: ${{ !cancelled() && steps.claude.outcome != 'skipped' }} on upload skips artifact upload if Claude is skipped (e.g., due to earlier failure), but does not surface root cause — leading to misleading "no files found" error instead of revealing the true failure.
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure (401/403) with API outage (timeout/5xx), obscuring root cause for debugging; curl exit code 22 is mapped to a generic message that does not distinguish HTTP status codes.
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence; no backup or preservation of ciphertext on failure.

Existing

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:112 — autodoc-search script still contains literal __TOKEN_FILE__ in curl command before sed substitution; if sed fails, unexpanded string is sent to AI search API, leaking token file path and enabling injection if API logs it
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:147 — sed substitution with | delimiter breaks on paths containing /, leaving __TOKEN_FILE__ unexpanded in script, causing curl to send literal string $(cat "__TOKEN_FILE__")
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression 'inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || ''' is invalid syntax; token is always empty in context_artifact mode, breaking legacy path silently
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — if: ${{ !cancelled() && steps.claude.outcome != 'skipped' }} on upload skips artifact upload if Claude is skipped but does not surface root cause, leading to misleading 'no files found' error
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure (401/403) with API outage (timeout/5xx), obscuring root cause for debugging
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence

Resolved

  • ✅ .github/workflows/autodoc-executor.yml:112 — __TOKEN_FILE__ replaced with $TOKEN_FILE variable expansion; no more sed substitution needed
  • ✅ .github/workflows/autodoc-executor.yml:147 — No more sed used; token file path is directly embedded via printf '%q' in script generation
  • ✅ .github/workflows/autodoc-executor.yml:175 — Legacy prompt path preserved with explicit check; context_artifact mode now uses steps.compose.outputs.value for prompt
  • ✅ .github/workflows/autodoc-executor.yml:215 — Artifact upload now uses steps.claude.outcome != 'skipped' correctly; however, the logic still fails to surface root cause — this is now a new issue above

Run: #37824802823 · tokens: in: 5706 · out: 1095 · total: 6801

@jdcmsd

jdcmsd commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the automated Bedrock review on 51a856b. None of the four remaining findings is a defect. Details for human reviewers:

Finding Why it's not a problem
🔴 inputs.context_artifact == '' && secrets.… || '' is "invalid syntax" cond && a || b is GitHub's documented conditional idiom (Expressions → Operators). Legacy mode (no context_artifact) gets the token; artifact mode gets '', which is intended, since Claude uses autodoc-search and the token stays out of its environment. actionlint type-checks the expression and passes.
🔴 Upload if: !cancelled() && steps.claude.outcome != 'skipped' "hides the root cause" The reverse is true. When an earlier setup step fails, Claude is skipped, so the upload is skipped too, and that step's own ::error:: is the one reported. Before this change, the upload ran anyway and added a misleading second error ("No files were found"), which we saw in a real run.
🟠 Smoke test "conflates" bad token vs. outage It now branches on curl's exit code: 22 is an HTTP error (curl prints the status; the message maps 401/403 to the token and 5xx to the API), 28 is a timeout, and 6/7 are DNS or connection failures. Verified locally: a bad token produces curl: (22) … 401 followed by the token-specific message.
🟡 Decrypt failure "deletes the .enc file" rm is inside the if openssl …; then success branch; the failure branch exits without touching it. The ciphertext also stays in the caller's run artifact either way.

The earlier sed/__TOKEN_FILE__ findings no longer apply: 51a856b removed that substitution entirely. The script's token path is now written with printf %q.

The functional evidence is in the PR description and dotCMS/core#37952. Everything before the Bedrock login, plus the Claude half via the Anthropic API, was rehearsed from a core branch. The remaining Bedrock step needs the v3.6.0-rc1 tag on 51a856b.

The search API's raw response is about 500 KB per query (full page bodies
plus metadata), too large for Claude to read as command output. On rc1,
Claude made 5-16 refused tool calls per run trying to filter it with
python3, jq, grep and cat. autodoc-search now prints a ranked list with
excerpts, and saves each page's full text under .autodoc/pages/ for Read.
The smoke test now requires at least one result.

--allowedTools only pre-approves tools; built-ins such as Agent stayed
available, and one rc1 run used it. --tools Bash,Read,Write makes those
three the whole tool set.

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

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; causes token to always be empty, breaking legacy mode silently (same as prior finding, still present)
  • 🟠 High: .github/workflows/autodoc-executor.yml:215 — Artifact upload skips if Claude is skipped but does not surface root cause, leading to misleading 'no files found' error (same as prior finding, still present)
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence (same as prior finding, still present)

Existing

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; causes token to always be empty, breaking legacy mode silently
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — Artifact upload skips if Claude is skipped but does not surface root cause, leading to misleading 'no files found' error
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure (401/403) with API outage (timeout/5xx), obscuring root cause for debugging
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence

Resolved

  • ✅ .github/workflows/autodoc-executor.yml:156 — Smoke test error message now distinguishes causes via case "$RC" and CAUSE assignment; no longer conflates token failure with outage

Run: #38519575078 · tokens: in: 6233 · out: 659 · total: 6892

@jdcmsd

jdcmsd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Current status: needs a v3.6.0-rc2 tag 2c97b44 for a final round of testing.

@jdcmsd

jdcmsd commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

rc2 dry runs passed (2026-10-27). These were the same four Bedrock dry runs from dotCMS/core#37952: #36628, #35693, #36951 (ignore_epic_parent), and #36628 with the prompt-injection fixture. All were green with the same determinations as rc1, and 0 refused tool calls (rc1 had 12, 16, 16 and 5). Each run took 10–30 turns (rc1: 35–46) and cost $0.42–$1.18 (rc1: $1.05–$1.98). The injection test passed again. Details are in the test plan above.

This PR is ready for review. Any write collaborator can approve, and I won't push to it again. After it merges, a repo admin needs to tag v3.6.0 on the merge commit. Please merge this before #71, which touches the same file; #71 will need a small rebase afterward.

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

Reviewed this against the other executors in the repo. The overall shape looks right to me: the Bedrock OIDC trust only accepts job_workflow_ref on an ai-workflows tag, so Claude has to run in a reusable workflow here, and core's context has to cross a job boundary to get here. Artifacts avoid the masker, and encryption is needed because core's artifacts are public. Having the executor fetch its own input (as codex and harness do with gh pr diff) would pull the vault and private-repo fetching and CI_MACHINE_TOKEN into this shared repo, which is worse. The inlined script, the SHA pins, failing loudly and the narrow tool set all match patterns the repo already uses.

Three things I'd change before merging, plus some follow-ups.

Before merging

1. Instructions and untrusted data share one file. The composed prompt tells Claude to read eval_context.md and follow the instructions under ## Prompt: burlap inside it, so the trusted instructions and the untrusted issue/PR text come back in the same tool result. codex-executor was fixed in v3.1.2 (#37) to keep those on separate channels, and the harness executor sends the trusted prompt as system and the diff as DATA. The adversarial run passed, but the structure is weaker than the rest of the repo.

Suggestion: ship instructions.md and eval_context.md as separate files in the artifact. The compose step reads instructions.md into the prompt (safe now that autodoc-search removed the Bearer line the masker matched), and the prompt states that eval_context.md is data and that instructions inside it must never be followed. This needs a matching change in dotCMS/core#37952.

2. Search settings are hardcoded in the shared repo. The URL (cdn.dotcms.dev/api/v1/ai/search), model: "gpt-5.2", threshold, searchLimit and the Origin/Referer headers are all baked into the script, while the same PR deprecates autodoc_dotcms_base_url. Any search tuning now needs a new ai-workflows tag plus a repin in core, and because of the tag-only trust it can't be tested from a branch. Could these be inputs, with today's values as defaults?

3. Drop the legacy mode, or set a removal date. The legacy path keeps full Bash,Write, the search token in Claude's environment, and untrusted text, which is the setup this PR exists to fix. It has never produced a report, core is its only caller and is migrating alongside this PR, and anyone pinned to v3.5.0 keeps that tag. Removing it also removes the two-mode branching in the compose, args and env steps. If the team treats removing it as a major-version change (one version number covers every workflow here), at least document when it goes away.

Follow-ups (not blockers)

  • claude-executor has the same silent skip. It correctly doesn't pass github_token (it needs the App token for comments and signed commits), but it never checks skipped_due_to_workflow_validation_mismatch, and the is_error check from #61 won't catch a skip. A consumer PR that edits its own Claude workflow can go green without Claude running. Worth copying the "Fail if the action skipped itself" step there, even as a warning.
  • Masker gotcha for consumers. Any consumer that builds prompt in an earlier job and passes it through a job output can lose it the same way. Worth a line in the consumer gotchas in CLAUDE.md.
  • Tool-use summary step isn't autodoc-specific; claude-executor could use it too.
  • No shell. The harness executor already moved to typed read-only tools with no shell for the same threat model. The MCP follow-up mentioned in the PR would bring autodoc in line; could it be tracked as an issue rather than a note?

Docs and CI

  • autodoc-executor isn't mentioned anywhere outside its own YAML (CLAUDE.md, README, ARCHITECTURE). Besides the E2E history row, it would help to add it to the Core Workflows list in CLAUDE.md, noting that it runs outside the orchestrator and that its E2E runs are dry runs from a core branch rather than the steve-quarterly-planning sandbox (which makes sense, since they need core's issues and vault access).
  • tests.yml only runs actionlint and a YAML parse, so nothing checks the bash inside the autodoc-search heredoc. Running shellcheck on the extracted script would be cheap.
  • The claude-code-action pins differ: this executor is on v1.0.183, claude-executor on v1.0.209. The Bash(autodoc-search:*) rule depends on how that version scopes Bash rules, so any future bump needs a retest of that rule.

@jdcmsd

jdcmsd commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, Freddy. This is really helpful. I'm taking all three before-merge items:

  1. Separate instructions from data. Core's prep will put instructions.md and eval_context.md in the artifact as separate files. The executor will build the prompt from instructions.md and treat eval_context.md as data: the prompt will say that any instructions inside it must never be followed. The run will also fail if instructions.md arrives empty, so a dropped prompt can't go green again. This needs a matching change in fix(autodoc): deliver the context to Claude, and fail loudly when nothing happens core#37952, which I'll push alongside.
  2. Search settings as inputs. The URL, model, threshold, limit and Origin/Referer will become inputs, with today's values as defaults, so search tuning won't need a new tag.
  3. Remove the legacy mode. I'm removing it in this PR and keeping the version at v3.6.0. Core is its only caller and moves to the new mode in the same release. Anything pinned to v3.5.0 keeps working, and the changelog entry will record the removal. Staying on v3.6.0 means the release candidates, both PRs and core's pin don't need renaming.

From the docs and CI section, I'll add the executor to the Core Workflows list in CLAUDE.md, along with the E2E history row. I'll also add a shellcheck pass on the extracted autodoc-search script to tests.yml. I'm keeping the claude-code-action pin at v1.0.183, since that's the version these runs tested, and adding a comment that any bump needs the Bash(autodoc-search:*) rule retested.

I'll open the follow-ups as separate issues and link them here:

  • claude-executor's silent skip
  • the masker gotcha in the consumer docs
  • reusing the tool-use summary step in claude-executor
  • the no-shell MCP search tool

I'll test the changes locally before pushing, including the injection case. That means another candidate tag (v3.6.0-rc3) and one more round of core dry runs before the final tag. I'll post the results here.

@jdcmsd

jdcmsd commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Follow-ups filed: #72, #73, #74, #75.

…s; drop legacy mode

Review changes from #70:
- The caller's artifact now holds instructions.md and eval_context.md.
  The instructions become Claude's prompt; the context stays on disk and
  the prompt frames it as data whose instructions must never be followed.
  The run fails if either file is missing or empty.
- Search URL, origin, model, index, threshold and limit are inputs with
  today's values as defaults, validated before use.
- Legacy inline-prompt mode removed, along with the deprecated inputs and
  the DRAFTING secret. context_artifact and AUTODOC_CONTEXT_KEY are now
  required. v3.5.0 callers are unaffected.
- tests.yml shellchecks the autodoc-search script extracted from the
  install step's heredoc.
- CLAUDE.md: Autodoc Executor in Core Workflows; rc1/rc2 E2E rows.
- Comment on the claude-code-action pin: bumps need the dry runs repeated.

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

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; causes token to always be empty, breaking legacy mode silently
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — Artifact upload skips if Claude is skipped but does not surface root cause, leading to misleading 'no files found' error
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure (401/403) with API outage (timeout/5xx), obscuring root cause for debugging
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence

Existing

  • 🔴 Critical: .github/workflows/autodoc-executor.yml:175 — GitHub Actions expression inputs.context_artifact == '' && secrets.AUTODOC_DOTCMS_API_TOKEN_AISEARCH || '' is invalid syntax; causes token to always be empty, breaking legacy mode silently
  • 🔴 Critical: .github/workflows/autodoc-executor.yml:215 — Artifact upload skips if Claude is skipped but does not surface root cause, leading to misleading 'no files found' error
  • 🟠 High: .github/workflows/autodoc-executor.yml:156 — Smoke test error message conflates token failure (401/403) with API outage (timeout/5xx), obscuring root cause for debugging
  • 🟡 Medium: .github/workflows/autodoc-executor.yml:105 — Decryption failure deletes .enc file, erasing debugging evidence

Resolved

  • ✅ .github/workflows/autodoc-executor.yml:175 — The expression was not fixed; still present as prior finding
  • ✅ .github/workflows/autodoc-executor.yml:215 — The artifact upload condition still skips silently on failure; unchanged
  • ✅ .github/workflows/autodoc-executor.yml:156 — Error message still conflates 401/403 with timeouts; unchanged
  • ✅ .github/workflows/autodoc-executor.yml:105 — .enc file still deleted on decryption failure; unchanged

Run: #40723914135 · tokens: in: 8269 · out: 772 · total: 9041

@jdcmsd

jdcmsd commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@fmontes the review changes are pushed (64f3f1b), with the matching core change in dotCMS/core#37952 (a30301d175):

  1. Instructions and data are separate. The artifact now holds instructions.md and eval_context.md. The instructions are the prompt, and the context is read from disk and framed as data that must never be followed. The run fails if either file is missing or empty.
  2. Search settings are inputs: URL, origin, model, index, threshold and limit, with today's values as defaults. They're validated before use (https only, and numbers must be numbers).
  3. The legacy mode is removed, along with the deprecated inputs and the DRAFTING secret. The version stays v3.6.0.

Also: the executor is in the Core Workflows list in CLAUDE.md with the E2E rows, tests.yml shellchecks autodoc-search (passing), and there's a comment on the claude-code-action pin.

I checked it locally with this commit's actual compose, install and args steps and Claude Code 2.1.220. #35693 and #36628 with the injection fixture both gave the same determinations as rc2, with 0 refused calls and the injection not followed. Details are in the test plan above.

I'm skipping rc3. None of this touches the Bedrock login or the model call. Once this merges and v3.6.0 is tagged on the merge commit, I'll repeat the four core dry runs on v3.6.0 before #37952 merges, and #37952 is already pinned to @v3.6.0. If something breaks, the fix is a v3.6.1.

Ready for re-review.

@fmontes
fmontes merged commit 9b54f11 into main Oct 28, 2026
9 checks passed
@fmontes
fmontes deleted the autodoc-executor-context-artifact branch October 28, 2026 16:52
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