@functional-systems/srcx 0.1.0-dev.3 → 0.1.0-dev.31

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 (61) hide show
  1. package/CHANGELOG.md +137 -1
  2. package/DESIGN.md +193 -58
  3. package/README.md +553 -38
  4. package/RELEASING.md +30 -9
  5. package/VALIDATION.md +855 -25
  6. package/dist/build.d.ts +81 -1
  7. package/dist/build.js +187 -37
  8. package/dist/build.js.map +1 -1
  9. package/dist/chunk.d.ts +9 -3
  10. package/dist/chunk.js +341 -14
  11. package/dist/chunk.js.map +1 -1
  12. package/dist/cli.js +103 -19
  13. package/dist/cli.js.map +1 -1
  14. package/dist/file-policy.d.ts +20 -0
  15. package/dist/file-policy.js +96 -0
  16. package/dist/file-policy.js.map +1 -0
  17. package/dist/implementation.d.ts +11 -0
  18. package/dist/implementation.js +191 -0
  19. package/dist/implementation.js.map +1 -0
  20. package/dist/publish.d.ts +18 -0
  21. package/dist/publish.js +158 -34
  22. package/dist/publish.js.map +1 -1
  23. package/dist/releases.js +21 -3
  24. package/dist/releases.js.map +1 -1
  25. package/dist/remote.d.ts +1 -0
  26. package/dist/remote.js +50 -9
  27. package/dist/remote.js.map +1 -1
  28. package/dist/repository.d.ts +4 -1
  29. package/dist/repository.js +26 -11
  30. package/dist/repository.js.map +1 -1
  31. package/dist/rerank.d.ts +16 -0
  32. package/dist/rerank.js +87 -0
  33. package/dist/rerank.js.map +1 -0
  34. package/dist/search.d.ts +14 -4
  35. package/dist/search.js +119 -23
  36. package/dist/search.js.map +1 -1
  37. package/dist/skills.d.ts +24 -0
  38. package/dist/skills.js +155 -0
  39. package/dist/skills.js.map +1 -0
  40. package/package.json +16 -5
  41. package/runtime/grammars/README.md +50 -0
  42. package/runtime/grammars/tree-sitter-bash.LICENSE +21 -0
  43. package/runtime/grammars/tree-sitter-bash.wasm +0 -0
  44. package/runtime/grammars/tree-sitter-sql.LICENSE +21 -0
  45. package/runtime/grammars/tree-sitter-sql.wasm +0 -0
  46. package/runtime/grammars/tree-sitter-wasm.LICENSE +21 -0
  47. package/runtime/qwen.py +132 -0
  48. package/runtime/requirements.txt +34 -0
  49. package/skills/srcx-search/SKILL.md +85 -0
  50. package/src/build.ts +258 -47
  51. package/src/chunk.ts +360 -12
  52. package/src/cli.ts +212 -24
  53. package/src/file-policy.ts +157 -0
  54. package/src/implementation.ts +253 -0
  55. package/src/publish.ts +226 -34
  56. package/src/releases.ts +36 -3
  57. package/src/remote.ts +70 -13
  58. package/src/repository.ts +40 -11
  59. package/src/rerank.ts +131 -0
  60. package/src/search.ts +154 -28
  61. package/src/skills.ts +205 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,140 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Look up explicit generated Collection names directly instead of discovering
6
+ every repository. Exact Collection names take precedence over aliases; only
7
+ missing Collections fall back to discovery. Preserve descriptor, schema and
8
+ immutable-version validation and ambiguity checks for repository names/keys.
9
+
10
+ - Add optional `read --implementation` for contiguous Python and TypeScript/TSX
11
+ overload groups. Return the pinned implementation with accurate citations;
12
+ preserve the selected span when linking is unsupported, ambiguous or too large.
13
+ Keep indexing and search defaults unchanged.
14
+
15
+ - Separate file selection from embedding eligibility. Exclude credential and
16
+ crypto payloads, virtual environments, caches and logs; keep lockfiles, generated
17
+ code, snapshots, tabular data and legal/author files available lexically without
18
+ embedding them. Fix case-sensitive minified-asset exclusions. Add pinned
19
+ `--file-policy` JSON rules for registration and local previews, explicit inventory
20
+ reasons and evaluation corpus exclusions for `eval/**`.
21
+
22
+ - Exclude image assets, including text SVG and portable pixel maps, before
23
+ indexing or embedding. Match image extensions case-insensitively, preserve
24
+ exclusion metadata, and keep inline SVG in source files searchable. Include
25
+ the source policy change in preset identity.
26
+
27
+ - Fix Shell indexing crashes on Bash comparisons such as `[[ "$value" == 1 ]]`
28
+ by bundling a runtime-compatible, checksum-pinned Bash grammar with its license.
29
+ Include the grammar in preset identity and installed-package validation.
30
+
31
+ - Bundle the srcx-search agent skill in npm and add `skills install`, `update`,
32
+ `remove` and `status` for Codex and Claude Code, with user/project scopes,
33
+ explicit setup and preservation of customized or unowned files. Removing an
34
+ absent skill stays read-only even when its parent directory already exists.
35
+
36
+ - Explain source-language query selection in README and search help, including
37
+ agent translation of query intent while preserving exact identifiers and
38
+ answering in the user's language. Keep multilingual input accepted without
39
+ adding automatic translation or changing retrieval defaults.
40
+
41
+ - Keep standard text analysis as the default and add `--analyzers` for any combination of
42
+ LambdaDB's English, Korean, Japanese and standard analyzers. Pin the canonical
43
+ selection in repository/build identity and verify it during discovery. This
44
+ pre-release preset requires an analyzer list; older presets are not accepted.
45
+ Make publication readiness independent of stop-word/tokenization behavior.
46
+ Pin existing evaluation harnesses to standard regardless of product defaults.
47
+
48
+ - Add Python/Go/Rust/C/C++/Shell/SQL syntax chunking with language-specific
49
+ declaration, function and statement boundaries, symbol/scope metadata and
50
+ bounded source-preserving splits. Bundle the pinned SQL grammar with licenses.
51
+
52
+ - Distinguish Qwen setup, cache, device, input-size and timeout failures with
53
+ actionable messages while keeping raw worker diagnostics private.
54
+
55
+ - Record three developer search/read investigations with concrete change maps,
56
+ bounded live usage and source verification, separate from ranking benchmarks.
57
+
58
+ - Refresh implemented/remaining scope and verify the published dev.17 package
59
+ through a fresh npm consumer and bounded live first-use workflow.
60
+
61
+ - Add opt-in local Qwen search reranking with bounded candidate pools, pinned
62
+ source evidence, separate scores and per-command timing.
63
+
64
+ - Evaluate fixed-candidate CosQA semantic reranking with local Qwen, shared
65
+ duplicate scores, stable ties and separate official-ID/content metrics.
66
+
67
+ - Cross-check the retained CosQA lexical baseline with an independent offline
68
+ BM25 ranker and the same StandardAnalyzer tokenization.
69
+
70
+ - Add pinned CoIR CoSQA and MTEB CodeSearchNet Python/Go retrieval baselines,
71
+ sharing srcx query construction and using trec_eval metrics on official labels.
72
+
73
+ - Add a bounded local Qwen reranking diagnostic with frozen inputs, durable
74
+ per-pair reservations and offline source-selection reporting.
75
+
76
+ - Prepare offline reranking inputs from verified retained Click/Cobra candidates,
77
+ with separate evaluator labels, original ranks and source provenance.
78
+
79
+ - Add a pending human review worksheet and fixed-candidate reranking experiment plan.
80
+
81
+ - Run bounded, explicitly unreviewed Click/Cobra retrieval diagnostics with managed small and unchanged source labels.
82
+
83
+ - Retain allowlisted CLI evaluation failure diagnostics without raw output or credentials.
84
+ - Prepare an offline, unreviewed Click/Cobra question set with pinned source evidence.
85
+ - Default CLI search/read evaluation across two pinned public repositories, with
86
+ alternative answer sets, exact source verification, and complete stdout accounting.
87
+ - Internal reproducible lexical chunking evaluation with pinned source labels,
88
+ equal path-only enrichment, isolated live indexes, and token-budget metrics.
89
+
90
+ ### Added
91
+
92
+ - Opt-in managed `text-embedding-3-large` (3072 dimensions) in separate pinned
93
+ Collections, with paired small/large evaluation and unchanged small identities.
94
+
95
+ - Paired identifier/natural-language/mixed-query diagnostics on eight new tasks,
96
+ with verified candidate-rank coverage and offline stdout-budget analysis.
97
+ - Bounded actual-CLI lexical/semantic/hybrid evaluation on identical managed
98
+ corpora, with reviewed and original labels, per-question regressions, stdout
99
+ token counts, command timings and durable request reservations.
100
+
101
+ - Opt-in LambdaDB managed OpenAI `text-embedding-3-small` Collections, offline
102
+ embedding input previews, and explicit semantic/RRF hybrid search modes.
103
+ - Candidate validation of generated vectors separately from exact source payloads,
104
+ unchanged-record reuse, and a bounded synthetic managed acceptance harness.
105
+
106
+ - Persistent one-to-one Git branch / Collection Branch mapping, branch-local
107
+ incremental updates, and branch-selected search, resolve, and read against the
108
+ last published commit Tag.
109
+ - Remote pending import ownership and resumable in-place branch updates, including
110
+ shared commit Tags across branches and non-fast-forward Git branch changes.
111
+ - `test:live:branches` for repeatable synthetic live acceptance with retained
112
+ checkpoint, retry, and resource evidence.
113
+
114
+ ### Changed
115
+
116
+ - Git branch imports update their fixed `git-*` writer; SHA/tag imports retain
117
+ manual workspaces. Existing publications and pending manual journals remain
118
+ usable. See README for migration and artifact behavior.
119
+ - Ambiguous indexed branch/Git tag names require explicit `refs/heads/...` or
120
+ `refs/tags/...` selectors.
121
+
122
+ ### Fixed
123
+
124
+ - Count failed and unsupported public-benchmark queries separately, retaining
125
+ both in the ranking metric denominators.
126
+
127
+ - Fetch omitted managed vectors from query responses through the same immutable
128
+ Tag, preserving hit order/scores and requiring exact non-vector payload equality.
129
+
130
+ - Reject an unprepared CLI evaluation run before creating its root/lock so a
131
+ subsequent offline preparation can use the same path.
132
+ - Pin branch control before enumerating versions so a concurrent publication
133
+ cannot advance the selector beyond the version list being read.
134
+ - Reject live checkpoint reuse across different code/harness inputs and preserve
135
+ the original validation revision and completion time on same-input reruns.
136
+
137
+ ## [0.1.0-dev.1] - 2026-09-25
138
+
5
139
  ### Added
6
140
 
7
141
  - Git commit imports, syntax-aware chunks, immutable LambdaDB versions, lexical
@@ -17,4 +151,6 @@
17
151
  - Pending imports resume without the previous local build artifact.
18
152
  - Search/read `--version` selects the corpus instead of printing the CLI version.
19
153
 
20
- No npm release has been published yet.
154
+ Initial npm bootstrap published to the `dev` channel from commit
155
+ `f94f947bf593b2f8498c07e130933b0ab444f868`. This local bootstrap has no
156
+ GitHub Actions provenance. No stable release has been published.
package/DESIGN.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # srcx: Initial Implementation Design
2
2
 
3
- Status: initial CLI implemented with local tests and live synthetic A/B validation
4
- on LambdaDB. See [README.md](README.md) for runnable interfaces and
3
+ Status: CLI implemented with persistent Git branch tracking, managed semantic/hybrid
4
+ search and optional local Qwen reranking. Local, live and public-benchmark evidence
5
+ have separate scopes. See [README.md](README.md) for runnable interfaces and
5
6
  [VALIDATION.md](VALIDATION.md) for the bounded live evidence and remaining scope.
6
7
 
7
- Updated: 2026-09-25.
8
+ Updated: 2026-09-26.
8
9
 
9
10
  ## 1. Purpose, decisions, and implementation defaults
10
11
 
@@ -18,14 +19,13 @@ supporting each result. The project name is `srcx`.
18
19
  | --- | --- |
19
20
  | Project and display name | `srcx` |
20
21
  | Local directory | `srcx` |
21
- | Intended GitHub repository | `lambdadb/srcx` |
22
+ | GitHub repository | `lambdadb/srcx` |
22
23
  | CLI executable | `srcx` |
23
- | Intended npm package | `@functional-systems/srcx` |
24
+ | npm package | `@functional-systems/srcx` |
24
25
  | Short description | Version-aware code search on LambdaDB |
25
26
 
26
- The name is selected; the GitHub repository and npm package have not been created
27
- or published in this project. The package manifest and executable entry point are
28
- present in the initial CLI. Keep display/configuration naming centralized and
27
+ The public GitHub repository and npm development channel are available. Current
28
+ publication evidence and stable-release status are recorded in RELEASING.md. Keep display/configuration naming centralized and
29
29
  distribution identity in `package.json`. Database IDs and the existing
30
30
  `code-*` Collection naming and `purpose=code-search-v1` protocol marker remain
31
31
  independent of the product name.
@@ -40,7 +40,7 @@ Confirmed boundaries from the discussion:
40
40
  - Map each Git tag to a LambdaDB Alias targeting its published commit Tag.
41
41
  Multiple Git tags for the same commit share one commit Tag and Snapshot.
42
42
  - Keep search results and subsequent source reads pinned to the selected version.
43
- - Replace a changed file's entire chunk set initially; cache embeddings by input.
43
+ - Replace a changed file's entire chunk set initially; retain unchanged remote records.
44
44
  - Keep core LambdaDB work, GitHub App/webhooks, UI, MCP, and a public SaaS outside
45
45
  the first deliverable. sbrain reference documents remain unchanged.
46
46
  - No remote repository creation, application commit, push, publication, real
@@ -53,7 +53,7 @@ Current recommendations, distinguished from user-confirmed choices:
53
53
  | Runtime | TypeScript and a supported Node.js release compatible with the existing SDK |
54
54
  | Database | LambdaDB only; no public backend selection or interchangeable database framework |
55
55
  | API key | Read `LAMBDADB_API_KEY` by default; optional environment-variable-name override |
56
- | Syntax | Java and TypeScript/JavaScript first; other text uses recorded fallback |
56
+ | Syntax | Java, TypeScript/JavaScript, Python, Go, Rust, C/C++, Shell and SQL; other text uses recorded fallback |
57
57
  | Source | Exact UTF-8 source inside file documents, with local blob cache |
58
58
  | File size | Start with a 1 MiB raw-source limit and explicit exclusions |
59
59
  | Embedding | A fixed `none` preset first; with a model, embed meaningful code and prose chunks while recording policy-based skips |
@@ -72,9 +72,10 @@ This document is not a deployed-revision audit or evidence of a passing live run
72
72
 
73
73
  The initial command set below is implemented; run it as `node dist/cli.js` from
74
74
  this checkout after `npm run build`. See README for exact options and recovery.
75
- The first implementation uses fresh `work-*` Branches and observed-local-tag Alias
76
- synchronization; persistent tracked branches and authoritative pruning remain
77
- follow-up work. Immutable manifest `requestedRef` is normalized to the resolved
75
+ Git branch imports now reuse persistent `git-*` Branches; explicit commit/tag
76
+ imports use frozen `work-*` writers. Observed-local-tag Alias synchronization is
77
+ implemented; automatic Git observation and authoritative pruning remain follow-up
78
+ work. Immutable manifest `requestedRef` is normalized to the resolved
78
79
  commit OID; the
79
80
  original user spelling remains in the local build artifact. The broader contract
80
81
  below remains the target design.
@@ -379,9 +380,10 @@ readers on multiple machines do not require local registration state.
379
380
  changed/deleted file, compute obsolete IDs as previous file/chunk IDs minus
380
381
  replacement IDs. A deleted file has an empty replacement set. Obtain previous
381
382
  IDs from the inventory, not mutable query-by-path results.
382
- 6. Apply the pinned per-chunk embedding policy. If embeddings are enabled, batch
383
- eligible cache misses across chunks/files within the provider's token/request
384
- limits. Validate successful vectors before caching.
383
+ 6. Apply the pinned per-chunk embedding policy. The managed preset materializes
384
+ eligible `embeddingText` inputs without calling a provider locally. LambdaDB
385
+ generates vectors during ordinary upsert. Skip unchanged remote records and
386
+ validate generated vectors in the candidate Tag before publication.
385
387
  Bound queue memory; do not load an entire repository's content into RAM.
386
388
  7. Materialize deterministic records and deletion lists as local build artifacts.
387
389
  Produce size-bounded inventory parts and a root manifest template. Check all
@@ -389,8 +391,10 @@ readers on multiple machines do not require local registration state.
389
391
  journal supplies the separate attempt ID when sealing the final manifest.
390
392
 
391
393
  Dry-run executes the same inventory/chunking path but performs no database mutation
392
- or embedding call. For pending embedding misses, report tokens and projected vector
393
- size separately; do not claim a completed vector/records hash. Report every entry,
394
+ or embedding call. Report `managed` eligible chunks and `managedTokens` (estimated
395
+ input tokens for the complete corpus), with `embedded=0` in the local artifact.
396
+ These are not billed usage or incremental upload counts. Record hashes bind the
397
+ submitted payload; server-generated vectors are validated separately. Report every entry,
394
398
  exclusion reason, parse status, byte size, chunk/token counts, embedding eligibility
395
399
  and skip reasons, and change summary. Dry-run plans may show pending embedding work;
396
400
  published chunk records may not silently treat missing required vectors as skips.
@@ -473,11 +477,12 @@ fields are omitted when absent; records of different kinds need not share them.
473
477
  | Record | Additional stored fields |
474
478
  | --- | --- |
475
479
  | File (`kind=file`) | `path`, `blobOid`, `contentHash`, `byteLength`, `sourceText`, `language`, `parseStatus`, `chunkCount` |
476
- | Chunk (`kind=chunk`) | `fileId`, `path`, parent `contentHash`, `language`, `chunkKind`, `startByte`, `endByte`, `startLine`, `endLine`, `ordinal`, `searchText`, `embeddingStatus`; optional `symbol`, `scope`, `signature`, `embeddingSkipReason`, `embeddingInputHash`, `embedding` |
480
+ | Chunk (`kind=chunk`) | `fileId`, `path`, parent `contentHash`, `language`, `chunkKind`, `startByte`, `endByte`, `startLine`, `endLine`, `ordinal`, `searchText`, `embeddingStatus`; optional `symbol`, `scope`, `signature`, `embeddingSkipReason`, `embeddingInputHash`, `embeddingText`, `embedding` |
477
481
  | Corpus root (`kind=manifest`, `role=corpus`, ID `__manifest__`) | `repoId`, `indexId`, full `commitOid`, `commitTime`, `requestedRef`, full `config`, `inventoryHash`, `recordsHash`, `counts`, `buildId`, `attemptId`, `inventoryPartIds` |
478
482
  | Inventory part (`kind=manifest`, `role=inventory`) | `partOrdinal`, `partHash`, ordered `entries` with path, file/chunk IDs, blob/content identities, inclusion/exclusion reasons, parse states, sizes, and embedding coverage |
479
483
  | Repository control (`kind=manifest`, `role=repository`, main ID `__repo__`) | Full source identity, repo/index IDs, immutable preset/config, initialization state |
480
- | Ref control (`kind=manifest`, `role=git-ref`, main) | Full Git ref name, encoded Alias/Branch name, observed commit/time, applied version and synchronization state |
484
+ | Git tag control (`kind=manifest`, `role=git-ref`, main) | Full Git tag ref, encoded Alias name, observed commit, applied version and synchronization state |
485
+ | Git branch control (`kind=manifest`, `role=git-branch`, main) | Full Git branch ref, encoded Branch name, validated writer baseline, canonical published Tag and pending attempt identity |
481
486
  | Validation summary (`kind=manifest`, `role=validation`, main) | Candidate name/Snapshot, build/config/attempt identity, verifier version and checked counts/hashes; no premature claim of publication |
482
487
 
483
488
  `startByte`/`endByte` are half-open; display lines are one-based/inclusive.
@@ -486,8 +491,13 @@ content such as function, declaration, documentation, imports, or fallback; it i
486
491
  separate from the file/chunk/manifest discriminator. `counts` includes included and
487
492
  excluded files, chunks, and embedded/skipped chunks with reason totals.
488
493
 
489
- In a completed corpus, `embeddingStatus=embedded` requires a valid vector and
490
- `embeddingInputHash`, and omits the skip reason. `embeddingStatus=skipped` requires
494
+ The managed preset uses `embeddingStatus=managed` to identify its generation policy,
495
+ not local completion. Eligible chunks carry `embeddingText=searchText` and an
496
+ `embeddingInputHash` over the exact input and embedding configuration; ordinary
497
+ upserts omit `embedding`. A completed candidate must contain a nonzero, finite
498
+ 1536-number vector for every eligible chunk. Local artifacts contain no vectors.
499
+ The internal fixture-only client embedder retains `embeddingStatus=embedded`;
500
+ its arbitrary presets cannot be published through the CLI. `embeddingStatus=skipped` requires
491
501
  an explicit policy reason and omits the vector and input hash. The lexical-only
492
502
  preset records `embedding-disabled`; an embedding-enabled preset records its
493
503
  specific exclusion reason. Pending or failed required embedding work stays in the
@@ -543,15 +553,24 @@ is stored in the file; enriched chunk search text is never the citation authorit
543
553
  `sourceText`, role, byte/line positions, hashes, commit identity, scope/signature,
544
554
  embedding diagnostics, and inventory/config objects are stored without entries in
545
555
  `indexConfigs`. Public documentation states that fields are stored even when not
546
- indexed. Do not invent an `index: false` option. The `standard` analyzer is a
547
- baseline, not a proven code-specific ranking solution. An initial enrichment
556
+ indexed. Do not invent an `index: false` option. The default text analyzer is
557
+ `standard`; users can choose any nonempty combination of `english`, `japanese`,
558
+ `korean`, and `standard`. The sorted, deduplicated list is part of the pinned
559
+ preset/configuration hash and configures both `searchText` and managed
560
+ `embeddingText`. Discovery requires the matching schema; a different selection
561
+ uses a different Collection. Analyzer selection does not change embedding input
562
+ text or the programming-language chunker. No analyzer is a proven universal
563
+ code-search ranking solution. An initial enrichment
548
564
  candidate preserves original identifiers while adding camelCase/snake_case terms;
549
565
  pin and evaluate that transformation before adopting it as the preset.
550
566
 
551
- An embedding-enabled preset adds an unmanaged `embedding` vector field with a
552
- concrete model-selected dimension and similarity metric, fixed before Collection
553
- creation. An indexed vector field does not require a vector on every chunk; file
554
- and manifest records also omit it. The `none` preset omits the vector index entirely.
567
+ The opt-in managed presets add indexed text `embeddingText` and a managed
568
+ `embedding` vector field with provider `openai`: `text-embedding-3-small` uses
569
+ 1536 dimensions and `text-embedding-3-large` uses 3072, both with cosine similarity.
570
+ The source field, dimensions and similarity are nested under the vector field's `embedding` configuration; there are no
571
+ top-level dimension/similarity properties. Collection discovery verifies the
572
+ complete resolved schema and pinned preset. Missing `embeddingText` on skipped
573
+ chunks, files and manifests means no vector is generated for those records. The `none` preset omits the vector index entirely.
555
574
  Changing presets creates a separate index; do not silently mutate an existing
556
575
  serving index. Do not write placeholder or test vectors into a real corpus.
557
576
 
@@ -593,21 +612,49 @@ must include stored-only source round-trip and mixed record kinds.
593
612
  ## 8. File policy, chunking, and embedding reuse
594
613
 
595
614
  Every Git tree entry must be accounted for. Include source, tests, documents,
596
- configuration, build definitions, and unknown readable text by default. Maintain
597
- explicit versioned rules for binaries, generated output, and vendored dependencies;
598
- do not treat working-tree ignore rules as a complete policy. Lockfiles are included
599
- unless an explicit generated/size rule excludes them.
615
+ configuration, build definitions, and unknown readable text by default, subject to
616
+ the versioned file-purpose policy. The preset pins `filePolicy: { version: 1, rules }`
617
+ and its ordered repository-relative path rules. File selection and embedding
618
+ eligibility are separate: source/lexical retrieval can remain available without a
619
+ vector. Do not treat working-tree ignore rules as a complete policy.
620
+
621
+ Credential filenames/directories, key/certificate payloads, image/binary assets
622
+ and PEM private-key headers are hard exclusions, including for tracked files.
623
+ Credential template suffixes (`.example`, `.sample`, `.template`) remain eligible.
624
+ This is a targeted policy, not comprehensive secret detection. Dependencies,
625
+ virtual environments, build/cache outputs, minified assets/maps and logs are
626
+ excluded by default. Lockfiles, legal/author files, tabular/JSONL data, snapshots,
627
+ and generated code (common suffixes or explicit generated/do-not-edit comments in the first 8 KiB) are
628
+ lexical-only by default. Tests, ordinary docs, manifests and build/CI config remain
629
+ eligible. Embedded license headers are not removed from source chunks.
630
+
631
+ `--file-policy` accepts JSON on registration and local path dry runs. Last matching
632
+ rule wins (`exclude`, `lexical`, `semantic`); rules use case-sensitive relative
633
+ paths, `*`, `?` and whole-segment `**`. Rules can override default purpose decisions,
634
+ but never hard content/path/size/encoding exclusions. The resolved policy is stored
635
+ in the preset, not reread from a mutable checkout on import. `.gitattributes` is
636
+ not interpreted. Inventory `retrieval`/`policyReason` and chunk skip reasons expose
637
+ the decision. Changing rules changes configHash and cannot reuse a prior baseline.
638
+
639
+ Evaluation labels require explicit exclusion independently of product defaults.
640
+ Both checkout source evaluation harnesses pin `eval/source-corpus-policy.json`
641
+ (excluding `eval/**`) and fingerprint it. New runs use new artifact roots; retained
642
+ results and their old corpus/runtime identities remain historical evidence.
600
643
 
601
644
  | Special entry | Initial handling |
602
645
  | --- | --- |
603
646
  | Submodule | Record gitlink OID/path; no recursive import |
604
647
  | LFS pointer | Record metadata; no payload download or pointer indexing |
648
+ | Image asset | Exclude known image extensions case-insensitively before chunking or embedding, including text SVG and portable pixel maps; retain inventory reason `image-extension` |
605
649
  | Symlink | Record target bytes; never follow or index as source |
606
650
  | Oversized file | Exclude with actual bytes and configured limit |
607
651
  | Invalid UTF-8 content/path | Record a diagnostic and lossless path identity; do not decode lossily |
608
652
  | Empty text file | File record, zero chunks |
609
653
  | Unsupported language or parse failure | Include bounded fallback chunks and distinguish the reason |
610
654
 
655
+ Inline SVG markup in actual source files (for example, TSX components) remains
656
+ source. The image exclusion policy participates in the immutable preset identity.
657
+
611
658
  Preserve raw UTF-8 bytes, BOM, CRLF, case, Unicode, and final newlines. Byte ranges
612
659
  are authoritative `[startByte, endByte)`; display lines are one-based/inclusive.
613
660
  JavaScript UTF-16 offsets must be converted explicitly. Preserve unusual Git paths
@@ -645,6 +692,25 @@ is not an unconditional one-function-per-chunk rule.
645
692
 
646
693
  ### Initial boundary and size rules
647
694
 
695
+ The implementation adds Python/Go/Rust/C/C++ using the existing pinned WASM
696
+ grammars and Shell/SQL using bundled, checksum-pinned grammars (see
697
+ `runtime/grammars/README.md`).
698
+ Python splits top-level declarations and class bodies, keeps decorators with their
699
+ function/class, and records nested class scopes. Go keeps functions/methods,
700
+ extracts receiver type scopes, and separates named types in grouped declarations.
701
+ Rust splits `impl`, `trait` and inline module bodies, retaining generic type/trait
702
+ scopes and outer attributes/doc comments with each declaration. Macros and `cfg`
703
+ conditions remain authored source; there is no compiler expansion or evaluation.
704
+ C/C++ walks declarators and namespace/class bodies, preserving templates and both
705
+ preprocessor branches without evaluating conditions. `.h` uses C; C++ header
706
+ extensions use C++. Shell covers `.sh`/`.bash` with the Bash grammar, keeping
707
+ functions and compound commands intact. SQL keeps each top-level statement,
708
+ including CTEs and supported quoted bodies, and records created object/schema
709
+ names. Unknown dialect syntax uses whole-file parse fallback.
710
+ Functions and SQL statements larger than the token ceiling use the common bounded text splitter with
711
+ their symbol/scope preserved; nested functions stay in the containing function.
712
+ These rules do not change Java/TypeScript/JavaScript boundaries.
713
+
648
714
  Prefer functions/methods and split large nodes along internal statement boundaries.
649
715
  Cover class headers, imports, types, fields, constants, top-level code, comments,
650
716
  punctuation, and gaps. Merge small adjacent units only within one scope and budget.
@@ -724,7 +790,7 @@ structural fragments, rather than build a complex value classifier.
724
790
  | Documentation, explanatory comments/docstrings | Embed; keep attached explanations with their code where practical |
725
791
  | Meaningful type/configuration declarations | Embed initially, then evaluate |
726
792
  | Imports-only or whitespace/punctuation-only fragments | Skip with a recorded reason |
727
- | Repeated license headers and mechanical listings | Candidates for explicit, versioned skip rules after evaluation |
793
+ | Lexical-only file categories or rules | Keep exact source/chunks, omit embedding inputs and record the file policy reason; embedded license comments in authored code are not stripped |
728
794
  | Parser fallback | Do not exclude solely because parsing failed; apply content policy |
729
795
 
730
796
  Skipped chunks remain in inventory and source coverage. Retain lexical search text
@@ -740,13 +806,46 @@ choice and the finer skip rules remain evaluation decisions, not measured result
740
806
 
741
807
  ### Embedding reuse
742
808
 
743
- Cache embeddings by the exact full input and provider/model/revision/dimensions/
744
- preprocessing settings. Do not include commit, line numbers, file IDs, or build IDs
745
- in that input. A line shift can update positions while reusing the same vector;
746
- changed chunk boundaries or a renamed path in the input can legitimately miss.
747
- Cache only successful validated outputs atomically. Query embeddings use the same
748
- compatible contract and have their own cache/budget accounting. Provider aliases
749
- may drift if no immutable model revision exists; record that limitation.
809
+ The managed implementation reuses unchanged records from the immutable baseline:
810
+ compare all submitted payload fields after separately validating and removing only
811
+ the server-generated vector. Do not upload those unchanged records again. Direct
812
+ managed vector writes are forbidden, including copies fetched from an old Tag.
813
+ Changed files receive new chunk IDs and may require re-embedding even if some text
814
+ is identical. Replaying an uncertain write may also incur embedding usage. There
815
+ is no srcx-managed document or query vector cache and no promised server cache.
816
+ The older local cache remains only for internal client-embedder fixtures.
817
+
818
+ The input includes path/symbol context and source text, not commit/line/build IDs.
819
+ The preset pins provider/model/dimensions/similarity and input policy, but the
820
+ provider model name is not an immutable model revision. Validation proves vector
821
+ shape and payload integrity, not deterministic numerical reproduction by OpenAI.
822
+
823
+ Search remains lexical by default. Explicit `--mode semantic` uses managed
824
+ `knn.queryText`; `--mode hybrid` combines the existing lexical query and that kNN
825
+ query using LambdaDB RRF. Both legs enforce `kind=chunk` and the same optional
826
+ path/language filters; kNN uses a prefilter and `k=limit`, or `k=candidates`
827
+ when optional reranking requests a wider pool. The lexical leg keeps
828
+ nonembedded chunks eligible. Query/fetch/list request vectors explicitly so the
829
+ same validation applies to pinned result handles. When a deployment omits managed
830
+ vectors from list responses, fetch the affected IDs from that same immutable Tag
831
+ and require identical non-vector payloads before vector validation. Source reads still use the
832
+ original file bytes, never enriched text. Bounded retrieval and reranking results
833
+ are recorded in [VALIDATION.md](VALIDATION.md); they do not establish a universal
834
+ winner or authorize default changes.
835
+
836
+ Optional `--rerank qwen` scores complete verified chunk bytes with a pinned local
837
+ Qwen3-Reranker-0.6B revision, preserves candidate identity and retrieval order on
838
+ ties, and returns a separate reranker score. Setup is explicit, inference is
839
+ offline, and failures do not silently fall back. Every CLI invocation loads its
840
+ own model. See [README.md](README.md#optional-local-qwen-reranker) for limits and
841
+ runtime setup; this path does not change stored Collections or embedding presets.
842
+
843
+ Managed source text and semantic/hybrid query text are sent through LambdaDB to
844
+ OpenAI and incur embedding usage plus normal LambdaDB operations/storage. Dry-run
845
+ and lexical queries do not request query embeddings. Use explicit opt-in and a
846
+ bounded synthetic acceptance run before evaluating private or larger corpora.
847
+ See [managed embeddings](https://docs.lambdadb.ai/guides/collections/managed-embeddings)
848
+ and [hybrid query](https://docs.lambdadb.ai/guides/search/hybrid) for the API contract.
750
849
 
751
850
  ## 9. Candidate validation, publication, and `versions`
752
851
 
@@ -814,10 +913,16 @@ they do not authorize the next commit on that workspace.
814
913
  attempt identity and verifier version. Use an ID derived from the full commit
815
914
  OID and candidate Snapshot ID so attempts cannot overwrite another Snapshot's
816
915
  evidence. Confirm its readback before publication.
817
- 5. Create the deterministic published Tag **from the validated candidate Tag**,
818
- not from the mutable Branch. Verify both Tags have the same Snapshot ID and
819
- matching manifest. Publication changes naming, not corpus content.
820
- 6. Update optional branch-progress/control records and return the published version.
916
+ 5. For a first publication, create the deterministic published Tag **from the
917
+ validated candidate Tag**, not from the mutable Branch. Verify both Tags have
918
+ the same Snapshot ID and matching manifest. If the commit is already published,
919
+ validate and reuse its canonical Tag; retain this writer's validated candidate
920
+ separately when its Snapshot ID differs. Publication never overwrites a commit
921
+ Tag with another writer's snapshot.
922
+ 6. For a tracked Git branch, update its control record with the validated writer
923
+ snapshot and published commit Tag, clear pending ownership, and return the
924
+ published version. Branch selectors keep using the preceding published Tag
925
+ until this control update succeeds.
821
926
  A delayed bookkeeping write does not erase an already published immutable Tag.
822
927
 
823
928
  An empty Snapshot or incomplete candidate never becomes published. A stale Tag
@@ -827,6 +932,33 @@ avoid repeatedly validating known stale Snapshot IDs. A payload/build defect
827
932
  requires explicit same-build recovery, not endless polling. Publication must
828
933
  finish before the same code Branch starts a later commit.
829
934
 
935
+ ### Persistent Git branch state
936
+
937
+ Each full `refs/heads/...` name maps to one `git-<ref-digest>` writer and one
938
+ `branch-<full-ref-digest>` control document on main (`role=git-branch`). The control
939
+ record holds the last applied immutable baseline, canonical published Tag name,
940
+ and pending attempt/build/commit identity. Record pending ownership before branch
941
+ creation or corpus writes. A missing local journal cannot authorize a second
942
+ import over pending remote state, even if the committed head still matches the
943
+ old baseline. Only the same journal may resume; automatic abandoned-attempt
944
+ recovery remains unimplemented.
945
+
946
+ Compare the writer head with the recorded baseline snapshot before the next
947
+ import, then reconcile old IDs and hashes through its immutable Tag. This works
948
+ without the prior local artifact and supports a branch moving backward or across
949
+ history. Every target commit still comes from one full committed Git tree.
950
+
951
+ An already published commit does not skip updating a different tracked branch.
952
+ Validate that branch's own candidate, reuse the existing canonical commit Tag,
953
+ and retain the candidate as the writer's exact baseline when the snapshot IDs
954
+ differ. Never overwrite the canonical commit publication with another writer's
955
+ snapshot. This also applies when a branch returns to a previously indexed commit.
956
+
957
+ Branch search/resolve/read selects the last published Tag from the control record,
958
+ including while the next import is pending. This promises the last indexed state,
959
+ not the current Git tip. A first pending import has no searchable branch version.
960
+ An ambiguous tracked branch/Git tag short name requires an explicit heads/tags ref.
961
+
830
962
  ### `versions` reads LambdaDB
831
963
 
832
964
  1. Resolve the repository Collection through remote metadata.
@@ -971,7 +1103,7 @@ Required meaningful checks:
971
1103
  - Byte coverage, Unicode/BOM/CRLF/trailing-newline/long-line spans are exact.
972
1104
  - Parse failures and huge nodes stay bounded and visible in reports.
973
1105
  - B contains additions/replacements/deletions while A reads remain unchanged.
974
- - A controlled line-shift fixture updates positions and reuses identical embeddings.
1106
+ - A controlled line-shift fixture updates positions; managed imports may re-embed changed IDs, while the internal client-cache fixture verifies input-based reuse.
975
1107
  - Different paths remain distinct even with identical bytes; reuse follows input.
976
1108
  - Fixed-config mismatches fail before writes; fake vectors never enter a real corpus.
977
1109
  - Explicit obsolete-ID deletion preserves replacement IDs and removes surplus chunks.
@@ -999,15 +1131,18 @@ latency, and operational cost are separate measurements.
999
1131
 
1000
1132
  ## 12. Remaining decisions and inspected evidence
1001
1133
 
1134
+ The initial parser/tokenizer presets, managed embedding choices and CLI retrieval
1135
+ modes are implemented and have bounded evaluation records. The following are
1136
+ future decisions or per-run requirements, not blockers awaiting initial design:
1137
+
1002
1138
  | Decision | When needed |
1003
1139
  | --- | --- |
1004
- | First real repositories and parser priority | Real-repository evaluation; defaults do not block fixtures |
1005
- | Exact parser/tokenizer/preset versions, enrichment and embedding skip rules | Bootstrap and retrieval evaluation; pin before publishing a corpus |
1006
- | Chunk size/overlap and syntax-versus-window tradeoff | Section 8 pilot after retrieval works; current values are starting points |
1007
- | Embedding model/dimensions/provider, data destination, spending cap | Before any real source upload or paid experiment |
1008
- | LambdaDB endpoint/project and credentials | Provisioning and live fixture run |
1009
- | Authoritative Git-tag source and observed-ref freshness policy | Manual Alias synchronization |
1010
- | Concurrent multi-host writers, retention/cleanup, configuration migration | Later internal operation, outside first CLI |
1140
+ | Additional parser languages and production repositories | Onboarding source beyond the currently tested coverage |
1141
+ | Quality/latency thresholds and any default changes | After actual development-task use; before stable rollout |
1142
+ | New embedding/reranking providers or chunking policies | A concrete unmet retrieval need; Jev access remains deferred |
1143
+ | Source authorization, endpoint/project, credentials and spending limits | Before every new corpus upload or paid experiment |
1144
+ | Authoritative Git-tag source and observation freshness | Automatic synchronization or pruning |
1145
+ | Multi-host writers, retention/cleanup and configuration migration | Later internal operation, outside the first CLI |
1011
1146
 
1012
1147
  Sources and evidence used during this design discussion:
1013
1148
 
@@ -1044,13 +1179,13 @@ Sources and evidence used during this design discussion:
1044
1179
  - [Tree-sitter parsing](https://tree-sitter.github.io/tree-sitter/using-parsers/2-basic-parsing.html):
1045
1180
  source ranges and encodings; verify the selected binding during implementation.
1046
1181
 
1047
- Development checkout references identify the inspected files, not runtime
1048
- dependencies. No
1049
- application tests, source uploads, embeddings, or live LambdaDB validation have
1050
- been performed as part of writing this document.
1182
+ Development checkout references identify the files inspected during the original
1183
+ design discussion, not runtime dependencies. That design-only review did not run
1184
+ application tests, source uploads, embeddings or live LambdaDB checks. Subsequent
1185
+ implementation and validation evidence is recorded in [VALIDATION.md](VALIDATION.md).
1051
1186
 
1052
- Document validation: the revised lexical `indexConfigs` JSON, description, four
1053
- reserved metadata labels, and one optional context label passed the local built
1187
+ Historical design validation (September 25): the revised lexical `indexConfigs`
1188
+ JSON, description, four reserved metadata labels, and one optional context label passed the local built
1054
1189
  SDK's Collection-create input validator on September 25. All three JSON examples,
1055
1190
  the illustrative source span, then-local links, code fences, and whitespace also passed
1056
1191
  document checks. These checks do not establish server acceptance, marker ordering,