I0807 — Discover knowledge sources from git, not from the filesystem
Implement the discovery stage of lib/knowledge.sh: a declared list of source classes, each with a scope of shared or operational, resolved through git ls-files for tracked repository artifacts and through the known state paths for operational records, producing a deterministic ordered list of sources with their content hashes.
DONE wave 1 · p1 · implementation profile · parallel safe
Part of M003 — A session is a durable envelope, and knowledge is compiled from what is already canonical.
Objective
Implement the discovery stage of lib/knowledge.sh: a declared list of source classes, each with a scope of shared or operational, resolved through git ls-files for tracked repository artifacts and through the known state paths for operational records, producing a deterministic ordered list of sources with their content hashes.
Why
A recursive filesystem walk indexes vendored trees, build output, editor droppings and untracked files that were never meant to be knowledge, and it produces a different answer on two machines. git ls-files answers with repository truth, in a stable order, and is already the boundary this project treats as authoritative.
Current state
Nothing in lib/ enumerates repository files. scripts/generate-site-data declares its canonical inputs, which is the precedent for a declared source list rather than a walk.
Desired state
`knowledge sources` prints each discovered source with its class, its scope and its hash, in a deterministic order, and the same repository produces the same list twice. An untracked file is not a source. Operational state paths are added explicitly and are marked operational, never shared.
Scope
- lib/knowledge.sh
- bin/majordomus
- test/cases/64_knowledge_discovery.sh
Out of scope
- Extraction, nodes, edges
- Any recursive walk of a hidden directory
- Indexing a path merely because it exists
Dependencies
What waits on this
Acceptance criteria
- The source classes are declared in one place and each carries its scope
- Discovery is driven by git for tracked sources, and a case proves an untracked file is excluded
- The output order is deterministic and independent of filesystem order
- A pathname containing a space or a non-ASCII character is handled without splitting
- A declared source class that discovers nothing is reported, so a forgotten path is visible
Validation
- bash test/run.sh 64_knowledge_discovery
- shellcheck -x -s bash lib/knowledge.sh
Evidence required
- discovery_deterministic
Evidence
| covers | type | command | result | at commit |
|---|---|---|---|---|
| discovery_deterministic | test | test/run.sh 64_knowledge_discovery | 1 passed, and the four cases the new command affected — 15_command_surface, 26_ci_wiring, 28_no_hardcoded_values, 51_derived_artifacts_committed — pass with it. The case proves an untracked file is never a source, that vendored and built trees are excluded because they are not tracked, that two runs agree and a touched file does not reorder them, that editing one source changes only its own hash, that a pathname with spaces and non-ASCII characters yields exactly one row, that no file is discovered by two classes, that a required class discovering nothing is a WARN, and that every read leaves the working tree byte-identical | 34cd249 |
Risk
The historical whitespace bug class lives here. Every pathname read out of git has to be read NUL-safely or with an explicit field separator, never through unquoted word splitting.
Timeline
- started
- 2026-09-04T16:31:17Z
- verified
- —
- completed
- 2026-09-04T17:01:31Z
Those three fields, the evidence above and the state of the dependencies are all the status is made of. There is no status field to disagree with them.
Canonical record: .ai/repo/project/issues/I0807.yaml. Read it back with majordomus plan show I0807.