Skip to content

fix(usage): preserve project identity and qualify session counts - #1271

Merged
iamtoruk merged 6 commits into
getagentseal:mainfrom
avs-io:codex/project-identity-session-counts
Sep 8, 2026
Merged

iamtoruk merged 6 commits into
getagentseal:mainfrom
avs-io:codex/project-identity-session-counts

Conversation

@avs-io

@avs-io avs-io commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Project summaries can split the same working directory across providers or attach a legacy pathless summary to the wrong project. Session totals can also look exact when the available history cannot establish unique session identities.

This preserves working-directory identity through discovery, parsing, caching and aggregation. It coalesces the same directory across providers, keeps distinct POSIX paths separate, preserves Windows path normalization, leaves ambiguous legacy summaries unallocated, and sums project savings correctly. Project details and charts use the same identities, including collision-safe rows and accessible full-path labels.

Counts now say “At least N” when history only supports a lower bound; unsupported per-session averages are omitted. Combined-device views show “Session count unavailable” when identities cannot be reconciled. The native menu uses the same count qualification and exposes project expansion as an accessible button.

Review order: this branch includes the two test-only prerequisite commits from #1270 because the existing process watchdog smoke test reproduced its startup race during verification. Please review/land #1270 first; I will remove those duplicate prerequisite commits when rebasing. The project/counting change is the separate f5fd47e8 commit.

Validation on current main (0b1cf56f) plus this change:

  • CLI build and full suite: 3,856 passed, 5 skipped. Also rerun from an unbuilt source export after correcting a regression test that originally assumed dist/cli.js existed: 3,856 passed, 5 skipped. The test now spawns the source CLI with an isolated temporary fixture and preserves the same assertions.
  • Desktop full suite with the test: stabilize process smoke and cache-lock regressions #1270 prerequisite: 864 passed, 4 skipped; typecheck and renderer build passed.
  • Native focused count/payload tests: 8 passed across two suites.
  • Independent adversarial source review, including comparison with the previously reviewed patch series.
  • Personally exercised the freshly built renderer using actual CLI fixture outputs: ambiguous/case-distinct projects, independent expansion, keyboard collapse, provider filtering, and a legacy-to-current refresh without leftover rows. This uses an isolated read-only bridge, not the installed app's transport.

Related to #1260. No dependency or workflow changes.

Upgrade handling: invalidate render-5 status snapshots written before the count metadata existed, including same-version rebuilds. Daily/session accounting caches are retained. Independently reproduced the old-snapshot failure, verified the correction with the unchanged reproduction, and passed 50 focused/adjacent CLI tests covering empty zero, nonempty totals, carried historical accounting and subsequent warm snapshot reuse.

Independent default app npmtest killed the chatty optimize child at 614ms
because the 600ms idle timer started at spawn and the first progress byte
waited on Node boot plus setInterval. Emit the first stderr byte immediately
after boot, then ten 400ms ticks (result ticks 11) under a 2s silence budget.
Node boot still counts; the larger smoke window absorbs it. Work still
outlives a fixed total-runtime cap. Production already resets on every byte;
timeout constants unchanged.
FORCE_COLOR=1 on agent/CI runners makes chalk paint table chrome with ESC.
The C0/C1 assertion is a model-ID sanitization check, not a color check.
The regression spawned dist/cli.js, which is absent in a clean npm-test
checkout. Drive the same end-to-end check through src/cli.ts and keep the
fixture on owned temporary paths isolated from inherited provider dirs.
Same-package render-5 records omit the field, so empty identity-0 is
served as unavailable. Bump STATUS_SNAPSHOT_RENDER_VERSION to 6. Daily
and session caches stay put so unknown retained accounting remains a
partial bound.
@avs-io
avs-io marked this pull request as ready for review September 7, 2026 18:09
@iamtoruk

iamtoruk commented Sep 7, 2026

Copy link
Copy Markdown
Member

Pushed df38e63 on top of the branch:

  • spendProjectIdentity now folds Windows case like normalizeAbsProjectPathKey; cache C:\Work\Vault + live c:/work/vault was producing two payload rows
  • overview projectAggKey uses the same helper, so POSIX case stays identity in the CLI table
  • --json rows carry sessionCountBasis and drop avgCostPerSession when the basis is not exact; overview block gets the basis too
  • deleted the five root-*.verify.test.ts scratch files (console.log, tautological asserts); ported the two uncovered assertions into existing suites
  • renamed the codex-review-* tests, scrubbed REVISE markers, removed unused label helpers, Set in addSessionOnce, compact session label on the Windows and Mac project rows
    Root 3853 pass, tsc clean, app typecheck clean, swift build + SessionCountLabel tests pass, CI green.

@iamtoruk iamtoruk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identity, qualification, cache invalidation and privacy paths verified; patch df38e63 closes the Windows/overview identity gaps and the --json qualification. Merging.

@iamtoruk
iamtoruk merged commit 159198b into getagentseal:main Sep 8, 2026
21 checks passed
mathieustan added a commit to mathieustan/codeburn that referenced this pull request Sep 11, 2026
A rooted pattern selects one project or nothing, so a typo does not fail:
it quietly reports a total over a set the caller did not mean, which
looks exactly like a correct answer. The run now says so on stderr.

Hits are recorded as the rule matches and reported once at exit, rather
than per call, because the live parse and the day cache are filtered
separately: a pattern that names only a carried project matches in the
second pass alone, and a per-call check would call it unmatched. A loose
word never warns, since a substring that matches nothing is not evidence
of a typo.

The README gains the two rules that were not written down: an absolute
POSIX path is case-sensitive (the identity rule from getagentseal#1271 applies to
patterns too) while a Windows drive or UNC path folds case, and a path
that names nothing is reported.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mathieustan added a commit to mathieustan/codeburn that referenced this pull request Sep 11, 2026
A rooted pattern selects one project or nothing, so a typo does not
fail: it reports a total over a set nobody asked for, which reads
exactly like a correct answer. The run now says so on stderr, and the
exit status is untouched.

unmatchedRootedPatterns() tries each pattern on its own against the
UNFILTERED project list, which is what keeps it honest. Judged inside
filterProjectsByName instead, an earlier --project would mask a later one
selecting the same project (include.some short-circuits), and an
--exclude would be tested against what --project had already removed.
The message is period-scoped, since a range-scoped parse is what was
checked; the durable path additionally passes the carried days' project
identities, so a pattern naming only an expired-source project stays
silent.

Nothing is reported under `serve`. That path routes process.stderr.write
into the progress-frame emitter (runCaptured), so a warning would reach
the desktop app as a scan-progress line.

The rule itself is now compiled once per filter instead of being
re-normalized per comparison, which matters because the day cache runs it
for every project of every day and again per provider slice, and the
include-then-exclude composition lives in one projectPassesFilters that
both filterProjectsByName and the day-cache slice call.

The README gains the two rules that were not written down: an absolute
POSIX path is case-sensitive (the identity rule from getagentseal#1271 applies to
patterns too) while a Windows drive or UNC path folds case, and a path
matching nothing in the period is reported.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mathieustan added a commit to mathieustan/codeburn that referenced this pull request Sep 11, 2026
filterProjectsByName matched every pattern as a raw substring, so
--exclude /a/my-company also removed the sibling /a/my-company-kit, and
no pattern the caller could type expressed "this project and not its
neighbours".

A rooted pattern (POSIX, Windows drive, UNC) now keys through
normalizeAbsProjectPathKey, the helper getagentseal#1271 added for project identity,
and matches the way isProxiedPath matches proxyPaths: equal to the
project path, or a prefix of it on a path-segment boundary. Going
through that helper keeps one identity rule in the parser: identified
Windows paths casefold, POSIX case stays identity, and a Codex-style
stripped absolute path ("root/vault") keys the same as the pattern
"/root/vault" the user types. A pattern that is not rooted stays the
loose substring people type on the command line, so --project
my-company keeps covering my-company-kit and worktrees.

The rule lives in one closure (makeProjectFilter) applied to the live
parse and to the carry-forward day cache alike. The cache path had its
own copy, lowercasing and substring-matching, so a filtered headline
anchored today's live days while matching every cached day loosely: on a
carried day split across /Users/gone/app ($30) and /Users/gone/app-kit
($70), --exclude /Users/gone/app returned 0 instead of 70, and --exclude
/users/gone/app excluded both instead of neither. Both shapes are in
tests/project-filter-durable-totals.test.ts, the suite that exists to
pin that a filter selects the same projects whether it is resolved
against a fresh parse or against the cache.

The README gains the rules that were not written down: an absolute POSIX
path is case-sensitive while a Windows drive or UNC path folds case, and
a leading ~ is the shell's to expand.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mathieustan added a commit to mathieustan/codeburn that referenced this pull request Sep 11, 2026
filterProjectsByName matched every pattern as a raw substring, so
--exclude /a/my-company also removed the sibling /a/my-company-kit, and
no pattern the caller could type expressed "this project and not its
neighbours".

A rooted pattern (POSIX, Windows drive, UNC) now keys through
normalizeAbsProjectPathKey, the helper getagentseal#1271 added for project identity,
and matches the way isProxiedPath matches proxyPaths: equal to the
project path, or a prefix of it on a path-segment boundary. Going
through that helper keeps one identity rule in the parser: identified
Windows paths casefold, POSIX case stays identity, and a Codex-style
stripped absolute path ("root/vault") keys the same as the pattern
"/root/vault" the user types. A pattern that is not rooted stays the
loose substring people type on the command line, so --project
my-company keeps covering my-company-kit and worktrees.

The rule lives in one closure (makeProjectFilter) applied to the live
parse and to the carry-forward day cache alike. The cache path had its
own copy, lowercasing and substring-matching, so a filtered headline
anchored today's live days while matching every cached day loosely: on a
carried day split across /Users/gone/app ($30) and /Users/gone/app-kit
($70), --exclude /Users/gone/app returned 0 instead of 70, and --exclude
/users/gone/app excluded both instead of neither. Both shapes are in
tests/project-filter-durable-totals.test.ts, the suite that exists to
pin that a filter selects the same projects whether it is resolved
against a fresh parse or against the cache.

The README gains the rules that were not written down: an absolute POSIX
path is case-sensitive while a Windows drive or UNC path folds case, and
a leading ~ is the shell's to expand.
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.

2 participants