') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); perf(test): shrink storage capacity and legacy Plan fixtures to minimal crossings by GabrielDrapor · Pull Request #2473 · apache/maka · GitHub
Skip to content

perf(test): shrink storage capacity and legacy Plan fixtures to minimal crossings - #2473

Merged
Astro-Han merged 1 commit into
apache:mainfrom
GabrielDrapor:perf/storage-test-amplification
Aug 8, 2026
Merged

perf(test): shrink storage capacity and legacy Plan fixtures to minimal crossings#2473
Astro-Han merged 1 commit into
apache:mainfrom
GabrielDrapor:perf/storage-test-amplification

Conversation

@GabrielDrapor

Copy link
Copy Markdown
Contributor

Refs #2388 (fixture-reduction PR; the stress-policy change comes separately per the issue).

What changed

Sandbox-boundary capacity test (sqlite-session-metadata-store.test.ts): each expansion request now carries 15 near-MAX_SANDBOX_BOUNDARY_PATH_CHARS paths instead of 32 shorter ones. Per-request serialized size stays near MAX_SANDBOX_BOUNDARY_SERIALIZED_BYTES (the fewest settles that can cross the 1 MiB execution-boundary cap), but each settle's boundary rescan now walks less than half the accumulated entries.

Legacy Plan ledger fixture (sqlite-workflow-store.test.ts): seedLegacyPlanLedger now exceeds each projection bound by just enough to force truncation — 4 steps (enough to push the shared text budget below the asserted 4,000 bytes), 51 files > PLAN_MAX_FILES_PER_STEP, 21 risks > PLAN_MAX_RISKS, 31-char titles > PLAN_STEP_TITLE_MAX_CHARS — instead of ~500KB of near-max fields per ledger event.

What deliberately did not change

  • Assertions: every truncation/atomicity/persisted-state assertion is untouched; the fixtures still cross every asserted boundary.
  • Catalog capacity test: already minimal — each connection sits at CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS × CONNECTION_MODEL_ID_MAX_LENGTH (~262KB), so ~16 commits is the floor for crossing the 4 MiB document cap.
  • Vault capacity test: already minimal — secrets are at MAX_SECRET_LENGTH (64 KiB), and the provider auth contract (coordinator.ts) requires one connection per stored secret (oauth_token is github-copilot-only), so 32 commits is the floor for the 2 MiB cap.
  • All three capacity loops break on first rejection, so their loop caps were never a cost driver.

Timing (Apple Silicon, node --test per file)

TestBeforeAfter
rejects an expansion atomically before the complete boundary exceeds capacity2,495ms1,171ms
projects a pre-bound legacy Plan ledger into the bounded Host contract517ms118ms
requires a projected legacy proposal to be revised or abandoned114ms41ms

Full @maka/storage suite: 766 tests, 754 pass / 12 skipped / 0 fail before and after. Suite wall time is bounded by the slowest test file, so the win shows up as ~3.8s less per-file CPU rather than lower end-to-end wall time.

Co-Authored-By: Claude noreply@anthropic.com

https://claude.ai/code/session_01Ac5rv6WUKWtMZgQb5QPN16

…al crossings
Refs apache#2388.
The sandbox-boundary capacity test now reaches MAX_EXECUTION_BOUNDARY_SERIALIZED_BYTES
with 15 near-max-length paths per request instead of 32 shorter ones — same
per-request byte size, less than half the accumulated entries each settle has
to rescan (2,495ms -> 1,171ms).
The legacy Plan ledger fixture now exceeds each projection bound by just
enough to force truncation (4 steps, 51 files, 21 risks, 31-char step titles)
instead of ~500KB of near-max fields per event (517ms -> 118ms, 114ms -> 41ms).
The catalog and vault capacity tests are unchanged: their per-item sizes
already sit at CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS x
CONNECTION_MODEL_ID_MAX_LENGTH and MAX_SECRET_LENGTH, and the provider auth
contract requires one connection per stored secret, so their commit counts are
already the minimum that crosses the aggregate byte limits.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ac5rv6WUKWtMZgQb5QPN16

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — this keeps the important capacity, atomicity, persistence, and truncation assertions intact while materially reducing fixture amplification. The direction is sound and CI is green.

Two non-blocking P3 notes:

  • The legacy Plan fixture can be reduced from four steps to three and still cross the shared text budget while preserving the existing files, risks, title, and truncation assertions.
  • The sandbox-boundary comment overstates “fewest settles”: 16 near-max paths still fit below the per-request cap and cross the aggregate boundary one settle earlier. Since #2388 originally marked this capacity test as already minimal, it may be worth either tightening the fixture/wording or leaving that hunk unchanged in a follow-up.

Neither point weakens the current assertions or blocks this improvement. Approved.

简体中文

感谢这次优化——容量、原子拒绝、持久状态和截断断言都保留了,同时明显降低了 fixture 放大成本。方向正确,CI 也已全绿。

两个不阻塞合并的 P3 建议:

  • Legacy Plan fixture 从 4 个 steps 改为 3 个,仍然足以越过共享文本预算,并保持现有 files、risks、title 和 truncation 断言。
  • Sandbox boundary 注释中的 “fewest settles” 不够准确:每轮 16 个接近上限的路径仍低于单请求容量,并能少一次 settle 越过总容量。考虑到 #2388 原先把这项容量测试列为已经最小,可以在后续进一步收紧 fixture/描述,或者保持该 hunk 不变。

这两点都没有削弱当前断言,也不阻塞本次优化。Approve。

@Astro-Han
Astro-Han merged commit c878316 into apache:mainAug 8, 2026
11 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@GabrielDrapor@Astro-Han