GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — aggregator(snapshots): SnapshotStore groups by serviceId into plain objects — a '__proto__'/'constructor'/'toString' serviceId crashes byService (blanking all snapshot history) and pollutes Object.prototype during compact · Issue #2941 · developing-today/code

aggregator(snapshots): SnapshotStore groups by serviceId into plain objects — a '__proto__'/'constructor'/'toString' serviceId crashes byService (blanking all snapshot history) and pollutes Object.prototype during compact #2941

New issue
Copy link
New issue
Copy link
Closed
#3733
Closed
aggregator(snapshots): SnapshotStore groups by serviceId into plain objects — a '__proto__'/'constructor'/'toString' serviceId crashes byService (blanking all snapshot history) and pollutes Object.prototype during compact#2941
#3733
Copy link
Assignees
dezren39
Labels
app/aggregatorPackage/app: aggregator (pm-stack in this repo)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 31, 2026
Issue body actions

aggregator(snapshots): SnapshotStore groups by serviceId into plain objects — a __proto__/constructor/toString serviceId crashes byService (blanking all snapshot history) and pollutes Object.prototype during compact

Evidence (verified this run, main df6d9f58)

SnapshotStore validates records with isSnapshotRecord, which checks only that serviceId is a non-empty string (pm-stack/aggregator/src/snapshots.ts:303). Two grouping sites then use that unvalidated id as a key in a plain object literal:

  • byService() — snapshots.ts:563-565:
    const grouped: Record<string, SnapshotRecord[]> = {};
    for (const r of await this.readAll()) {
      (grouped[r.serviceId] ??= []).push(r);
    }
  • compactInner() per-service report — snapshots.ts:703-711: the same (perService[r.serviceId] ??= { before: 0, after: 0 }) accumulation in three loops.

For a prototype spelling, the ??= read walks the prototype chain and returns an inherited member instead of undefined, so nothing is ever assigned under that key:

  • grouped["__proto__"] → Object.prototype (no .push)
  • grouped["constructor"] → the Object constructor function (no .push)
  • grouped["toString"] → Object.prototype.toString (no .push)

Probe (laptop, real module md5-identical to main)

Probe: ~/git/fleet/probe-2026-10-30-laneA-snapproto/ on the laptop — verbatim snapshots.ts (md5 b5055f8a2576d57e25bba0413f08ca78, matching main df6d9f58) + model.ts, run under bun 1.4.2, one process per case. Store file usage-2026-10.jsonl with a normal claude record plus one record whose serviceId is the test spelling (all other fields valid; isSnapshotRecord(bad) === true in every case):

case result
control (serviceIds claude + whatever) byService() ok, keys ["claude","whatever"]
byService() with __proto__ THREW TypeError: (grouped[r.serviceId] ??= []).push is not a function
byService() with constructor THREW same TypeError
byService() with toString THREW same TypeError
compact() with __proto__ (2025-01 month) completed, but report perService keys = ["claude"] only (the __proto__ service silently missing though recordsBefore: 2), and Object.prototype gained own properties before/after (both NaN) — ({}).before === NaN afterwards
compact() with constructor completed, perService keys = ["claude"] only; counts were written onto the Object constructor function instead
compact() control (claude + claude2) report keys ["claude","claude2"], no prototype change

Why it matters

  • One poisoned record blanks ALL snapshot history, persistently. byService()'s only production caller is pm-stack/aggregator/src/sources/live.ts:849: const history = await store.byService().catch(() => ({})); — the throw is swallowed and the whole history section renders empty, for every service, not just the bad one. And because the record passes isSnapshotRecord, store.append(feed.snapshots) (live.ts:~846) happily writes it into the monthly JSONL, so the store stays poisoned on every subsequent read until someone hand-edits the file. The snapshot writers are external jobs (fleet-feed collector, stewardship-cycle, backfill) feeding service ids through the feed — the aggregator's own store philosophy is "one bad line never poisons the store" (snapshots.ts:~550), and this line does exactly that.
  • Compaction corrupts its own report and the process. With __proto__, compact's counts are added onto Object.prototype (before/after = NaN) for the rest of the scripts/compact-usage-snapshots.ts process, and the service vanishes from perService while still counting in recordsBefore. With constructor, counts land on the Object function. (The rollup data itself is built with a Map at snapshots.ts:201-205 and is unaffected — only the report and the prototype are hit.)
  • The safe pattern already exists in the same file/package: appendLocked groups with new Map (snapshots.ts:~620), compactRecordsToRollups groups with a Map, and quota-current.ts:153 groups by serviceId with a Map. These two sites are the outliers. Related but distinct: design(own-key lookups): a plain object is not a map for untrusted keys — one own-key rule for every dynamic lookup #2792 (read-side own-key lookups; its scope note explicitly leaves write-side instances to be reported/fixed separately, cf. aggregator(cost-explorer): a setup named '__proto__' is silently never saved — save/import assign into a plain object, so the name becomes the store's prototype instead of an entry #2851), aggregator(snapshots): isSnapshotRecord never checks limit/resetsAt — a numeric resetsAt crashes the service history chart, a non-numeric limit NaNs it #2483 (isSnapshotRecord limit/resetsAt — different fields/effect).

Acceptance criteria

  • byService() returns an entry for a record whose serviceId is __proto__, constructor, or toString (e.g. via a Map converted at the boundary, or an own-key-safe accumulator), and never throws for a record isSnapshotRecord accepts; normal serviceIds unchanged.
  • compact()'s perService report includes prototype-spelled serviceIds with correct before/after counts, and running compact leaves Object.prototype untouched (Object.getOwnPropertyNames(Object.prototype) unchanged, ({}).before === undefined).
  • Regression tests in the aggregator suite (e.g. pm-stack/aggregator/test/snapshot-retention.test.ts or a snapshots test) covering __proto__/constructor/toString serviceIds for both byService() and compact(), plus the unchanged normal control.
  • Triage decides whether isSnapshotRecord should additionally reject prototype spellings as serviceIds — but the grouping fix must not depend on that, since existing store files may already hold such a line.

Found by new-issue-creator-code-a (lane A) this run; probe and this evidence retained at the laptop path above.

Activity

Next
  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 31, 2026
  2. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator (lane A, new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a, run 2026-10-30 23:05 CDT
    • Found via: filed this run
    • Task: Filed after verifying on main df6d9f5 with a laptop probe using the real snapshots.ts (md5-identical): SnapshotStore.byService() throws TypeError for a record whose serviceId is proto/constructor/toString (all pass isSnapshotRecord), so live.ts's catch blanks the entire snapshot history — persistently, since append() writes such records into the store; compact() additionally drops those services from its perService report and, for proto, writes before/after=NaN onto Object.prototype. Full probe table in the issue body.
    • Expectation: effort/xs; done = byService/compact group serviceIds safely (Map or own-key-safe accumulator, matching the Map pattern already used in appendLocked/rollups/quota-current), regression tests for the three spellings in both paths, prototype untouched after compact.
    • Links: probe (laptop) ~/git/fleet/probe-2026-10-30-laneA-snapproto/ · related design(own-key lookups): a plain object is not a map for untrusted keys — one own-key rule for every dynamic lookup #2792 (read-side design; write-side instances are filed separately per its scope note), aggregator(snapshots): isSnapshotRecord never checks limit/resetsAt — a numeric resetsAt crashes the service history chart, a non-numeric limit NaNs it #2483 (different fields)
  3. dezren39
    added a parent issue on Oct 31, 2026
    • Design: define, don't assign — untrusted keys are stored with define semantics, never through the __proto__ setter #2953
  4. dezren39
    added
    source/design-architectFiled by the repo design architect job
    on Oct 31, 2026
  5. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    agent-note:v1 — design-architect pass 24 (2026-10-31): ADOPTED as Phase 1 of design #2953 (define, don't assign — the write-side prototype contract) and linked as its sub-issue (verified). Triage: do NOT re-file/re-scope/split; record the phase structure instead. Per #2953's recorded decisions: fix by container construction (group into a Map, convert at the boundary — the idiom already used by appendLocked and compactRecordsToRollups in this same file), NOT by rejecting prototype spellings in isSnapshotRecord (your acceptance already requires the grouping fix to stand alone, since a poisoned line may already be on disk), and preserve the serviceId as data. Lands first among the design's phases: it is the only instance that pollutes Object.prototype itself and blanks all snapshot history.

  6. github-actions
    assigned
    dezren39
    on Oct 31, 2026
  7. dezren39
    added
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    on Nov 1, 2026
  8. 39 remaining items

  9. dezren39
    added
    queue/queuedHas a queued queue task
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    queue/queuedHas a queued queue task
    on Nov 1, 2026
  10. dezren39 commented on Nov 1, 2026

    @dezren39
    dezren39
    on Nov 1, 2026
    MemberAuthor
    More actions

    agent-note:v1 — state=picked_up
    worker: repo-worker-code
    task_id: 5666
    issue: #2941
    branch: pending
    summary: Claimed small-fix task; fresh state confirms issue is open, no matching open PR found, and no hard-stop labels are present. Epic #2953 confirms preserve-not-reject and Map grouping design.
    next: create isolated worktree, implement both grouping sites and regression tests.

  11. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 1, 2026
  12. dezren39 commented on Nov 1, 2026

    @dezren39
    dezren39
    on Nov 1, 2026
    MemberAuthor
    More actions

    agent-note:v1 — state=done
    worker: repo-worker-code
    task_id: 5666
    issue: #2941
    pr: #3733 #3733 (open)
    branch: queue/5666-2941-snapshotstore-map-grouping
    summary: Map-based grouping now preserves prototype-spelled service IDs in byService and compaction reports without mutating built-in prototypes. Queue task completed as pr_opened.
    verification: snapshot-retention suite 13/13; file-scoped TypeScript check passed. Full suite has one registry-fixture failure, reproduced on clean main; full package typecheck has unrelated pre-existing errors.

  13. dezren39
    added
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 1, 2026
  14. dezren39
    closed this as completedin #3733on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/aggregatorPackage/app: aggregator (pm-stack in this repo)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.