@saasontools/strauss-kb 0.1.16 → 0.1.17

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.
package/ARCHITECTURE.md CHANGED
@@ -84,11 +84,28 @@ from Zod, and `strauss-kb schema` is the contract.
84
84
  A fresh stamp is a baseline nobody has checked, so only a run where every
85
85
  checkable anchor already matched appends `verified[]`.
86
86
 
87
- The v1 resolver is regex-based, biased so a wrong answer loses to no answer: a
88
- span short of the code it claims hashes as stable while that code moves. It
89
- ranks by shape, scopes a dotted symbol to its parent, captures by brace depth or
90
- Python indentation, and returns `null` otherwise. A pure `AnchorResolver`
91
- interface admits a tree-sitter replacement.
87
+ Symbols resolve through tree-sitter first: a WASM parser per language, each
88
+ grammar's own upstream `queries/tags.scm` over definition sites, and the
89
+ definition node's range as the span. A dotted symbol matches the definition whose enclosing chain
90
+ matches; a bare name matching two is `symbol-ambiguous`. Only declarations are
91
+ captured: a symbol appearing solely in a call is no match.
92
+
93
+ The chain is tree-sitter, then regex, then a whole-file hash. A resolver that
94
+ parsed the file answers for it unless it defines no such symbol at all — tags
95
+ queries capture functions and types, not constants, aliases or fields — so
96
+ `symbol-not-found` continues down the chain and the anchor records whichever
97
+ resolver answered. `symbol-ambiguous` and `resolver-unavailable` stop it:
98
+ picking one of two definitions by text search, or swapping a precise span for a
99
+ heuristic one when a grammar will not load, is how a wrong span comes to hash
100
+ as `match`. A grammar that will not load is a finding, never a throw.
101
+
102
+ Grammars download on first use, sha256-pinned by `grammars/manifest.json` and
103
+ cached under `~/.strauss/grammars`; the reasoning is in the
104
+ [specification](https://saasontools.github.io/strauss-agent-tools/specification#symbol-resolution).
105
+
106
+ Each anchor records the resolver that stamped it. A hash only the previous
107
+ resolver reproduces is `drifted`, reason `resolver-changed`. Trees are cached
108
+ per content hash, grammars load once per process.
92
109
 
93
110
  Repository identity is normalised and compared, not parsed: an invented format
94
111
  would reject correct values from unseen hosts.
package/README.md CHANGED
@@ -206,17 +206,18 @@ Why a lock was rejected: [ARCHITECTURE.md](./ARCHITECTURE.md).
206
206
 
207
207
  An anchor names where a record attaches in the code: a `file`, optionally a
208
208
  `symbol` — symbolic, because a line number written mid-change is wrong by the
209
- end of it. Five optional fields extend it:
209
+ end of it. Six optional fields extend it:
210
210
 
211
211
  | Field | Meaning |
212
212
  | ------------- | ------------------------------------------------------------------------------------- |
213
213
  | `hash` | `sha256:<hex>` over the anchored text, algorithm-prefixed. |
214
214
  | `lines` | Line count the hash covered. |
215
215
  | `resolved_at` | When the anchor last resolved. |
216
+ | `resolver` | Which resolver produced the hash: `tree-sitter` or `regex`. |
216
217
  | `repo` | Which repository — remote URL or short name. Absent means this base's own repository. |
217
218
  | `ref` | Git rev the evidence was taken at. |
218
219
 
219
- `hash`, `lines`, and `resolved_at` are **measured** — a resolution pass stamps
220
+ `hash`, `lines`, `resolved_at`, and `resolver` are **measured** — a resolution pass stamps
220
221
  them; `repo` and `ref` are **author-owned identity** and a resolution pass
221
222
  never writes them.
222
223
 
@@ -246,8 +247,17 @@ carries a hash; unstamped anchors and unreachable remotes never fail.
246
247
  A fully clean run — every anchor checked and `match`, none stamped this run —
247
248
  appends a `verified[]` event.
248
249
 
249
- Symbol resolution is a v1 heuristic; ties and unclosed blocks return
250
- `unresolved`.
250
+ Symbols resolve tree-sitter first the 20 language packs that have both a
251
+ grammar and a definitions query, pinned together by `pnpm grammars pin` from
252
+ `grammars/packs.json` and proved at pin time — then the regex heuristic for
253
+ other extensions and for symbols the tags query does not define (constants,
254
+ type aliases, class fields), then a
255
+ whole-file hash when the anchor names no symbol; an ambiguous match or an
256
+ unloadable grammar returns `unresolved` rather than falling through to a guess. Neither half of a pack is published with the
257
+ package: grammar and query both download on first use, sha256-pinned against
258
+ `grammars/manifest.json`, and are cached under `~/.strauss/grammars`. A hash the old resolver still reproduces and
259
+ the new one does not is `drifted` with reason `resolver-changed` — accept it
260
+ with `--rebaseline`.
251
261
 
252
262
  Drift also surfaces on read: `kb_load` and `kb_query` attach a
253
263
  `{ kind: "drifted" }` warning — or `{ kind: "unchecked" }` for a foreign anchor
@@ -4,7 +4,7 @@ import {
4
4
  KB_DIR,
5
5
  KbStore,
6
6
  VERSION
7
- } from "./chunk-H5W53NVU.js";
7
+ } from "./chunk-ZKIQOBHT.js";
8
8
 
9
9
  // src/cli.ts
10
10
  import { join } from "path";
@@ -121,4 +121,4 @@ function usage() {
121
121
  export {
122
122
  runKbCli
123
123
  };
124
- //# sourceMappingURL=chunk-RINBOAQZ.js.map
124
+ //# sourceMappingURL=chunk-RMJUGTAQ.js.map
@@ -2,7 +2,7 @@ import {
2
2
  KB_COMMANDS,
3
3
  KbStore,
4
4
  VERSION
5
- } from "./chunk-H5W53NVU.js";
5
+ } from "./chunk-ZKIQOBHT.js";
6
6
 
7
7
  // src/mcp.ts
8
8
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -46,4 +46,4 @@ export {
46
46
  createKbMcpServer,
47
47
  runKbMcpServer
48
48
  };
49
- //# sourceMappingURL=chunk-MEZCF646.js.map
49
+ //# sourceMappingURL=chunk-SA3A2SPY.js.map