Skip to content

feat: implement cdd scan - #39

Merged
hammadmajid merged 2 commits into
mainfrom
feat/scan
Sep 16, 2026
Merged

hammadmajid merged 2 commits into
mainfrom
feat/scan

Conversation

@hammadmajid

Copy link
Copy Markdown
Contributor

What

Adds internal/scan.Run(ctx, cfg config.Config, hist *history.History) (Summary, error), per the resolution in #13 and #9.

  • Discovers Projects under cfg.Root with cfg.Exclude and cfg.IncludeHidden via project.Discover.
  • For each Project, computes an evidence time: git.LastCommit when it is a repository with a commit, else the Project directory's mtime (truncated to UTC second precision to match History's line format, so repeated Scans compare equal).
  • Calls hist.Seed(project.Rel(), evidence) for each Project. Seed's own idempotency rule (never overwriting a newer real Visit) is not re-implemented here.
  • Bounds concurrent git calls to a worker pool of 8.
  • Returns Summary{Seeded, Projects int} so the cli can print "Seeded 12 Visits across 40 Projects".

Why

Closes #19. A fresh cdd installation has no History until a Jump happens; Scan seeds one Visit per discovered Project so the Picker has a sensible starting order.

Tests

Table of scenarios in internal/scan/scan_test.go, using t.TempDir() Roots and real git repositories:

  • a repository Project is seeded from its commit time
  • a non-repository Project is seeded from its directory mtime
  • an already-jumped Project is left alone
  • a second Run seeds nothing new
  • an excluded Project is skipped

Notes for reviewer

  • Summary.Seeded is derived by comparing hist.Count before and after each Seed call, rather than re-implementing Seed's idempotency rule in this package.
  • Git calls are gathered concurrently (bounded to 8 workers) before any Seed calls, which run sequentially; Seed itself is already safe for concurrent use (it takes an advisory flock), so this ordering is purely about keeping Summary.Seeded accounting simple, not about correctness.

Closes #19

🤖 Generated with Claude Code

hammadmajid and others added 2 commits September 17, 2026 00:49
Covers a repository Project seeded from git.LastCommit, a
non-repository Project seeded from directory mtime, an already-jumped
Project left alone, a second Scan seeding nothing new, and an excluded
Project being skipped.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
internal/scan.Run discovers Projects under cfg.Root, honoring
cfg.Exclude and cfg.IncludeHidden, and seeds hist with one Visit per
Project. Evidence time is git.LastCommit when a Project is a
repository with a commit, else the Project directory's mtime,
truncated to UTC second precision to match History's line format.
Git calls are bounded to 8 concurrent workers. Seed's own idempotency
rule decides whether a Visit is actually appended; Run reports the
result as Summary{Seeded, Projects} for the cli to print.

Closes #19

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hammadmajid
hammadmajid merged commit d062aa8 into main Sep 16, 2026
3 checks passed
@hammadmajid
hammadmajid deleted the feat/scan branch September 16, 2026 20:27
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.

Implement cdd scan

1 participant