Title: Design: define, don't assign — untrusted keys are stored with define semantics, never through the __proto__ setter · Issue #2953 · developing-today/code · GitHub
Open Graph Title: Design: define, don't assign — untrusted keys are stored with define semantics, never through the __proto__ setter · Issue #2953 · developing-today/code
X Title: Design: define, don't assign — untrusted keys are stored with define semantics, never through the __proto__ setter · Issue #2953 · developing-today/code
Description: Summary One rule for the write side of the prototype family: a value keyed by an externally-spellable name is stored with define semantics, never assignment semantics. Assignment (obj[key] = v, obj[key] ??= …, dst[k] = src[k] copy loops,...
Open Graph Description: Summary One rule for the write side of the prototype family: a value keyed by an externally-spellable name is stored with define semantics, never assignment semantics. Assignment (obj[key] = v, obj...
X Description: Summary One rule for the write side of the prototype family: a value keyed by an externally-spellable name is stored with define semantics, never assignment semantics. Assignment (obj[key] = v, obj...
Opengraph URL: https://github.com/developing-today/code/issues/2953
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design: define, don't assign — untrusted keys are stored with define semantics, never through the __proto__ setter","articleBody":"## Summary\n\nOne rule for the write side of the prototype family: **a value keyed by an externally-spellable name is stored with define semantics, never assignment semantics.** Assignment (`obj[key] = v`, `obj[key] ??= …`, `dst[k] = src[k]` copy loops, `Object.assign(dst, src)`) goes through `[[Set]]`, and for exactly one spelling — `__proto__` — `[[Set]]` invokes the `Object.prototype` setter instead of creating an own property: a non-object value is silently ignored, an object value replaces the container's prototype. Three filed instances in three surfaces prove the class; this design adopts them as its phases and closes with an inventory audit.\n\nThis is the write-side counterpart of #2792 (read-side own-key lookups), whose design doc explicitly scoped this class out (\"a different bug class with a different fix… a future design decides\") and whose pass-23 assessment recorded the trigger: originate when a second write-side instance files after #2851. There are now three.\n\nDesign doc: `files/designs/code-proto-write-side.md` in the keep-the-four-repos-healthy goal workspace (problem, evidence, alternatives, risks, open questions).\n\n## The instances (audited at origin/main `106b0571`)\n\n- **#2941 — aggregator snapshots (Phase 1, the polluting instance).** `SnapshotStore.byService()` (`pm-stack/aggregator/src/snapshots.ts:562-565`) groups with `(grouped[r.serviceId] ??= []).push(r)` and `compactInner()` (:703-711) accumulates its report the same way; `serviceId` is validated only as a non-empty string (:303) and arrives from external feed jobs. A `__proto__`/`constructor`/`toString` id makes `byService()` throw (its only caller swallows the throw into `{}` — all snapshot history blanks, persistently, since the record passes validation and is stored), and `compact()` with a `__proto__` id writes its counts onto `Object.prototype` itself (`({}).before === NaN` afterwards). The same file already groups with `Map` at `appendLocked` (~:620) and in `compactRecordsToRollups` — these two sites are outliers in their own file.\n- **#2851 — aggregator cost-explorer (Phase 2).** Saved setups live in a plain object from localStorage (`pm-stack/aggregator/src/render.ts:4338` save `all[name] = …`, :4359 import `all[k] = parsed[k]`). A setup named `__proto__` is silently never saved; an imported one mutates the store object's prototype. Silent data loss both directions.\n- **#2828 — bin/record (Phase 2).** `parseLoose` (`bin/record.mjs:110`) builds fields by assignment; a loose `__proto__` field counts toward the keyed-segment threshold but never reaches the appended JSONL line — breaking record's never-lose-a-field contract for exactly the key an agent records while reporting this bug class. The JSON path preserves it (parse + spread = define semantics); the two paths disagree.\n\n## Decisions recorded\n\n1. **Preserve, don't reject.** The key is data: a `__proto__` field / setup name / serviceId is stored, listed, exported and re-read like any other key. (#2851's acceptance permits visible rejection for setup names; this design records *preserve* so all surfaces behave identically and #2941's already-stored records become readable instead of stranded. Validation-side rejection is also not the fix — #2941's acceptance already states the grouping fix must not depend on it.)\n2. **The prototype must not move** — asserted as a test property: after any covered write, the container's prototype is unchanged (or `null` by design) and `Object.prototype` gains no own properties.\n3. **Accumulators are construction, not lookup.** Grouping/counting sites are fixed by changing the container (`Map`, converted at the boundary via `Object.fromEntries`/spread), not by `hasOwn` guards — that is the boundary with #2792. (`byService()`'s crash is a `??=` read, but its fix is container construction, so it lives here; #2792's Phase 3 audit should disposition it as covered by this design.)\n4. **One probe matrix everywhere:** `__proto__` with a string value *and* an object value (the setter treats them differently), `constructor`, `toString`, an ordinary key — asserting own-property presence, JSON round-trip preservation, and decision 2.\n\n## Phased breakdown\n\n- **Phase 1 = #2941** (aggregator snapshots): `Map` grouping in `byService()` + `compactInner()`, converted at the boundary. Lands first — the only instance that corrupts global state and blanks a whole surface, and its store may already hold a poisoned line.\n- **Phase 2 = #2828 + #2851** (silent loss at the edges): define-semantics construction in `record.mjs`'s loose parser and in the cost-explorer save/import paths. Independent of Phase 1.\n- **Phase 3 = new issue (filed with this design)**: closing inventory audit — grep TS/JS/mjs (vendored assets and tests excluded) for the four non-conforming forms with dynamic keys, disposition each (covered / external-key → fixed here or filed as a named follow-up / internal-only → named in the closing evidence), state the contract in the app docs that already state contracts, and close this design with the evidence. Candidates already visible, to be dispositioned not pre-judged: antigravity-direct's schema walkers (`merged[k]`, `sub[name]`, `props[name]` — external tool-schema keys); provider-catalog-sync's `report.providers[providerId]` and `(added[pid] ??= [])`; pkgs/id/web `Object.assign(records, frame.records)` (`world.ts:181`, a peer-supplied frame); sync-models' `prov.models[baseId]` family. Gated on Phases 1–2.\n\nPhases 1–2 adopt the origin issues (no parallels — they carry explicit acceptance with verified probes and queued triage packets). Related, deliberately NOT adopted: today's read-side filings #2920 / #2919 (id/web) belong to #2792's Phase 3 audit — their fix is a read guard.\n\n## Open questions (stay in the design doc, not filed)\n\n- Lint enforcement of define-semantics (false-positive rate known only after Phase 3's inventory — same deferred question as #2792's for reads).\n- Recursive/deep-merge helpers, if Phase 3's audit finds one in-tree (none known).\n- Cost-explorer storage-format change (per-name keys) — unnecessary once names are safe; revisit only if that format is revised for another reason.\n\n---\n*Filed by the repo design architect (pass 24, 2026-10-31) for developing-today/code. Implementation phases are the linked sub-issues; phases with open questions stayed in the design doc.*\n\n## Acceptance criteria\n- The design doc (`files/designs/code-proto-write-side.md`, goal workspace) is adopted or amended with the decision recorded on this issue.\n- Each filed write-side instance (the three surfaces named in the design, incl. #2851) is linked as a phase of this epic, with its fix approach stated in define-semantics terms.\n- The closing inventory audit is posted: every externally-keyed write site in the prototype family is listed and dispositioned (define semantics, guarded, or filed as a follow-up).\n- Read-side counterpart #2792 is cross-linked and the boundary between the two classes stays explicit.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-31T05:32:29Z","url":"https://github.com/developing-today/code/issues/2953"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:61f3b689-cd34-da08-bf2f-153fb96a917f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE04:1243D2:2E7859:3EDA27:6B076086 |
| html-safe-nonce | b0915cbc6e3a7b8c381189aec97b9c0fed51d04df0223c7dfb79db05d7c381a1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTA0OjEyNDNEMjoyRTc4NTk6M0VEQTI3OjZCMDc2MDg2IiwidmlzaXRvcl9pZCI6IjIzMDY2NDQ0OTA1NjE0Nzg3OTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d0246f432fc3e0e4a5672b0ff389134af35a518164841d662cc37a4b8fa36a25 |
| hovercard-subject-tag | issue:6131585447 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/2953/issue_layout |
| twitter:image | https://opengraph.githubassets.com/15fb05b894c94f1480ad5e79e97a8f3fe624d659cb3ce6d24d4837180d0dcb2c/developing-today/code/issues/2953 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/15fb05b894c94f1480ad5e79e97a8f3fe624d659cb3ce6d24d4837180d0dcb2c/developing-today/code/issues/2953 |
| og:image:alt | Summary One rule for the write side of the prototype family: a value keyed by an externally-spellable name is stored with define semantics, never assignment semantics. Assignment (obj[key] = v, obj... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7a557ecc960a3ae6e299fc66b0bc9132072f8860191648e6749fee5d3ff00d82 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bd845eb7947c1ed8c850f7ab415a51339d162de3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width