Repository navigation
test(mock): judge plain data through the owner - #521
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused mock changes match the shared helpers' contracts and include regression coverage, with no blocking issues identified.
Review effort: Balanced
Findings: None
What changed in this PR
Aligns the end-to-end mocks with the engine's shared plain-data handling.
Changes:
- Replaces duplicate plain-object checks with the shared helper.
- Uses safe property reads and writes when merging seed data.
- Adds regression coverage for
__proto__keys and owner reslugging.
| File | Description |
|---|---|
| test/e2e/mock/state.ts | Uses shared helpers for plain-object checks and safe seed merging. |
| test/e2e/mock/state.test.ts | Verifies __proto__ remains data and the owner is reslugged. |
| test/e2e/mock/request-body.ts | Uses the shared plain-object check and removes an unused import. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Vivswan
force-pushed
the
test/tidy-copies-and-long-lines
branch
from
October 6, 2026 22:42
931b294 to
80fcdc9
Compare
The mock judged plainness five ways beside the engine's owner in src/plain-data.ts: two private isPlainObject copies (state.ts, request-body.ts), two inline checks (support.ts asObject, the chaos stripped arm), and the GraphQL variables guard in routes.ts, all accepting any non-null, non-array object, where the owner also refuses a foreign prototype. All five now use the owner; its predicate type is the type the mock's Json alias names, so no wrapper or cast is needed, and routes.ts drops its cast. A live_state seed can carry a foreign prototype after all: the yaml parser turns !!timestamp into a Date, !!set into a Set, and !!binary into a Uint8Array, and the schema passes them through as unknown. Under the owner such a seed replaces like a scalar, as the engine treats the same tag in a settings file, where the old checks spread it into the state. Three arbitrary-key copies assigned out[key], so a key spelled __proto__ set the output's prototype: deepMerge (under the stricter predicate reslugRepo then skipped the seeded owner), the chaos missing_envelope arm (the seeded key vanished from the reply), and protectionFromPut. All three write through the owner's put, and deepMerge reads through own; a test each pins deepMerge and the chaos arm with a parsed seed.
Vivswan
force-pushed
the
test/tidy-copies-and-long-lines
branch
from
October 6, 2026 22:58
80fcdc9 to
aa61a56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
How
Jsonalias, no wrapper or cast.!!timestamp,!!set,!!binary) now replaces like a scalar, as the engine does, where the old checks spread it into the state.__proto__stays data: deepMerge keeps the seeded owner reslugged, and the missing_envelope reply keeps the key.Proof
grep -rc Array.isArray test/e2e/mocksums to 21 before, 16 after; the five gone were plainness checks; the rest judge lists.out[key]again; the other mock tests green, 96 across six files.Technical details
src/plain-data.ts, the repository's one plain-mapping judgment; the npmis-plain-objectpackage would be a second judgment beside it.Jsonintest/e2e/mock/support.tsand instate.tsis an alias ofRecord<string, unknown>, the owner's predicate type, so every caller typechecks unchanged and routes.ts drops itsas Jsoncast.test/sections/*/scenariosortest/e2eseeds a YAML tag or a__proto__key; both reachlive_statethroughz.unknown(), and the change takes the owner's semantics for them.actions_retention: !!binaryseed is a Uint8Array there, replaced whole under the owner where the old check spread its indices into the state.routes.tsvalue && typeof value === "object"after a list branch in the node-id walk,support.tstypeof rule === "object" && rule !== nullin the rule-type read,server.tson the bound address.state.tsthe URL rewrite loop, the stored-twins loops, the extras loop;support.tsstored[key] = payload[key];server.tsquery parsing.test/e2e/mock/{state.ts,request-body.ts,support.ts,chaos.ts,routes.ts}(+15 -20),test/e2e/mock/{state.test.ts,chaos.test.ts}(+43).