Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format follows Keep a Changelog and the package uses semantic versioning.

## Unreleased

- Fixed collection-keyed browser layout/index and engine index options reading
inherited properties as settings. Legal names such as `constructor` and
`__proto__` now use the existing defaults when no own entry exists.
Own/null-prototype entries, getters, formats and existing-index mismatch
guards are preserved. Programmatic inherited settings must become own entries.

- Coalesced overlapping same-key persistent reads within a tiered cache,
excluding `/HEAD.json` and `/current.json` publication metadata. Waiters
retain independent entries, per-caller metrics and mutation fences; settled
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/own-collection-options/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitattributes text eol=lf
*.mjs text eol=lf
results/*.svg text eol=lf
results/native-*.json -text -diff
221 changes: 221 additions & 0 deletions benchmarks/own-collection-options/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
# Own collection-option entries

## Decision

Merge-worthiness: 93/100. Recommend the scoped change after full CI and CodeQL
pass on the current pull request head and the required review is complete.
Every mandatory gate remains required regardless of score.

Legal collection names such as `constructor`, `toString` and `__proto__`
can currently be mistaken for inherited layout or index configuration.
Default engine writes fail, browser queries/plans throw, and accepted bundles
can unnecessarily invalidate the client. The candidate uses the existing
`ownValue` helper at eight collection-keyed lookups across the browser client
and both immutable engines.

Ordinary explicit configuration, null-prototype own maps and missing ordinary
names preserve complete measured I/O and encoded bytes. Additional own-property
checks have unmeasured runtime cost. Corrected operations perform useful work
that historical failures never reached; no performance improvement is claimed.

## Scope and compatibility

| Boundary | Revision |
| --- | --- |
| Historical main, including merged P21 | `48be1414f9a55393c14a91cf3441e0c4fe3935b5` |
| Prospective protocol published before edits | `d0a1de6e80ef24efd3841e8b1c260a26211abe0b` |
| Frozen implementation, fixtures, collector, verifier and tests | `43b030ff54beead27ab1ef12326c0248678a4f67` |

Only `src/browser/client.ts`, `src/engines/content-trie.ts` and
`src/engines/immutable-snapshot.ts` change in production. Existing helper,
interfaces, defaults, validation, serialization, addresses, envelopes, query
predicates, planner, ordering, cache policy and lifecycle rules are preserved.

Collection option dictionaries now use own entries. Missing own entries use
the existing trie/no-index defaults. Own getters, null-prototype maps and
nullish fallback retain their behaviour. Intended programmatic settings
inherited from another object must be declared as own properties instead.
This is an intentional compatibility correction.

Persisted index references still need matching explicit definitions or the
existing maintenance path. Ignoring inherited configuration does not silently
drop stored indexes. Six focused both-engine/prototype-name cases verify that
the mismatch guard rejects a write without altering stored state.

This is configuration correctness, not a new security or authorisation
guarantee. Already ordinary or explicit-own configurations have no demonstrated
behavioural benefit. Parked P22 equality/qualification, P19 range predicates and
the P7 cloud campaign remain unchanged.

## Method and evidence

The [prospective protocol](protocol.json) fixes four collection names, three
map forms and five paths: 60 trials per arm, 120 original rows. Forms are
empty ordinary maps, explicit own entries and null-prototype own entries.
Paths are both engines' replacement/update/read sequence, browser query,
browser explain and browser bundle publication.

One document changes from `label=v1` to `label=v2` in engine trials. Own forms
configure the `by-kind` scalar equality index and browser snapshot layout.
Empty browser forms mean default trie/no index. Browser fixtures are seeded
by both real engines with explicit null-prototype configuration, independently
of the options under test.

Actual APIs use a deterministic recording in-memory object store and synthetic
JSON reader, with memory caching and persistence disabled. Every store
get/put/delete/list, condition, result, error, UTF-8 body, reader call, final
state and input-ownership descriptor is retained. Measured work excludes
hashing/serialization internals, allocation, cache-memory operations, browser
transport and runner overhead. It is not disk, encrypted IndexedDB, network
or provider evidence.

One scored comparison ran from detached frozen source, from 21:03:29.328Z
to 21:03:30.437Z on 4 December 2026, using Node 22.22.2 on Windows x64
10.0.26300. Duration is provenance, not a latency sample.

Independent verification reconstructs expected results, validates the complete
store ledger and content hashes/HEAD references, rebuilds both complete
19-module exact-Git public API graphs and replays all 120 observations.
It checks 84 frozen inputs, all 45 paired measured-I/O controls, every CSV
cell, both graphs and all native attachments.

Only global event sequence/interleaving is removed for multiset comparison.
Operation, phase, key, conditions, payloads, byte counts, results and state
remain. Native runtime TypeError wording is recorded but not required to equal
Node wording; error classes and the explicit bundle-invalidation contract are
checked. No language-engine sort callback counts are treated as API contracts.

| Artifact | Contents |
| --- | --- |
| [Scored capture](results/local-2026-12-04.json) | Every row, configuration descriptor, operation, state and both executable graphs |
| [Per-trial CSV](results/local-2026-12-04-trials.csv) | Every trial and measured phase cost |
| [Successful-contract graph](results/local-2026-12-04-success.svg) | All names, forms and paths |
| [Measured-work graph](results/local-2026-12-04-work.svg) | All measured store/reader invocations, including setup and verification |
| [Original native capture](results/native-2026-12-04.json) | All original attachments from one zero-retry invocation |
| [Qualification manifest](results/qualification-2026-12-04.json) | Source/artifact/log identities, test results and all 360 original attachment digests |

## Results

Each name has 15 trials per arm.

| Collection | Historical successful contracts | Candidate successful contracts |
| --- | ---: | ---: |
| `notes` | 15/15 | 15/15 |
| `constructor` | 10/15 | 15/15 |
| `toString` | 10/15 | 15/15 |
| `__proto__` | 10/15 | 15/15 |
| Total | 45/60 | 60/60 |

![Successful collection-option contracts](results/local-2026-12-04-success.svg)

All 15 historical defect trials reproduce their specified exceptions or
unnecessary layout invalidation. All 60 candidate trials satisfy exact
document, revision, layout, index, input and active-client contracts.
All 45 ordinary/own/null-prototype controls preserve complete measured I/O,
encoded bytes and final state.

The table retains every measured setup, exercise, verification and cleanup
operation. Values are historical/candidate. Reader requests also cause store
gets in this fixture; the two columns are separate layers and must not be
interpreted as independent provider requests.

| Phase | Store gets | Store puts | Put-body bytes | Reader gets | Recorded events |
| --- | ---: | ---: | ---: | ---: | ---: |
| Setup | 72/72 | 192/192 | 32,232/32,232 | 0/0 | 456/456 |
| Exercise | 234/300 | 140/176 | 22,786/26,680 | 20/32 | 534/684 |
| Cleanup | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 |
| All | 306/372 | 332/368 | 55,018/58,912 | 20/32 | 990/1,140 |

![Complete measured store and reader invocations](results/local-2026-12-04-work.svg)

Corrected operations add 66 store gets, 36 puts, 3,894 put-body bytes and
12 reader calls. This is completion of previously failing work, not a
performance comparison. Local checks, memory, CPU, throughput, heap,
allocations and production incidence remain unmeasured.

## Native qualification

One invocation passes 180 paired tests, with zero failures, retries, flakes
or skips. All 360 observations pass independent per-arm validation and
logical/I-O correspondence with the matching Node rows. All 135 same-runtime
paired controls match.

| Engine | Version | Pairs | Historical/candidate successful contracts | I/O controls |
| --- | --- | ---: | ---: | ---: |
| Chromium | 153.0.8010.12 | 60 | 45/60 | 45/45 |
| Firefox | 155.0 | 60 | 45/60 | 45/45 |
| WebKit | 26.6 | 60 | 45/60 | 45/45 |

Each observation is converted to JSON text inside the browser, then parsed
once by the runner. An own `__proto__` sentinel must survive transport in every
observation. This method was specified before collection. It does not repair
or requalify P22's failed series. No global serializer/sort-call instrumentation
is used. Windows WebKit does not qualify Apple Safari.

## Other checks and score

| Check | Result |
| --- | --- |
| Focused candidate cases | 69/69 pass |
| Exact-historical substitution | 47 pass, 22 targeted failures |
| Related regressions | 937/937 pass across 23 files |
| Candidate-only preparation | 60/60 independently verified; both graphs build |
| Repository, Studio, Worker and explicit fixture/native types | Pass |
| Package and isolated packed consumers | Pass; browser isolation and optional-provider exports preserved |
| Built public-entrypoint probes | 60/60 complete normalised JSON observations match retained candidate rows |
| Documentation and links | Checked with existing validators and publication audit |
| Supported-Node site build, full CI and CodeQL | Required on the current pull request head |

Fixture query generic typing was corrected before freeze. Original diagnostics
are retained. No frozen source, harness, verifier, protocol or original capture
was edited or rerun after collection.

| Score component | Score | Basis |
| --- | ---: | --- |
| Correctness and fit | 37/40 | Reproduced legal-name failures corrected; ordinary configurations already work |
| Compatibility and work | 23/25 | Formats, guards and complete controls preserved; inherited settings need explicit ownership and checks add unmeasured cost |
| Reproduction | 19/20 | Complete exact-Git replay, original ledgers and three native engines; one local host and no Safari qualification |
| Simplicity | 14/15 | Existing helper reused at eight reads in three dependent modules; no interface or dependency |
| Total | 93/100 | Threshold 85 plus every mandatory gate |

Reject promotion if any candidate or existing-index guard fails, a declared
control changes, sentinel/independent/native verification fails, an unrelated
format/predicate/default changes, or publication-head checks fail.

## Reproduce

Use the locked dependencies and audit the retained observations:

```powershell
node benchmarks\own-collection-options\verify.mjs benchmarks\own-collection-options\results\local-2026-12-04.json benchmarks\own-collection-options\results\native-2026-12-04.json
npx vitest run tests\own-collection-options.test.ts
npx tsc --project benchmarks\own-collection-options\tsconfig.json --noEmit
```

The historical substitution exits nonzero with 47 passes and 22 failures:

```powershell
npx vitest run --config benchmarks\own-collection-options\baseline-vitest.config.ts
```

For new collection, use an isolated checkout detached at the frozen source and
an unused results JSON filename. The collector refuses existing outputs or
changed frozen inputs. Candidate preparation uses `run.mjs --preflight`.
Do not overwrite published evidence.

Native validation uses `tests/e2e/own-options.spec.ts`. Require absent
`.thimble-e2e` and free ports 5173/8787/8790 before launching the existing helper,
which deletes that directory at startup. Keep new validation output separate
from the archived invocation; subsequent CI execution does not replace it.

## Primary research

- [Object.hasOwn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn):
own-property tests exclude inherited members and support null-prototype maps
and shadowed names.
- [RFC 8259 object members](https://www.rfc-editor.org/rfc/rfc8259#section-4):
JSON members are explicit data; JavaScript prototype members are not extra
configuration.

Both sources were checked on 4 December 2026. No security, production-frequency
or general performance benefit is established.
9 changes: 9 additions & 0 deletions benchmarks/own-collection-options/baseline-vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {execFileSync} from "node:child_process";
import {readFileSync} from "node:fs";
import {fileURLToPath} from "node:url";
import path from "node:path";
import {defineConfig} from "vitest/config";
const root=fileURLToPath(new URL("../../",import.meta.url));
const protocol=JSON.parse(readFileSync(new URL("./protocol.json",import.meta.url),"utf8")) as {baseline:string;production:string[]};
const sources=new Map(protocol.production.map(p=>[path.join(root,...p.split("/")).replaceAll("\\","/"),execFileSync("git",["show",`${protocol.baseline}:${p}`],{cwd:root,encoding:"utf8"})]));
export default defineConfig({root,plugins:[{name:"exact-own-options-baseline",enforce:"pre",load(id){return sources.get(id.replaceAll("\\","/").split("?")[0]!)??null}}],test:{include:["tests/own-collection-options.test.ts"]}});
Loading