Repository navigation
feat(autodoc-executor): read context from an encrypted artifact; restrict Claude tools (v3.6.0) - #70
Conversation
…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>
🤖 Bedrock Review —
|
- 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>
🤖 Bedrock Review —
|
…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>
🤖 Bedrock Review —
|
…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>
🤖 Bedrock Review —
|
|
Triage of the automated Bedrock review on
The earlier sed/ 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 |
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>
🤖 Bedrock Review —
|
|
Current status: needs a |
|
rc2 dry runs passed (2026-10-27). These were the same four Bedrock dry runs from dotCMS/core#37952: #36628, #35693, #36951 ( 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 |
fmontes
left a comment
There was a problem hiding this comment.
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 checksskipped_due_to_workflow_validation_mismatch, and theis_errorcheck 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
promptin 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-executorisn'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 thesteve-quarterly-planningsandbox (which makes sense, since they need core's issues and vault access).tests.ymlonly runs actionlint and a YAML parse, so nothing checks the bash inside theautodoc-searchheredoc. 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.
|
Thanks, Freddy. This is really helpful. I'm taking all three before-merge items:
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 I'll open the follow-ups as separate issues and link them here:
I'll test the changes locally before pushing, including the injection case. That means another candidate tag ( |
…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>
🤖 Bedrock Review —
|
|
@fmontes the review changes are pushed (
Also: the executor is in the Core Workflows list in CLAUDE.md with the E2E rows, 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 Ready for re-review. |
Summary
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_artifactplus secretAUTODOC_CONTEXT_KEY, both required). It holds two files:instructions.mdis the task prompt, written by the caller's workflow. It becomes Claude's prompt.eval_context.mdis 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-searchcommand. 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/forRead. 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_thresholdandsearch_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,ReadandWrite(--tools), with Bash allowed only forautodoc-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.ymlnow shellchecks theautodoc-searchscript, which actionlint can't see inside its quoted heredoc.Why
Diagnostic runs in dotCMS/core on 2026-10-08 established three things.
Skip output 'eval_context' since it may contain secret). The prompt's curl exampleAuthorization: Bearer $AUTODOC_…matches the masker's Bearer pattern: the same context minus that line got through intact, andBearer placeholderalone was dropped. So the executor receivedprompt: "", the action loggedNO 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.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'sGH_TOKEN, next to unrestricted Bash and untrusted issue text. Claude needs no GitHub access here, so the job's owncontents: readtoken is passed instead. This also skips the exchange.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
promptinput (the v3.5.0 legacy mode) and the deprecatedautodoc_dotcms_site_folderandautodoc_dotcms_base_urlinputs andAUTODOC_DOTCMS_API_TOKEN_DRAFTINGsecret. The legacy mode never produced a report, and it ran with fullBash,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.0keeps working. The version staysv3.6.0; the v3.6.0 release notes should record the removal.Test plan
actions/download-artifact@3e5f45b…resolved to commitv8.0.1via the documented procedure; other pins are unchanged from mainautodoc-searchrun locally against the live API: results returned, empty query exits 2, quotes in queries are safev3.6.0-rc1cut on51a856b@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.2c97b44. (1) Claude made 5–16 refused tool calls per run, trying to filter search output. (2) One run used the Agent tool, which--allowedToolsdoesn't remove.python3/cat/jqattempts, 2 refused, 18 turns. Formatted search: 0 refused, 11 turns, same determination.Results: 0and a visible failure).v3.6.0-rc2cut on2c97b44; 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.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:none(same as rc2), 0 refused calls, 7 turns, $0.63.none(same as rc2), injection not followed, no canary, 0 refused calls, 10 turns, $0.63.Readon the context and saved pages,autodoc-search,Write. Nothing else.instructions.mdoreval_context.mdstops the run.search_url, an origin with a path, a non-numeric threshold and a zero limit are each rejected.autodoc-searchscript passes shellcheck (the same extractiontests.ymlruns)v3.6.0on the merge commit, then repeat the four core dry runs on it before #37952 mergesNotes for reviewers
be7b93b, Claude Code 2.1.220) includes the fix for scoped Bash rules being widened, whichBash(autodoc-search:*)relies on. A comment on the pin says any bump needs the core dry runs (includinginject_test) repeated.cd,grep) regardless of--allowedTools, so Bash isn't strictlyautodoc-search-only. Replacing it with a typed search tool is autodoc-executor: replace the Bash search wrapper with a typed search tool (no shell) #75.Readis allowed, so Claude could read the search token file. The caller's finalize refuses to post a report containing any autodoc secret. The token is read-only search access.v3.6.0directly and dry-run it from core before #37952 merges. If something breaks, the fix is av3.6.1, which is no worse than an rc3.🤖 Generated with Claude Code