Skip to content

fix: Code Mode rejects division after optional property access - #196785

Merged
roboclaw-bot merged 2 commits into
mainfrom
openclaw/swift-lobster-2
Nov 12, 2026
Merged

roboclaw-bot merged 2 commits into
mainfrom
openclaw/swift-lobster-2

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: Code Mode rejects valid JavaScript when division follows optional access to a keyword or contextual-name property, such as value?.return / 2 / 3.

User Impact

These expressions execute without extra parentheses. Shell commands, malformed JavaScript, and module access remain rejected before nested tool dispatch. There are no version upgrades, configuration changes, or migration steps.

Scoped maintainer proof exception, November 12: @vincentkoc explicitly approved landing this PR using the verified production-tool, parser, packaging and review evidence while waiving only the missing isolated Gateway/real-agent/real-model proof. That test remains unexecuted: the normal agent CLI refused an agent-exec invocation because it would lose inter-session attribution. The marker and guard were preserved; no alternate dispatch route or credential substitution was used. Full CI completed with five reproduced inherited-main failures, detailed below; CI is not green. Landing must use the native exact-head inherited-failure route and still satisfy current dependency, security, enforced-review and writer-authority checks. This exception does not waive any tool or security guard.

Why This Change Was Made

Patch Acorn 8.19.0 at its token-context owner, including matching class/function identifier cleanup, rather than rewriting guest source. Both published module formats are regenerated from canonical upstream source.

Keep those patched bytes in npm and ClawHub artifacts. Codex explicitly selects Acorn for bundling while retaining its native-heavy full-dependency opt-out. Unselected patches and blanket bundling still fail closed; global bundling cannot pull in the native platform closure.

Evidence

  • Production Code Mode regressions were red before the repair under Node and QuickJS. The final parser passed 355 focused tests across 17 files and 13,725 upstream grammar tests. Isolated production tools return 2 for the original expression and of/generator-yield siblings; shell, syntax, import and require controls reject before dispatch. This is not a Gateway/model end-to-end claim or live Team deployment.
  • Both selective-package regressions were red. The packaging suite passed 54 cases; two new cases then exposed a missing synthetic dependency snapshot. After correcting that fixture, all six affected opt-out cases passed. Unchanged passing proof is reused, not represented as one final full-suite green run.
  • Real Codex npm and ClawHub pack routes produced byte-identical artifacts bundling only patched Acorn, with no native platform closure and unchanged public dependency specifications. A production npm install retained exact patched CJS/ESM bytes. Installed transcript-projector/parser checks used synthetic inputs and executed no native command or model call.
  • Scoped types, lint, formatting, frozen installation, patch guard and generated-validator checks passed. Full build exited 0 with three nonfatal UI gzip-budget overages whose baseline attribution remains unverified; thresholds were unchanged. Four generated-patch whitespace warnings are blank unified-diff context prefixes, not added Acorn whitespace; no hand edit or ignore change hid them.
  • The initial independent review found a context-cleanup defect; it was reproduced, fixed and covered by red/green proof. Fresh independent P0–P3 review found no actionable findings in the full 15-file snapshot a0c232f2ebf962d44aa8b8e5942a1a2586a232f932556b5a0049807c1caa56f4.
  • Local ClawSweeper was unavailable because its located checkout was dirty/divergent. Canonical autoreview completed P0–P3 review of 37a3b162a0c58aaceb1634aaef726d0e178a529c..2ff3e3f51750d95ed1a42b9892fc8a1b9b35e39b: scoped-clean, no findings. It reviewed supplied source without project-code execution and noted unavailable broader unchanged context. Hosted ClawSweeper completed the published 5f5518bf4321f9038581df3d882aa5021f2467d7 review on November 10 with no source findings and the same missing live-proof qualification. No duplicate request was made for this unchanged source.
  • Net test growth is 41 lines, allocated to parser-context and selective-packaging regressions. Focused proof took 136.86 seconds, additional plugin-parser proof 45.48 seconds, and packaging proof 87.31 seconds plus the 48.04-second affected-case replay.

Exact-head CI: reproduced inherited-main failures

Run 43150112087, attempt 1 completed failure on November 12 at 04:17:08 UTC. All 162 jobs were terminal: 133 succeeded, 23 skipped, five test jobs failed, and the downstream openclaw/ci-gate failed. CI is not green.

The job tested merge ee1d4a395be9e1f05da2fb269f10b7459e705c6f of this head into main 9c2e60f7d003e30d417d60655a4bd2dc56168e8d. Each exact assertion reproduced with the unchanged failed sub-shard/singleton selection on both that merge and unpatched contemporaneous main:

Failed job Signature Merge / unpatched main Attribution
130957804934 Memory CLI orphaned provenance: expected exit code 1, actual 0 Each 173 passed / 1 failed Inherited
130957804387 Telegram provider-failure settlement: expected failure send, actual [] Each 0 passed / 1 failed Inherited; internal no-send cause not isolated
130957804693 Codex native-result middleware: expected pretty JSON, received compact JSON Each 30 passed / 1 failed Inherited; main producer changed in #196756
130957808546 Invalid-seal memory admission: expected full-verification receipt, actual undefined Each 99 passed / 1 failed Inherited
130957805143 Borrowed memory connection: expected /foreign_key_check/ rejection, no throw Each 113 passed / 1 failed Inherited

Both sides used independent frozen dependencies and the identical pinned OpenClaw Bun engine, SHA-256 0cef667e2f3fd465b6429904ed074381a679be379ec44fa42b5f460ed118b2b8. The local Node launcher was 26.12.1 versus CI 24.22.1, so local hardware/launcher is not claimed to clone the runner. The same signatures reproduced on both sides; 21 relevant source fingerprints were unchanged. Original base and candidate also both passed the 174-test CLI shard. Only failed sub-shards were replayed; Telegram's source-specific QA builds passed on both trees. No introducing-commit bisection was added for memory or Telegram.

These controlled observations supplement the automatic classifier's unknown/no-matching-main-job result. They establish inherited failure attribution, not a passing status. No source, assertion, timeout or baseline was weakened, and no CI rerun, dispatch or green-chasing push occurred. @vincentkoc's November 12 scoped land instruction authorizes the native inherited-failure exception for these identified baseline failures; the separate missing real Gateway/agent/model proof is explicitly waived as recorded above, not claimed as passed. Applicable dependency, security, enforced-review and live writer-authority admission remain required.

Contributor credit

Requested and scoped with @vincentkoc, including explicit approval for this dependency patch.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 2 commits November 10, 2026 17:55
Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: c65a8e11-78d4-847b-85c7-6dc3dba5d0cc
@clawsweeper

clawsweeper Bot commented Nov 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling extensions: codex size: M labels Nov 10, 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR patches Acorn to accept division after optional property access and preserves the patched parser in published packages.

Example: Code Mode executes const value = { return: 12 }; return value?.return / 2 / 3;.

  • Before: Source preparation rejects valid JavaScript with a syntax error.
  • After: The expression executes and returns 2.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source change is coherent and focused, but the declared required behavior proof is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An agent's valid JavaScript arithmetic fails before execution when division follows an optional keyword or contextual-name property.
Reason: This restores documented JavaScript behavior, preserves module-access rejection, and has maintainer-authored direction without adding a user setting.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored draft open: it addresses a documented current-main defect, and source review found no actionable introduced bug.

Priority: P2
Reviewed head: 5f5518bf4321f9038581df3d882aa5021f2467d7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The explicitly required isolated Gateway with a real agent and model has not exercised the repaired expression and rejection controls through the shipped entry point.
Agent review details

How this fits together

Code Mode parses submitted JavaScript with Acorn before module-access validation and Node or QuickJS execution; package producers must preserve the patched parser in installed artifacts.

flowchart TD
  A[Agent JavaScript] --> B[Acorn syntax parser]
  B --> C[Module access validation]
  C --> D[Node or QuickJS executor]
  D --> E[Execution result]
  F[Patched dependency packaging] --> B
Loading

Technical review

Best possible solution:

Repair Acorn's paired token-context owners and ship those exact bytes through the existing package producers.

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

The exact failure is documented on current main and explained by Acorn's ordinary-dot-only token-context guards; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch addresses the parser owner directly, preserves matching class/function cleanup, and reuses existing packaging machinery without rewriting guest source or adding a competing parser.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff changes Acorn token contexts in both module formats, registers the exact-version patch, and extends the existing packaging owner to preserve explicitly selected patched dependencies. (patches/[email protected]:10, 5f5518bf4321)
  • Current main acknowledges the exact defect: Current main's Code Mode troubleshooting documentation identifies optional keyword-property division as valid JavaScript rejected by the parser and recommends parentheses as a workaround. (docs/tools/code-mode/troubleshooting.md:54, afaaa8d287a3)
  • Authoritative dependency contract inspected: The patch directly modifies Acorn, making its source authoritative: tokencontext.js handles ordinary-dot properties but omits optional-dot properties, while expression.js performs corresponding class/function context cleanup; both owners must change together. (acorn/src/tokencontext.js:74, 0e0ece7cc720)
  • Selective packaging retains existing ownership: The native-heavy opt-out still prevents global full-closure bundling; selected patch names reuse the existing frozen-install verification, staging, script-disabled installation, and artifact producer. (scripts/lib/plugin-npm-package-manifest.mts:713, 5f5518bf4321)
  • Draft hold and supplied evidence: The complete PR body reports parser and package checks, explicitly states that isolated Gateway/agent/model proof remains unexecuted, and records a draft merge hold; discussion contains no additional behavior artifact or approval. (5f5518bf4321)
  • Checks have not established broad validation: The reviewed head has five successful checks and 104 skipped checks, with no failing checks; this does not establish completed product CI or a diff-caused CI defect. (5f5518bf4321)

Likely related people:

  • Peter Steinberger: Raw commit 0fa0315 adds src/agents/code-mode-script-syntax.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0fa0315a75fb; files: src/agents/code-mode-script-syntax.ts)
  • Vincent Koc: Raw commit 1165ac2 adds src/agents/code-mode-engine-parity.test.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1165ac21d253; files: src/agents/code-mode-engine-parity.test.ts)

PR surface

Tests +41, Docs +33, Config +5, Other +80. Total +159 across 15 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 96 55 +41
Docs 3 41 8 +33
Config 3 5 0 +5
Generated 0 0 0 0
Other 5 99 19 +80
Total 15 241 82 +159

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:

No label changes.

Label justifications:

  • P2: Valid Code Mode arithmetic is rejected, but the affected syntax is narrow and parentheses provide a documented workaround.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 10, 2026, 1:19 PM ET / 18:19 UTC.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 12, 2026 03:43
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Nov 12, 2026
@github-actions

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: 5f5518bf4321f9038581df3d882aa5021f2467d7
  • Maintainer: @roboclaw-bot
  • Repository role: maintain

These dependency graph changes were made:

  • pnpm-lock.yaml
  • patches/[email protected]
  • patches/README.md
  • pnpm-workspace.yaml
  • extensions/codex/package.json
  • package.json

Carefully review these changes before merging.

@roboclaw-bot
roboclaw-bot merged commit 7ea57a8 into main Nov 12, 2026
356 of 364 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/swift-lobster-2 branch November 12, 2026 08:12
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…law#196785)

* fix: accept division after optional property access

Co-authored-by: vincentkoc <[email protected]>

* fix: Code Mode rejects division after optional property access

Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: c65a8e11-78d4-847b-85c7-6dc3dba5d0cc

---------

Co-authored-by: vincentkoc <[email protected]>
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: codex P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: M 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