Skip to content

feat(discover): two-speed scan engine with discovery index (#213) - #214

Draft
Theosakamg wants to merge 1 commit into
mainfrom
feature/two-speed-scan-engine
Draft

feat(discover): two-speed scan engine with discovery index (#213)#214
Theosakamg wants to merge 1 commit into
mainfrom
feature/two-speed-scan-engine

Conversation

@Theosakamg

Copy link
Copy Markdown
Contributor

Summary

Introduce a two-speed scan engine to serve gaal status/info from a
fast-path discovery index while keeping a full compliance walk for
gaal audit and init --import-all.

Fast-path (ScanModeIndex) — used by status, info

After every write operation (sync, prune), the discovered resource
list is serialised into ~/.cache/gaal/gaal/discovery-index.json atomically
(temp file + os.Rename). On read-only commands each entry is validated
via a single stat() on its parent directory — unchanged mtime means the
entry is still valid; a changed mtime triggers a partial re-walk of that
one directory only. Falls back to ScanModeFull when the index is missing.

Compliance walk (ScanModeFull) — used by audit, init --import-all

  • scanGlobal and scanWorkspace run concurrently via goroutines.
  • No arbitrary timeout applied.
  • skipDirs extended with: Library, .local, .steam, .wine, .gem, __pycache__

Unification

ops/audit.go collectAuditSkills / collectAuditMCPs / scanDeduped
removed. Audit() and BuildImportCandidates() now delegate to
discover.Scan(ScanModeFull).

Option B — MCP scope alignment

AuditMCPEntry gains a Scope field ("project" or "global").
The audit renderer groups MCPs by scope: "mcps (project)" / "mcps (global)",
mirroring the existing skill grouping.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Refactor (no functional change, code quality improvement)

Related Issues

Closes #213

Checklist

  • make lint passes — gofmt formatting + go vet clean
  • make build passes on Linux and macOS
  • make test passes — unit tests with race detector
  • Every new function has at least one slog.Debug / slog.DebugContext call
  • Documentation updated (docs/discover.md, docs/architecture.md)
  • No secrets or credentials are exposed in logs or config snippets

Introduce ScanMode discriminant (ScanModeIndex / ScanModeFull) in
ScanOptions to serve latency-sensitive commands (status, info) from a
persisted JSON index while keeping the full FS walk for compliance
commands (audit, init --import-all).

Fast-path (ScanModeIndex):
- Load ~/.cache/gaal/gaal/discovery-index.json and validate each entry
  via parent-directory mtime check (same technique as Git UNTRACKED_CACHE).
- Entries with unchanged parent mtime are served directly; stale entries
  trigger a partial re-walk of that one directory only.
- Falls back to ScanModeFull when the index is missing or empty.

Compliance walk (ScanModeFull):
- scanGlobal and scanWorkspace now run concurrently via goroutines.
- No arbitrary timeout applied.
- skipDirs extended: Library, .local, .steam, .wine, .gem, __pycache__

Index lifecycle:
- discover.RebuildIndex() called by engine after RunOnce() and Prune().
- ops.Collect() / ops.Status() pass ScanModeIndex + cacheRoot.

Unification:
- ops/audit.go collectAuditSkills / collectAuditMCPs / scanDeduped
  removed; Audit() delegates to discover.Scan(ScanModeFull).
- ops/init_build.go BuildImportCandidates uses discover.Scan(ScanModeFull).
- Resource.Meta now carries 'source' and 'desc' keys for skill entries,
  so audit conversion is lossless.

Option B (MCP scope alignment):
- AuditMCPEntry gains a Scope field ('project' or 'global').
- mcpGroups renderer groups by scope: 'mcps (project)' / 'mcps (global)'
  mirroring the existing skill grouping by source.

Closes #213
@Theosakamg

Theosakamg commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

strict mode for remove, vs keep and inform.

@gmoigneu

gmoigneu commented May 6, 2026

Copy link
Copy Markdown
Contributor

Need another name than strict

@gmoigneu gmoigneu added the enhancement New feature or request label May 15, 2026
@gmoigneu gmoigneu added this to the Backlog milestone May 15, 2026
@Theosakamg
Theosakamg marked this pull request as draft July 2, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Two-speed scan engine: fast-path index for status/info + full compliance walk for audit

2 participants