test: make hard-coded caps overridable behind seams (#1781 B5) - #1858
test: make hard-coded caps overridable behind seams (#1781 B5)#1858thymikee wants to merge 4 commits into
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks: no changes in the largest emitted chunks. |
|
Two validation blockers at exact
Coverage is also red from the inherited current-main ratchet mismatch tracked by #1860, and the PR remains draft. Harmony live evidence is still a residual readiness item for the changed snapshot path (or state the practical blocker). |
ab2ec38 to
f5a349d
Compare
|
Re-reviewed exact head
No HarmonyOS live-device evidence or practical blocker/exact verification command is documented, so that changed snapshot path remains residual readiness risk. Scope is accurate and all exact-head checks are green; the PR remains draft. |
|
Undrafted on green CI. 28/28 checks pass on |
|
Correction to my previous comment: it claimed the review findings were addressed, but it was posted one minute after a re-review of this same head ( |
755b6b0 to
0b31462
Compare
|
Re-reviewed exact |
HarmonyOS snapshot gains a maxNodes seam (mirroring the Android helper and Linux AT-SPI capture options) so the node cap's truncation signal is exercised below the 5,000 default; the durable descriptor JSON node cap gets its boundary test alongside the existing depth one.
… cap The walk returned as soon as the cap filled, so an omitted node's descendants reached neither rawNodeCount nor maxDepth and analysis under-reported exactly the oversized trees the cap exists for. Emission is now capped while accounting continues, matching the whole-tree claim the Android helper's analysis makes. Also pins the durable descriptor JSON node cap at its exact boundary: 4,096 nodes accepted, 4,097 rejected, through both the object-owned and array-owned counting sites.
…tion B5 asked for caps to be overridable so tests can reach them; for this cap the better answer is to extract the policy rather than widen the production interface. collectArkUiNodes takes every bound explicitly, so the emission limit and the accounting-continues-below-it rule are tested at their owning interface, and snapshotHarmony keeps its SnapshotOptions shape with no option no caller sets.
0b31462 to
39393b2
Compare
|
Re-reviewed exact |
Summary
Wave-3 item B5 (#1781): make hard-coded caps reachable from tests where hitting the cap has a real failure mode, and say which caps were surveyed and left alone.
Two caps get coverage; the rest of the survey is tabled below so the next reader does not redo it.
Result worth carrying to the rest of the wave: B5 was framed as "make caps overridable so tests can reach them", and for this cap that framing turned out to be the wrong answer. An option on the production snapshot interface that no caller ever sets is a test affordance wearing production clothes — the repo's rule is to make the invariant testable at its owning interface instead of widening a public one to reach it. So the traversal/emission policy was extracted into a pure function that takes its bounds explicitly, and
snapshotHarmonykept itsSnapshotOptionsshape. "Extract the policy" beats "add an override" wherever the cap governs a decision rather than a resource.src/platforms/harmonyos/snapshot.ts,MAX_NODES = 5_000): reaching the cap exposed a second, real bug that the seam made visible — the walkreturned as soon as the cap filled, so an omitted node's descendants reached neitherrawNodeCountnormaxDepth, andanalysisunder-reported exactly the oversized trees the cap exists for. Emission is now capped while accounting continues, which is what makes the whole-tree claim mirrored from the Android helper true. The policy now lives incollectArkUiNodes(root, { maxNodes, maxDepth, interactiveOnly })— a pure function with no defaults of its own, so the limit and the accounting rule are exercised directly at the interface that owns them.buildHarmonySnapshotsuppliesMAX_NODESand the caller's depth/interactive options;snapshotHarmony's signature is unchanged (SnapshotOptions), and no option was added anywhere. No CLI/MCP surface changes.packages/capture-kit/src/durable-json.ts,MAX_DESCRIPTOR_JSON_NODES = 4_096): reachable in memory without a seam, so it gets a boundary test instead. Every node counts — root object,itemsarray, each leaf — so the fixtures sit exactly on the cap: 4,094 leaves = 4,096 nodes accepted, 4,095 leaves = 4,097 nodes rejected. The count is enforced at two sites (validateObject,validateArray) and only whichever owns the offending node rejects, so both are pinned with an object-leaf and an array-leaf document.Survey — what has a real failure mode, what already has a seam, what was left
MAX_NODES5,000truncated; and under-reportedanalysisbelow the capMAX_DESCRIPTOR_JSON_NODES4,096false)MAX_DESCRIPTOR_JSON_DEPTH32@agent-device/xmlMAX_XML_NESTING_DEPTH256 /maxDocumentCharsErrorthere is #1792's class)MAX_OVERLAY_REFS24 (screenshot-overlay.ts)maxRefs)runner-startup-transport.ts)timeoutMs; exhaustion tested withtimeoutMs=100retryWithPolicyalready takesmaxAttempts/baseDelayMs/jitter, and 39 suites usevi.useFakeTimers()), just not carried here: the exhaustion outcome is already a typed error with its own coverage. Not a CI constraintIOS_SIMULATOR_SCREENSHOT_RETRY_MAX_ATTEMPTS5retryWithPolicyPREPARE_RUNNER_HEALTH_MAX_SESSION_ATTEMPTS2,ANDROID_KEYBOARD_DISMISS_MAX_ATTEMPTS2,HELPER_CONTENT_CAPTURE_ATTEMPTS3,MAX_UPLOAD_REDIRECTS5AppErrorOUTCOME_RETRY_ATTEMPTS2, Android freshness / divergence retry delays,MAX_REPLAY_TEST_RETRIESclampretried:false,staleAfterRetries,unavailable)IOS_DEVICE_TRACE_RECORD_MAX_ATTEMPTS3 (declared twice:perf.ts,perf-xctrace.ts)LEDGER_MAX_ENTRIES512 (runner recycle ledger)MAX_RUNNER_RECYCLES_PER_REQUEST = 1guard that exists because of the #1105 wedgeresetRunnerRecycleLedgerForTestsalready existsMAX_REF_PINS_PER_SCOPE1,000,MAX_CRASH_ARTIFACT_BYTES64 MB,MAX_HTTP_RPC_BODY_BYTES1 MB, app-event/push 8 KB payload capsNETWORK_MAX_SCAN_LINES4,000 (parser layer hasmaxScanLines)events.ndjson(no cap at all)No central limits/config module exists; each cap is declared once at its use site and the two numeric env overrides in the tree (
AGENT_DEVICE_APP_LOG_MAX_BYTES,AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS) each live beside the limit they override. This PR follows that: no newprocess.envreads.Validation
Both new tests were run red against the pre-change code before going green:
const maxNodes = MAX_NODESrestored,snapshotHarmony reports truncation once the node cap is hit …fails withAssertionError: Expected values to be strictly equal: + actual - expected / + undefined / - true(the cap is never reached, sotruncatedstays unset).collectArkUiNodes: restoring the earlyreturnat the limit →× collectArkUiNodes keeps counting the tree below a node the limit omitted,+ maxDepth: 1, rawNodeCount: 3against- maxDepth: 3, rawNodeCount: 5.MAX_DESCRIPTOR_JSON_NODESby one either way reddens it, so the fixtures are on the cap and not merely past it:4_097→- false / + true(the over-cap document is wrongly accepted);4_095→- true / + false(the on-cap document is wrongly rejected).validateArray; the object-leaf case rejects invalidateObject, and the array branch was uncovered until the second document was added): deleting the conjunct atdurable-json.ts:31reddens it, and so does deleting the one at:57.pnpm check:affected --rungreen locally (fallow, layering, coverage over the related set: 241 files / 1,632 tests). Provider-integration and coverage lanes are CI-owned forsrc/platforms/**.truncatedsignal, and a durable-descriptor guard that stops bounding node count — both unobservable before because nothing reached either cap.maxDepth: 64was a hard cap nobody could exercise below the real tree; the private-AX ladder only landed after on-device failure. Both caps here had zero tests at the boundary (survey above).Residual readiness risk: no HarmonyOS device evidence
The HarmonyOS change is covered only by unit tests that mock
runHarmonyHdc, which is whatdocs/agents/testing.mdrequires of CI (GitHub has no DevEco/HDC/emulator). No live HarmonyOS device or emulator run backs the changed snapshot path, and I have no HarmonyOS hardware. The accounting change altersanalysis.rawNodeCount/maxDepthon real oversized trees, so someone with a device should confirm on a screen large enough to exceed the default 5,000-node cap:Treat that as the merge gate for the HarmonyOS half if this repo wants device evidence for a platform-path change; the durable-JSON half is host-only and needs none.
Touched files: 3 (
src/platforms/harmonyos/snapshot.ts, its test,packages/capture-kit/src/durable-json.test.ts). Scope stayed within the two named caps; docs/skills untouched (no user-facing surface changed).