Skip to content

fix: isolate assist publication credentials - #479

Merged
steipete merged 5 commits into
mainfrom
fix/assist-token-isolation
Jul 11, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/assist-token-isolation

Conversation

@steipete

@steipete steipete commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • split untrusted Codex assist generation from a fresh, ephemeral publisher; scope both GitHub App tokens to the configured repository and pin publisher code to the triggering workflow SHA
  • validate a bounded, strict artifact bound to the workflow run, request, target revision, source comment, PR head, and stable prompt context; recheck live state immediately before the single GitHub mutation
  • make publication retry-safe and idempotent, and categorically prevent assist/visual output from being routed back into ClawSweeper commands

Live findings fixed

  • exact-head live publication initially failed because the publisher token had issue-write but only pull-request-read; the trusted publisher now requests pull-request-write while the model job remains read-only
  • identical successful runs initially produced different markers when material prompt context drifted; retry identity now uses stable request identity while live revision/context bindings remain mandatory stale-publication guards
  • fresh exact-head review found generated publication text could still enter the fast webhook acknowledgement/dispatch path; webhook ingestion now applies the shared publication guard before command matching, with no-request coverage proving no acknowledgement or dispatch

Validation

  • pnpm -s build
  • pnpm run build:repair
  • focused assist/context/router/webhook suite — 170 passed
  • pnpm run lint:src
  • pnpm run lint:repair
  • pnpm run lint:scripts
  • pnpm run format:check
  • actionlint .github/workflows/assist.yml
  • branch-wide autoreview — clean; no accepted/actionable findings
  • dependency freshness — no outdated packages; audit reports 0 vulnerabilities

pnpm run check reaches the same three macOS harness failures reproduced from an archived clean current-main snapshot: two Bash 3.2 lowercase-expansion cases and one coverage-tail fixture. Exact-head hosted Linux CI is green.

Exact-head live proof

Exact head: 7d3b4834b62f36803bb1a52ee4273128a853aed4

Both final runs used the same idempotency key. The first publisher reported action: posted; the retry reported action: updated; exactly one marker-backed assist comment remains at the same comment ID. Each run shows the read-only token in the generation job, bounded artifact upload/download and validation, and the fresh write token only in the separate trusted publisher job.

The earlier failed publication run is retained as root-cause proof: https://github.com/openclaw/clawsweeper/actions/runs/29154425050

@steipete
steipete requested a review from a team as a code owner July 10, 2026 12:00

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4257f83a1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/assist-artifact.ts
throw new Error(
`unsupported assist artifact schema version: ${String(artifact.schema_version)}`,
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove duplicate repo declaration

When src/assist-artifact.ts is included by tsconfig.json, this second const repo is in the same block as the declaration on the previous line, so the module is rejected before the build/tests or assist workflow can start. This makes every pnpm run build/workflow setup fail; drop the duplicate declaration.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 11, 2026, 10:07 AM ET / 14:07 UTC.

Summary
The PR separates untrusted assist generation from trusted comment publication, validates a bounded artifact against live GitHub state, makes publication retry-safe, and prevents generated assist or visual comments from entering command-routing paths.

Reproducibility: yes. at source level. Current main gives issue-write permission to the workflow that performs model generation, and the earlier reviewed branch left command-bearing generated publications eligible for fast webhook routing; these paths are explicit in source, although current main was not mutated to exercise them.

Review metrics: 4 noteworthy metrics.

  • Changed surface: 11 files, +1631/-105. The security change spans workflow permissions, artifact validation, publication, routing, schema, documentation, and regression tests.
  • Credential boundary: 1 read-only generator, 1 trusted publisher. Untrusted generation is separated from the only job capable of writing GitHub comments.
  • Exact-head assist proof: 2 successful runs, 1 owned comment. The final head posted and then updated the same marker-backed comment while exercising validation and idempotency.
  • Current-head checks: 4 core checks successful. The full pnpm check, Windows launcher test, and both CodeQL analyses passed on the reviewed head.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The exact-head live proof exercises pull-request comment publication; issue-target publication is covered by source and tests rather than a separate live demonstration.
  • [P1] The trusted publisher intentionally receives repository-scoped issue and pull-request write permissions, so future changes must preserve artifact validation and immediate live-state revalidation.

Maintainer options:

  1. Merge the proven head (recommended)
    Accept the reviewed boundary change now that the exact head is cleanly mergeable, fully checked, and proven through successful live publication and retry runs.
  2. Request issue-path proof
    Delay merge only if maintainers require a separate live issue-comment publication run beyond the existing tests and pull-request proof.

Next step before merge

  • [P2] No repair work remains; the exact reviewed head is cleanly mergeable, fully checked, and ready for normal maintainer merge handling.

Security
Cleared: The current-head patch enforces least-privilege generation and strictly validates untrusted output before the only write-capable publication step.

Review details

Best possible solution:

Merge the exact reviewed head and retain the read-only generator, bounded artifact contract, single trusted publisher, immediate stale-state checks, and publication-marker filtering as one security boundary.

Do we have a high-confidence way to reproduce the issue?

Yes at source level. Current main gives issue-write permission to the workflow that performs model generation, and the earlier reviewed branch left command-bearing generated publications eligible for fast webhook routing; these paths are explicit in source, although current main was not mutated to exercise them.

Is this the best way to solve the issue?

Yes. Repository-scoped read-only generation, a strict bounded artifact, fresh narrow publisher credentials, immediate live-state revalidation, retry-safe ownership, and pre-routing publication filters are the narrowest coherent least-privilege solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 483cc21ca765.

Label changes

Label changes:

  • add merge-risk: 🚨 security-boundary: Merging changes where GitHub write credentials are minted and how untrusted model output crosses into trusted publication.
  • add merge-risk: 🚨 automation: Merging replaces the assist artifact handoff, live validation, retry identity, comment publication, and generated-comment routing behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient. Exact-current-head runs prove bounded artifact validation, trusted publication, retry-safe updating, and suppression of a visible generated ClawSweeper command suggestion.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.

Label justifications:

  • P1: This PR urgently hardens a live automation path where untrusted generated output previously shared a workflow with write-capable publication credentials.
  • merge-risk: 🚨 security-boundary: Merging changes where GitHub write credentials are minted and how untrusted model output crosses into trusted publication.
  • merge-risk: 🚨 automation: Merging replaces the assist artifact handoff, live validation, retry identity, comment publication, and generated-comment routing behavior.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • proof: sufficient: Contributor real behavior proof is sufficient. Exact-current-head runs prove bounded artifact validation, trusted publication, retry-safe updating, and suppression of a visible generated ClawSweeper command suggestion.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: Current-main history shows repeated merged work introducing and maintaining the assist workflow, webhook classifier, command router, and central automation implementation. (role: feature owner and recent area contributor; confidence: high; commits: 76360b98742b, f4b714d0867e, 7ee8bb2b00c0; files: .github/workflows/assist.yml, src/clawsweeper.ts, src/repair/comment-router-core.ts)
  • Matt Van Horn: Recent merged work modified event records and review-lease behavior in the same repair routing area. (role: recent adjacent contributor; confidence: medium; commits: ef7a067f7170; files: src/repair/comment-router-core.ts, src/repair/comment-webhook.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (6 earlier review cycles)
  • reviewed 2026-07-10T12:05:26.284Z sha 4257f83 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T12:21:12.296Z sha 0ff6ea2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T12:26:00.674Z sha 0ff6ea2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T12:42:41.781Z sha b5d454b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T13:48:43.912Z sha 3a54187 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T13:54:28.391Z sha 3a54187 :: needs changes before merge. :: [P2] Filter assist publications before webhook dispatch

@steipete
steipete force-pushed the fix/assist-token-isolation branch 2 times, most recently from 0ff6ea2 to b5d454b Compare July 10, 2026 12:37
@steipete
steipete force-pushed the fix/assist-token-isolation branch from b5d454b to b198eb8 Compare July 11, 2026 13:30
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Jul 11, 2026
@openclaw openclaw deleted a comment from clawsweeper Bot Jul 11, 2026
@openclaw openclaw deleted a comment from clawsweeper Bot Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a54187d2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

comment: LooseRecord,
{ trustedAuthors = new Set() }: LooseRecord = {},
) {
if (isAssistPublicationCommentBody(String(comment?.body ?? ""))) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Filter assist publications before webhook dispatch

When an assist/visual answer contains a visible command such as /review or @clawsweeper automerge, this guard only protects the scheduled router path. The fast webhook classifier in src/repair/comment-webhook.ts still checks only proof-nudge markers before running COMMAND_PATTERN/parseCommand, so accepted issue_comment events for ClawSweeper's own assist publication can still get an ack/reaction and dispatch a command-router run, which violates the new “never routes assist output” boundary. Reuse this predicate in webhook classification before the command-pattern check.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact head 3a54187d2ee5bdb7e94c18eca3df647d0e2ad582 now has real behavior proof. Final runs https://github.com/openclaw/clawsweeper/actions/runs/29154716573 and https://github.com/openclaw/clawsweeper/actions/runs/29154767497 show read-only generation, bounded artifact handoff/validation, and a fresh write token only in the separate trusted publisher. Both used the same retry identity: first posted, second updated; exactly one owned assist comment remains at #479 (comment). Hosted CI and CodeQL are green; branch-wide autoreview is clean.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 11, 2026
@clawsweeper clawsweeper Bot removed merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient Contributor real behavior proof is sufficient. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper assist: The remaining proof is a fresh correctness review of the current head 7d3b4834b62f36803bb1a52ee4273128a853aed4, specifically confirming that the new webhook-level filtering fully resolves the P2 command-routing finding. The existing live behavior, hosted CI, and CodeQL proof applies to the prior head 3a54187d2ee5bdb7e94c18eca3df647d0e2ad582.

Evidence:

Suggested next action: Run @clawsweeper review on #479 for the current head.


Source comment: unknown
Assist reasoning: high.

@openclaw openclaw deleted a comment from clawsweeper Bot Jul 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact head 7d3b4834b62f36803bb1a52ee4273128a853aed4 closes the reported fast-webhook ingress gap before command matching. Focused tests prove command-bearing assist/visual publications make zero GitHub requests, so they receive no acknowledgement or dispatch; fresh autoreview is clean. Final runs https://github.com/openclaw/clawsweeper/actions/runs/29155314306 and https://github.com/openclaw/clawsweeper/actions/runs/29155375862 show read-only generation, bounded artifact handoff/validation, and a fresh write token only in the separate trusted publisher. Both used the same retry identity: first posted, second updated; exactly one owned assist comment remains at #479 (comment). Hosted CI is https://github.com/openclaw/clawsweeper/actions/runs/29155304737 and CodeQL is green at https://github.com/openclaw/clawsweeper/actions/runs/29155304722.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@steipete
steipete merged commit 8891c32 into main Jul 11, 2026
20 checks passed
@steipete
steipete deleted the fix/assist-token-isolation branch July 11, 2026 14:09
@steipete

Copy link
Copy Markdown
Contributor Author

Landed as 8891c32.

Final reviewed head: 7d3b4834b62f36803bb1a52ee4273128a853aed4

Local pnpm run check retained the three macOS harness failures reproduced unchanged from clean current-main; hosted Linux CI and Windows coverage passed on the exact head.

azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
* fix: isolate assist publication credentials

* test: pin assist reasoning binding

* fix: grant assist publisher pull request writes

* fix: stabilize assist retry identity

* fix: block generated webhook commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 Urgent regression or broken agent/channel workflow affecting real users now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant