> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_21/session_01_pricing_daily_activity_accuracy.md).

# Session 01: Pricing And Daily Activity Accuracy

**Session ID**: `phase21-session01-pricing-daily-activity-accuracy` **Status**: Not Started **Estimated Tasks**: \~18-24 **Estimated Duration**: 3-4 hours

***

## Objective

Port the v2.3 usage-accuracy mechanisms for model pricing and per-day session counts into the modular aios aggregate and home-transform layers without adopting stale v2.3 prices.

***

## Source Reference Detail

### A1 Pricing Robustness

* v2.3 adds `priceForModel()` with exact table lookup, family fallback for `claude-{opus,sonnet,haiku}-*`, older 3.x rows, and `null` for genuinely unknown models: [V23/scripts/aggregate.ts:463](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/claudeos/claude-os-v2.3/scripts/aggregate.ts:463) through `:522`.
* v2.3 routes `computeCost` through the helper: [V23/scripts/aggregate.ts:560](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/claudeos/claude-os-v2.3/scripts/aggregate.ts:560).
* aios currently has exact-match-only 4.x pricing, including `claude-opus-4-8`, at [AIOS/scripts/lib/session-scanner.ts:6](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/aios/scripts/lib/session-scanner.ts:6) through `:12`.
* aios currently returns zero for unknown models: [AIOS/scripts/lib/session-scanner.ts:112](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/aios/scripts/lib/session-scanner.ts:112).
* Caveat: do not copy v2.3's `$15/$75` Opus rates. aios's current Opus 4.8 era rate is `$5/$25`; derive family fallback rates from the current aios table.

### A3 Real Per-Day Session Counts

* v2.3 uses a `Set` of JSONL file paths in each day bucket: [V23/scripts/aggregate.ts:535](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/claudeos/claude-os-v2.3/scripts/aggregate.ts:535) and [V23/scripts/aggregate.ts:553](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/claudeos/claude-os-v2.3/scripts/aggregate.ts:553).
* v2.3 emits `sessions: v.sessions.size`: [V23/scripts/aggregate.ts:1283](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/claudeos/claude-os-v2.3/scripts/aggregate.ts:1283).
* v2.3 home consumes `daily[].sessions` directly and falls back only for old data: [V23/src/routes/index.tsx:16115](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/claudeos/claude-os-v2.3/src/routes/index.tsx:16115) through `:16168`.
* aios day buckets currently have no session Set: [AIOS/scripts/lib/session-scanner.ts:568](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/aios/scripts/lib/session-scanner.ts:568).
* aios emits `daily[]` at [AIOS/scripts/lib/aggregate-orchestration.ts:1094](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/aios/scripts/lib/aggregate-orchestration.ts:1094) without per-day sessions.
* aios home still derives sessions from messages with `sessionsFromMessages(messages)`: [AIOS/src/lib/home-transforms.ts:373](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/aios/src/lib/home-transforms.ts:373).

***

## Scope

### In Scope (MVP)

* Add a local `priceForModel()` helper to `AIOS/scripts/lib/session-scanner.ts` or a focused helper module used by that scanner.
* Keep aios's current exact model prices as the source of truth.
* Add Claude 3.x rows and family fallback for date-suffixed or otherwise variant Claude model names.
* Return `null` for genuinely unknown models so spend is uncounted, not misreported as zero.
* Route `computeCost` through the new helper and preserve aggregate output compatibility for known models.
* Add `sessions: Set<string>` to the per-day bucket, mirroring the existing per-project session Set at [AIOS/scripts/lib/session-scanner.ts:447](https://github.com/moshehbenavraham/ai-os/blob/main/home/aiwithapex/projects/aios/scripts/lib/session-scanner.ts:447).
* Emit `daily[].sessions = set.size`.
* Extend `DailyEntry` in `AIOS/src/lib/live-data-types.ts`.
* Extend `AIOS/src/lib/validate-live-data.ts` and `AIOS/src/data/live-data.example.json`.
* Update `computeDailyActivity` in `AIOS/src/lib/home-transforms.ts` to prefer `daily[].sessions` and retain the old message heuristic for old data.
* Add focused tests for price lookup, unknown handling, daily sessions, and fallback transforms.

### Out of Scope

* Changing aios's current Opus 4.8 prices to v2.3 prices.
* Replacing the modular `scripts/lib/` aggregator with v2.3's monolith.
* UI redesign beyond preserving existing home activity semantics.

***

## Prerequisites

* [ ] Confirm the current aios pricing table before editing so fallback rates derive from the active target table.
* [ ] Confirm existing aggregate and home-transform tests to extend.

***

## Deliverables

1. A robust pricing helper with exact, family, 3.x, and unknown-null behavior.
2. Real per-day unique-session counts in generated `daily[]` data.
3. Updated live-data types, validation, example data, and home transform logic.
4. Focused regression tests proving no silent undercount regressions.

***

## Success Criteria

* [ ] Exact known model prices still compute as before.
* [ ] A date-suffixed Claude family variant falls back to the current aios family rate.
* [ ] Older Claude 3.x model names compute with explicit rows.
* [ ] Unknown models return `null` or an equivalent uncounted state, not zero.
* [ ] `daily[].sessions` is emitted from a unique-session Set.
* [ ] Home daily activity prefers `daily[].sessions` and only uses `messages/6` fallback for old data.
* [ ] Script tests, home-transform tests, typecheck, and validation tests pass.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_21/session_01_pricing_daily_activity_accuracy.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
