Skip to content

fix: keep projected GitHub reads out of ETag cache - #1242

Merged
steipete merged 1 commit into
openclaw:mainfrom
goutamadwant:fix/etag-projected-read-bypass
Aug 27, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
goutamadwant:fix/etag-projected-read-bypass

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1239

What Problem This Solves

Exact-publication apply runs could reuse a durable ETag body produced by a different GitHub output projection. A cached projected response could therefore omit requested reviewers or teams from a later close-safety read.

Why This Change Was Made

Projected gh api reads now bypass the durable ETag broker for jq and template output flags, including split, attached, compact, and clustered short-option forms. Full-resource GETs retain the existing durable cache path and cache-key contract.

User Impact

Pull requests with active requested reviewers or teams are no longer exposed to auto-close eligibility because another call site cached a differently projected body.

OpenClaw Bay Impact

OpenClaw Bay is unaffected. This changes apply-lane GitHub read admission only and does not alter Bay data contracts, status, or navigation.

Documentation Impact

No documentation update is required. The existing ETag broker contract remains unchanged; this narrows broker admission for response projections.

Evidence

  • node --version (v24.16.0)
  • pnpm run build:all
  • node --test test/github-etag-read-broker.test.ts (6/6 passed)
  • pnpm run check:static
  • pnpm run lint
  • git diff --check origin/main...HEAD
  • pnpm run check passed static checks, all builds, lint, and changed coverage before the exhaustive suite reached an unrelated local-review fixture that did not terminate; hosted CI remains authoritative for the full gate.

Real Behavior Proof

Claim

Projected GitHub reads execute their requested projection directly instead of consulting or replaying the durable ETag broker.

Exercised Surface

The built production createGitHubRuntime().ghWithPreparedTimeout() path under exact event publication, using real read-only gh api calls and an intentionally unreachable broker endpoint.

Scenario And Environment

Node 24 and GitHub CLI 2.92.0 read an existing public ClawSweeper pull request using split, attached, compact, and clustered projections. The broker endpoint was deliberately unavailable, so successful results demonstrate direct execution rather than broker fallback or replay.

Command

node --input-type=module <<'EOF'
import { spawnSync } from "node:child_process";
import { pathToFileURL } from "node:url";

const { createGitHubRuntime } = await import(
  pathToFileURL(`${process.cwd()}/dist/clawsweeper-github-runtime.js`).href,
);
Object.assign(process.env, {
  EXACT_EVENT_PUBLICATION: "true",
  EXACT_REVIEW_QUEUE_URL: "http://127.0.0.1:9",
  CLAWSWEEPER_WEBHOOK_SECRET: "proof-secret-placeholder",
  GITHUB_REPOSITORY: "openclaw/clawsweeper",
});

const invocations = [];
const runtime = createGitHubRuntime({
  ROOT: process.cwd(),
  targetRepo: () => "openclaw/clawsweeper",
  run: (command, args, options = {}) => {
    invocations.push([command, ...args]);
    const result = spawnSync(command, args, {
      cwd: options.cwd ?? process.cwd(),
      env: { ...process.env, ...options.env },
      encoding: "utf8",
      timeout: options.timeoutMs,
    });
    if (result.error) throw result.error;
    if (result.status !== 0) throw new Error(result.stderr.trim() || `exit ${result.status}`);
    return result.stdout.trim();
  },
});

const route = "/repos/openclaw/clawsweeper/pulls/1236";
const body = JSON.parse(runtime.ghWithPreparedTimeout(["api", route, "--jq", "{body: .body}"], 20_000));
const reviewers = JSON.parse(runtime.ghWithPreparedTimeout(["api", route, "--jq", "{requested_reviewers,requested_teams}"], 20_000));
const attached = JSON.parse(runtime.ghWithPreparedTimeout(["api", route, "--jq={state: .state}"], 20_000));
const compact = JSON.parse(runtime.ghWithPreparedTimeout(["api", route, "-q{state: .state}"], 20_000));
const clustered = runtime.ghWithPreparedTimeout(["api", route, "-iq", "{state: .state}"], 20_000);

console.log(JSON.stringify({
  brokerEndpointReachable: false,
  directGhInvocations: invocations.length,
  body: typeof body.body === "string",
  reviewerArrays: Array.isArray(reviewers.requested_reviewers) && Array.isArray(reviewers.requested_teams),
  attached: typeof attached.state === "string",
  compact: typeof compact.state === "string",
  clustered: clustered.includes("HTTP/") && clustered.includes('"state"'),
  productionMutations: 0,
}, null, 2));
EOF

Result

All five projected reads completed through direct GitHub CLI invocations and returned their requested shapes while the broker was unreachable. Production mutations: 0.

Recorded after-fix output for head c6c0908b99ff824a0a83abe922e0b4a7c136b1a4:

{
  "exactEventPublication": "true",
  "brokerEndpointReachable": false,
  "directGhInvocations": 5,
  "firstProjectionReturnedBody": true,
  "secondProjectionReturnedReviewerArrays": true,
  "attachedProjectionReturnedState": true,
  "compactProjectionReturnedState": true,
  "clusteredProjectionReturnedHeadersAndState": true,
  "productionMutations": 0
}

Limits

The live proof is read-only and did not run a live apply-decisions close attempt. Full-resource GET broker behavior remains covered by the existing focused tests.

Disclosure: AI was used to understand the codebase and review the fix.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 1:13 AM ET / 05:13 UTC.

ClawSweeper review

What this changes

The PR excludes jq and Go-template GitHub CLI output projections from the durable ETag cache and adds coverage for split, attached, compact, and clustered flag forms.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still allows projected GitHub CLI reads into the durable ETag broker. This narrow fix correctly bypasses that broker for jq/template projections, and the PR body supplies sufficient after-fix read-only CLI proof for the current head.

Priority: P1
Reviewed head: c6c0908b99ff824a0a83abe922e0b4a7c136b1a4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation, regression coverage, and recorded direct-runtime proof provide normal merge-ready evidence, subject to the stated quota trade-off.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body records an after-fix, read-only real GitHub CLI run on the current head: five projected reads returned their requested shapes while the configured broker endpoint was unreachable and no production mutation occurred.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body records an after-fix, read-only real GitHub CLI run on the current head: five projected reads returned their requested shapes while the configured broker endpoint was unreachable and no production mutation occurred.
Evidence reviewed 6 items Current-main defect remains: Current main only excludes include, pagination, and request-body flags from broker admission; jq/template projections can still receive an ETag cache key.
Requested-reviewer guard consumes a projection: The inactivity guard requests only requested reviewers and teams, so replaying another projection could suppress its active-review block.
Patch preserves the full-resource cache path: The new admission check returns no ETag key only for jq/template output forms; unprojected GETs continue into the existing broker path.
Findings None None.
Security None None.

Live Verification

Command: pnpm run build:all && node --test test/github-etag-read-broker.test.ts

Result: PASS (completed)

pnpm run build:all && node --test test/github-etag-read-broker.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-1242-A5el2m/target$ pnpm run build:all && node --test test/github-etag-read-broker.test.ts
pnpm run build:all && node --test test/github-etag-read-broker.test.ts
$ pnpm run build && pnpm run build:repair && pnpm run build:dashboard
$ tsc -p tsconfig.json
$ tsc -p tsconfig.repair.json
$ tsc -p tsconfig.dashboard.json
✔ ETag keys fence credential pool, media type, query, and page (1.830193ms)
✔ projected GitHub reads bypass the durable ETag broker (19.704035ms)
✔ durable broker revalidates every read and keeps wire calls while avoiding quota charges (1.276665ms)
✔ durable store confirms 304 bodies by ETag and digest and enforces bounds (9.442595ms)
✔ publisher HMAC endpoints persist and confirm bodies while operator scope is rejected (47.681791ms)
✔ dashboard health reads send If-None-Match and replay only after durable confirmation (20.819858ms)
ℹ tests 6
ℹ suites 0
ℹ pass 6
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 416.505964
runner@runnervm76f27:/tmp/clawsweeper-live-proof-1242-A5el2m/target$ pnpm run build:all && node --test test/github-etag-read-broker.test.ts
$ pnpm run build && pnpm run build:repair && pnpm run build:dashboard




























Assertions:

  • PASS expect_output: projected GitHub reads bypass the durable ETag broker

How this fits together

The apply lane reads GitHub metadata before deciding whether a proposal is safe to close. The durable ETag broker caches full API responses for quota efficiency, while projected output must remain specific to the caller’s requested fields for close-safety guards.

flowchart LR
A[Apply lane] --> B[GitHub CLI read]
B --> C{Output projection?}
C -->|jq or template| D[Direct GitHub response]
C -->|Full resource| E[Durable ETag broker]
D --> F[Close-safety guards]
E --> F
F --> G[Apply decision]
Loading

Before merge

  • Resolve merge risk (P1) - Projected reads will make unconditional GitHub API responses rather than reusable 304 validations, so maintainers should accept the bounded REST-quota trade-off and observe apply-lane egress telemetry after landing.
  • Complete next step (P2) - No repair-lane action is needed because the submitted PR has no actionable code finding.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused patch size runtime +19/-4; tests +53; 2 files affected The change is confined to broker admission and its focused regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1239
Summary: This PR is a concrete candidate fix for the projected-response cache collision reported by the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the bounded direct-read trade-off (recommended)
    Merge the projection bypass and monitor GitHub egress because it fixes close-safety correctness while replacing projected 304 validations with direct reads.
  2. Use projection-aware cache keys instead
    Replace the bypass with a versioned projection discriminator only if retaining projected-read quota savings is more important than keeping the current cache contract narrow.

Technical review

Best possible solution:

Land the narrow projection bypass, retain durable caching for full-resource GETs, and monitor apply-lane quota telemetry rather than widening the persisted cache-key contract.

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

Yes—current-main source shows projected pull metadata can share a broker key despite the requested-reviewer guard consuming a distinct projection; the linked issue supplies the concrete sequence.

Is this the best way to solve the issue?

Yes—the bypass is the narrowest safe repair because it preserves the existing full-resource cache contract while preventing projection-shaped bodies from being replayed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 91a2bf645327.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body records an after-fix, read-only real GitHub CLI run on the current head: five projected reads returned their requested shapes while the configured broker endpoint was unreachable and no production mutation occurred.
  • 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. Sufficient (live_output): The PR body records an after-fix, read-only real GitHub CLI run on the current head: five projected reads returned their requested shapes while the configured broker endpoint was unreachable and no production mutation occurred.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The defect can cause an active requested-reviewer signal to be missed in an automatic close-safety path.
  • merge-risk: 🚨 availability: Bypassing ETag validation for projected reads can increase GitHub REST quota consumption in the apply lane.
  • 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. Sufficient (live_output): The PR body records an after-fix, read-only real GitHub CLI run on the current head: five projected reads returned their requested shapes while the configured broker endpoint was unreachable and no production mutation occurred.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records an after-fix, read-only real GitHub CLI run on the current head: five projected reads returned their requested shapes while the configured broker endpoint was unreachable and no production mutation occurred.

Evidence

What I checked:

Likely related people:

  • clawsweeper[bot]: Blame attributes the broker-admission logic and cache-key integration to the original runtime implementation. (role: introduced the ETag-broker runtime boundary; confidence: high; commits: 6774bfd70cd5; files: src/clawsweeper-github-runtime.ts, src/github-etag-cache-contract.ts)
  • Martin Cleary: Recent main history includes the verified-provenance close-safety work adjacent to the apply path this fix protects. (role: recent close-safety contributor; confidence: medium; commits: 023046ec0354; files: src/clawsweeper-apply-close-execution.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T02:57:12.621Z sha c6c0908 :: needs real behavior proof before merge. :: none

@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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 25, 2026
@steipete
steipete merged commit a2641b2 into openclaw:main Aug 27, 2026
29 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Squash-merged as a2641b2 and verified that commit is on remote main. #1239 auto-closed. Thanks @goutamadwant.

Validated exact head c6c0908b99ff824a0a83abe922e0b4a7c136b1a4: the current durable runner proof reports node --test test/github-etag-read-broker.test.ts passing 6/6 (#1242 (comment)). Hosted pnpm check, sparse build, and Windows launcher checks passed at https://github.com/openclaw/clawsweeper/actions/runs/32803164537; CodeQL passed too. Independent Codex review reported no accepted/actionable findings. Before merge, the head, body, and comments were unchanged, the source-revision hash matched the durable review, and no inline review comments were present.

The main PR body's built-runtime, real read-only GitHub proof shows five projected reads returning their requested shapes with the broker deliberately unreachable. No live apply-decisions closure was run. Projected reads now incur direct REST quota; that accepted trade-off prevents another projection's cached body from weakening close-safety reads while preserving full-resource caching. No safety policy or OpenClaw Bay contract changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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.

apply: ETag cache key omits the jq projection, so the requested-reviewer close guard reads another call site's body and fails open

2 participants