fix(extract): attribute extraction cost to its project#100
Open
serhiizghama wants to merge 2 commits into
Open
fix(extract): attribute extraction cost to its project#100serhiizghama wants to merge 2 commits into
serhiizghama wants to merge 2 commits into
Conversation
recordCost upserted the sessions row by session_id alone and never wrote project_id. For a sparse session whose first DB write is the cost row (no SessionStart/UserPromptSubmit injection ever fired), the cost lands on a project_id IS NULL row, and status's per-project total filters by project_id, so the cost is dropped from the project view it belongs to. Resolve the project id before recording cost and persist it in the upsert, filling it only when absent (COALESCE) so an injection-set value is never clobbered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #66.
recordCostupserted thesessionsrow bysession_idalone and never wroteproject_id. In a sparse session where the cost row is the first DB write — no SessionStart/UserPromptSubmit injection ever fired, so nothing else setproject_id— the cost lands on aproject_id IS NULLrow.statusfilters its per-project total byproject_id, so the cost silently drops out of the project view it actually belongs to (it still shows under "All projects", so it's mis-attributed rather than lost).The project id is already derivable a few lines down, so I just resolve it before
recordCostand persist it in the upsert. On conflict it's filled withCOALESCE(project_id, @projectId)so a value an injection already set is never clobbered. Cost arithmetic and the "All projects" total are untouched.Added a test in
run.test.tsthat runs extraction for a session with no prior injection and asserts the resulting row'sproject_idis the project's id rather than NULL; reverting the fix fails it.