Skip to content

fix(gateway): preserve private fixture directories - #201875

Merged
vincentkoc merged 1 commit into
mainfrom
fix/gateway-fixture-directory-mode
Nov 19, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/gateway-fixture-directory-mode

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Related: #200486

What Problem This Solves

Gateway tests can lose a private fixture directory's permissions when they update session or runtime configuration. A subsequent operation can reject that directory as an unsafe writable ancestor, preventing the test from exercising its intended behavior.

User Impact

No released runtime behavior changes. This repair keeps existing private Gateway fixture directories private across configuration writes.

Why This Change Was Made

Both fixture writers now share their existing config-runtime owner's atomic write policy with dirMode: "preserve". The three existing config-publication cases check that real session and adapter writes preserve the parent directory's device, inode and 0700 mode on POSIX, while retaining their functional assertions on Windows.

The pinned dependency, fs-safe0.27.1, derives its default numeric directory mode from the process umask and applies that policy to existing directories. Its preserve policy retains the existing directory mode. See the versioned atomic-write default and directory-mode implementation. This follows the production config writer's existing stateRootDirectoryMode policy; the shared production writer and unsafe-directory guard are unchanged.

Production changes: zero. Fixture and test changes: +47/-4 across three files. This completes the fixture directory's creation-and-write policy; it does not establish the original failed worker's umask, first affected dependency version or release exposure.

Evidence

Independent source reviews are complete for 46b757a9e3eb41cc98ab54041f8df4e708d62002. The complete committed-range local autoreview finished with one P0-only pass, zero findings and final source verification. This scoped review does not replace the independent source reviews or exact-head hosted review and CI.

The regression-only baseline 2df69d70d1c70cdff4b01fd5e8a75de4abaa6b30 produced one pass, two assertion failures and seven filtered cases under each child-only umask. The real session writer and config adapter preserved the parent device/inode but widened 0700 to 0777 under 000, and to 0775 under 002. Reply preparation passed because that path did not invoke either writer. Both negative mechanisms and native cleanup were independently verified.

The retained runs are mask 000 and mask 002. Their delegated workloads correctly exited 1; the Actions carriers were cancelled during normal native cleanup. These are scoped negative proofs, not green CI.

The same three cases on the repaired source passed under both child-only masks: six selected passes, zero failures and fourteen explicitly filtered rows across two invocations. Both real writer paths retained the same parent device/inode and 0700 mode. The repaired-source proof and native cleanup were independently verified. Its workload exited 0; the Actions carrier was cancelled during normal native cleanup and is not a green CI claim.

On the same repaired head, the full ordinary proof passed all 10 cases in src/gateway/test-helpers.server-rpc.test.ts, with no skips, filtering or forced umask. Targeted formatting and lint for all three changed files, plus the canonical core-test-gateway-root and core-test-gateway-server type graphs, passed. The workload and static-check receipts were independently reviewed. Dependency preparation emitted five module-directive warnings; lint reported zero warnings and errors. The delegated workload exited 0 and native cleanup completed; its cancelled Actions carrier is not a green CI claim.

The original integration context passed all 103 cases across 13 files, with zero failures, skips, filtering or unrun cases. This separate private proof used 7ab975c477f225975bcd6889705d02c784f4f497, derived from the parent proof baseline with the same three-file fixture repair and the separately reviewed placement-fixture correction. It preserved the original two-fork shared-process context, case order, timeouts and ambient umask. All 27 private-completion cases and all four placement cases passed. Workload, unchanged source, actual workflow inputs and complete native cleanup were independently verified; the cancelled Actions carrier is not a green CI claim. This private source is distinct from the ordinary PR head.

Required exact-head hosted checks, hosted review and final native landing gates remain open. The parent R5 obligation remains unresolved; no inherited-CI exception is requested.

Follow-up: private-completion gate waits that do not race admitted-operation failure or cancellation can cascade into long timeouts after a failed restart. That lifecycle issue is outside this permission repair.

@vincentkoc vincentkoc self-assigned this Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 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 gateway Gateway runtime size: S labels Nov 19, 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. labels Nov 19, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 19, 2026 14:19
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 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 Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes both Gateway test configuration writers preserve existing parent-directory permissions.

Example: A Gateway fixture writes configuration inside a POSIX directory with mode 0700 under umask 002.

  • Before: The atomic writer can widen the existing directory to 0775.
  • After: The writer preserves the directory's identity and 0700 permissions.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-infrastructure repair with meaningful boundary assertions, verified dependency semantics and successful hosted gates; separate workload receipts were not independently inspected.
Proof confidence 🐚 platinum hermit (4/6) Only test helpers and their regression assertions change, so shipped-entry-point proof is unnecessary; reported fault-controlled runs support the source analysis, while their raw workload logs were inaccessible to this review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Gateway tests can reject their own formerly private fixture directories after configuration writes broaden their permissions.
Reason: The maintainer-authored direction repairs a source-confirmed test-infrastructure defect without adding product settings or changing released behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a concrete fixture-permission defect still present on main, with no actionable correctness or security findings.

Priority: P2
Reviewed head: 46b757a9e3eb41cc98ab54041f8df4e708d62002

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway test helpers publish fixture configuration for real and mocked readers; both session synchronization and adapter writes reach fs-safe's atomic JSON writer.

flowchart TD
  A[Session fixture synchronization] --> C[Gateway test config writer]
  B[Config adapter writes] --> C
  C --> D[fs-safe atomic JSON writer]
  D --> E[Fixture config file]
  D --> F[Preserved parent permissions]
Loading

Technical review

Best possible solution:

Keep the shared fixture writer with dirMode preserve and retain the existing boundary tests for both callers.

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

The old fixture calls and pinned fs-safe implementation establish the permission-widening path under permissive POSIX umasks; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch fixes the policy at the existing fixture owner, serves both callers, preserves atomicity, and avoids changing the shared production writer or unsafe-directory guard.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Atomic session-fixture publication keeps the original intent (a482a50: Publish configuration atomically so deferred session-change readers cannot observe a partial file.)
  • Configuration-runtime owner and write completion keeps the original intent (c26d9db: Keep acknowledged configuration writes aligned with the published runtime configuration; this PR retains the completion and snapshot-publication path.)
  • Consolidated publication coverage keeps the original intent (2a0601f: Exercise fixture publication through existing connected cases while preserving authored configuration and avoiding duplicate setup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Focused shared-owner repair: The introduced diff adds dirMode preserve at the existing config-runtime owner and routes both existing atomic writers through it, retaining durability and newline settings. (src/gateway/test-helpers.config-runtime.ts:120, 46b757a9e3eb)
  • Current main still needs the repair: Both current-main fixture writers still invoke writeJsonAtomic without an explicit directory-mode policy; the production configuration writer already uses stateRootDirectoryMode. (src/gateway/test-helpers.config-runtime.ts:169, 307d9c45fb25)
  • Verified dependency contract: OpenClaw pins and executes fs-safe 0.27.1 through its JSON facade, making this dependency contract applicable. At the resolved tag commit, writeJson forwards dirMode to writeTextAtomic, whose default is 0777 masked by umask; prepareDirectoryMode preserves existing identity and permissions for preserve. The dependency's root policy was read. (src/text-atomic.ts:26, ea225ba262cf)
  • Regression coverage at existing boundaries: Existing publication cases now check parent device, inode and 0700 mode around session synchronization and adapter writes while retaining functional RPC assertions; Windows retains functional coverage without POSIX mode assertions. (src/gateway/test-helpers.server-rpc.test.ts:346, 46b757a9e3eb)
  • Original atomic-publication intent retained: The history introducing atomic session-fixture publication explicitly sought to prevent deferred readers observing incomplete configuration; this PR retains atomic publication and changes only directory handling. (src/gateway/test-helpers.server.ts:199, a482a50cda88)
  • Current head and hosted gates: Live REST reads confirm the reviewed head remains mergeable and clean, with successful dependency-review, security-sensitive-review and ci-gate statuses; supplied check context reports no failed checks. (46b757a9e3eb)

Likely related people:

  • Vincent Koc: Raw commit 67ecf6b adds src/gateway/test-helpers.server.ts:1140 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 67ecf6bf352d; files: src/gateway/test-helpers.server.ts)

PR surface

Source +8, Tests +35. Total +43 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 12 4 +8
Tests 1 35 0 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 47 4 +43

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: A concrete permission defect can prevent Gateway integration tests from exercising their intended behavior, with no released runtime impact.
  • 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.

Label justifications:

  • P2: A concrete permission defect can prevent Gateway integration tests from exercising their intended behavior, with no released runtime impact.
  • 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.

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 November 19, 2026, 9:52 AM ET / 14:52 UTC.

@vincentkoc
vincentkoc merged commit 44267df into main Nov 19, 2026
235 checks passed
@vincentkoc
vincentkoc deleted the fix/gateway-fixture-directory-mode branch November 19, 2026 15:01
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

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

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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