Skip to content

S2 entity-scoped how-many (P54 140/180) - #171

Merged
cursor[bot] merged 12 commits into
devfrom
pr/s2-entity-scoped-counts-1e9e
Aug 26, 2026
Merged

cursor[bot] merged 12 commits into
devfrom
pr/s2-entity-scoped-counts-1e9e

Conversation

@sdntsng

@sdntsng sdntsng commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Product /recall how-many answers were dumping the typed hop set (all children-adjacent rows, all pets, all times). This ships a generic S2 enumerate/count fix: hop only the counted predicate, entity-scope the count set to the queried subject, keep quantified class phrases, collapse bare class labels (including possessed-class provenance parens), and intersect a specific head only when items mention it.

Same-store skip-ingest 180 is 140/180 vs P53 137/180. Unique losses: none. Named recoveries: Melanie children 7→3, Andrew Sep pets 13→1, John ankle 38→2. Andrew Dec pets is honest 4 (Scout stored as Andrew) vs gold 3 — no gold special-case.

This is not leftover covering. Not 90% (162/180 on this sample; public LoCoMo is n=1540 at 11.4%). Not a Mem0 same-pin. Do not merge leftover-covering PRs #133, #131, #143, #145.

Changes

  • internal/memory/planner.go: count queries hop only the first (counted) predicate.
  • internal/memory/recall.go: filterCountItems entity-scopes via metadata subject; drops sibling predicates, child like-complements, owner accessories, and non-instances; MONTH YEAR as-of is end of month; hop Values bind to the extracting content row; earliest matching ObservedAt; class-noun collapse keeps quantity phrases and naming referents; possessed-class labels with provenance parens stay bare; specific-head intersect only when items mention the head.
  • Tests in internal/memory/recall_test.go for quantified children, Ferrari vs cottage, pet paren class labels, as-of bounds.
  • Pin: docs/benchmarks/artifacts/locomo-s0-diag-mh-135-p54-20260826.md, README row, cycle-closeout P54 section, summary JSON + failure ledger.

Test plan

  • go test ./internal/memory/ green on this branch
  • Live /recall holds: children=3, Ferraris=2, Sep pets=1, ankle=2; P53 self-care leftover held
  • Skip-ingest 180 on tenant diag-mh-135: 140/180, unique losses none
  • gofmt -l . clean on touched files
  • go vet ./...
  • Full go test ./... (embedded-postgres; first run slow)

Linear / tracking

ENG-176 (MH), parent ENG-168.

Risk / follow-ups

  • Andrew Dec pets remains 4 vs gold 3 (honest store). Do not special-case Scout.
  • Isolated leftover covering stays saturating — do not grow it item-by-item from this 180.
  • Next generic lever: S2 list completeness (truncated tags/collars / extra tricks / food lists), then S2b OD, then S1 WRITE with re-ingest, then S5 industry.
  • Do not treat 140/180 as 90% or as beating Mem0. Full n=1540 only at S6. Fair Mem0 180 waits on quota 2026-09-01.
  • dev is staging. Do not fast-forward main from this PR unless explicitly asked.
Open in Web Open in Cursor 

sdntsng and others added 12 commits August 26, 2026 04:27
Count queries were enumerating sibling predicates and then using dump
length as the answer, so preference junk counted as children, another
person's possessions counted as pets, and every health row counted as
an incident. Counts now hop only the counted predicate, keep items
whose subject matches the query entity, collapse class nouns, honor
as-of month bounds, and count times by the object token.

Co-authored-by: aria <aria@engramhq.com>
Fixtures: preference junk is not children, another person's pets are
not counted, times counts object incidents not all health, and as-of
month-year keeps possessions observed through end of that month.

Co-authored-by: aria <aria@engramhq.com>
Hop Values are deduped and were paired with MemoryIDs by index, so
as-of bounds used the wrong session date. Bind each value to the
content row that extracted it. As-of counts read historical atoms.
Child counts drop kids-like preference complements stored as family
members. Pet counts keep class instances and named individuals, not
accessories whose lexical head is bed/toy/pad/garden.

Co-authored-by: aria <aria@engramhq.com>
Family-member 'kids like nature' must not add to a child count. Dog
toys owned by the same person must not add to a pet count.

Co-authored-by: aria <aria@engramhq.com>
How-many used current-state (one latest slot) so child enumerations
collapsed to a single role. Counts now retrieve historical atoms.
As-of uses the earliest matching observation so a later mention does
not date-shift an individual. Times answers prefer distinct values
when evidence IDs collided from overlapping slot strings.

Co-authored-by: aria <aria@engramhq.com>
Bare class labels (kids, pets) still yield when named instances exist.
Quantified phrases such as "two children" are the counted set, not a
duplicate label, so collapsing them to the last lexical head dropped
real quantity from how-many answers.

Co-authored-by: aria <aria@engramhq.com>
Cover daughter + "man and two children" as 3, and assert collapse keeps
the numbered phrase while dropping bare kids/children.

Co-authored-by: aria <aria@engramhq.com>
How-many Ferraris was collapsing "a new Ferrari" as a bare class noun
and then counting every remaining possession. Prefer items that mention
the counted noun; if none do (coupe/sedan vs cars), keep the typed set.
Modified class mentions are instances, not duplicate labels.

Co-authored-by: aria <aria@engramhq.com>
Ferrari counts stay 2 when studios and unlabeled sports cars are in the
typed dump. Generic "a new Ferrari" labels still count as instances.

Co-authored-by: aria <aria@engramhq.com>
"dog (shelter adoption)" is a class label, not a fifth pet, when named
dogs already exist. Named slots ("puppy named Toby") stay instances.

Co-authored-by: aria <aria@engramhq.com>
Co-authored-by: aria <aria@engramhq.com>
Same-store skip-ingest 180 is 140/180 (MH 20, OD 4, SH 85, temporal 31)
versus P53 137/180. Unique gains: children 7→3, Sep pets 13→1, ankle 38→2.
Unique losses none. Not leftover covering. Not 90%. Not a Mem0 same-pin.

Co-authored-by: aria <aria@engramhq.com>
@cursor cursor Bot changed the title S2: entity-scoped how-many answers (no leftover covering) S2 entity-scoped how-many (P54 140/180) Aug 26, 2026
@cursor
cursor Bot merged commit 7e95b1b into dev Aug 26, 2026
2 checks passed
@sdntsng
sdntsng deployed to dev - brainy-worker-staging August 26, 2026 05:18 — with Render Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant