Skip to content

perf(agents): prepare generation authority off-thread for file writes - #188552

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-async-effect-authority-20261030
Oct 30, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-async-effect-authority-20261030

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Generation-backed host file writes repeatedly revalidated retained session authority through synchronous physical-identity probes and native SQLite reads on the Gateway main thread.

Change and User Impact

The generation owner now prepares physical identity checks and committed native-revision refreshes on the existing session workers. Lifecycle, command-owner and receipt adapters carry those prepared facts to the file effect. The final synchronous assertion still checks live owner state, the exact native handle and revision, permissions and pending native execution. Revoked, released, replaced or changed authority fails closed.

The host and Memory Core pin the published @openclaw/fs-safe 0.26.15. Its additive API prepares authority after overwrite rollback capture and asserts immediately before mutation, including empty truncation. The dependency API merged in fs-safe #1049 at 80b9af0a5211d3ad4013a0c25f936480e2aca297; this PR does not publish a release. The Memory Core pin keeps its existing race-injection hooks on the same dependency instance as SDK file operations; all three race tests pass without changing their assertions.

Arbitrary legacy opaque callbacks, generic entry/conversation sources, and active same-connection native transactions retain their existing synchronous checks. The zero-probe claim applies to the migrated generation-backed file-write path, not every lifecycle assertion. No schema or configuration options change. The obsolete overwrite barrel export is removed.

Production delta excluding tests/docs and dependency metadata: +388 / -85 lines (net +303). The growth preserves the existing synchronous and transaction contracts while adding the async final-effect boundary.

Measurement and Proof

Actual generation → command-owner → receipt → writeHostFile, after a committed native no-op revision, with 25 ms injected synchronous-probe latency:

Main-thread work per integrated write Base owner Candidate
Identity probes 8 0
Candidate-currentness probes 0 0
Native generation reads 1 0
SQL prepares 1 0

The baseline substitutes the unchanged main generation owner in the same consumer harness, using the released dependency in both arms. It fails the committed zero-count assertion; the candidate writes the expected bytes with all counts zero. This is owner-level proof, not a whole-Gateway CPU, allocation or latency claim.

  • Final head ad94d5a49707b8b7cbc09d689ffc27df19563c91, base 797540497ae53253adb5fa0581c2171389919cad: 52 focused tests pass (the original 49 plus three Memory Core migration races). All three commits remained patch-identical across the final rebase.
  • An additional 88-test focused repair/closure run passed across generation-native, source-authority, fs-safe import-boundary, eager-import-closure and PR-wrapper source-closure files.
  • Four real-file checks through the published fs-safe API pass: replacement/empty writes succeed under current authority; revocation during preparation rejects and preserves original bytes.
  • pnpm 12.15.0 regenerated the lockfile; frozen install, dependency-pin checks and all 110 npm package-lock validations pass. JavaScript and Darwin native artifacts resolve to 0.26.15. Registry integrity: sha512-6O0NiLjrEeY8H5wBUmBy5qbIW0qu5ICw5jYvcIswduYkxnqxf+SDzpJMIJVC5L5IXvRlMh8ZZHQYkmjWxVy9DQ==.
  • pnpm check:changed --timed completed all stages. Its two PR-caused cleanup typing errors and obsolete barrel export were repaired; the complete pnpm tsgo:all rerun and targeted lint passed. Remaining broad local lint/unused-export failures are in unchanged files with unchanged lint/Knip configuration, recorded as inherited; exact-head hosted guards cover the final diff.
  • Codex autoreview of the full implementation and incremental dependency/allocation repair: scoped-clean at P0/P1, no findings.
  • No Team access, deployment, restart or load test.

Approved Test Allocation

The lead explicitly approved config/test-lines-allocations/async-effect-authority.txt: exactly 307 net new lines for the integrated zero-probe write proof and distinct fail-closed generation, receipt and prepared-source regressions. The shared scalar is unchanged. The final local ratchet passes at 6,307,747 lines / 6,307,779 effective ceiling; the 32 lines of slack are inherited from main. This PR adds exactly 307 lines and 307 credit. The hosted ratchet passes too.

Exact-Head CI and Inherited Failures

Run 41120260179 is bound to ad94d5a49707b8b7cbc09d689ffc27df19563c91. Completed: 152 successful, 21 skipped, six failed checks: the five attributed inherited test jobs below and the aggregate CI gate. All PostgreSQL conformance shards pass. The five failing test jobs have the same cases and assertion signatures as retained baseline evidence; no CI rerun was requested.

Failing job Baseline attribution
Cron admission, 8 cases Same failures in main run 41107007551, job 124239592031, and local base/candidate replay. Main #188513 intentionally stopped retaining the manual caller guard after durable enqueue; stale tests expect skipped instead of ok.
Visible-spawn fallback, 9 cases Same cases/signatures in main run 41107007551, job 124239592431; affected source unchanged.
Direct-command steering Same expected followup / received steered assertion in main run 41107007551, job 124239592357; affected source unchanged.
Agent-terminal delivery E2E Exact base 6f39e23d920a7fd8a234bda419705edb13e1e456, frozen 0.26.14 dependencies and built isolated Gateway reproduce expected error / received ok.
Telegram tool-failure settlement E2E The same exact-base Gateway reproduces expected visible error / received empty delivery list.

The Memory Core and test-line failures from the previous head are repaired and green. The previous trajectory failure is green on this head; five base and five candidate full-file replays also passed, with no underlying flake fix claimed. Security and dependency reviews pass. The lead authorized exact-head admin landing when only attributed inherited reds remain.

Related: #188474

@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L labels Oct 30, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR prepares generation-backed file-write authority through session workers and checks retained authority immediately before mutation.

Example: Overwrite /tmp/report.txt with "replacement" after an unchanged native session update.

  • Before: Generation validation performs synchronous database identity probes and native session reads on the Gateway thread.
  • After: The generation owner prepares validation through workers, then checks retained facts before writing the replacement bytes.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The scoped implementation is useful, but frozen installation is broken and the required authority-chain proof is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Repeated synchronous generation validation during host file writes can block the Gateway thread.
Reason: The maintainer-authored direction removes measured synchronous work from a specific consumer while explicitly preserving legacy contracts and limiting its claims.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: this maintainer-authored draft contains useful unique work, but its dependency pin currently breaks frozen installation.

Priority: P2
Reviewed head: a7aa9b1e0f1a1fd852d6a5ee99a815e8ee53b732

Before merge

  • Add real behavior proof - Authority-chain proof required: the body reports successful generation → command-owner → receipt → writeHostFile execution with real session workers and source-backed fs-safe on Darwin, but does not provide the corresponding final-file result for revoked or replaced real OpenClaw authority; the dependency's public allowed/refused output proves only its own boundary, and released-package validation remains pending. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • [P1] Regenerate the lockfile for the new fs-safe requirement (P1) - The manifest now requires 0.26.15, but pnpm-lock.yaml still records the root importer specifier and resolution as 0.26.14. Consequently, frozen installation fails before the new export can be used, even after 0.26.15 is published. Once the dependency is available, regenerate and commit the lockfile through the package manager.
  • Resolve security concern: Verify rejection through the complete authority chain - The native tests reject stale generations at preparation, while final-write rejection tests supply synthetic callbacks; neither demonstrates a revoked or replaced real OpenClaw generation preserving file bytes through the complete changed chain.
  • Resolve merge risk - Before merge, the dependency release owner must make the required fs-safe API available in a published package.
  • Resolve merge risk - Before merge, the author must establish that asynchronous preparation preserves rejection of revoked or replaced OpenClaw authority at the final filesystem effect.

Findings

  • [P1] [P1] Regenerate the lockfile for the new fs-safe requirement — package.json:2409
  • [medium] Verify rejection through the complete authority chain — src/agents/host-file-write.ts:41

Tests

  • Missing end-to-end proof: Show the complete OpenClaw generation-to-file-write path allowing an authorized write and preserving original bytes when its generation, owner, or physical database is revoked or replaced during preparation, using the published dependency and redacted output.
Agent review details

How this fits together

Agent host-file writes consume caller receipts backed by command-owner and session-generation authority; session workers prepare database facts, and filesystem operations consume the final synchronous assertion.

flowchart TD
  A[Agent file write] --> B[Caller receipt]
  B --> C[Command and generation owners]
  C --> D[Session workers]
  D --> E[Prepared live assertion]
  E --> F[Filesystem mutation]
Loading

Technical review

Best possible solution:

Keep preparation in the existing generation and worker owners, preserve live final checks, and complete the published dependency integration.

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

Current-main host writes invoke generation checks that synchronously validate database identity and may read native session state; the author also reports a consumer-harness comparison, but this review executed no reproduction.

Is this the best way to solve the issue?

Preparing through existing workers at the overwrite boundary is a coherent narrow solution, and retaining synchronous checks for opaque callbacks and active transactions is justified.

Full review comments:

  • [P1] [P1] Regenerate the lockfile for the new fs-safe requirement — package.json:2409
    The manifest now requires 0.26.15, but pnpm-lock.yaml still records the root importer specifier and resolution as 0.26.14. Consequently, frozen installation fails before the new export can be used, even after 0.26.15 is published. Once the dependency is available, regenerate and commit the lockfile through the package manager.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Finish the dependency and authority boundary (recommended)
    Wait for the dependency publication, regenerate the lockfile, and demonstrate allowed and revoked generation-backed writes through the complete production chain.
  2. Retain the draft
    Keep this PR paused while the dependency release and final-effect evidence remain outstanding.

Provenance checked

  • Generation identity and native revision checks changes intended behavior with a stated reason (27ae5f7: Retained filesystem tools must reject database replacement even when they never enter the database writer.)
  • Host-write source preparation keeps the original intent (bc60cd9: Carry worker-prepared source facts to effects while preserving live commit or dispatch validation.)
  • Command-owner authority keeps the original intent (39183ae: Retained work must preserve its original owner and refuse effects after owner revocation.)
  • Session-event ownership keeps the original intent (a578746: Use authoritative session and database owners instead of adding a competing transient ownership system.)
  • Filesystem dependency pin changes intended behavior with a stated reason (03ba6b4: The base pins released fs-safe 0.26.14; this PR needs the additive authority-preparation export merged afterward.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was established, but the changed authority chain still needs final-effect rejection evidence.

Evidence

Security concerns:

  • [medium] Verify rejection through the complete authority chain — src/agents/host-file-write.ts:41
    The native tests reject stale generations at preparation, while final-write rejection tests supply synthetic callbacks; neither demonstrates a revoked or replaced real OpenClaw generation preserving file bytes through the complete changed chain.
    Confidence: 0.95

What I checked:

PR surface

Source +307, Tests +303, Docs +9, Config 0. Total +619 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 387 80 +307
Tests 4 305 2 +303
Docs 1 9 0 +9
Config 1 1 1 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 702 83 +619

Review metrics

Metric Value Why it matters
Production versus test changes Production +388/-81; tests +305/-2 Growth adds a distinct asynchronous effect boundary and propagates it through existing adapters; synchronous APIs remain necessary for opaque callbacks and transaction-local semantics.

Labels

Label changes:

  • add P2: This is a focused Gateway responsiveness improvement without evidence of an urgent user-facing outage.
  • add merge-risk: 🚨 compatibility: The dependency manifest and lockfile disagree, preventing frozen installation.
  • add merge-risk: 🚨 security-boundary: The patch changes how retained session and command authority reaches filesystem effects, and complete forbidden-authority proof remains outstanding.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a focused Gateway responsiveness improvement without evidence of an urgent user-facing outage.
  • merge-risk: 🚨 compatibility: The dependency manifest and lockfile disagree, preventing frozen installation.
  • merge-risk: 🚨 security-boundary: The patch changes how retained session and command authority reaches filesystem effects, and complete forbidden-authority proof remains outstanding.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 execution lanes are retired.

Reviewed October 30, 2026, 1:31 PM ET / 17:31 UTC.

@steipete
steipete force-pushed the steipete/perf-async-effect-authority-20261030 branch from a7aa9b1 to 8efccc8 Compare October 30, 2026 19:11
@steipete
steipete marked this pull request as ready for review October 30, 2026 19:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T20:05:54.295788Z ad94d5a New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Dependency graph changes

This maintainer PR changes the dependency graph.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: ad94d5a49707b8b7cbc09d689ffc27df19563c91
  • Maintainer: @steipete
  • Repository role: admin

These dependency graph changes were made:

  • pnpm-lock.yaml
  • pnpm-workspace.yaml
  • extensions/memory-core/package.json
  • package.json

Carefully review these changes before merging.

Record the lead-approved exact 307-line allocation for integrated zero-probe writes and fail-closed generation, receipt, and prepared-source coverage. Align Memory Core fs-safe with the host so existing race injection targets the same dependency instance.
@steipete
steipete force-pushed the steipete/perf-async-effect-authority-20261030 branch from 8efccc8 to ad94d5a Compare October 30, 2026 20:03
@openclaw-barnacle openclaw-barnacle Bot added the extensions: memory-core Extension: memory-core label Oct 30, 2026
@steipete
steipete merged commit b1a2aa2 into main Oct 30, 2026
260 of 270 checks passed
@steipete
steipete deleted the steipete/perf-async-effect-authority-20261030 branch October 30, 2026 20:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged at b1a2aa2c3f32088b1426a210167ce82b05c591c4 from exact reviewed head ad94d5a49707b8b7cbc09d689ffc27df19563c91, under the lead-authorized inherited-failure exception.

Final CI run: 152 passed, 21 skipped, six failed checks—the five attributed test jobs plus the aggregate gate. Cron admission (8 cases), visible-spawn fallback (9 cases), and direct-command steering match main run 41107007551. The agent-terminal and Telegram settlement E2Es reproduce the same assertions on exact base 6f39e23d920a7fd8a234bda419705edb13e1e456 with frozen dependencies and an isolated built Gateway. Detailed job links and attribution are in the PR body. No CI rerun was requested.

The task-caused Memory Core dependency-instance mismatch and test-line gate are fixed and green. The lead-approved allocation grants exactly 307 regression/proof lines; the shared scalar is unchanged. All 52 final focused tests, published-package validation, security/dependency reviews and Codex review pass. Integrated main-thread identity probes are 8→0, native generation reads 1→0, and SQL prepares 1→0. No Team access or deployment.

nxmxbbd added a commit to nxmxbbd/openclaw that referenced this pull request Oct 30, 2026
…d-tool-snapshot

Resolve src/agents/agent-tools.delegated-authority.test.ts after openclaw#188552
appended its prepared-write tests: keep both test blocks and the combined
gateway-caller-context import. The import now replaces main's one-line
import, so the exact test-line allocation drops from 868 to 867.
steipete added a commit that referenced this pull request Oct 30, 2026
#188552 moved the root package and memory-core to @openclaw/fs-safe
0.26.15 but left eleven bundled plugins on 0.26.14. Package candidate
resolution rejects conflicting bundled plugin dependency specs, so every
ref-sourced package build (Update Migration, package acceptance, release
checks) failed before any lane ran.

Align the remaining plugins to the version the root already ships. No new
upstream version enters the lockfile; the unused 0.26.14 entries drop out.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…openclaw#188552)

* perf(agents): prepare generation authority before file effects

* build(deps): consume released fs-safe effect authority API

* test(agents): allocate currentness regression proof budget

Record the lead-approved exact 307-line allocation for integrated zero-probe writes and fail-closed generation, receipt, and prepared-source coverage. Align Memory Core fs-safe with the host so existing race injection targets the same dependency instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: memory-core Extension: memory-core merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant