Skip to content

perf: index cross-owner universal draft lookups - #1011

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/universal-draft-lookup-981
Sep 9, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/universal-draft-lookup-981

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Index draft owners lazily within a universal render attempt when a hook or ref reads another owner's draft. The newest draft remains an allocation-free direct lookup.
  • Preserve last-draft-wins behavior after a render-phase retry and keep the lookup isolated across nested preparations and aborts.
  • Add a public object-root regression and a registered production benchmark for ancestor, own-ref, single distant-read, and plain-property workloads.

Why

Part of #981: each sibling reading or writing a ref owned by an earlier ancestor otherwise scans the growing draft-owner list. Repeated ancestor-ref access becomes quadratic across a wide sibling tree.

Changes

  • Add an attempt-local lazy Map that catches up with appended draft owners in order; duplicate records overwrite earlier drafts. Reads of the latest owner use the direct tail check.
  • Exercise chained ancestor and predecessor ref reads across keyed siblings, nested prepare/abort, retries, reordering, retained hosts, effects, and cleanup.
  • Register universal-draft-lookup in the benchmark runner and MCP catalog; add patch changesets for octane and @octanejs/mcp-server.

Validation

  • pnpm sync and git diff --check
  • pnpm format:files:check for all eight changed files
  • pnpm typecheck:files packages/octane/src/universal-core.ts packages/octane/tests/universal-state-updates.test.ts
  • Targeted universal development/production tests and MCP suite-list test: 37 files, 733 tests passed
  • Deliberate missing non-tail lookup and first-draft-wins mutants made the new regression fail in development and production; both restored, final suite green
  • node benchmarks/bench.mjs --quick universal-draft-lookup (16 targets, output and identity checks)
  • Full pnpm test, repository-wide pnpm typecheck and pnpm format:check locally; current-head CI will run these gates

Production Node 26.4.0 object-driver B–C–C–B comparison (13 samples per run, eight accepted updates per sample): at 1,024 child owners, repeated ancestor-ref reads took 2.019/1.882 ms per update on the frozen baseline and 1.238/1.080 ms on the candidate (about 41% lower paired mean). The 128-owner result was inconclusive. Single distant reads, own-ref reads, and plain-property controls showed mixed small differences within run variability. All 16 targets matched output hashes across runs with stable hosts, 104 accepted commits and zero structural commands.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches universal render-attempt hook/ref resolution in universal-core.ts; incorrect indexing could corrupt ref/state across siblings, preparations, or retries, though new tests and the benchmark gate correctness.

Overview
Cross-owner hook/ref reads no longer scan the full draft-owner list on every lookup. findDraftOwner keeps an allocation-free tail check for the newest owner and builds an attempt-local Map only when a render needs an earlier owner's draft; later appends extend the index and overwrites keep last-draft-wins after retries.

Adds a Node universal-draft-lookup benchmark (ancestor ref, own-ref, single distant read, plain-object controls at 0–1,024 child owners) plus runner/MCP registration, patch changesets, and a regression test for shared ancestor refs across keyed siblings, nested prepare/abort, and render-phase retry.

Reviewed by Cursor Bugbot for commit 3942da5. Bugbot is set up for automated code reviews on this repo. Configure here.

@domgan-oai
domgan-oai marked this pull request as ready for review September 9, 2026 10:49
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 9, 2026
@domgan-oai
domgan-oai merged commit de3f2e6 into octanejs:main Sep 9, 2026
46 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant