Skip to content

feat(db): model-aware cost estimation and sidecar cleanup#48

Merged
ashu17706 merged 3 commits intodevfrom
feat/cost-estimation
Mar 3, 2026
Merged

feat(db): model-aware cost estimation and sidecar cleanup#48
ashu17706 merged 3 commits intodevfrom
feat/cost-estimation

Conversation

@ashu17706
Copy link
Contributor

Summary

  • Model-aware cost estimation — adds estimateCost() with per-million-token pricing for the Claude model families. Matches on model family prefix (claude-opus-4, claude-sonnet-4, claude-haiku-4) so versioned model strings like claude-sonnet-4-20250514 resolve correctly. Falls back to Sonnet pricing for unknown models.
  • Cost persisted per sessionupsertSessionCosts() now computes and accumulates estimated_cost_usd on every turn, so cost is always up to date in smriti_session_costs.
  • Sidecar cleanup — adds deleteSidecarRows() to remove all sidecar data for a session in one call (tool usage, file ops, commands, errors, git ops, costs). Needed for re-ingestion and test teardown.

Pricing table

Model family Input ($/M) Output ($/M) Cache read ($/M)
claude-opus-4 $15.00 $75.00 $1.50
claude-sonnet-4 $3.00 $15.00 $0.30
claude-haiku-4 $0.80 $4.00 $0.08

Test plan

  • Ingest a Claude Code session and verify smriti status shows estimated cost
  • Confirm cost accumulates correctly across multiple turns for the same session
  • Verify unknown model names fall back to Sonnet pricing without error

ashu17706 and others added 3 commits February 28, 2026 21:05
* chore: new branch (#33)

* fix(ci): bench scorecard ci windows fixes (#34)

* ci: auto-template and title for dev to main PRs

* release: v0.3.2 (dev -> main) (#35)

* New branch (#33)

* chore: add pending project files

* refactor(ingest): centralize ingestion via parser/resolver/store layers

* docs: document layered ingest architecture

* test(perf): add qmd benchmark harness and non-blocking CI regression check

* perf(bench): add ingest hotpath benchmark and record qmd optimization

* perf(ingest): batch session writes and add stable benchmark tooling

* Add benchmark scorecard to CI summary and sticky PR comment

* Fix bench import path and temporarily disable design-contract workflow

* CI: checkout qmd submodule in perf bench workflow

* Fix Windows path handling in ingest session discovery

* Feature/bench scorecard ci windows fixes (#34)

* chore: add pending project files

* refactor(ingest): centralize ingestion via parser/resolver/store layers

* docs: document layered ingest architecture

* test(perf): add qmd benchmark harness and non-blocking CI regression check

* perf(bench): add ingest hotpath benchmark and record qmd optimization

* perf(ingest): batch session writes and add stable benchmark tooling

* Add benchmark scorecard to CI summary and sticky PR comment

* Fix bench import path and temporarily disable design-contract workflow

* CI: checkout qmd submodule in perf bench workflow

* Fix Windows path handling in ingest session discovery

* CI: run full test matrix only on merge branches

* CI: auto-create draft prerelease on successful dev CI

* CI: auto-template and title for dev to main PRs

* ci: create dev draft release after successful dev test matrix

* chore: add e2e dev release flow test marker (#36)

* release: v0.3.2 (dev -> main) (#37)

* New branch (#33)

* chore: add pending project files

* refactor(ingest): centralize ingestion via parser/resolver/store layers

* docs: document layered ingest architecture

* test(perf): add qmd benchmark harness and non-blocking CI regression check

* perf(bench): add ingest hotpath benchmark and record qmd optimization

* perf(ingest): batch session writes and add stable benchmark tooling

* Add benchmark scorecard to CI summary and sticky PR comment

* Fix bench import path and temporarily disable design-contract workflow

* CI: checkout qmd submodule in perf bench workflow

* Fix Windows path handling in ingest session discovery

* Feature/bench scorecard ci windows fixes (#34)

* chore: add pending project files

* refactor(ingest): centralize ingestion via parser/resolver/store layers

* docs: document layered ingest architecture

* test(perf): add qmd benchmark harness and non-blocking CI regression check

* perf(bench): add ingest hotpath benchmark and record qmd optimization

* perf(ingest): batch session writes and add stable benchmark tooling

* Add benchmark scorecard to CI summary and sticky PR comment

* Fix bench import path and temporarily disable design-contract workflow

* CI: checkout qmd submodule in perf bench workflow

* Fix Windows path handling in ingest session discovery

* CI: run full test matrix only on merge branches

* CI: auto-create draft prerelease on successful dev CI

* CI: auto-template and title for dev to main PRs

* CI: create dev draft release after successful dev test matrix

* chore: add e2e dev release flow test marker (#36)

* docs: update CHANGELOG.md for v0.4.0 [skip ci]

* docs: add CI/release workflow architecture and north-star plan

* ci: add commit lint, semver metadata, and deterministic release notes

* docs: finalize workflow policy docs without backlog sections

* ci: scope commit lint to pull request commit ranges only

* fix(ci): setup bun before dev draft release metadata step

* fix(ci): allow legacy non-conventional history for dev draft metadata

* fix(release): align dev-main PR version with latest stable tag

* ci: improve workflow and check naming for PR readability

* ci: skip PR test job for dev to main release PRs

* fix(ci): use import.meta.dir for cross-platform path resolution

new URL(import.meta.url).pathname produces /D:/a/... on Windows,
causing ENOENT errors. import.meta.dir is Bun's cross-platform
alternative.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* ci: add auto-release job for main branch merges

After tests pass on main, automatically compute the next semver
version and create a GitHub release. Handles squash merges (which
lose individual commit types) by defaulting to patch when commits
exist but bump is "none". Skips if HEAD is already tagged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Baseline User <baseline@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Previous squash merge body contained [skip ci] from an old commit
message, which prevented GitHub Actions from running.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add MODEL_PRICING map for Claude model families, estimateCost() for
per-turn USD estimation, wire estimated_cost_usd into upsertSessionCosts,
and add deleteSidecarRows() for force re-ingest cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Benchmark Scorecard (ci-small)

Bench Scorecard (ci-small)

threshold: 20.00%

metric baseline current (median) delta status
ingest_throughput_msgs_per_sec 1735.800 375.530 -78.37% WARN
ingest_p95_ms_per_session 6.960 30.886 +343.76% WARN
fts_p95_ms 0.410 0.676 +64.88% WARN
recall_p95_ms 0.436 0.762 +74.77% WARN

Summary: WARN (4 metrics)

@ashu17706 ashu17706 merged commit e148c75 into dev Mar 3, 2026
9 checks passed
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