feat(metrics): ADR-0030 P-CODE.1 — git workspace code-activity (/api/code-activity)#72
Merged
Merged
Conversation
…code-activity) Make the code-activity contract surface real (it was design-only in ADR-0030). Honest framing: this is REPO/WORKSPACE activity (every commit), NOT AI authorship — that's the separate aiLoc metric (ADR-0031). - tools/memory_data.ts: codeActivity() + pure parseNumstat()/renamedPath(). `git log --numstat` for the calendar month via an args ARRAY (no shell), each workspace confined with pathWithin to the home subtree (ADR-0022/0023), 15s timeout, vendored-churn pathspec excludes, rename + binary handling. Fail-closed: a non-git / out-of-home / failed-git workspace is OMITTED, never faked (#3). Spend attribution is deferred to P-CODE.2 (spend: 0). - desktop/dev.ts: GET /api/code-activity (30s memo — each call spawns git per workspace; ?force=1 bypasses the cache). - desktop/renderer: CodeActivity bridge type + accessor; a "workspace activity" ledger-card row (+added / -deleted / files) with green/red CSS; a "lines" rail tile. Labels say "workspace activity", not "AI-authored" (AGENTS.md #10). - harness/code_activity.test.ts: 12 tests (numstat parser keystone — renames, binary, dedup, blank lines, CRLF; fail-closed omits; pinned shape). - demo-P-CODE.1 (Makefile + package.json) + harness/scripts/demo_pcode1.ts. Verified: 456/456 harness tests green; demo OK; no new typecheck errors; live endpoint 403 without token and real data with it (+39,271/-2,801, 302 files this month); UI rendered + screenshot, no console errors. Prompt prefix untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Implements ADR-0030 P-CODE.1, making the code-activity contract surface real (it was design-only until now). Honest framing throughout: this is repo/workspace activity (every commit), not AI authorship — that's the separate
aiLocmetric (ADR-0031).What's included
tools/memory_data.ts—codeActivity()+ pureparseNumstat()/renamedPath().git log --numstatfor the calendar month via an args array (no shell), each workspace confined withpathWithinto the home subtree (ADR-0022/0023), 15s timeout, vendored-churn pathspec excludes, rename + binary handling. Fail-closed: a non-git / out-of-home / failed-git workspace is omitted, never faked (invariant build(deps): bump github/codeql-action from 3 to 4 #3). Per-workspace spend is deferred to P-CODE.2 (spend: 0).desktop/dev.ts—GET /api/code-activity(30s memo;?force=1bypass).desktop/renderer—CodeActivitybridge type + accessor; a "workspace activity" ledger-card row (+added / −deleted / files) with green/red CSS; a "lines" rail tile. Labels say "workspace activity", not "AI-authored" (AGENTS.md build(deps-dev): bump electron from 33.4.11 to 42.4.1 in /desktop #10).harness/code_activity.test.ts(12 tests; numstat parser keystone: renames, binary, dedup, blank lines, CRLF; fail-closed omits; pinned shape) +demo-P-CODE.1.Verification
demo-P-CODE.1passes.desktop/personal.ts:50failure from ADR-0042 is unrelated and left as-is.)403without token (fail-closed); real data with it —LucidAgentIDE: +39,271 / −2,801, 302 files this month.Scope
Per the one-increment rule, stops at P-CODE.1. P-CODE.2 (monthly workspace table + spend attribution) and P-CODE.3 (polish: no-changes / detached-HEAD edges) are follow-ups.
🤖 Generated with Claude Code