Skip to content

feat(profile): declared-vs-discovered drift (Pillar 4 step 2) - #296

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 9, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

Step 2 of the versioned, traveling project profile (Pillar 4). Builds the deterministic drift core on top of the schema landed in #295. The profile declares the intended toolchain; this measures how far the actual project has drifted. Still no CLI and no auto-mutation — reporting only (the kit profile command is step 3). Zero-LLM.

Type of Change

  • New feature (non-breaking change that adds functionality)

Related Issues

Changes Made

  • src/profile/reconcile.ts, split for testability:
    • computeProfileDrift(declared, actual) — PURE set-difference + exact version comparison over skills / mcp / workflows / plugins + vault store. Emits removed / added / version-drift / in-sync entries, sorted deterministically (kind → name → status). Version-drift only when both sides pin a differing version — an unpinned declaration matches any found version, and an unknown found version is never called drift (no false drift).
    • discoverActualState(cwd) — thin, best-effort fs wiring over discoverAgentToolchain + .kit.toml secrets.store; degrades to "unknown" instead of throwing, mirroring the SBOM discovery's defensive posture.
  • src/profile/reconcile.test.ts: 13 tests (clean / removed / added / version-drift / unpinned / unknown-found / vault in-sync·drift·not-declared / unaudited / determinism + sort; plus discoverActualState against real temp projects and an end-to-end feed into computeProfileDrift).

Testing

Test Coverage

  • Added new tests (13)
  • All tests pass (npm test) — full suite 2633 pass / 0 fail (2620 baseline + 13)

Manual Testing

  1. npx tsc --noEmit → clean.
  2. npx eslint src/profile/*.ts → clean.
  3. npm run build && node scripts/test.mjs → 2633 pass, 0 fail.
  4. npx prettier --check src/profile/*.ts → formatted.

Breaking Changes

None / N/A — new module; nothing imports it yet.

Checklist

  • My code follows the project's style guidelines
  • All new code has test coverage
  • All tests pass locally (npm test)
  • No new warnings or errors introduced
  • No hardcoded secrets or sensitive data
  • Code has been self-reviewed

Performance Impact

  • No performance impact

Reviewer Notes

The no-false-green posture is the key design point: a component kind the profile declares but whose actual state can't be discovered yet (workflows, plugins — their discovery lands in step 4) is reported as unaudited, never folded into clean and never counted as drift. Unknown ≠ clean and unknown ≠ dirty. This is why DiscoveredState.workflows/plugins are null (unknown) rather than [] (empty). Next step (3) wires kit profile show|freeze|check via COMMAND_REGISTRY to render this.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2


Generated by Claude Code

Adds src/profile/reconcile.ts — the deterministic drift core for the traveling
project profile (design: pillar4-traveling-profile-5.0.md §4.3). Split for testability:

- computeProfileDrift(declared, actual): PURE set-difference + exact version compare over
  skills/mcp/workflows/plugins + vault store. Emits removed/added/version-drift/in-sync
  entries, sorted deterministically (kind, name, status). Version-drift only when BOTH sides
  pin a differing version (an unpinned declaration matches anything; an unknown found version
  is never called drift) — no false drift.
- discoverActualState(cwd): thin, best-effort fs wiring over discoverAgentToolchain +
  .kit.toml secrets.store; degrades to unknown (never throws), like the SBOM discovery.

Honesty (no false green): a kind the profile declares but whose actual state can't be
discovered yet (workflows, plugins — discovery lands in step 4) is reported as UNAUDITED,
never folded into 'clean'. Unknown != clean, and unaudited kinds don't count as drift.

No CLI, no auto-mutation — reporting only (the kit profile command is step 3). 13 tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit b8148a2 into main Jul 9, 2026
18 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 9, 2026 21:56
sandstream added a commit that referenced this pull request Jul 9, 2026
#297)

Wires the profile schema (#295) + drift core (#296) into a CLI verb via COMMAND_REGISTRY
(design: pillar4-traveling-profile-5.0.md). Adds src/commands/profile.ts:

- show   — render the declared profile with per-line reconciliation marks (✓/DRIFT/REMOVED/
           ADDED), fingerprint, and an unaudited note for kinds not yet discoverable.
- freeze — snapshot the DISCOVERED toolchain (skills/mcp via discoverAgentToolchain, vault
           store from .kit.toml) into .kit-profile.toml, PRESERVING operator-authored
           name/workflows/plugins/gates/scope verbatim. Deliberate action, like baseline freeze.
- check  — report declared-vs-discovered drift; --gate turns any drift into a non-zero exit
           for CI (default is warn/exit-0). Honest skip (exit 0) when no profile is declared.

--json on every subcommand. Zero-LLM, deterministic; never auto-mutates the toolchain.
Registry entry (experimental) + SUBCOMMAND_HELP; contracts/public-surface.json regenerated
for the new verb. 7 command tests.


Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants