Skip to content

Cli#2

Merged
davidabram merged 39 commits intomainfrom
cli
Mar 5, 2026
Merged

Cli#2
davidabram merged 39 commits intomainfrom
cli

Conversation

@davidabram
Copy link
Copy Markdown
Member

No description provided.

Create a canonical no-git-wrapper Agent Trace contract
  in context/sce/agent-trace-implementation-contract.md
  with normative invariants, hook/reconciliation contracts,
  metadata keys, confidence policy, failure/idempotency rules,
  compliance matrix, and internal-to-Agent-Trace mapping.
Add a deterministic adapter in services/agent_trace that maps
  internal attribution inputs to Agent Trace-shaped records.

Pin git VCS identity, centralize reserved dev.crocoder.sce
  metadata keys, and cover required-field/contributor/metadata
  mapping with unit tests.
… suite

Add a canonical build_trace_payload path on top of the adapter,
  normalize AI model_id values toward provider/model format when inferable,
  and add deterministic serialization + schema compliance tests
  (including URI/date-time format validation).
Add a pre-commit finalization contract that filters
  pending attribution to staged ranges only,
  drops unstaged-only files, and preserves index/head tree anchors.

Add guard-path behavior for disabled SCE, unavailable CLI,
  and bare repositories, plus fixture tests that prove
  unstaged edits are excluded.
Add commit-message normalization that appends exactly one canonical
 SCE trailer when SCE is enabled, co-author policy is enabled,
 and staged SCE attribution exists.

Keep behavior idempotent via canonical-trailer dedupe and preserve existing
  newline semantics.
Add a post-commit finalization seam that builds Agent Trace payloads,
  enforces commit-level idempotency, and attempts notes plus
  DB persistence in one pass. Queue failed targets for retry fallback
  and extend hook contracts/tests to cover already-finalized no-op,
  successful dual-write, and transient persistence failure behavior.
Add an implemented `sce doctor` command that resolves effective
  hook-path source and validates required hooks
  (`pre-commit`, `commit-msg`, `post-commit`) for presence and
  executable permissions before local attribution rollout.
Parses post-rewrite old/new SHA pairs with strict validation,
  normalizes rewrite methods, and dispatches replay-safe
  remap requests using deterministic per-pair idempotency keys.
Add `finalize_rewrite_trace` to materialize Agent Trace records
  for rewritten SHAs with canonical rewrite metadata and
  confidence-derived quality status. Preserve post-commit persistence
  behavior by keeping notes/DB dual-write parity, retry fallback,
  and idempotent no-op handling for already finalized revisions.
Add an idempotent migration entrypoint for local Turso storage
  that creates foundational Agent Trace tables and indexes for repository,
  commit, record, and range persistence.

Include focused migration tests that verify clean creation on empty databases
and safe reapplication on preexisting state.
Extend local DB migrations with reconciliation persistence tables for runs,
  rewrite mappings, and conversations, including replay-safe
  idempotency keys and lookup indexes.

Add targeted migration tests for upgrade safety, uniqueness, and
  representative reconciliation queries.
…estration

Verifies GitHub and GitLab webhook signatures before parsing rewrite payloads,
  normalizes provider events into deterministic reconciliation run requests,
  and enforces replay-safe created-vs-duplicate outcomes via idempotency keys.

Adds focused hosted intake tests for signature validation, required field handling,
  deterministic key derivation, and duplicate replay behavior.
Add hosted rewrite mapping resolution with strict precedence:
  patch-id exact match, then range-diff scoring, then fuzzy fallback.
  Classify unresolved outcomes for ambiguous, unmatched, and low-confidence
  cases using a 0.60 threshold, and add deterministic fixture tests
Implements DB-first retry queue recovery for failed notes/DB writes,
  adds bounded retry processing with per-attempt runtime/error metrics,
  and introduces reconciliation mapped/unmapped plus confidence histogram telemetry.
Document the canonical `sce setup --hooks` behavior
  for path resolution, idempotent outcomes, backup/rollback guarantees,
  and failure diagnostics so T02-T05 have a stable implementation target.
Embed canonical pre-commit, commit-msg, and post-commit templates
  at compile time and expose deterministic setup-service accessors
  for required-hook lookup and iteration.

Add focused tests that verify completeness, normalized/sorted manifest paths,
  and stable hook resolution.
…mes and rollback

Resolve hooks destination from git truth
  (rev-parse --show-toplevel, rev-parse --git-path hooks)
  and install canonical required hooks with deterministic
  Installed/Updated/Skipped status.

Add staged-swap backup/restore safety, executable-bit enforcement,
  targeted setup-service tests for default/custom hook paths
  plus rollback failures, and sync T03 context/plan state to current behavior.
Add setup command parsing/dispatch for required hook installation with deterministic
  validation (`--repo` requires `--hooks`; `--hooks` cannot mix with target flags),
  and emit stable per-hook installed/updated/skipped + backup-status output.
Anchor git command execution to the inspected repository root and normalize
  relative hook paths to absolute paths so `sce doctor` reports readiness
  correctly for default and per-repo `core.hooksPath` setups.

Add post-setup readiness tests and align hook-doctor context contract text.
Replace custom SHA-256/HMAC internals with crate-backed hashing
  for GitHub signature verification and hosted idempotency key derivation.

Align the CLI dependency contract and docs context to the new crypto baseline
  while preserving hosted intake behavior and existing test expectations.
…d serde_json extraction

Parse hosted webhook payloads through serde_json::Value
  instead of manual substring scanning.

Enforce deterministic missing/type/object-shape validation
  for required fields and keep SHA checks unchanged

Add parse-hardening tests and align dependency/context references
  with the runtime serde_json contract
Replace direct float equality in rewrite candidate scoring with an explicit
  1e-5 tie window so near-equal scores are handled deterministically
  as ambiguous instead of precision-sensitive winners.

Add boundary tests for within-epsilon and outside-epsilon score
  comparisons while preserving existing threshold and candidate-ordering behavior.
Refactor local DB target resolution to use an explicit fallible UTF-8
  path conversion instead of to_string_lossy, returning contextual errors
  for invalid paths.
Drop the module-wide `#![allow(dead_code)]` from `services/agent_trace.rs`
  so dead-code hygiene is no longer broadly suppressed for this subsystem.
Avoid cloning tail_args just to initialize lexopt::Parser by passing
  a borrowed iterator (iter().map(String::as_str)),
  preserving existing parse behavior while reducing avoidable allocation.
Replace the manual set-then-get flow with a single get_or_init path
  after runtime construction.
…dules

Move large inline #[cfg(test)] blocks out of hooks.rs and setup.rs into sibling tests.rs files.
Enable the clippy toolchain extension and add dedicated
  `apps.clippy` and `checks.cli-clippy` entries.

This makes linting available as a first-class Nix app/check for the CLI crate.
Replace placeholder sce hooks dispatch with explicit pre-commit, commit-msg,
  post-commit, and post-rewrite subcommand parsing and execution paths.

Add deterministic invocation validation and parser/runtime coverage tests so
  invalid hook usage fails with actionable errors while valid invocations
  route through the new runtime entrypoints.
…sistence

Resolve pre-commit runtime state from real repository signals,
  collect staged vs unstaged unified-diff ranges, and finalize
  checkpoints from live git anchors.

Persist finalized staged-only attribution to the git-resolved
  pre-commit checkpoint artifact and keep runtime behavior
  fail-open on collection/persist errors.
Route commit-msg runtime through repository-aware gate resolution,
  detect staged attribution from the pre-commit checkpoint,
  and mutate COMMIT_EDITMSG only when canonical trailer insertion is required.
Wire the post-commit runtime to collect commit attribution input and execute
  finalize_post_commit_trace with concrete persistence adapters for git notes,
  local JSONL record storage, retry queue, and emission ledger.
Replace git-path JSONL trace record persistence with a Turso-backed
  persistent local DB target.

Ensure runtime path resolution, directory creation, and schema
 migration bootstrap run before post-commit writes, and
 extend tests to validate runtime persistence and restart durability.
…ization

Connect the post-rewrite runtime to local DB-backed remap ingestion
  with idempotency checks, then finalize rewritten traces through
  the existing notes/DB persistence pipeline with retry and emission-ledger handling. Add runtime tests that verify successful rewrite-trace persistence and duplicate pair replay skipping.
Process up to 16 queued retry entries after finalization,
  aggregate transient/permanent failure metrics,
  and append deterministic retry summary output to both hook flows.
…hook docs

Drop obsolete placeholder hook event/generated-region
  contracts from production hooks runtime and update
  tests to reflect real subcommand flows.

Clean up warning-prone/test-only paths and small lint nits
  while documenting production `sce hooks` subcommands in the CLI README.
@davidabram davidabram merged commit 511b07a into main Mar 5, 2026
4 checks passed
@davidabram davidabram deleted the cli branch March 5, 2026 12:47
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