| name | share-semantic-analysis |
| description | Consolidate or review repository discovery, semantic parsing, functional-pattern detection, codebase fingerprints, and snapshot generation. Use for context init, DocumentationGenerator, AgentGenerator, SemanticSnapshotService, CodebaseAnalyzer, FileMapper, analysis caching, or large-monorepo performance work. |
Share Semantic Analysis
Compute one bounded analysis bundle per operation and reuse it.
Workflow
- Map every repository scan, glob, file read, parse, fingerprint, and derived output in the operation.
- Define one AnalysisBundle owner at the harness application boundary.
- Discover relevant files once with shared ignores.
- Parse each selected file once and derive symbols, architecture, and functional patterns from the same analyses.
- Pass the same bundle to documentation, agent, plan, and snapshot consumers.
- Apply file-count, per-file byte, total-byte, and concurrency limits.
- Mark partial analysis and skipped reasons explicitly.
- Release operation-scoped caches in finally.
Fingerprinting
Enumerate only relevant files. Reuse content hashes when path, size, and mtime are unchanged. Include dirty files when using git identity. Limit stabilization retries and keep the previous snapshot readable until publication succeeds.
Required invariants
- Never perform a second semantic read only to derive functional patterns.
- Never let generators silently create independent analyzers in the main context-init path.
- Never glob the entire repository and filter relevance only afterward.
- Never call an analysis complete after a configured limit was hit.
- Honor cacheEnabled.
- Keep snapshot publication atomic.
Dotcontext routing
- Own AnalysisBundle in src/harness/application/context.
- Keep parsing in semantic adapters.
- Inject data into generators instead of importing transport state.
- Follow F-05.
Review gate
Instrument tests to count discovery calls, file reads, parse calls, maximum concurrency, bytes read, and fingerprint attempts. Require one parse per selected file in default type=both context init.