semantic-atlas 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/.agents/skills/semantic-atlas/SKILL.md +172 -0
  2. package/.agents/skills/semantic-atlas/references/graph-patch.md +109 -0
  3. package/.agents/skills/semantic-atlas/references/result-routing.md +91 -0
  4. package/LICENSE +21 -0
  5. package/README.md +118 -0
  6. package/dist/business-flow/business-flow-derivation-service.d.ts +11 -0
  7. package/dist/business-flow/business-flow-derivation-service.d.ts.map +1 -0
  8. package/dist/business-flow/business-flow-derivation-service.js +151 -0
  9. package/dist/business-flow/business-flow-draft.d.ts +16 -0
  10. package/dist/business-flow/business-flow-draft.d.ts.map +1 -0
  11. package/dist/business-flow/business-flow-draft.js +150 -0
  12. package/dist/business-flow/framework-business-strategy.d.ts +7 -0
  13. package/dist/business-flow/framework-business-strategy.d.ts.map +1 -0
  14. package/dist/business-flow/framework-business-strategy.js +1 -0
  15. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +10 -0
  16. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +1 -0
  17. package/dist/business-flow/strategies/bullmq-business-strategy.js +79 -0
  18. package/dist/business-flow/strategies/called-operation-derivation.d.ts +13 -0
  19. package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +1 -0
  20. package/dist/business-flow/strategies/called-operation-derivation.js +32 -0
  21. package/dist/business-flow/strategies/graphql-business-strategy.d.ts +8 -0
  22. package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +1 -0
  23. package/dist/business-flow/strategies/graphql-business-strategy.js +65 -0
  24. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +8 -0
  25. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +1 -0
  26. package/dist/business-flow/strategies/nestjs-business-strategy.js +72 -0
  27. package/dist/business-flow/strategies/strategy-helpers.d.ts +32 -0
  28. package/dist/business-flow/strategies/strategy-helpers.d.ts.map +1 -0
  29. package/dist/business-flow/strategies/strategy-helpers.js +49 -0
  30. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +10 -0
  31. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +1 -0
  32. package/dist/business-flow/strategies/typeorm-business-strategy.js +136 -0
  33. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +5 -0
  34. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +1 -0
  35. package/dist/business-flow/strategies/verified-invariant-strategy.js +38 -0
  36. package/dist/business-flow/strategies/verified-test-strategy.d.ts +5 -0
  37. package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +1 -0
  38. package/dist/business-flow/strategies/verified-test-strategy.js +26 -0
  39. package/dist/business-flow/structural-flow-catalog.d.ts +21 -0
  40. package/dist/business-flow/structural-flow-catalog.d.ts.map +1 -0
  41. package/dist/business-flow/structural-flow-catalog.js +125 -0
  42. package/dist/business-flow/types.d.ts +51 -0
  43. package/dist/business-flow/types.d.ts.map +1 -0
  44. package/dist/business-flow/types.js +1 -0
  45. package/dist/cli/argument-parser.d.ts +3 -0
  46. package/dist/cli/argument-parser.d.ts.map +1 -0
  47. package/dist/cli/argument-parser.js +174 -0
  48. package/dist/cli/bin.d.ts +3 -0
  49. package/dist/cli/bin.d.ts.map +1 -0
  50. package/dist/cli/bin.js +23 -0
  51. package/dist/cli/cli-application.d.ts +38 -0
  52. package/dist/cli/cli-application.d.ts.map +1 -0
  53. package/dist/cli/cli-application.js +515 -0
  54. package/dist/cli/cli-error.d.ts +12 -0
  55. package/dist/cli/cli-error.d.ts.map +1 -0
  56. package/dist/cli/cli-error.js +44 -0
  57. package/dist/cli/cli-presenter.d.ts +14 -0
  58. package/dist/cli/cli-presenter.d.ts.map +1 -0
  59. package/dist/cli/cli-presenter.js +36 -0
  60. package/dist/cli/main.d.ts +3 -0
  61. package/dist/cli/main.d.ts.map +1 -0
  62. package/dist/cli/main.js +45 -0
  63. package/dist/cli/types.d.ts +46 -0
  64. package/dist/cli/types.d.ts.map +1 -0
  65. package/dist/cli/types.js +1 -0
  66. package/dist/contracts/cli.d.ts +2139 -0
  67. package/dist/contracts/cli.d.ts.map +1 -0
  68. package/dist/contracts/cli.js +232 -0
  69. package/dist/contracts/graph.d.ts +262 -0
  70. package/dist/contracts/graph.d.ts.map +1 -0
  71. package/dist/contracts/graph.js +182 -0
  72. package/dist/contracts/identifiers.d.ts +4 -0
  73. package/dist/contracts/identifiers.d.ts.map +1 -0
  74. package/dist/contracts/identifiers.js +7 -0
  75. package/dist/contracts/public-contracts.d.ts +4 -0
  76. package/dist/contracts/public-contracts.d.ts.map +1 -0
  77. package/dist/contracts/public-contracts.js +3 -0
  78. package/dist/evaluation/comparison.d.ts +30 -0
  79. package/dist/evaluation/comparison.d.ts.map +1 -0
  80. package/dist/evaluation/comparison.js +108 -0
  81. package/dist/evaluation/contracts.d.ts +204 -0
  82. package/dist/evaluation/contracts.d.ts.map +1 -0
  83. package/dist/evaluation/contracts.js +269 -0
  84. package/dist/graph/graph-store.d.ts +47 -0
  85. package/dist/graph/graph-store.d.ts.map +1 -0
  86. package/dist/graph/graph-store.js +719 -0
  87. package/dist/graph/types.d.ts +168 -0
  88. package/dist/graph/types.d.ts.map +1 -0
  89. package/dist/graph/types.js +1 -0
  90. package/dist/index.d.ts +19 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +9 -0
  93. package/dist/knowledge/business-knowledge-service.d.ts +24 -0
  94. package/dist/knowledge/business-knowledge-service.d.ts.map +1 -0
  95. package/dist/knowledge/business-knowledge-service.js +200 -0
  96. package/dist/knowledge/graph-patch-conflict-error.d.ts +8 -0
  97. package/dist/knowledge/graph-patch-conflict-error.d.ts.map +1 -0
  98. package/dist/knowledge/graph-patch-conflict-error.js +12 -0
  99. package/dist/knowledge/structural-target-binding.d.ts +14 -0
  100. package/dist/knowledge/structural-target-binding.d.ts.map +1 -0
  101. package/dist/knowledge/structural-target-binding.js +11 -0
  102. package/dist/repository/git-command.d.ts +3 -0
  103. package/dist/repository/git-command.d.ts.map +1 -0
  104. package/dist/repository/git-command.js +25 -0
  105. package/dist/repository/repository-inspector.d.ts +7 -0
  106. package/dist/repository/repository-inspector.d.ts.map +1 -0
  107. package/dist/repository/repository-inspector.js +84 -0
  108. package/dist/repository/repository-language-support.d.ts +14 -0
  109. package/dist/repository/repository-language-support.d.ts.map +1 -0
  110. package/dist/repository/repository-language-support.js +64 -0
  111. package/dist/repository/types.d.ts +9 -0
  112. package/dist/repository/types.d.ts.map +1 -0
  113. package/dist/repository/types.js +1 -0
  114. package/dist/snapshots/repository-snapshot.d.ts +4 -0
  115. package/dist/snapshots/repository-snapshot.d.ts.map +1 -0
  116. package/dist/snapshots/repository-snapshot.js +119 -0
  117. package/dist/snapshots/types.d.ts +30 -0
  118. package/dist/snapshots/types.d.ts.map +1 -0
  119. package/dist/snapshots/types.js +1 -0
  120. package/dist/storage/atlas-database.d.ts +14 -0
  121. package/dist/storage/atlas-database.d.ts.map +1 -0
  122. package/dist/storage/atlas-database.js +552 -0
  123. package/dist/storage/snapshot-store.d.ts +19 -0
  124. package/dist/storage/snapshot-store.d.ts.map +1 -0
  125. package/dist/storage/snapshot-store.js +77 -0
  126. package/dist/structural-backend/codegraph-backend.d.ts +54 -0
  127. package/dist/structural-backend/codegraph-backend.d.ts.map +1 -0
  128. package/dist/structural-backend/codegraph-backend.js +1224 -0
  129. package/dist/structural-backend/codegraph-worker-client.d.ts +5 -0
  130. package/dist/structural-backend/codegraph-worker-client.d.ts.map +1 -0
  131. package/dist/structural-backend/codegraph-worker-client.js +118 -0
  132. package/dist/structural-backend/codegraph-worker-protocol.d.ts +35 -0
  133. package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +1 -0
  134. package/dist/structural-backend/codegraph-worker-protocol.js +1 -0
  135. package/dist/structural-backend/codegraph-worker.d.ts +2 -0
  136. package/dist/structural-backend/codegraph-worker.d.ts.map +1 -0
  137. package/dist/structural-backend/codegraph-worker.js +131 -0
  138. package/dist/structural-backend/process-instance.d.ts +18 -0
  139. package/dist/structural-backend/process-instance.d.ts.map +1 -0
  140. package/dist/structural-backend/process-instance.js +207 -0
  141. package/dist/structural-backend/structural-fact-changes.d.ts +7 -0
  142. package/dist/structural-backend/structural-fact-changes.d.ts.map +1 -0
  143. package/dist/structural-backend/structural-fact-changes.js +78 -0
  144. package/dist/structural-backend/structural-publication.d.ts +12 -0
  145. package/dist/structural-backend/structural-publication.d.ts.map +1 -0
  146. package/dist/structural-backend/structural-publication.js +252 -0
  147. package/dist/structural-backend/structural-write-lock.d.ts +8 -0
  148. package/dist/structural-backend/structural-write-lock.d.ts.map +1 -0
  149. package/dist/structural-backend/structural-write-lock.js +415 -0
  150. package/dist/structural-backend/types.d.ts +144 -0
  151. package/dist/structural-backend/types.d.ts.map +1 -0
  152. package/dist/structural-backend/types.js +11 -0
  153. package/dist/world/types.d.ts +77 -0
  154. package/dist/world/types.d.ts.map +1 -0
  155. package/dist/world/types.js +1 -0
  156. package/dist/world/world-graph-query.d.ts +31 -0
  157. package/dist/world/world-graph-query.d.ts.map +1 -0
  158. package/dist/world/world-graph-query.js +453 -0
  159. package/dist/world/world-model-service.d.ts +21 -0
  160. package/dist/world/world-model-service.d.ts.map +1 -0
  161. package/dist/world/world-model-service.js +211 -0
  162. package/dist/world/world-snapshot-store.d.ts +40 -0
  163. package/dist/world/world-snapshot-store.d.ts.map +1 -0
  164. package/dist/world/world-snapshot-store.js +555 -0
  165. package/docs/architecture/codegraph-backend.md +193 -0
  166. package/docs/contracts/cli-v1.md +119 -0
  167. package/docs/contracts/graph-model.md +102 -0
  168. package/docs/contracts/graph-patch-v1.md +98 -0
  169. package/docs/evaluation.md +128 -0
  170. package/docs/product-contract.md +148 -0
  171. package/package.json +78 -0
  172. package/schemas/cli-envelope-v1.schema.json +1359 -0
  173. package/schemas/evaluation-plan-v1.schema.json +211 -0
  174. package/schemas/evaluation-run-v1.schema.json +365 -0
  175. package/schemas/graph-patch-v1.schema.json +392 -0
@@ -0,0 +1,193 @@
1
+ # CodeGraph Backend Architecture
2
+
3
+ ## Decision
4
+
5
+ Semantic Atlas embeds the verified `@colbymchenry/codegraph` 1.5.0 package as its initial structural-index SDK. It sets `CODEGRAPH_DIR=.atlas` and accepts `.atlas/codegraph.db` as the v0.1 physical database path.
6
+
7
+ This decision produces one product, one index command, one durable SQLite database, and one logical world graph. It avoids waiting for an upstream database-path option and avoids copying a large language-analysis implementation into Atlas.
8
+
9
+ ## System model
10
+
11
+ ```text
12
+ Calling AI
13
+ |
14
+ Semantic Atlas Skill
15
+ |
16
+ semantic-atlas CLI
17
+ |
18
+ WorldModelService
19
+ |-- CodeGraphBackend ------ @colbymchenry/codegraph SDK
20
+ | |-- extraction and resolution
21
+ | |-- structural search and traversal
22
+ |
23
+ |-- BusinessKnowledgeStore -- capabilities, flows, data, rules, evidence
24
+ |
25
+ `-- WorldGraphQuery -------- normalizes and composes both domains
26
+ |
27
+ .atlas/codegraph.db
28
+ ```
29
+
30
+ `CodeGraphBackend` is an anti-corruption layer, not a second public API. Atlas domain code depends on Atlas structural query types. Backend node kinds, edge kinds, identifiers, errors, and version metadata are translated at this boundary.
31
+
32
+ ## Physical and logical ownership
33
+
34
+ The SQLite file contains multiple table families because they have different writers and lifecycles. They are one database, not two exported datasets.
35
+
36
+ | Owner | Table family | Lifecycle |
37
+ | --- | --- | --- |
38
+ | CodeGraph | `nodes`, `edges`, `files`, `unresolved_refs`, FTS, schema and backend metadata | Rebuilt or incrementally synchronized from source |
39
+ | Atlas | `atlas_metadata`, `atlas_snapshots`, `atlas_business_nodes`, `atlas_business_relations`, `atlas_evidence`, `atlas_assertion_validity` | Migrated and updated by Atlas only |
40
+
41
+ Atlas accesses structural behavior through the CodeGraph public SDK. Atlas SQL migrations and repositories access only `atlas_*` objects. The world graph is composed in `WorldGraphQuery`; the public CLI never exposes table origin.
42
+
43
+ The implementation contains no Atlas-owned structural projection tables. Keeping those tables would duplicate CodeGraph data and restore the two-graph problem this design resolves.
44
+
45
+ ## Stable Atlas contracts
46
+
47
+ The adapter exposes only the structural operations required by business understanding:
48
+
49
+ ```ts
50
+ interface StructuralIndexBackend {
51
+ inspect(): Promise<StructuralIndexState>;
52
+ build(): Promise<StructuralBuildResult>;
53
+ sync(): Promise<StructuralBuildResult>;
54
+ listRoots(): Promise<StructuralNode[]>;
55
+ readProjectGraph(query: StructuralProjectGraphQuery): Promise<StructuralTraversalResult>;
56
+ search(query: StructuralSearchQuery): Promise<StructuralSearchResult[]>;
57
+ getNode(reference: StructuralReference): Promise<StructuralNode | undefined>;
58
+ traverse(query: StructuralTraversalQuery): Promise<StructuralTraversalResult>;
59
+ getCallers(reference: StructuralReference): Promise<StructuralCallRelation[]>;
60
+ getCallees(reference: StructuralReference): Promise<StructuralCallRelation[]>;
61
+ getFileDependencies(path: string): Promise<StructuralFileDependency[]>;
62
+ }
63
+ ```
64
+
65
+ These are domain-level capabilities rather than a mirror of every CodeGraph API. The adapter may use `CodeGraph.init`, `open`, `indexAll`, `sync`, search, callers, callees, call graph, impact, and file-dependency APIs internally.
66
+
67
+ Business-flow derivation requests one bounded project graph containing only the
68
+ declaration kinds used by its framework strategies. A caller supplies explicit
69
+ capability roots; Atlas follows exact ownership and execution relations from
70
+ those roots and uses same-file framework declarations only as interpretation
71
+ context. The adapter returns normalized declaration kinds, decorator names,
72
+ supported relations, and unknown boundaries in one query so Node 22
73
+ private-worker execution does not degenerate into a process-per-node traversal.
74
+
75
+ `WorldModelService` owns orchestration. `BusinessKnowledgeStore` owns Atlas tables and transactions. `WorldGraphQuery` resolves cross-domain references and returns the existing versioned CLI graph contract.
76
+
77
+ `WorldGraphQuery` is the only read coordinator used by map and change workflows. It requires one published world snapshot, combines business hierarchy and evidence relations with backend traversal, and verifies that the published snapshot did not change while an asynchronous structural query was running. Structural results retain normalized support and provenance; business results retain certainty, validity, and evidence.
78
+
79
+ Lexical search uses deterministic reciprocal-rank fusion across Atlas business vocabulary and CodeGraph structural search. Raw backend scores are not compared across domains because their scales are implementation-specific. The query layer performs no embeddings, model calls, or natural-language inference.
80
+
81
+ When CodeGraph has no explicit module or namespace nodes, the adapter exposes deterministic top-directory module roots with Atlas `module:` references. These roots are computed from the current backend file manifest and traverse to backend file nodes; they are not stored in Atlas tables or presented as business facts.
82
+
83
+ ## Evidence references
84
+
85
+ Atlas business knowledge does not own CodeGraph rows. An evidence record contains:
86
+
87
+ - an optional backend node locator for fast rebinding;
88
+ - a normalized repository-relative source path;
89
+ - a structural kind and qualified symbol identity when available;
90
+ - a one-based source range;
91
+ - a source content hash;
92
+ - the Atlas snapshot and structural-backend version observed at learning time.
93
+
94
+ No cascading foreign key points from `atlas_*` evidence to a CodeGraph structural table. CodeGraph may clear and recreate its structural rows during a supported rebuild. After every successful index, Atlas attempts to rebind evidence from the durable locator tuple. A unique match is current, a missing or ambiguous match is stale, and certainty remains unchanged.
95
+
96
+ Structural relation targets own the same kind of durable locator independently from their supporting evidence. A relation may target one structural node while its evidence cites another; Atlas resolves both locators separately and marks the relation stale when either one is missing or ambiguous.
97
+
98
+ ## Directory lifecycle
99
+
100
+ Atlas owns directory preparation:
101
+
102
+ 1. resolve the current Git worktree root;
103
+ 2. create `<worktree>/.atlas/` when needed;
104
+ 3. create an Atlas-owned `.atlas/.gitignore` that ignores the directory contents, including itself, so generated state remains invisible to normal Git status;
105
+ 4. run CodeGraph in a scoped environment where `CODEGRAPH_DIR` is `.atlas`;
106
+ 5. verify the resolved CodeGraph database path is exactly `<worktree>/.atlas/codegraph.db` before writing.
107
+
108
+ The environment override is contained inside `CodeGraphBackend`; callers do not configure CodeGraph. Each worktree has its own `.atlas/` because CodeGraph's index, SQLite locks, and dirty source state are worktree- and operating-system-specific.
109
+
110
+ ## Index state machine
111
+
112
+ ```text
113
+ missing -> building -> current
114
+ | |
115
+ v v
116
+ failed <- building
117
+ ```
118
+
119
+ - `missing` means no completed Atlas world snapshot exists.
120
+ - `building` is written before structural mutation begins.
121
+ - `current` is published only after CodeGraph completes and Atlas snapshot/evidence reconciliation commits.
122
+ - `failed` records the last failure while preventing a partial structural graph from being reported as current.
123
+
124
+ All Semantic Atlas commands use one Atlas-owned worktree lock. Its PID, operating-system process-instance proof, and ownership token cover the complete publication lifecycle, do not expire while that process instance is alive, and permit recovery after that instance exits even if its PID is later reused. Linux and Windows use high-resolution OS process-start identities. On macOS and other POSIX hosts without `/proc`, owners keep the authoritative lease inode open for the full lifecycle; process exit closes that kernel-held proof, which cannot be inherited by a later process reusing the PID. Structural writes complete before Atlas knowledge writes. Read commands require a `current` snapshot or return explicit stale/failed state.
125
+
126
+ Normal updates use CodeGraph incremental sync. A full structural rebuild uses `CodeGraph.clear()` followed by `indexAll()` because the current SDK clears only structural rows. The adapter never calls:
127
+
128
+ - `CodeGraph.recreate()`, which removes `codegraph.db` and its sidecars;
129
+ - `CodeGraph.uninitialize()`, which removes the entire `.atlas/` directory;
130
+ - the CodeGraph CLI rebuild path, which is allowed to choose destructive lifecycle operations.
131
+
132
+ Before mutating an existing structural index, the adapter captures an online backup of the shared database. Both full rebuild and incremental sync discard that backup only after a complete result; an incomplete result or exception restores the previously published structural graph and colocated `atlas_*` data before the Atlas lock is released.
133
+
134
+ A future physical-database recovery command must copy or export Atlas-owned tables, replace the structural database, restore Atlas data, and verify evidence before publishing `current`.
135
+
136
+ ## Snapshot semantics
137
+
138
+ CodeGraph's structural tables represent the current code projection. Atlas snapshots record repository content identity, Git state, relevant file hashes, the CodeGraph package and extraction versions, build outcome, and evidence validity.
139
+
140
+ Atlas does not preserve a second full historical structural graph. Repository snapshots are content-addressed and may recur, while every successful index/sync creates a distinct immutable Atlas publication occurrence. The current world state points to the latest occurrence; each occurrence points to its predecessor, its content snapshot, target validity metadata, and path-level backend diagnostics. Business assertions remain durable across snapshots and expose validity for the requested current snapshot.
141
+
142
+ The change query proves the requested source snapshot is an ancestor of the target by following the immutable publication-occurrence chain. Repeated content identities resolve deterministically within the current chain: `to` selects the latest matching occurrence and `from` selects the latest match at or before that target; equal endpoints select the same occurrence. Atlas compares the supported source content stored in the two endpoint snapshots and returns the net added, changed, and removed `file:` references. This endpoint comparison is independent of the structural backend's incremental Git baseline: intermediate additions that are later removed and removals restored with identical content cancel naturally. Stale assertions describe validity at the selected target occurrence rather than the union of intermediate failures. Atlas does not query mutable CodeGraph rows as if they were a historical snapshot or reconstruct unsupported historical node and relation changes.
143
+
144
+ World publication captures the repository snapshot after acquiring the Atlas write lock, verifies it again after structural indexing, and compares its source hashes with CodeGraph's indexed file manifest. If source changes during that interval, including a transient change that restores the same final snapshot, Atlas rolls the structural database back and leaves the prior world snapshot as the last published revision. Every publication occurrence is immutable, so a later sync of identical content appends a new occurrence instead of replacing earlier path-level diagnostics.
145
+
146
+ ## Failure and upgrade behavior
147
+
148
+ - A CodeGraph index or sync error fails the Atlas index command and leaves the world snapshot non-current.
149
+ - Atlas schema migration failure leaves CodeGraph structural data present but unpublished through Atlas until migration succeeds.
150
+ - Unsupported structure is returned as backend support metadata or an unresolved boundary; Atlas does not invent an exact edge.
151
+ - The dependency version is pinned exactly rather than selected through a semver range. The compatible host range is Node.js 22.12 through 24. Node.js 22.12 through 22.15 lack the FTS5 module required by CodeGraph 1.5.0, so the adapter runs its private SDK worker with the dependency's bundled Node.js runtime on those hosts; Node.js 22.16 through 24 use the SDK in process. Both paths expose the same Atlas contract and invoke no CodeGraph CLI, MCP, or daemon lifecycle. Upgrades run fixture repositories through index, sync, rebuild, query normalization, schema coexistence, and evidence-rebinding tests before changing the lockfile.
152
+ - If an upstream release changes structural IDs, locator-based rebinding preserves stable Atlas business keys and makes unmatched evidence stale.
153
+
154
+ Run `pnpm validation:backend` to validate the installed tarball against the
155
+ current exact dependency. To evaluate a new release before changing the pin,
156
+ run `pnpm validation:backend -- --candidate <version> --allow-network`. The
157
+ isolated consumer overrides only its installed candidate; the source manifest
158
+ and lockfile remain unchanged. A pinned consumer first creates the database and
159
+ learns business knowledge; after it closes, a separate candidate consumer must
160
+ open and preserve that same store through incremental and full operations. The
161
+ command also compares required structural endpoints and bounded false exact
162
+ links with the pinned baseline. It rejects candidates that change the database
163
+ location, SDK lifecycle, schema ownership, normalized support, business data,
164
+ evidence, prior publications, recovery, structural quality, or worktree
165
+ isolation contracts, and prints the measured index, database, and query costs.
166
+
167
+ ## Pre-release storage transition
168
+
169
+ The pre-release external `atlas.sqlite` layout is intentionally reset rather than imported. It contains the superseded duplicate structural projection, was never part of a published release, and cannot be copied into the shared database without violating schema ownership. Rebuild the worktree-local structural index, then relearn any experimental business assertions through GraphPatch.
170
+
171
+ The shared layout preserves the business node, relation, GraphPatch, evidence, certainty, validity, transaction, and lexical contracts in `atlas_*` objects. Evidence keeps public structural references without foreign keys to CodeGraph rows. The following reconciliation task extends those records with backend locators, qualified names, structural kinds, snapshot/backend versions, and the combined publication state machine.
172
+
173
+ ## Alternatives considered
174
+
175
+ ### Wait for an upstream database-path option
176
+
177
+ This would permit an `atlas.db` filename, but the filename has no product value and waiting creates schedule risk. `.atlas/codegraph.db` already satisfies the single-directory and single-database boundary.
178
+
179
+ ### Run CodeGraph as a separate CLI or MCP product
180
+
181
+ This would force agents to coordinate two tools, two public contracts, and two failure models. It conflicts with the single Semantic Atlas workflow.
182
+
183
+ ### Store a CodeGraph database and an Atlas database
184
+
185
+ This creates duplicate lifecycle, backup, freshness, and joining problems. Co-locating the schemas in one SQLite file provides clear ownership without creating data islands.
186
+
187
+ ### Copy CodeGraph source into Semantic Atlas
188
+
189
+ This imports a large parser, resolver, database, CLI, MCP, and maintenance surface. Direct SDK use preserves the boundary with much lower ownership cost. A thin fork remains available only if a demonstrated SDK limitation blocks the product contract.
190
+
191
+ ### Extend CodeGraph node and edge enums with business concepts
192
+
193
+ CodeGraph structural rows require code-centric fields and are legitimately disposable during structural rebuilds. Business assertions have different identity, evidence, certainty, and validity lifecycles, so they remain Atlas-owned and are composed at the query boundary.
@@ -0,0 +1,119 @@
1
+ # CLI Contract v1
2
+
3
+ ## Invocation
4
+
5
+ The npm package and executable are both named `semantic-atlas`. Development uses Node.js 24; the published CLI supports Node.js 22.12 through 24.
6
+
7
+ Global options:
8
+
9
+ - `--repo <path>` selects a directory within the target repository; the default is the current directory.
10
+ - `--pretty` indents JSON without changing fields or values.
11
+
12
+ Commands:
13
+
14
+ | Command | Contract |
15
+ | --- | --- |
16
+ | `status` | Report worktree identity, current revision, latest world snapshot, freshness, local store location, language support, and additive structural-backend metadata. |
17
+ | `index` | Build or synchronize the embedded structural index, reconcile Atlas evidence, publish the completed world snapshot, and report changed facts and unknowns. |
18
+ | `map roots` | Return top-level capabilities or structural module roots before learning. |
19
+ | `map children <node-id>` | Follow `part_of` and `contains` children. |
20
+ | `map search <query> [--limit <n>]` | Lexically rank labels, aliases, summaries, symbols, and paths; the default limit is 20. |
21
+ | `map show <node-id> [--depth <n>]` | Return locations, evidence-rich neighbors, invariants, tests, validity, and unknowns; depth defaults to 1 and is limited to 3. |
22
+ | `learn --stdin` | Read one complete GraphPatch v1 JSON value from standard input and apply it atomically. |
23
+ | `changes [--from <snapshot-id>] [--to <snapshot-id>]` | Report net semantic graph changes between persisted Atlas snapshot endpoints, not a raw Git diff. The source must be an ancestor of the target in the publication chain; defaults compare the previous and current snapshots. |
24
+
25
+ `map` commands are graph access primitives. The calling agent extracts concepts, reformulates searches, reads source, and judges impact.
26
+
27
+ ## Response envelope
28
+
29
+ Every command writes one JSON envelope to standard output. The normative discriminated schema is `schemas/cli-envelope-v1.schema.json`.
30
+
31
+ ```json
32
+ {
33
+ "schemaVersion": 1,
34
+ "repository": {
35
+ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
36
+ "root": "/workspace/example",
37
+ "headCommit": "0123456789abcdef0123456789abcdef01234567"
38
+ },
39
+ "snapshot": null,
40
+ "status": "ok",
41
+ "data": {
42
+ "command": "status",
43
+ "currentRevision": {
44
+ "headCommit": "0123456789abcdef0123456789abcdef01234567",
45
+ "changes": { "staged": 0, "unstaged": 0, "untracked": 0 }
46
+ },
47
+ "freshness": "missing",
48
+ "storeLocation": "/workspace/example/.atlas/codegraph.db",
49
+ "languages": [
50
+ { "language": "typescript", "support": "supported" }
51
+ ]
52
+ },
53
+ "warnings": []
54
+ }
55
+ ```
56
+
57
+ - Successful responses have `status: "ok" | "partial"`, a non-null repository, and command data selected by `data.command`.
58
+ - `snapshot` is `null` before the first successful index. Otherwise it includes the snapshot ID, Git HEAD, creation time, and `current` or `stale` freshness.
59
+ - `partial` means usable data contains explicit unsupported, stale, or unknown boundaries.
60
+ - Business map nodes and relations always include `certainty`, derived `validity`, and evidence. Structural relations preserve normalized backend provenance and support as additive result metadata; unknown boundaries expose `unknown`, their reason, location, and candidates. Unsupported languages include a reason instead of an approximate analysis.
61
+ - `warnings` contains stable codes and descriptions for non-fatal conditions. Consumers use codes rather than parsing messages.
62
+
63
+ ## Command data
64
+
65
+ The schema requires these fields while allowing additive fields inside command data:
66
+
67
+ | `data.command` | Required result fields |
68
+ | --- | --- |
69
+ | `status` | `currentRevision`, `freshness`, `storeLocation`, `languages` |
70
+ | `index` | `snapshotId`, fact counts, unknown-boundary counts; backend version and evidence-rebinding counts are additive metadata until promoted by a later schema version |
71
+ | `map.roots` | top-level `Capability` or structural `Module` nodes |
72
+ | `map.children` | `nodeId`, `children` |
73
+ | `map.search` | `query`, `limit`, scored `results` |
74
+ | `map.show` | `node`, `depth`, evidence-aware `neighbors`, `Invariant` nodes, agent-verified structural test declarations, `unknowns` |
75
+ | `learn` | `baseSnapshotId`, `snapshotId`, applied operation counts |
76
+ | `changes` | source and target snapshot IDs, node/relation change sets, stale assertions |
77
+
78
+ `index.facts` uses one structural-fact unit across every publication: one backend node or
79
+ relation is one fact. `added`, `changed`, and `reused` partition the facts in the newly
80
+ published graph; `removed` counts facts present only in the previous publication. A fact
81
+ is changed when its stable node identity or relation endpoints remain while its structural
82
+ content, location, or support changes.
83
+
84
+ Map node and relation objects preserve their evidence lifecycle. When evidence cannot uniquely rebind after indexing, a business node can remain addressable by key while its `summary` is returned with `validity: "stale"`; callers therefore cannot confuse vocabulary identity with a current fact.
85
+
86
+ Change ranges follow the current publication history and fold the requested endpoints into one content comparison. When a content-addressed snapshot was published more than once, `--to` selects its latest occurrence in that history and `--from` selects the latest matching occurrence at or before the target; equal IDs compare the selected occurrence with itself. Paths that have the same presence and content at both endpoints are omitted even if they changed in between, while `staleAssertions` reports the selected target occurrence's final validity state. An unknown target has no change result.
87
+
88
+ ## Errors
89
+
90
+ Handled failures have `status: "error"` and structured data:
91
+
92
+ ```json
93
+ {
94
+ "command": null,
95
+ "error": {
96
+ "code": "INVALID_INPUT",
97
+ "message": "The command arguments are invalid."
98
+ }
99
+ }
100
+ ```
101
+
102
+ `command` is null when parsing fails before a public command is identified. Scalar or command-success data is invalid in an error envelope. Standard output contains only the envelope; human diagnostics and unexpected stack information go to standard error. Pretty formatting never changes the schema.
103
+
104
+ ## Exit codes
105
+
106
+ | Code | Meaning |
107
+ | --- | --- |
108
+ | `0` | Command completed with `ok` or `partial` data |
109
+ | `1` | Unexpected internal failure |
110
+ | `2` | Invalid command, option, stdin, or schema version |
111
+ | `3` | Repository discovery or unsupported-repository failure |
112
+ | `4` | Required Atlas state is missing or stale for the requested operation |
113
+ | `5` | GraphPatch concurrency, evidence, or repository-boundary rejection |
114
+
115
+ Handled nonzero failures still emit a versioned error envelope when a response can be formed. Diagnostics never replace the machine-readable response.
116
+
117
+ ## Compatibility
118
+
119
+ Top-level envelope fields, command discriminants, and required command fields are closed within version 1. Additive fields may appear inside command data and map result objects; callers ignore fields they do not understand. A removed field, changed meaning, enum incompatibility, or operation change requires a new `schemaVersion`. GraphPatch and other input objects remain strict and reject unknown fields.
@@ -0,0 +1,102 @@
1
+ # Graph Model
2
+
3
+ ## One graph, two ownership domains
4
+
5
+ Semantic Atlas exposes one world graph. Its two domains have different authorities and write lifecycles:
6
+
7
+ - structural nodes and relations are normalized from the embedded CodeGraph backend and are replaced or synchronized by indexing;
8
+ - business nodes and relations are evidence-bound Atlas assertions changed only through GraphPatch;
9
+ - evidence relations connect the domains and are rebound after indexing.
10
+
11
+ Both domains live in `.atlas/codegraph.db`, but Atlas does not copy CodeGraph nodes and edges into parallel structural tables. The world-graph query layer composes CodeGraph SDK results with Atlas-owned `atlas_*` tables and returns one versioned Atlas contract.
12
+
13
+ ## Node kinds
14
+
15
+ | Domain | Kind | Meaning |
16
+ | --- | --- | --- |
17
+ | Structural | `Repository` | The indexed worktree |
18
+ | Structural | `Module` | A code or framework composition unit |
19
+ | Structural | `File` | A normalized repository-relative source file |
20
+ | Structural | `Symbol` | A normalized CodeGraph declaration such as a class, function, method, field, interface, route, or component |
21
+ | Structural | `Test` | A backend-statically identified test declaration when such identity is available |
22
+ | Structural | `UnknownBoundary` | An unresolved or unsupported structural relationship |
23
+ | Business | `Capability` | A durable business ability |
24
+ | Business | `Scenario` | A user or system scenario within a capability |
25
+ | Business | `Operation` | A business action or use-case step |
26
+ | Business | `Invariant` | A rule that constrains behavior or data |
27
+ | Business | `Interface` | A business-facing API, event, queue, or integration contract |
28
+ | Business | `Data` | A business data concept or persisted record |
29
+
30
+ Repository and snapshot IDs are content identifiers produced by Atlas repository inspection. Public structural IDs are deterministic Atlas references derived from normalized backend identity, path, kind, and qualified name. Backend row IDs remain internal locators and may change after a CodeGraph upgrade or rebuild.
31
+
32
+ Business keys are stable slash-separated keys such as `commerce/orders/place-order`. Labels and aliases form stable vocabulary while evidence-bound summaries can evolve without changing the key.
33
+
34
+ ## Relation kinds
35
+
36
+ | Domain | Relation | Meaning |
37
+ | --- | --- | --- |
38
+ | Structural | `contains` | A structural container owns a child |
39
+ | Structural | `declares` | A file or module declares a symbol |
40
+ | Structural | `imports` | A file or module imports another unit |
41
+ | Structural | `exports` | A file or module exports a symbol |
42
+ | Structural | `references` | A symbol or file references another symbol |
43
+ | Structural | `calls` | A symbol invokes another symbol |
44
+ | Structural | `extends` | A declaration extends another declaration |
45
+ | Structural | `implements` | A declaration implements a contract |
46
+ | Structural | `instantiates` | A symbol creates an instance |
47
+ | Structural | `decorated_by` | A declaration has a resolved decorator |
48
+ | Business | `part_of` | A business node belongs to another business node |
49
+ | Business | `invokes` | A scenario or operation invokes another operation |
50
+ | Business | `realized_by` | A business node is implemented by a structural node |
51
+ | Business | `reads` | A business action reads business data |
52
+ | Business | `writes` | A business action writes business data |
53
+ | Business | `publishes` | A business action publishes an interface or data contract |
54
+ | Business | `consumes` | A business action consumes an interface or data contract |
55
+ | Business | `constrained_by` | A business node is governed by an invariant |
56
+ | Business | `verified_by` | A business node is checked by an agent-verified structural declaration |
57
+
58
+ All learned relations originate at a business node. `realized_by` and `verified_by` target structural nodes; the other business relations target business nodes. A test directory or filename is structural context only. Atlas exposes a declaration in `map.show.tests` after an agent verifies it through `verified_by`; the declaration remains a `Symbol` when the structural backend cannot identify a test case independently.
59
+
60
+ ## Structural support
61
+
62
+ Structural results preserve backend provenance. Direct syntax and uniquely resolved relations can be reported as exact structural support. CodeGraph relations with heuristic provenance remain visibly inferred. Unresolved references become `UnknownBoundary` results rather than exact edges.
63
+
64
+ Structural support and business certainty are separate concepts. A structurally exact call edge does not by itself prove a business assertion, and an agent may create an inferred business relation from several exact structural facts.
65
+
66
+ ## Evidence, certainty, and validity
67
+
68
+ Every learned business node summary and learned relation has a certainty and one or more evidence records containing:
69
+
70
+ - a public Atlas structural reference and optional internal backend locator;
71
+ - a normalized repository-relative source path;
72
+ - a qualified symbol identity and structural kind when available;
73
+ - a one-based source range;
74
+ - the SHA-256 content hash observed at learning time;
75
+ - the Atlas snapshot and structural-backend version observed at learning time.
76
+
77
+ Evidence does not have a cascading foreign key to CodeGraph rows. After indexing, Atlas rebinds each evidence locator to the current structural graph.
78
+
79
+ Certainty and validity are independent:
80
+
81
+ - `exact` means the evidence uniquely proves the business assertion;
82
+ - `inferred` means the evidence supports the assertion and includes agent inference;
83
+ - `hypothesis` is exploratory and is never a verified fact;
84
+ - `valid` means every evidence record uniquely rebinds and its source hash still matches;
85
+ - `stale` means at least one evidence record changed, disappeared, or became ambiguous;
86
+ - `unknown` describes an explicit structural boundary rather than a business assertion.
87
+
88
+ Validity is derived state and is never accepted as GraphPatch input. Stable business identity remains navigable while stale summaries and relations stay visibly stale. Certainty never upgrades automatically.
89
+
90
+ ## Unknown boundaries
91
+
92
+ An `UnknownBoundary` records the unresolved operation, backend reason, location, and any finite candidates. It is a first-class query result. Map responses preserve it through traversal and never convert it into an exact edge. Examples include unresolved references, reflection, runtime dependency lookup, dynamic imports, and non-unique string tokens.
93
+
94
+ ## Traversal
95
+
96
+ `map roots` returns business capabilities when present and structural module roots otherwise. Every business concept produced by one capability-scoped derivation has a direct `part_of` relation to that capability, so entry scenarios, operations, invariants, interfaces, and data remain reachable even when the flow has no route. `map children` follows `part_of` and `contains`. `map show` composes Atlas business neighbors, evidence links, and CodeGraph structural neighbors with depth 1 by default and at most 3.
97
+
98
+ Lexical search combines Atlas business vocabulary with CodeGraph structural search. The calling AI performs natural-language interpretation; the CLI does not add a language model or pretend lexical scores are business inference.
99
+
100
+ The two search domains are combined with deterministic reciprocal-rank fusion. Scores express ordering inside the combined result only; they do not convert structural relevance into business certainty.
101
+
102
+ Structural nodes and relations include normalized `support.status` and `support.provenance`. Business assertions use `certainty`, `validity`, and evidence instead. Unknown boundaries keep their structural owner, unresolved operation, support, reason, source location, and finite candidates.
@@ -0,0 +1,98 @@
1
+ # GraphPatch v1
2
+
3
+ GraphPatch is the only public write contract for agent-learned knowledge. It cannot create, change, or delete CodeGraph-backed structural nodes or relations. The normative input schema is `schemas/graph-patch-v1.schema.json`.
4
+
5
+ ## Shape
6
+
7
+ ```json
8
+ {
9
+ "schemaVersion": 1,
10
+ "baseSnapshotId": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
11
+ "nodeOperations": [
12
+ {
13
+ "op": "upsert",
14
+ "node": {
15
+ "key": "commerce/orders/place-order",
16
+ "kind": "Operation",
17
+ "label": "Place order",
18
+ "summary": "Validates and creates a customer order.",
19
+ "aliases": ["checkout"],
20
+ "certainty": "exact",
21
+ "evidence": [
22
+ {
23
+ "symbolId": "symbol:src/orders/order.service.ts#OrderService.placeOrder",
24
+ "file": "src/orders/order.service.ts",
25
+ "range": {
26
+ "start": { "line": 18, "column": 3 },
27
+ "end": { "line": 24, "column": 4 }
28
+ },
29
+ "contentHash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ ],
35
+ "relationOperations": [
36
+ {
37
+ "op": "upsert",
38
+ "relation": {
39
+ "from": {
40
+ "domain": "business",
41
+ "key": "commerce/orders/place-order"
42
+ },
43
+ "type": "realized_by",
44
+ "to": {
45
+ "domain": "structural",
46
+ "id": "symbol:src/orders/order.service.ts#OrderService.placeOrder"
47
+ },
48
+ "certainty": "exact",
49
+ "evidence": [
50
+ {
51
+ "symbolId": "symbol:src/orders/order.service.ts#OrderService.placeOrder",
52
+ "file": "src/orders/order.service.ts",
53
+ "range": {
54
+ "start": { "line": 18, "column": 3 },
55
+ "end": { "line": 24, "column": 4 }
56
+ },
57
+ "contentHash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
58
+ }
59
+ ]
60
+ }
61
+ }
62
+ ]
63
+ }
64
+ ```
65
+
66
+ ## Operations
67
+
68
+ Business node upserts contain a stable hierarchical `key`, one of `Capability`, `Scenario`, `Operation`, `Invariant`, `Interface`, or `Data`, plus a label, summary, aliases, certainty, and at least one evidence record. The key, kind, label, and aliases form vocabulary identity; the summary is an assertion governed by certainty and evidence. A node-only patch without assertion evidence is invalid. Removing a node uses `{ "op": "remove", "key": "..." }`.
69
+
70
+ Business relation upserts contain a source reference, relation type, target reference, certainty, and at least one evidence record. Removing a relation supplies its source, type, and target selector. The stable relation identity is that `(from, type, to)` tuple; repeated upserts replace the assertion and its evidence idempotently.
71
+
72
+ Reference domains make ownership explicit:
73
+
74
+ - `{ "domain": "business", "key": "..." }` addresses an existing or same-patch business node.
75
+ - `{ "domain": "structural", "id": "symbol:..." }` addresses an Atlas-normalized CodeGraph node in the base snapshot.
76
+
77
+ All learned relations originate at a business node. `realized_by` and `verified_by` target structural nodes; `part_of`, `invokes`, `reads`, `writes`, `publishes`, `consumes`, and `constrained_by` target business nodes.
78
+
79
+ ## Evidence and certainty
80
+
81
+ Each node or relation evidence item binds an Atlas structural symbol or test reference, normalized repository-relative file, one-based source range, and lowercase SHA-256 content hash. Atlas also records the backend locator and version needed for later rebinding. Evidence must resolve inside the same worktree and match the current completed snapshot exactly.
82
+
83
+ `exact` means the node summary or relation is uniquely established by evidence. `inferred` means the agent made a supported inference. `hypothesis` records exploration and remains visibly non-factual even while its evidence is current. Certainty never upgrades automatically.
84
+
85
+ ## Atomic validation
86
+
87
+ `learn --stdin` performs these checks before writing:
88
+
89
+ 1. The schema version and complete JSON value are valid.
90
+ 2. `baseSnapshotId` equals the current working-tree snapshot.
91
+ 3. Every referenced node exists either in the current snapshot or in the patch.
92
+ 4. Relation endpoints and kinds satisfy the graph contract.
93
+ 5. Every node and relation evidence symbol, path, range, and hash belongs to the current repository snapshot.
94
+ 6. Removes do not leave dangling business relations.
95
+
96
+ The patch is one transaction. Any failure rejects every operation with exit code 5 and a machine-readable error; retries start from a freshly read snapshot. No partial success is exposed.
97
+
98
+ Validity is derived rather than accepted from GraphPatch. After later indexing, only node summaries and relations with changed evidence become `stale`. Stable node identity and unaffected assertions remain available, and hypotheses remain hypotheses.
@@ -0,0 +1,128 @@
1
+ # Fresh Agent Evaluation Protocol
2
+
3
+ ## Goal
4
+
5
+ The evaluation compares an ordinary Fresh Agent source workflow with the same agent using Semantic Atlas. It measures whether Atlas preserves answer correctness and necessary dependency recall while reducing source context. The gate and metrics are fixed in the product contract before results are collected.
6
+
7
+ ## Artifacts
8
+
9
+ The protocol separates three responsibilities:
10
+
11
+ 1. An evaluation plan defines the prompt, immutable fixture revision, framework/category labels, and an oracle of acceptance criteria, required files, and required symbols.
12
+ 2. A run record captures the agent identity, mode, timing, source observations, Atlas calls, complete answer text, answer references, and adjudication.
13
+ 3. The validator checks the contracts and derives recall, unique opened files, source token usage, and Atlas call count.
14
+
15
+ Normative schemas are:
16
+
17
+ - `schemas/evaluation-plan-v1.schema.json`;
18
+ - `schemas/evaluation-run-v1.schema.json`.
19
+
20
+ The official planned cases are in `evaluation/cases/plan.json`. `evaluation/examples/no-atlas-run.json` demonstrates the run format and is not a measured product result.
21
+
22
+ ## Reproducible run procedure
23
+
24
+ For each case and mode:
25
+
26
+ 1. Check out the exact fixture revision recorded by the case.
27
+ 2. Start a new agent conversation with no prior task or repository context. Record the agent product and model. Disable host Skills, plugins, apps, hooks, MCP servers, memory, multi-agent delegation, and Skill search while preserving the local Codex authentication and model-provider configuration needed to execute the run.
28
+ 3. Give the agent the case prompt and repository only. Keep the oracle and the other mode's result outside the agent context.
29
+ 4. Keep model, agent instructions, tool policy, fixture revision, and task prompt identical for the paired runs. The only workflow difference is whether the Semantic Atlas Skill and CLI are available.
30
+ 5. In `no-atlas` mode, use normal source and shell tools and record zero Atlas calls. In `atlas` mode, record each Semantic Atlas command.
31
+ 6. Record a `sourceOpens` event whenever repository source text is returned to the agent, including file reads and search snippets. Split multi-file tool output into one event per file.
32
+ 7. Record the number of source tokens exposed by each event using the execution environment's source-input accounting. Put the stable method/version in `sourceTokenMethod`. Count repeated reads again in token totals.
33
+ 8. Save the agent's reported files and symbols. An evaluator who did not guide the run compares the answer with the oracle and records correctness plus notes.
34
+ 9. Publish the complete Codex shell-command sequence with the run, then validate and summarize the baseline with `pnpm evaluation:validate` or pass additional run paths to `scripts/validate-evaluation.ts --baseline`.
35
+
36
+ A run is invalid when it lacks exact source-token accounting, is not a fresh context, uses a different fixture revision, sees its oracle, contains an Atlas call in `no-atlas` mode, reads a host instruction, or uses a shell command outside the versioned allowlist. Invalid runs are repeated rather than estimated.
37
+
38
+ The published `fresh-agent-v1` run uses the repository-owned source observer and
39
+ `tiktoken-o200k_base-v1`. Every observer invocation appends one JSONL record per
40
+ returned file. The runner normalizes those atomically appended records to a
41
+ strict event sequence. The `fresh-agent-shell-allowlist-v4` policy accepts only
42
+ observer reads/searches, read-only Semantic Atlas status/map/changes commands,
43
+ bounded file-name listings, and content-free availability probes. Atlas commands
44
+ must satisfy the product CLI's complete argument grammar, and `--repo` is
45
+ prohibited because each process already runs from its measured fixture. The
46
+ policy rejects alternative readers, arbitrary executables and wrappers, external
47
+ instruction paths, command substitution, redirection, unsupported command
48
+ composition, and unquoted shell word generation such as brace, parameter, tilde,
49
+ or filename expansion. The fixed `$EVALUATION_OBSERVER` parameter is the only
50
+ permitted shell expansion. The runner rejects failed audits before adjudication,
51
+ and published-result validation re-audits every recorded command sequence and
52
+ its derived Atlas calls.
53
+
54
+ ## Metrics
55
+
56
+ - Required-file recall is the fraction of oracle files present in `answer.reportedFiles`.
57
+ - Required-symbol recall is the fraction of `(file, symbol name)` oracle pairs present in `answer.reportedSymbols`.
58
+ - Final-answer correctness is the independent boolean adjudication against the case prompt and oracle.
59
+ - Opened source files count unique paths in `observations.sourceOpens`.
60
+ - Source input tokens sum every source-open event, including repeated reads.
61
+ - Atlas call count is the number of recorded Atlas commands.
62
+
63
+ The comparative report shows per-case results and medians by mode. It also classifies failures such as missed dependency, incorrect answer, stale knowledge, unknown boundary mishandling, unsupported source, or protocol violation.
64
+
65
+ The release passes this evaluation portion only when every Atlas-assisted case has no lower required-file recall, required-symbol recall, or answer correctness than its paired no-Atlas run; no stale, hypothesis, or unknown fact is represented as exact; and either median unique opened source files or median source input tokens falls by at least 30 percent.
66
+
67
+ ## Published result
68
+
69
+ The measured `fresh-agent-v1` artifacts are in
70
+ `evaluation/results/fresh-agent-v1/`. They contain 24 independently adjudicated
71
+ runs over the frozen 12-case matrix. Both modes use Codex CLI 0.146.0 with
72
+ `gpt-5.6-sol`, fresh ephemeral contexts, the same fixture commit and task input,
73
+ and the same command policy. Atlas mode differs only by the availability of the
74
+ Semantic Atlas Skill, CLI, and current worktree-local index. The retained 22
75
+ `fresh-agent-runner-v1` records were re-audited from preserved raw command logs;
76
+ the affected NestJS provider-contract pair was replaced under
77
+ `fresh-agent-runner-v2` with host capabilities explicitly disabled. All 24
78
+ published command sequences were subsequently re-audited under the v3
79
+ fixture-local Atlas grammar.
80
+
81
+ All 12 pairs retained 100 percent required-file recall, required-symbol recall,
82
+ and answer correctness. Median unique opened source files fell from 6.5 to 4
83
+ (38.46 percent), and median source tokens fell from 1,351 to 688 (49.07
84
+ percent). Atlas runs recorded 61 routed partial, unknown, or related boundary
85
+ events and no uncertainty-handling failure. The fixed gate passed without being
86
+ changed after results were collected.
87
+
88
+ Validate the published records with:
89
+
90
+ ```sh
91
+ pnpm evaluation:results
92
+ ```
93
+
94
+ `pnpm evaluation:run` rebuilds the deterministic fixture repositories, runs 24
95
+ new ephemeral Codex contexts plus an independent adjudication context, and
96
+ replaces the published run records and report. It requires a working local
97
+ Codex login and incurs model usage.
98
+
99
+ A protocol repair can replace one independently adjudicated pair and recompute
100
+ the complete report while retaining only records that pass the current schema
101
+ and command audit:
102
+
103
+ ```sh
104
+ pnpm evaluation:run -- --case <case-id> --publish-selected
105
+ ```
106
+
107
+ ## Planned case matrix
108
+
109
+ | Category | Case | Frameworks |
110
+ | --- | --- | --- |
111
+ | Location | Locate a NestJS operation provider | NestJS |
112
+ | Location | Locate a GraphQL query implementation | GraphQL |
113
+ | Location | Locate a TypeORM entity relation | TypeORM |
114
+ | Location | Locate a BullMQ job consumer | BullMQ |
115
+ | Location | Trace a GraphQL mutation to a NestJS provider | NestJS, GraphQL |
116
+ | Location | Trace a BullMQ job to a TypeORM write | TypeORM, BullMQ |
117
+ | Dependency/impact | Assess a NestJS provider contract change | NestJS |
118
+ | Dependency/impact | Assess a GraphQL output field change | GraphQL |
119
+ | Dependency/impact | Assess a TypeORM column change | TypeORM |
120
+ | Dependency/impact | Assess a BullMQ job payload change | BullMQ |
121
+ | Dependency/impact | Assess a NestJS and TypeORM transaction change | NestJS, TypeORM |
122
+ | Dependency/impact | Assess a GraphQL to BullMQ workflow change | GraphQL, BullMQ |
123
+
124
+ The synthetic fixture described by this plan is implemented by later indexing and framework-adapter work. Its stable paths and oracle symbols are already fixed so the gate cannot be tailored after product results are known.
125
+
126
+ ## Private real-project cases
127
+
128
+ Real-repository prompts, paths, revisions, or answers may be sensitive. Store their plan and run records outside the published repository, or under the ignored `evaluation/private/` directory. The evaluation schema supports a `private` fixture with an opaque `repositoryAlias`; validate such a plan without the `--baseline` flag. The private operator mapping from that alias to a local repository never enters published fixtures. Aggregated reports may publish counts and metrics only after removing identifying paths and answers.