Skip to content

refactor: import GitHub execution and context directly - #1905

Merged
obviyus merged 2 commits into
mainfrom
cleanup/row3-github-imports
Oct 10, 2026
Merged

obviyus merged 2 commits into
mainfrom
cleanup/row3-github-imports

Conversation

@obviyus

@obviyus obviyus commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Authority-separation repair and current proof

Current head: 271e40eec00ed12dc45ee5e91a3ac3a45b84de74. The hosted security concern was an evidence gap; no publication-authority bypass was found. The real apply owner still selects the restricted runner for every mutation request, including retries. The CodeQL alert is fixed rather than dismissed.

Native macOS arm64, Node v24.21.0; Pueue 1716 runs the real node dist/clawsweeper.js apply-decisions with temporary report/closed directories, --skip-dashboard, and executable GitHub/coordinator fixtures. A read-only Node load hook adds an observation callback immediately after the real apply owner installs its unchanged runner. The callback supplies forbidden mutation attempts through ghObservedMutationCommand; it does not substitute a permissive apply callback. The ordinary allowed comment is then published by the unmodified apply workflow.

Required proof Observed result
Allowed record_comment_only publication All three apply subprocesses exit 0; executable GitHub fixture records the ordinary review-comment write.
Comment-only principal attempts close and label mutation Both rejected with manual publication forbids this mutation; zero forbidden GitHub mutation dispatches.
Expired authority before retry First request reaches GitHub and returns HTTP 502; authority then returns HTTP 409. Retry is denied before a second GitHub dispatch.
Reassigned authority before retry Same boundary, independently replayed with reassigned authority: HTTP 409 prevents the second GitHub dispatch.
Overlapping restricted apply and review receipt scopes Review's pending null-runner scope remains open while the real apply runner rejects both close and label writes; four denials per run (isolated and overlapping), zero forbidden transports.
Receipt-isolation base failure On main f58fc2d9, successful imports, sequential control and four executable PATCH requests precede the failing overlap assertion: receipts [[], [command_1, command_2]]. Candidate returns [[command_1], [command_2]].
Real coordinator fencing Three Worker tests pass, including current lease/run/attempt ABA+expiry and manual batch member/owner fencing (Pueue 1713).

Redacted trace (synthetic item identity; no credentials, IPs or private endpoints):

apply owner installed restricted runner
item_close:321 -> denied before transport
issue_label_add:321:security -> denied before transport
review receipt scope -> active, null runner
item_close:321 -> denied before transport
issue_label_add:321:security -> denied before transport
apply receipt scope -> restricted runner retained
publication authority -> current, HTTP 200
GitHub attempt 1 -> HTTP 502
publication authority -> expired [or reassigned], HTTP 409
GitHub attempt 2 -> NOT DISPATCHED
ordinary apply review-comment publication -> succeeded

Retained drivers and raw traces: ~/Developer/.agents/handoffs/clawsweeper-row3/1905-authority/ (run.mjs, preload.mjs, head-271e40eec/, receipt-overlap-negative-control.mjs, receipt-overlap-sMyyRl/, validation-logs.json). The baseline fails specifically at overlapping commands must retain their own mutation receipt runner, not an import or fixture failure; both sequential controls and all four executable requests pass.

Limits: controlled executable transports, not live GitHub writes or a deployed coordinator. The overlapping review side exercises the production command receipt-scope owner, not a full model-backed review; the restricted side is the actual apply owner. Coordinator HTTP 409 replay and the real Worker ABA/expiry tests are complementary, not a claim of a deployed end-to-end queue call. No live apply, merge or deployment occurred. Early fixture setup failures (missing reviewed revision/lease tuple and invalid short head SHA) were corrected before the retained successful run; no production authority guard was weakened.

CodeQL disposition and validation

The failed check annotation at candidate line 628 is “Polynomial regular expression used on uncontrolled data.” Archived main has the identical expression at line 621. This explains the moved-line attribution but does not excuse the alert: replace the backtracking expression with fixed-prefix parsing, whitespace trimming and explicit line-terminator checks. Runtime-to-ETag-broker cases preserve case-insensitive headers, duplicate-header precedence, empty/whitespace-only behavior, long whitespace prefixes and malformed line terminators.

  • pnpm run build:all: passed (Pueue 1708, before the test-fixture-only correction).
  • 76 focused tests passed: ETag broker/parser, action ledger/receipt isolation, manual publication authority (Pueue 1715).
  • pnpm run lint and pnpm run format:check: passed (Pueue 1715).
  • codex review --base origin/main: no actionable defects; its independent build and 114 focused tests also passed (Pueue 1715).
  • One new test initially returned HTTP headers when runtime had not requested -i; fixed the executable fixture to honor the real invocation before the successful run.

OpenClaw Bay is unaffected: no observer payload, schema or status contract changes. Merge danger is a two-way door (revert restores the former implementation); blast radius is command mutation-runner selection and durable ETag cache-key parsing. Hosted CodeQL/CI for this new head remain to be observed.

Summary

Row 3 slice 4b, now rebased onto origin/main (f58fc2d9de10b383b9f6505f157c53f73bef6472) after #1898 was squash-merged. The original refactor commit is c6bfa988958fb868ef1e89184084ebcbe341ae9d; the authority-proof/CodeQL repair head is recorded above.

  • Remove createGitHubExecution, createGitHubContext, and the test-only execution wrappers; production, tests and proof callers use plain imports.
  • Keep repository-qualified activity-cursor fallbacks in the command-lifetime GitHub data scope and mutation receipt runners in their separate review/apply command scope.
  • Remove unused injected mutation request/prepare/sleep callbacks and the one-use wrapper, preserving request admission and accepted/rejected/unknown accounting.
  • Rebase resolution preserves main's complete-timeline callback in the exported pagination owner, without reintroducing a factory or adapter. The newly inherited legacy inline-comment test now uses real executable-gh fixtures, including the real --paginate --slurp output shape and isolated per-case cleanup.

No schema, stored-format or Bay contract change. No new production adapters.

Previous-head shipped-CLI equivalence proof

Claim: direct imports preserve repository routing, JSON parsing, retry behavior, terminal throttling, requests and credential selection.

Driver: ~/Developer/.agents/handoffs/clawsweeper-row3/github-cli-revision-proof.mjs.

node ~/Developer/.agents/handoffs/clawsweeper-row3/github-cli-revision-proof.mjs \
  ~/Developer/.worktrees/clawsweeper/refactor-typed-queue-client \
  ~/Developer/.worktrees/clawsweeper/cleanup-row3-github-imports \
  ~/Developer/.agents/handoffs/clawsweeper-row3/slice4b-restack-proof

The baseline executable has main's GitHub runtime/context at f58fc2d9de10b383b9f6505f157c53f73bef6472 (built in the queue-part-2 worktree; its additional queue commands do not participate in this CLI). Candidate is the head above. 8/8 actual node dist/clawsweeper.js reserve-review-lease subprocess comparisons passed, with identical stdout, exit status, request traces and error classes:

Scenario, for both OpenClaw and ClawHub Exit Requests Result
Closed item 0 1 superseded / item_not_open
Transient first response 0 2 same
Malformed first JSON 0 2 same
Terminal throttle 1 1 GitHubRateLimitError

Full arm traces and summary: ~/Developer/.agents/handoffs/clawsweeper-row3/slice4b-restack-proof/ (Pueue 1675).

Previous-head validation

Pueue 1675, native macOS arm64, Node v24.21.0:

  • pnpm run build:all passed.
  • 302/302 focused tests passed, covering GitHub runtime/deadlines/ETags/credentials/circuits, context, mutation receipt isolation, action ledger, apply budgets, close reasons, review blob hydration and batch callers.
  • node scripts/e2e/ci-comment-read-budget.mjs, its --inline mode, graphql-activity-cursor-v2-loopback.mjs, and publication-quota-budget.mjs passed.
  • pnpm run lint and pnpm run format:check passed.
  • codex review --base origin/main: no actionable defects; reviewer also passed 87 focused tests and the GraphQL loopback check.
  • Eight shipped-CLI equivalence cases passed.
  • Linux node:24.21.0-bookworm, network disabled: docs/proof/hydration-deadline/run-proof.mjs --source-root <current-worktree> --expected-head c6bfa988958fb868ef1e89184084ebcbe341ae9d --expect candidate passed. Output: ~/Developer/.agents/handoffs/clawsweeper-row3/hydration-1905-restack/; result SHA-256 278e37981fe3e77c5631bc1609ddfdeae47b24ed39bd4b6ac42f58a2a65b940c.
  • Historical pre-deadline baseline replay also passed (Pueue 1660), output ~/Developer/.agents/handoffs/clawsweeper-row3/hydration-1905-restack-history/. The driver preserves independent SIGTERM, child exit/identity, no-metadata-response, no-fetch and missing-blob assertions; it observes the retry boundary's GitHubOperationDeadlineError and admitted deadline.

The initial restack exposed the inherited factory-based context test; it was migrated rather than restoring a compatibility factory. An intermediate run also observed an ETag fixture JSON parse failure; no ETag production change was made, and that test passed in the final 302-test run.

Limits: not the full suite; controlled transports do not measure production throughput or real quota accounting. The CLI fixture covers closed-item reservation, not lease creation or a deployed Worker. No live GitHub or Worker mutation occurred. No report-reading/retention changes, so the 80k report-memory proof is inapplicable. OpenClaw Bay is unaffected because no payload or status contract changes. Slice 5 remains separate. No merge or deployment is requested.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces GitHub execution and context factories with direct imports, isolates mutation runners by command, and removes backtracking from Accept-header parsing.

Example: Two overlapping commands PATCH issues 1 and 2.

  • Before: Shared runner state can record both writes in the second command’s receipts.
  • After: Each command records its own write while restricted apply mutations retain their authorization checks.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent ownership cutover with shipped-command authority evidence, meaningful executable regression coverage, and no actionable introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Current-head macOS arm64 Node 24 traces exercise the shipped apply-decisions command with the real restricted apply owner: ordinary comment publication succeeds, close/label attempts are denied during isolated and overlapping scopes, and coordinator expiry or reassignment prevents a second GitHub dispatch after HTTP 502. Controlled executable transports and an observation hook are disclosed; this does not establish deployed coordinator behavior or production throughput.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Shared mutation-runner ownership can mix command receipts, and factory wiring obscures the GitHub execution owner.
Reason: This completes the established ownership cleanup, removes the replaced factories, and supplies concrete isolation evidence without adding configuration or public contracts.

Merge readiness

✅ Ready for maintainer review

This PR remains useful work absent from current main; the updated authority traces resolve the previous review’s evidence gap, and no actionable introduced defect was found.

Priority: P3
Reviewed head: 271e40eec00ed12dc45ee5e91a3ac3a45b84de74

Before merge

None.

Findings

None.

Agent review details

How this fits together

Review and apply commands use the GitHub execution layer to turn context reads and guarded mutation requests into subprocess calls, parsed responses, and mutation receipts.

flowchart TD
  A[CLI command] --> B[Command data scope]
  A --> C[Mutation receipt scope]
  B --> D[GitHub context reads]
  C --> E[Apply authority checks]
  D --> F[GitHub execution]
  E --> F
  F --> G[GitHub transport]
Loading

Technical review

Best possible solution:

Land the direct-import cutover with command-local mutation ownership and the existing per-attempt authorization guards intact.

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

This is primarily a refactor; supplied base-versus-head executable traces additionally demonstrate overlapping receipt misattribution on the base and isolation on the candidate.

Is this the best way to solve the issue?

Direct imports remove the obsolete factories while command scopes preserve independent receipt ownership and existing transport, retry, and authority checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 70cfbb0677b2.

Provenance checked

  • Execution/context factories and runtime wiring changes intended behavior with a stated reason (6e7ed03: The earlier module extraction separated orchestration and GitHub execution while preserving command contracts; this PR retains those modules and removes their construction layer.)
  • Command data and activity fallback lifetime keeps the original intent (f58fc2d: The predecessor established isolated command data; repository-qualified fallback state now follows that lifetime without changing cursor fallback policy.)
  • Shared mutation runner selection changes intended behavior with a stated reason (unknown: The base prioritizes the apply runner over the review runner; the scoped git log -S search failed on a missing historical blob, so its earliest rationale remains unknown. The candidate explicitly replaces shared selection with command isolation and supplies a failing-base comparison.)
  • ETag Accept-header parsing changes intended behavior with a stated reason (dc67620: The durable ETag broker distinguishes media representations; the follow-up removes polynomial parsing while retaining representation-aware cache keys.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change and current-main comparison: The pinned introduced diff removes both factories and replaces shared mutation-runner variables with command scopes; fetched main still contains the factories and shared runner selection. (src/clawsweeper-github-execution.ts:31, 271e40eec00e)
  • Final-effect authority boundary: Every observed mutation attempt selects the current command runner; the unchanged restricted apply runner rejects forbidden identities and checks current coordinator authority before invoking transport. (src/clawsweeper-apply-decision-workflow.ts:663, 271e40eec00e)
  • Current-head authority proof: The captured body, source revision 224edd22003933bd6cb2e7c15e1a3d385a0a4bd1a62c2bd2217e4ed2b0989cde, supplies macOS Node 24 apply-decisions traces showing allowed comment publication, forbidden close/label rejection, overlapping scope isolation, and expiry/reassignment preventing retry dispatch; this addresses the request at refactor: import GitHub execution and context directly #1905 (comment). (271e40eec00e)
  • Predecessor and ownership direction: refactor: own GitHub runtime state per command #1898 merged command-lifetime GitHub data ownership and explicitly deferred execution/context factory removal to this PR; the candidate preserves that scope and keeps mutation-runner ownership separate. (src/clawsweeper-github-runtime.ts:66, f58fc2d9de10)
  • Parser repair and regression coverage: The follow-up replaces the Accept-header backtracking expression with prefix parsing and adds runtime-to-broker cases for duplicate headers, whitespace, long prefixes, and malformed terminators without changing the persisted cache contract. (src/clawsweeper-github-runtime.ts:628, 271e40eec00e)
  • History and inspection limits: Path history covers the earlier orchestration/module extractions, quota handling, activity snapshots, deadlines, and recent direct-import work. A scoped git log -S search encountered a missing promisor blob, leaving the earliest runner introduction unconfirmed; pinned base/head inspection remained available. (src/clawsweeper-github-execution.ts, 70cfbb0677b2)

Likely related people:

  • Ayaan Zaidi: Raw commit f58fc2d adds src/clawsweeper-github-runtime.ts:56 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f58fc2d9de10; files: src/clawsweeper-github-runtime.ts)
  • Peter Steinberger: Raw commit 74e5e42 adds src/clawsweeper-github-runtime.ts:44 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 74e5e42e80df; files: src/clawsweeper-github-runtime.ts)

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.

Label justifications:

  • P3: This is internal ownership cleanup with no established urgent production failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-10T15:00:50.178Z sha 0d278a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T15:19:04.156Z sha 721fa89 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T15:39:24.195Z sha c6bfa98 :: needs real behavior proof before merge. :: none

Reviewed October 10, 2026, 11:51 AM ET / 15:51 UTC (Revision 4).

@obviyus
obviyus force-pushed the cleanup/row3-github-runtime branch from 40f30d5 to 6f8ca66 Compare October 10, 2026 15:15
@obviyus
obviyus force-pushed the cleanup/row3-github-imports branch from 0d278a6 to 721fa89 Compare October 10, 2026 15:16
@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Base automatically changed from cleanup/row3-github-runtime to main October 10, 2026 15:23
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: refactor: import GitHub execution and context directly This is item 1/1 in the current shard. Shard 0/1.

This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@obviyus
obviyus force-pushed the cleanup/row3-github-imports branch from 721fa89 to c6bfa98 Compare October 10, 2026 15:34
@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and 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: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Oct 10, 2026
@obviyus
obviyus merged commit 0fc6d57 into main Oct 10, 2026
31 checks passed
@obviyus
obviyus deleted the cleanup/row3-github-imports branch October 10, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant