Skip to content

feat(#278): improve pipeline observability with file tracking, git SHA, diff stats, token usage - #303

Merged
admarble merged 2 commits into
mainfrom
feature/278-improve-pipeline-observability-file-tracking-git-s
Feb 20, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/278-improve-pipeline-observability-file-tracking-git-s

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive observability to pipeline run logs, addressing all 5 areas specified in #278:

  • File tracking (AC-1): Populate filesModified in phase logs via git diff --name-only
  • Git SHA capture (AC-2): startCommit/endCommit on RunLog, commitHash on PhaseLog via git rev-parse HEAD
  • Diff stats (AC-3): Per-file fileDiffStats array with additions/deletions/status
  • Token usage (AC-5/6): SessionEnd hook script + transcript parsing utilities + metrics integration
  • Cache metrics (AC-7): quality-checks.sh writes JSON cache metrics, read into QA phase logs

Key design decisions

  • Shared getGitDiffStats() utility avoids redundant git operations (single function for AC-1 + AC-3)
  • All new schema fields are z.___().optional() for full backward compatibility
  • Token capture hook exists as infrastructure — requires hook registration in settings.json (deployment step)
  • Graceful degradation throughout: all git/fs operations return empty/undefined on failure

Files changed

Area Files
New utilities git-diff-utils.ts, token-utils.ts
New tests git-diff-utils.test.ts (10 tests), token-utils.test.ts (24 tests)
New hook .claude/hooks/capture-tokens.sh
Schema run-log-schema.ts, metrics-schema.ts
Integration run.ts, log-writer.ts
Display logs.ts, stats.ts
QA script quality-checks.sh (+ template)

Test results

  • 34 new unit tests, all passing
  • Full test suite: 1281 pass (8 pre-existing failures on main, unrelated)
  • Build: clean (tsc exit 0)

Closes #278

…A, diff stats, token usage

Add comprehensive observability to run logs:
- Populate filesModified in phase logs via git diff --name-only
- Capture startCommit/endCommit on RunLog and commitHash on PhaseLog
- Add per-file diff stats (additions/deletions/status) to phase logs
- Token usage capture via SessionEnd hook + transcript parsing
- Cache hit/miss metrics written by quality-checks.sh for QA phases
- Display new fields in `sequant logs` and `sequant stats`
- Shared getGitDiffStats() utility to avoid redundant git operations
- All new fields are optional for backward compatibility

Closes #278
The capture-tokens.sh hook existed but was never registered in
settings.json, so it would never fire and token usage would stay at 0.
@admarble
admarble merged commit 25f3bea into main Feb 20, 2026
6 checks passed
@admarble
admarble deleted the feature/278-improve-pipeline-observability-file-tracking-git-s branch February 20, 2026 04:52
admarble added a commit that referenced this pull request Jun 23, 2026
…ng) + CI gate (#742)

* chore(#738): reconcile skill-mirror divergences + CI gate

Skill files live in three mirrored roots (.claude/skills/ canonical,
templates/skills/ consumed by sequant init/sync, skills/ published as
the plugin). check-skill-sync.ts reported 8 diverged, 10 missing — so
downstream installs could receive stale or missing skill content.

- AC-2/AC-3: reconciled all 18 in the canonical direction
  (.claude/skills/ -> mirrors) after per-file review. quality-checks.sh
  needed a MERGE not a blind copy: .claude had test-tautology detection
  (#310), the mirrors had the #278/#303 cache-metrics JSON writer that
  worktree-manager.ts reads for PhaseLog.cacheMetrics. Both features now
  live in all three roots, restoring cache-metrics observability that had
  silently broken here. Dropped the vestigial `- Task` tool grant from the
  security-review mirror (canonical has no Task usage).
- AC-5: check-skill-sync.ts now skips dotfiles/dot-dirs (kills the
  .sequant/.token-usage-*.json false-positive "missing") + documented
  EXCLUDE allowlist escape hatch. collectFiles/EXCLUDE exported and main()
  guarded so the module is importable for tests.
- AC-1: documented the canonical direction in CONTRIBUTING.md
  ("Skill mirror sync") and strengthened the script header.
- AC-4: added `npm run lint:skill-sync` + a CI step (alongside
  lint:skill-calls) that fails the build on any future drift.

Tests: unit (collectFiles dotfile/dot-dir/allowlist skip) + integration
(whole-repo 0 diverged / 0 missing, exit 0).

Entire-Checkpoint: 00964ffb6426

* fix(#738): skip references/ shared dir in skill validation jobs

Reconciling the mirrors (AC-3) propagated references/shared/framework-gotchas.md
into skills/ and templates/skills/, creating a new top-level references/ dir in
each. .claude/skills/ has had this non-skill dir since #43, but the mirrors never
did, so the gap was hidden. Both CI validators (Plugin Structure Validation,
validate-skills) treat every top-level dir except _shared/ as a skill and failed
because references/ has no SKILL.md.

Skip references/ alongside _shared/ in both jobs and in the validate:skills npm
script (POSIX case so it runs under npm's sh). The framework-gotchas.md content
stays propagated — AC-3 still satisfied.

Entire-Checkpoint: c8b3aebfa756

* fix(#738): repoint sync:skills at canonical fixer (was reversed)

`npm run sync:skills` ran `cp -r templates/skills/* .claude/skills/` —
mirror -> canonical, the reverse of the direction this PR establishes and
documents in CONTRIBUTING. A contributor editing the canonical copy and
running the obvious-named `sync:skills` to "sync" would silently revert
their edits to stale mirror content: the exact drift bug #738 fixes,
re-armed under a misleading name. Repoint it at `check-skill-sync.ts --fix`,
which propagates canonical -> mirrors (same logic CONTRIBUTING documents).
Only CHANGELOG referenced the old script (historical #30 entry, left as-is).
Idempotent no-op when already synced.
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.

Improve pipeline observability: file tracking, git SHA, diff stats, token usage

1 participant