semantic-atlas 0.1.0 → 0.1.2

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.
@@ -1,172 +1,153 @@
1
1
  ---
2
2
  name: semantic-atlas
3
- description: "Use Semantic Atlas for evidence-bound project understanding and impact analysis in TypeScript or JavaScript repositories: locate business capabilities and implementations, trace dependencies, inspect invariants and tests, assess semantic changes, and preserve verified business knowledge. Use when a repository has the semantic-atlas CLI or a local Atlas map; route source editing, testing, Git, and review to normal engineering workflows."
3
+ description: "Use Semantic Atlas as the required first business-understanding loop in supported TypeScript or JavaScript repositories before feature implementation, bug fixing, debugging, refactoring, behavior-changing review, business-flow tracing, invariant and test discovery, or dependency or impact analysis. Git-only release work, mechanical formatting, unrelated documentation, and unsupported repositories stay in normal workflows."
4
4
  compatibility: "Requires Node.js 22.12 through 24 and the semantic-atlas CLI."
5
5
  ---
6
6
 
7
7
  # Semantic Atlas
8
8
 
9
- Use the local, deterministic Atlas world map as the first project-understanding
10
- surface. Source code remains authoritative; Atlas data is a revision-aware
11
- projection that supplies bounded context, evidence, certainty, validity, and
12
- explicit structural limits.
13
-
14
- The calling Agent owns concept extraction and natural-language reasoning. The
15
- CLI accepts lexical terms, graph identifiers, snapshot identifiers, and a
16
- structured GraphPatch; it does not interpret a natural-language task.
17
-
18
- Run one Atlas CLI command at a time within a worktree and wait for its complete
19
- response before starting the next command. The worktree-local database and
20
- publication lifecycle are a serialized evidence boundary; parallel status,
21
- index, map, changes, or learn calls can observe transient publication state.
22
-
23
- ## First use
24
-
25
- 1. Identify the exact target Git worktree. Keep all commands scoped to that
26
- worktree with the current directory or `--repo <path>`.
27
- 2. Run `semantic-atlas status` and parse the versioned JSON envelope. Use fields
28
- such as `status`, `data.freshness`, `snapshot`, `warnings`, and
29
- `data.backend.completeness`; use stable codes rather than message text.
30
- 3. Run `semantic-atlas index` when freshness is `missing` or `stale`, or when
31
- backend completeness is not `complete`. Indexing owns generated `.atlas/`
32
- state inside this worktree.
33
- 4. Run `semantic-atlas map roots` on a current snapshot. Business `Capability`
34
- roots appear after learning; structural `Module` roots provide the initial
35
- map before business knowledge exists.
36
- 5. Extract two to four compact concepts from the task: business vocabulary,
37
- likely symbols, interfaces or data, and dependency/impact terms. Use those
38
- concepts to begin the recurring-task protocol.
39
-
40
- When the CLI, repository, or language is unavailable, follow [result
41
- routing](references/result-routing.md) and continue through bounded source
42
- fallback.
43
-
44
- ## Recurring task
45
-
46
- 1. Start every distinct task with `semantic-atlas status`. Trust a stored map
47
- only when the world snapshot is current and the backend is complete.
48
- 2. Query before broad source exploration:
49
- - use `semantic-atlas map search <query> [--limit <n>]` for each compact
50
- lexical concept;
51
- - use `semantic-atlas map show <node-id> [--depth <n>]` to inspect promising
52
- nodes, evidence-rich neighbors, invariants, tests, and unknown boundaries;
53
- - use `semantic-atlas map children <node-id>` to descend business `part_of`
54
- or structural `contains` hierarchies;
55
- - revisit `semantic-atlas map roots` when the task crosses capabilities or
56
- the first search vocabulary is weak.
57
- 3. Begin with depth 1 and expand a promising node to depth 2 or 3 only when the
58
- task requires the additional dependency path. Treat search score as ranking,
59
- not certainty.
60
- 4. Stop map traversal when it identifies the necessary symbols, files,
61
- relationships, evidence, and explicit uncertainty for the task. Open the
62
- cited source ranges to confirm behavior that controls the answer or change.
63
- 5. Perform implementation, debugging, tests, and review through the normal
64
- engineering workflow, using the Atlas results as bounded context.
65
-
66
- ## Interpret Atlas results
67
-
68
- Classify every result before using it:
69
-
70
- | Result | Agent treatment |
71
- | --- | --- |
72
- | `valid` plus `exact` | Use as current evidence for the stated assertion and confirm decisive behavior in source. |
73
- | `valid` plus `inferred` | Preserve the result as a supported Agent inference and inspect source before presenting it as exact. |
74
- | `hypothesis` | Treat as an exploration lead and verify it independently. |
75
- | `stale` | Use identity and vocabulary only; reindex, then re-open authoritative source for the assertion. |
76
- | `unknown` | Preserve the owner-linked unknown boundary, reason, location, and candidates; inspect that bounded source area. |
77
- | `unsupported` | Use supported results as partial context and inspect the unsupported language or construct in source. |
78
- | `partial` | Consume usable fields and route each warning or boundary independently. |
79
- | `insufficient` map | Fall back from the best available seeds and complete the task from source. |
80
-
81
- Structural `support.status` describes backend resolution. Business `certainty`
82
- describes the Agent's assertion. Business `validity` describes evidence
83
- freshness. Keep these dimensions separate: an exact call edge alone does not
84
- prove a business rule, and a current hypothesis remains a hypothesis.
85
-
86
- Read [result routing](references/result-routing.md) when status, index, or a map
87
- query returns an error envelope, warnings, no relevant results, or competing
88
- candidates.
89
-
90
- ## Bounded source fallback
91
-
92
- 1. Assemble the smallest source seed set from current result locations,
93
- evidence, structural IDs, unknown owners, and finite candidates.
94
- 2. Open the cited ranges and enough surrounding code to understand the owning
95
- declaration. Follow only the imports, callers, callees, interfaces, data, or
96
- tests required by the task.
97
- 3. Reformulate one Atlas query when source supplies a more precise business or
98
- symbol term. This often reconnects the task to mapped context.
99
- 4. When Atlas supplies no usable seed, run a narrow ordinary source search for
100
- the task's most distinctive identifier or contract, then continue the normal
101
- source workflow from confirmed results.
102
- 5. Base the conclusion on source for every stale, hypothesis, unknown,
103
- unsupported, ambiguous, or map-insufficient portion. Retain the boundary in
104
- the answer when source inspection cannot resolve it.
105
-
106
- This fallback bounds discovery without replacing the calling Agent's generic
107
- source-reading and search capabilities.
9
+ Use the local, deterministic Atlas world map as the first business-understanding
10
+ surface for every supported task. Source code remains authoritative; Atlas is a
11
+ revision-aware projection that supplies bounded evidence, business context,
12
+ certainty, validity, and explicit structural limits.
13
+
14
+ The calling Agent owns task interpretation, source changes, tests, Git, and
15
+ review. The CLI accepts lexical queries, graph identifiers, snapshot identifiers,
16
+ and structured GraphPatch input; it does not interpret natural-language tasks.
17
+
18
+ ## Required business-understanding loop
19
+
20
+ 1. Identify the exact target Git worktree before any Atlas command. Run from
21
+ that worktree or pass its absolute path with `--repo <path>`, and confirm the
22
+ response `repository.root` is the intended worktree.
23
+ 2. Run one Atlas CLI command at a time and wait for its complete response. The
24
+ worktree-local database and publication lifecycle form a serialized evidence
25
+ boundary.
26
+ 3. Start with `semantic-atlas status` before broad source discovery. Read the
27
+ versioned envelope, `data.freshness`, snapshot, warnings, and
28
+ `data.backend.completeness` by stable fields and codes.
29
+ 4. Complete the matching procedure in [Conditional references](#conditional-references)
30
+ as soon as the observed status needs indexing or bootstrap.
31
+ 5. Query the current map with compact task vocabulary before broad source
32
+ search. Let map evidence, owners, candidates, and unknown boundaries define
33
+ the initial source seed set.
34
+ 6. Classify the map response and complete every triggered reference before
35
+ source confirmation. Relevant structural nodes with no relevant business
36
+ node trigger snapshot bootstrap; weak, partial, unknown, unsupported, or
37
+ otherwise insufficient results trigger result routing.
38
+ 7. Open cited ranges and confirm decisive behavior in authoritative source.
39
+ Follow only the dependencies, interfaces, data, invariants, or tests needed
40
+ to answer or change the behavior.
41
+ 8. Perform implementation, debugging, testing, and review through the normal
42
+ engineering workflow.
43
+ 9. Reconcile relevant source changes with Atlas, then make the mandatory
44
+ knowledge-capture decision before completing the task.
45
+
46
+ ## Query before broad source discovery
47
+
48
+ Extract two to four compact concepts from the task: business vocabulary,
49
+ likely symbols, interfaces or data, and dependency or impact terms. Query them
50
+ in this order as useful:
51
+
52
+ 1. Use `semantic-atlas map search <query> [--limit <n>]` for each distinct
53
+ lexical concept.
54
+ 2. Use `semantic-atlas map show <node-id> [--depth <n>]` on promising business
55
+ or structural nodes. Begin at depth 1 and expand to 2 or 3 only for a needed
56
+ dependency path.
57
+ 3. Use `semantic-atlas map children <node-id>` to descend business `part_of` or
58
+ structural `contains` hierarchies.
59
+ 4. Use `semantic-atlas map roots` when the task crosses capabilities, the
60
+ initial vocabulary is weak, or the current map has no relevant business root.
61
+
62
+ When search and roots return relevant structural nodes but no relevant business
63
+ node, read snapshot bootstrap before opening source. That state starts the
64
+ incremental business-map path rather than the abnormal-result path alone.
65
+
66
+ Treat search score as ranking rather than certainty. Stop map traversal when it
67
+ identifies the necessary symbols, files, relationships, evidence, and explicit
68
+ uncertainty. If the map remains weak, use its best seeds for bounded source
69
+ inspection and route the observed weak state through the conditional reference.
70
+
71
+ ## Source authority
72
+
73
+ Confirm every answer-controlling or change-controlling claim in source even
74
+ when Atlas reports `valid` plus `exact`. Keep structural support, business
75
+ certainty, and evidence validity separate:
76
+
77
+ - `exact` identifies uniquely supported structure or business evidence;
78
+ - `inferred` is supported Agent synthesis that remains distinguishable from an
79
+ exact fact;
80
+ - `hypothesis` remains an exploration lead;
81
+ - `stale`, `unknown`, `unsupported`, `partial`, and `insufficient` results bound
82
+ source fallback rather than authorizing a decisive claim.
83
+
84
+ Preserve every owner-linked unknown boundary with its reason, location, and
85
+ finite candidates. Source inspection may resolve the task while the Atlas
86
+ boundary remains honestly unknown.
108
87
 
109
88
  ## After source changes
110
89
 
111
- 1. Preserve the pre-change current snapshot ID when the task may need impact or
112
- semantic-change inspection.
113
- 2. Complete source editing and relevant tests through the normal workflow.
114
- 3. Run `semantic-atlas index` after relevant source changes. Treat a failed or
115
- incomplete publication as unavailable map state and keep working from source.
116
- 4. Run `semantic-atlas changes`; provide `--from <snapshot-id>` and
117
- `--to <snapshot-id>` when the task requires an explicit persisted range.
90
+ 1. Preserve the pre-change current snapshot ID when impact or semantic change
91
+ matters.
92
+ 2. Complete source changes and relevant tests through the normal workflow.
93
+ 3. Run `semantic-atlas index` after relevant source changes and require a
94
+ current, complete publication before trusting the refreshed map.
95
+ 4. Run `semantic-atlas changes`; use `--from <snapshot-id>` and
96
+ `--to <snapshot-id>` for an explicit persisted range.
118
97
  5. Inspect node and relation additions, changes, removals, and
119
- `staleAssertions`. Re-run map queries for affected concepts and confirm the
120
- resulting impact against source and tests.
121
- 6. Consider learning only after the new snapshot is current and the engineering
122
- result is verified.
123
-
124
- Structural fact counters summarize graph publication work; semantic impact
125
- comes from `changes`, map traversal, source, and tests.
126
-
127
- ## Learn verified knowledge
128
-
129
- Learning is optional. Use it for durable business capabilities, scenarios,
130
- operations, invariants, interfaces, data, and their supported relationships
131
- when that knowledge will help later tasks.
132
-
133
- 1. Read [GraphPatch authoring](references/graph-patch.md).
134
- 2. Recheck `semantic-atlas status` immediately before authoring. Use the current
135
- snapshot ID as `baseSnapshotId`.
136
- 3. Derive evidence from current map results and inspected source. Every evidence
137
- item must use a current structural symbol ID, exact repository-relative file,
138
- one-based range, and current file `contentHash` returned by Atlas.
139
- 4. Choose `exact` for uniquely proven assertions, `inferred` for supported Agent
140
- synthesis, and `hypothesis` for explicitly exploratory knowledge. Prefer
141
- fresh, exact evidence for durable facts.
142
- 5. Send one complete JSON GraphPatch value to `semantic-atlas learn --stdin`.
143
- Apply related operations together so optimistic-concurrency validation is
144
- atomic.
145
- 6. Inspect the response and query the learned key with `semantic-atlas map show`
146
- to verify the resulting certainty, validity, evidence, and relationships.
147
- 7. If the snapshot or evidence changed, refresh the map and rebuild the patch
148
- from current results. The current snapshot ID and evidence are the write
149
- boundary.
98
+ `staleAssertions`. Re-query affected concepts and confirm the result against
99
+ source and tests.
100
+
101
+ Treat a failed or incomplete publication as unavailable map state and retain
102
+ source as authority.
103
+
104
+ ## Knowledge-capture decision
105
+
106
+ Before completing every supported task, classify the business meaning learned
107
+ during source confirmation:
108
+
109
+ - Persist every new durable, verified `Capability`, `Scenario`, `Operation`,
110
+ `Invariant`, `Interface`, or `Data` concept, plus every supported relationship
111
+ between them, when missing or insufficient Atlas knowledge caused the source
112
+ inspection.
113
+ - Keep transient or unverified observations only in task context. Examples
114
+ include debugging symptoms, one-off implementation notes, tentative runtime
115
+ paths, Git facts, and hypotheses that lack durable evidence.
116
+ - When current Atlas knowledge already expresses the verified business meaning,
117
+ reuse it and avoid a duplicate patch.
118
+
119
+ When durable knowledge exists, read GraphPatch authoring, recheck status, submit
120
+ one atomic patch with `semantic-atlas learn --stdin`, then run
121
+ `semantic-atlas map show <learned-key>` to verify current validity, certainty,
122
+ evidence, and relationships. The verified node must be reusable by a later
123
+ fresh task through normal map search and traversal.
124
+
125
+ ## Conditional references
126
+
127
+ Load detailed procedures only after their matching observable state:
128
+
129
+ - Read [snapshot bootstrap](references/snapshot-bootstrap.md) only when status
130
+ reports `missing`, `stale`, or incomplete state; a current map has no relevant
131
+ business knowledge; or the user explicitly requests project initialization.
132
+ - Read [result routing](references/result-routing.md) only when a command returns
133
+ an error, warning, `hypothesis`, `unknown`, `unsupported`, `partial`, empty,
134
+ competing, or otherwise `insufficient` result.
135
+ - Read [GraphPatch authoring](references/graph-patch.md) only when the
136
+ knowledge-capture decision identifies durable verified knowledge to persist.
150
137
 
151
138
  ## Answer contract
152
139
 
153
- Use Atlas internally as context rather than dumping raw envelopes. In the task
154
- answer:
155
-
156
- - state the relevant business concept, files, symbols, and relationships;
157
- - distinguish current exact evidence from Agent inference;
158
- - identify stale, hypothesis, unknown, unsupported, ambiguous, or insufficient
159
- portions and the source inspection used to handle them;
160
- - cite the authoritative source and relevant verification for engineering
161
- conclusions;
162
- - mention reindexing, semantic changes, or learned knowledge when those actions
163
- materially affect the result.
140
+ Use Atlas internally as context rather than dumping raw envelopes. State the
141
+ relevant business concepts, files, symbols, and relationships; distinguish
142
+ exact evidence from inference; identify unresolved boundaries and their source
143
+ fallback; cite authoritative source and verification; and mention reindexing,
144
+ semantic changes, or learned knowledge when they materially affect the result.
164
145
 
165
146
  ## Responsibility boundary
166
147
 
167
148
  Semantic Atlas owns deterministic indexing, revision-aware map queries,
168
- semantic change records, and evidence-bound business knowledge in local Atlas
169
- data. The calling Agent owns concept extraction, natural-language reasoning,
149
+ semantic change records, and evidence-bound business knowledge in local Atlas data.
150
+ The calling Agent owns concept extraction, natural-language reasoning,
170
151
  source editing, tests, Git operations, and review. Keep repository-specific
171
- facts in Atlas or authoritative source; keep this Skill reusable across
152
+ facts in Atlas or authoritative source and keep this Skill reusable across
172
153
  repositories.
@@ -11,8 +11,9 @@ written to Semantic Atlas.
11
11
  certainty, and evidence separately.
12
12
  3. Current map output supplies every structural symbol ID, exact source range,
13
13
  and file `contentHash` used as evidence.
14
- 4. The knowledge is reusable business meaning rather than a task note,
15
- implementation instruction, test result, Git fact, or generic code summary.
14
+ 4. The knowledge is durable, verified, reusable business meaning rather than a
15
+ task note, implementation instruction, test result, Git fact, debugging
16
+ symptom, or generic code summary.
16
17
 
17
18
  Use the repository's `schemas/graph-patch-v1.schema.json` and
18
19
  `docs/contracts/graph-patch-v1.md` as the normative contract when they are
@@ -20,20 +21,72 @@ available. The outline here is an authoring checklist.
20
21
 
21
22
  ## Patch shape
22
23
 
23
- A patch is one strict JSON object:
24
+ A patch is one strict JSON object. Every operation uses the discriminator `op`.
25
+ Relation endpoints are domain-tagged objects rather than key or ID strings:
24
26
 
25
27
  ```json
26
28
  {
27
29
  "schemaVersion": 1,
28
30
  "baseSnapshotId": "<current 64-character snapshot ID>",
29
- "nodeOperations": [],
30
- "relationOperations": []
31
+ "nodeOperations": [
32
+ {
33
+ "op": "upsert",
34
+ "node": {
35
+ "key": "commerce/orders/place-order",
36
+ "kind": "Operation",
37
+ "label": "Place order",
38
+ "summary": "Creates and persists a customer order.",
39
+ "aliases": ["checkout"],
40
+ "certainty": "exact",
41
+ "evidence": [
42
+ {
43
+ "symbolId": "symbol:<current structural identity>",
44
+ "file": "src/orders/order.service.ts",
45
+ "range": {
46
+ "start": { "line": 18, "column": 3 },
47
+ "end": { "line": 24, "column": 4 }
48
+ },
49
+ "contentHash": "<current 64-character file hash>"
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ ],
55
+ "relationOperations": [
56
+ {
57
+ "op": "upsert",
58
+ "relation": {
59
+ "from": {
60
+ "domain": "business",
61
+ "key": "commerce/orders/place-order"
62
+ },
63
+ "type": "realized_by",
64
+ "to": {
65
+ "domain": "structural",
66
+ "id": "symbol:<current structural identity>"
67
+ },
68
+ "certainty": "exact",
69
+ "evidence": [
70
+ {
71
+ "symbolId": "symbol:<current structural identity>",
72
+ "file": "src/orders/order.service.ts",
73
+ "range": {
74
+ "start": { "line": 18, "column": 3 },
75
+ "end": { "line": 24, "column": 4 }
76
+ },
77
+ "contentHash": "<current 64-character file hash>"
78
+ }
79
+ ]
80
+ }
81
+ }
82
+ ]
31
83
  }
32
84
  ```
33
85
 
34
- Node operations upsert or remove business keys. Relation operations upsert or
35
- remove a `(from, type, to)` relationship. A single patch can create related
36
- nodes and connect them atomically.
86
+ Node removal uses `{ "op": "remove", "key": "..." }`. Relation removal uses
87
+ `op: "remove"` with the same domain-tagged `from`, `type`, and `to` selector but
88
+ without certainty or evidence. A single patch can create related nodes and
89
+ connect them atomically.
37
90
 
38
91
  ## Business vocabulary
39
92
 
@@ -55,10 +108,18 @@ Business relation types:
55
108
  - `part_of`, `reads`, `writes`, `publishes`, `consumes`, and `constrained_by`
56
109
  connect a business source to a business target;
57
110
  - `realized_by` and `verified_by` connect a business source to a structural
58
- target.
111
+ `Symbol` or `Test` declaration returned by the current map. A `File` or
112
+ `Module` is navigation context, not a learned implementation or verification
113
+ target. When the backend exposes only a test file, cite that source in the
114
+ task result and omit `verified_by` until a declaration target is available.
59
115
 
60
116
  Every learned relation originates at a business node.
61
117
 
118
+ - Every `from` is `{ "domain": "business", "key": "..." }`.
119
+ - A business target is `{ "domain": "business", "key": "..." }`.
120
+ - A structural target is `{ "domain": "structural", "id": "symbol:..." }` or
121
+ a current `test:...` declaration ID.
122
+
62
123
  ## Evidence
63
124
 
64
125
  Every upserted node summary and relation includes at least one evidence item:
@@ -84,7 +145,10 @@ Certainty is independent from evidence freshness:
84
145
 
85
146
  - `exact` means the evidence uniquely proves the assertion;
86
147
  - `inferred` means the evidence supports an explicit Agent synthesis;
87
- - `hypothesis` marks exploratory knowledge that remains visibly unverified.
148
+ - `hypothesis` is available in the GraphPatch contract for explicitly requested
149
+ exploratory records. The required task-completion capture keeps unverified
150
+ hypotheses in task context and persists only verified `exact` or `inferred`
151
+ knowledge.
88
152
 
89
153
  Use one assertion per clear business meaning. Multiple source locations can
90
154
  support one assertion; one nearby symbol should not stand in for an unproven
@@ -0,0 +1,53 @@
1
+ # Snapshot and business-map bootstrap
2
+
3
+ Read this reference after the required `status` call shows that the structural
4
+ snapshot needs publication, or after a current map proves that relevant
5
+ business knowledge is absent. Keep all commands serialized in the exact target
6
+ worktree.
7
+
8
+ ## Publish structural state
9
+
10
+ 1. For `missing`, `stale`, failed, or incomplete state, run
11
+ `semantic-atlas index` and inspect the returned envelope.
12
+ 2. Run `semantic-atlas status` again. Continue with Atlas only when freshness is
13
+ `current` and backend completeness is `complete`.
14
+ 3. Run `semantic-atlas map roots`. Structural `Module` roots are valid initial
15
+ navigation when no business `Capability` root exists.
16
+ 4. Use source as authority while publication is unavailable. Read result routing
17
+ when the index or follow-up status contains warnings or errors.
18
+
19
+ ## Bootstrap during a normal task
20
+
21
+ A normal task grows only the business area it actually verifies:
22
+
23
+ 1. Search task vocabulary and inspect the closest structural owner, neighbors,
24
+ and finite unknown candidates.
25
+ 2. Open the bounded source path required by the task and confirm the decisive
26
+ behavior.
27
+ 3. Identify each durable business concept and relationship that the source now
28
+ proves but the current map lacks.
29
+ 4. Follow GraphPatch authoring, submit those verified facts together, and verify
30
+ each learned entry through `semantic-atlas map show`.
31
+ 5. Stop after the task-relevant capability is reusable. Leave unrelated roots
32
+ for later tasks.
33
+
34
+ ## Bootstrap an explicitly requested project map
35
+
36
+ Treat project initialization as a bounded mapping task rather than an attempt
37
+ to describe every symbol:
38
+
39
+ 1. Begin with `semantic-atlas map roots` and select the requested directories,
40
+ domains, or a small set of the most evidence-rich structural roots when the
41
+ request supplies no narrower boundary.
42
+ 2. For each selected root, follow one representative path through public
43
+ interfaces, operations, data, invariants, and verification where present.
44
+ 3. Confirm the controlling declarations in source and record the initialization
45
+ boundary in the task result.
46
+ 4. Learn only durable verified capabilities and their supported child concepts
47
+ and relationships. Preserve unknown or unsupported behavior as boundaries,
48
+ not exact business facts.
49
+ 5. Verify learned capability keys with `semantic-atlas map show`, then start a
50
+ fresh query from one learned term to prove the initial map is reusable.
51
+
52
+ Future tasks extend this initial map incrementally as they verify more business
53
+ behavior.