@c4a/context-cli 0.6.18 → 0.6.19

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 (46) hide show
  1. package/README.md +6 -2
  2. package/README.zh-CN.md +5 -2
  3. package/cli.js +8551 -5388
  4. package/docs/document-optimization.md +35 -11
  5. package/docs/document-optimization.zh-CN.md +29 -9
  6. package/package.json +2 -2
  7. package/plugins/VERSION +1 -1
  8. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  9. package/plugins/claude/commands/context.md +36 -6
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +36 -6
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +36 -6
  14. package/plugins/skills/c4a-context/SKILL.md +36 -6
  15. package/providers/context/actions/apply-code-index-guidance.yaml +5 -0
  16. package/providers/context/actions/maintain-evidence.yaml +1 -1
  17. package/providers/context/actions/migrate-codeindex.yaml +5 -0
  18. package/providers/context/actions/register-source-batch.yaml +1 -1
  19. package/providers/context/actions/restore-repository-sources.yaml +1 -1
  20. package/providers/context/codes.yaml +2 -0
  21. package/providers/context/graphs/workspace.yaml +32 -2
  22. package/providers/context/manifest.json +76 -58
  23. package/providers/context/provider.yaml +1 -1
  24. package/providers/context/resources/dialogue/code-extraction.md +12 -0
  25. package/providers/context/resources/dialogue/document-classification.md +1 -1
  26. package/providers/context/resources/dialogue/knowledge-review.md +7 -1
  27. package/providers/context/resources/dialogue/source-boundary.md +9 -1
  28. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +11 -8
  29. package/providers/context/resources/dialogue/workflow-mode-after-creation.md +6 -4
  30. package/providers/context/resources/manuals/guides/lark-resources.md +7 -0
  31. package/providers/context/resources/manuals/guides/package-outputs.md +3 -3
  32. package/providers/context/resources/manuals/reference/code-extractors.md +5 -4
  33. package/providers/context/resources/manuals/reference/package-templates.md +18 -10
  34. package/providers/context/resources/manuals/reference/project-api.md +47 -22
  35. package/providers/context/resources/procedures/close-and-build.md +24 -9
  36. package/providers/context/resources/procedures/code-extraction.md +35 -11
  37. package/providers/context/resources/procedures/code-index-audit.md +53 -13
  38. package/providers/context/resources/procedures/document-capture.md +9 -0
  39. package/providers/context/resources/procedures/document-optimization.md +69 -21
  40. package/providers/context/resources/procedures/document-revision.md +11 -6
  41. package/providers/context/resources/procedures/knowledge-review.md +4 -1
  42. package/providers/context/resources/procedures/source-boundary.md +20 -8
  43. package/providers/context/resources/semantic/align/structure-planning.md +4 -4
  44. package/providers/context/resources/semantic/code-index/classification.md +8 -5
  45. package/providers/context/schemas/document-optimization-decisions.schema.json +29 -6
  46. package/providers/context/schemas/source-batch-input.schema.json +18 -3
@@ -104,7 +104,7 @@ configuration problem, not a Review decision.
104
104
 
105
105
  If no current capability can parse the source reliably, stop at configuration
106
106
  and report the missing generic capability. Do not silently emit an empty
107
- codegraph or reuse an unrelated parser.
107
+ codeindex or reuse an unrelated parser.
108
108
 
109
109
  ## Plan Before Parsing
110
110
 
@@ -114,7 +114,7 @@ application, adapter, CLI/tool, monorepo container, derived source,
114
114
  authoritative contract source, or unknown.
115
115
  A hybrid module may declare several `moduleTypes` and several behavior `facets`;
116
116
  keep one primary `moduleType` for concise reports. Record inspected paths in
117
- `moduleTypeEvidence`, then read all matching Route-recommended files below
117
+ `moduleTypeEvidence`, record every Markdown file actually read in `documents`, then read all matching Route-recommended files below
118
118
  `resources/semantic/code-index/templates/` and combine them into one plan.
119
119
  After that, choose exactly one closed output profile: `module-map`,
120
120
  `application-map`, `protocol-index`, `service-boundary`, `runtime-map`,
@@ -136,8 +136,9 @@ selected symbol and permits one owning index unit per source. Use it for an
136
136
  intentional granular public reference. Use `extractCustom()` for module-level
137
137
  aggregation, registries, protocol indexes, cross-module flows, or multiple
138
138
  candidate owners over one source; each candidate declares its `module` and
139
- evidence-scoped `sections`. Each section's typed coverage and exact evidence is
140
- checked against the output profile during preview. Resolve repositories from
139
+ at least one evidence-scoped `section`; there is no page-level Markdown
140
+ fallback. Each section's typed coverage and exact evidence is checked against
141
+ the output profile during preview. Resolve repositories from
141
142
  the extractor context's `sources[].absolutePath`, never from a
142
143
  machine-specific checkout path. Cross-module flow output must also emit
143
144
  source-backed structured edges. Generated clients/models, mirrored sources, legacy
@@ -47,7 +47,7 @@ kbPackage({
47
47
  llmsPackage({
48
48
  name: "component-lib-llms",
49
49
  template: "src/package-templates/llms",
50
- select: { include: ["codegraph/component-lib/**"] },
50
+ select: { include: ["codeindex/component-lib/**"] },
51
51
  });
52
52
  ```
53
53
 
@@ -265,7 +265,7 @@ its pages instead of producing one index per path segment.
265
265
  The generated
266
266
  `dist/<package-name>/wikis/` tree is the required default
267
267
  KB entry surface. Internal collections are mapped into OKF roots during build:
268
- `codegraph`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
268
+ `codeindex`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
269
269
  `faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
270
270
  `rules/`; and `feats` goes to `feats/`. Treat `wikis/` as the structured
271
271
  entity-and-relationship layer. Guides and rules may explain, operationalize,
@@ -313,17 +313,25 @@ wants project-specific behavior beyond knowledge lookup.
313
313
 
314
314
  ## Context OKF Profiles
315
315
 
316
- Approved Markdown under `knowledge/` is the production source of truth:
316
+ Approved Markdown under `knowledge/` and its deterministic
317
+ `knowledge/structure.yaml` projection form the authoring source of truth:
317
318
 
318
319
  - top-level YAML frontmatter uses OKF fields such as `type`, `title`,
319
320
  `description`, `tags`, `timestamp`, and `resource`;
320
- - Context production metadata such as `sources`, `node_type`, `visibility`,
321
- `code_symbols`, relationship records, and `candidate_fingerprint` also lives
322
- at the top level;
321
+ - each Markdown page keeps reader fields, stable page identity, `sources`, and a
322
+ small recovery capsule (`resource`, `node_type`, containment fields, and
323
+ relationship mode);
324
+ - large or repeated machine state such as complete `code_symbols`, code
325
+ evidence, relationship records, candidate fingerprints, and optimization
326
+ decisions lives once in the corresponding `structure.yaml` view record;
327
+ - Context readers hydrate that machine state in memory before verify, audit,
328
+ revision, or build. Do not copy a compact page as a new page without using a
329
+ Context authoring command;
323
330
  - do not nest Context production metadata under `context`; fields such as
324
331
  `context.sources` and `context.code_symbols` are not part of the 0.6 profile;
325
332
  - section provenance lives in `<!-- context:section ... source_ref="..." -->`
326
- comments;
333
+ comments. When a Section needs more than one citation, the CLI preserves the
334
+ complete set in its adjacent `context:source_refs` block;
327
335
  - do not add frontmatter `source_refs`; page-level provenance is derived from
328
336
  section source refs when needed;
329
337
  - do not add `context` or `schema` fields.
@@ -346,7 +354,7 @@ src-N#span:<heading-hint> L<start>-<end>@<span-hash>
346
354
 
347
355
  The code symbol form includes the source-relative file so same-name symbols in
348
356
  different files resolve to one exact symbol-index row. Consumers should still
349
- treat the complete `source_ref` as opaque. Production codegraph pages keep
357
+ treat the complete `source_ref` as opaque. Production codeindex pages keep
350
358
  `candidate_fingerprint` at the top level and do not duplicate this evidence in
351
359
  `code_origin`.
352
360
 
@@ -398,8 +406,8 @@ current closed state.
398
406
 
399
407
  Before writing output, `context build` validates that rendered template paths
400
408
  are safe, unique, and do not collide with copied knowledge paths. For example,
401
- a template file that renders to `wikis/codegraph/foo.md` is rejected if
402
- selected knowledge such as `knowledge/codegraph/foo.md` maps to that same OKF
409
+ a template file that renders to `wikis/codeindex/foo.md` is rejected if
410
+ selected knowledge such as `knowledge/codeindex/foo.md` maps to that same OKF
403
411
  output path. Rename the template file or use `select.exclude` when the
404
412
  collision is intentional.
405
413
 
@@ -35,7 +35,7 @@ the date:
35
35
  ```text
36
36
  knowledge/<collection>/<slug>.md
37
37
  knowledge/<collection>/<containment>/<slug>.md # only for an intentional hierarchy
38
- knowledge/codegraph/<module>/symbol/<slug>.md
38
+ knowledge/codeindex/<module>/symbol/<slug>.md
39
39
  repo:<date>/<module>#symbol:...
40
40
  file:<date>/<module>/<document>#span:...
41
41
  lark:<date>/<module>/<document>#span:...
@@ -47,12 +47,12 @@ dist/<source-name>-kb/...
47
47
  Choose the module boundary before extraction. In a monorepo, register each
48
48
  confirmed package/subdirectory under the same date batch. A repo root that
49
49
  resolves to multiple modules is for inspection; it is not an extraction unit.
50
- Approved codegraph paths use the stable module name; the date remains only in
50
+ Approved codeindex paths use the stable module name; the date remains only in
51
51
  source selectors, phase ids, and evidence refs:
52
52
 
53
53
  ```text
54
- knowledge/codegraph/module-a/...
55
- knowledge/codegraph/module-b/...
54
+ knowledge/codeindex/module-a/...
55
+ knowledge/codeindex/module-b/...
56
56
  ```
57
57
 
58
58
  For prose Views, provide a stable filename `slug` and omit `path`; the CLI
@@ -63,7 +63,7 @@ it is not a required source/module wrapper.
63
63
 
64
64
  The registry stores this as one date entry containing several `modules` entries,
65
65
  and materializes each module at `sources/repo/<date>/<module>`.
66
- Repo module names are project-wide codegraph identities and therefore cannot be
66
+ Repo module names are project-wide codeindex identities and therefore cannot be
67
67
  reused under another date batch. Refresh an existing module through its original
68
68
  date/module selector.
69
69
  When a repo module and the Context workspace share the same Git root, the CLI
@@ -408,7 +408,7 @@ alignProse({
408
408
  ```
409
409
 
410
410
  `collection` is an internal knowledge classification, not a package directory.
411
- Package build maps `codegraph`/`business`/`product` to `wikis/`,
411
+ Package build maps `codeindex`/`business`/`product` to `wikis/`,
412
412
  `architecture`/`sop`/`faq`/`decision`/`incident` to `guides/`,
413
413
  `standards`/`test` to `rules/`, and `feats` to `feats/`. The complete output
414
414
  contract is documented in [Package Outputs](../guides/package-outputs.md).
@@ -598,7 +598,7 @@ Extract exported TypeScript / TSX symbols into draft candidates:
598
598
  ```ts
599
599
  extractTs({
600
600
  source: componentLib,
601
- collection: "codegraph",
601
+ collection: "codeindex",
602
602
  });
603
603
  ```
604
604
 
@@ -607,7 +607,7 @@ Options:
607
607
  | Field | Meaning |
608
608
  |---|---|
609
609
  | `source` | `source("date", "module")` for one repo module |
610
- | `collection` | Code extraction uses `"codegraph"` |
610
+ | `collection` | Code extraction uses `"codeindex"` |
611
611
  | `include` | Optional glob list inside the selected source; default is `["src/**/*.{ts,tsx}"]` |
612
612
  | `mode` | `"exports"` (default) traces public exports from automatic or configured entries; `"scan"` uses every file matched by `include` as an entry root |
613
613
  | `entries` | Optional source-relative entry files for `"exports"` mode. They override `package.json` entry detection and live only in the Context project configuration |
@@ -620,7 +620,7 @@ An explicit index unit records production intent rather than parser settings:
620
620
  ```ts
621
621
  extractTs({
622
622
  source: componentLib,
623
- collection: "codegraph",
623
+ collection: "codeindex",
624
624
  indexUnits: [{
625
625
  id: "component-public-api",
626
626
  inputSources: ["20260712/component-lib"],
@@ -629,6 +629,7 @@ extractTs({
629
629
  moduleTypes: ["sdk-library"],
630
630
  facets: ["public-api", "plugin-extension"],
631
631
  moduleTypeEvidence: ["package.json exports and src/index.ts public entry"],
632
+ documents: ["README.md", "docs/public-api.md"],
632
633
  outputProfile: "public-api-reference",
633
634
  responsibility: "Document stable exported component contracts.",
634
635
  entries: ["src/index.ts"],
@@ -655,6 +656,9 @@ behaviors such as routing, protocol consumption, events, persistence, plugins,
655
656
  release, or cross-module chains. `moduleTypeEvidence` records the inspected
656
657
  paths that support the classification. Classify first, then read the matching
657
658
  Route-provided code-index templates, and only then finish the extraction plan.
659
+ `documents` contains exact source-relative Markdown paths read for that plan;
660
+ Context compares it with discovered module documents instead of treating a
661
+ source-code comment as documentation coverage.
658
662
  `lifecycle` is `"authoritative"`, `"generated"`, `"mirrored"`, `"legacy"`,
659
663
  or `"vendored"`; derived sources normally use `"provenance-only"` rather
660
664
  than duplicating reader-facing pages. These are generic project facts, not
@@ -680,7 +684,7 @@ editing the source repository:
680
684
  ```ts
681
685
  extractTs({
682
686
  source: componentLib,
683
- collection: "codegraph",
687
+ collection: "codeindex",
684
688
  include: ["src/**/*.ts"],
685
689
  entries: ["src/api.ts"],
686
690
  });
@@ -740,7 +744,7 @@ remain report signals and do not create another Gate.
740
744
  Phase id shape:
741
745
 
742
746
  ```text
743
- extract:<source-name-or-repo>:codegraph
747
+ extract:<source-name-or-repo>:codeindex
744
748
  ```
745
749
 
746
750
  Codegraph extraction has two execution policies:
@@ -751,7 +755,7 @@ Codegraph extraction has two execution policies:
751
755
  the Agent re-evaluates `context status --format json`; only
752
756
  `workflow.current` decides whether Review is now required.
753
757
  - `context run <phase-id> --auto-promote` is the explicit CI/CD path. It is valid
754
- only for `phase.extract.ts` codegraph phases, applies deterministic code deltas
758
+ only for `phase.extract.ts` codeindex phases, applies deterministic code deltas
755
759
  without Review, refreshes deterministic close when approved knowledge changed,
756
760
  then runs project verification. Close or verification errors make the command
757
761
  fail; JSON output reports applied/materialized/removed counts plus a `close`
@@ -763,7 +767,7 @@ other semantic knowledge. Agents must not infer a human gate from a phase-local
763
767
  result. Human gates and their inspection/resolution Actions are exposed only by
764
768
  `workflow.current`.
765
769
 
766
- Approved codegraph sections use the local evidence form
770
+ Approved codeindex sections use the local evidence form
767
771
  `src-N#symbol:<file>:<symbol>:<kind>@<digest>`. The file segment makes reverse
768
772
  lookup exact when multiple files contain the same symbol name, kind, and digest;
769
773
  the complete ref remains opaque to agents. New pages keep only top-level
@@ -779,7 +783,7 @@ aggregated repository protocol:
779
783
  extractCustom({
780
784
  id: "extract:service:protocol",
781
785
  sources: [service],
782
- collection: "codegraph",
786
+ collection: "codeindex",
783
787
  indexUnits: [{
784
788
  id: "service-protocol",
785
789
  inputSources: ["20260811/service"],
@@ -850,6 +854,12 @@ least one source-backed structured edge. `context status` therefore treats this
850
854
  pending code extraction target, and Review can verify snapshot freshness
851
855
  without a placeholder `extractTs` phase.
852
856
 
857
+ Each `sections[].markdown` value is Section body content only; do not copy the
858
+ template heading into it. Context renders `sections[].title` and rejects nested
859
+ reader headings at the SDK boundary so empty template chapters cannot leak into
860
+ knowledge. Evidence `symbol` and `kind` are canonical-ref tokens and cannot
861
+ contain `:` or `@`; exact qualified signatures remain reader-facing prose.
862
+
853
863
  `indexUnits` is also the batch scale and ownership contract. Candidate
854
864
  `module` must match one declared unit id or output owner. Older callbacks that
855
865
  omit `indexUnits` remain compatible: Context groups candidates by `module` and
@@ -879,6 +889,21 @@ output profile. Coverage is based on source-backed evidence paths, not Markdown
879
889
  page count, so one aggregate page can pass while an entry-only static module
880
890
  card cannot.
881
891
 
892
+ For a single-source index unit, Context also scans every represented language
893
+ family and Markdown/MDX file after the unit's declared exclusions. The adapter's
894
+ `eligibleFileTargets` and `eligibleLoc` must cover that independent baseline.
895
+ Configuration files may be evidence, but a hand-picked evidence list cannot be
896
+ reused as the source or LOC denominator. Cross-module-flow units remain scored
897
+ against their declared entry, protocol, operation, and handoff boundaries rather
898
+ than treating several repositories as one source-code page.
899
+
900
+ The same baseline discovers conventional sibling page entries, route-register
901
+ calls in Go router files, and exported receiver operations when a Go handler is
902
+ the declared service source of truth. Every discovered identity must appear in
903
+ the target-symbol and boundary denominators. An aggregate page may summarize
904
+ these identities, but an adapter cannot list one representative sibling and
905
+ silently omit the rest.
906
+
882
907
  The extractor returns knowledge semantics (`nodeRef`, rendered Markdown,
883
908
  Review summary and source-backed evidence). It must not write `knowledge/`,
884
909
  `.tmp/context-runtime/lifecycle/candidates.jsonl`, extraction fingerprints or
@@ -899,9 +924,9 @@ import { indexGoRepository } from "@c4a/extract-go";
899
924
  import { extractCustom } from "@c4a/context";
900
925
 
901
926
  extractCustom({
902
- id: "extract:service:codegraph",
927
+ id: "extract:service:codeindex",
903
928
  sources: [service],
904
- collection: "codegraph",
929
+ collection: "codeindex",
905
930
  extract: async ({ projectRoot }) => {
906
931
  const facts = await indexGoRepository(resolveServiceCheckout(projectRoot));
907
932
  return { candidates: buildServiceCandidates(facts) };
@@ -927,7 +952,7 @@ and its evidence coverage auditable before candidate writes.
927
952
  Declare the review step for a collection:
928
953
 
929
954
  ```ts
930
- reviewValidity({ collection: "codegraph" });
955
+ reviewValidity({ collection: "codeindex" });
931
956
  ```
932
957
 
933
958
  Declare one review gate for all current draft collections:
@@ -939,7 +964,7 @@ reviewValidity({ scope: "all" });
939
964
  Phase id:
940
965
 
941
966
  ```text
942
- review:codegraph:validity
967
+ review:codeindex:validity
943
968
  review:all:validity
944
969
  ```
945
970
 
@@ -965,7 +990,7 @@ continue wording does not invoke it.
965
990
 
966
991
  The gate is batch-scoped: prose waits for every planned View across all active
967
992
  structure slots and every declared `pendingStructureTargets` item in the round;
968
- codegraph waits for every pending extract phase in the confirmed module round.
993
+ codeindex waits for every pending extract phase in the confirmed module round.
969
994
  Candidate count/hash therefore describes the complete current batch rather than
970
995
  one page, source slot, or module. Deterministic close later merges all active
971
996
  slots into `knowledge/structure.yaml`, retains only their source, collection,
@@ -995,13 +1020,13 @@ const sample = source("20260712", "sample");
995
1020
 
996
1021
  customPhase("custom:20260712/sample:review", async (ctx) => {
997
1022
  await ctx.ensureSources({ source: sample });
998
- await ctx.extract.ts(extractTs({ source: sample, collection: "codegraph" }));
999
- await ctx.review.html(reviewValidity({ collection: "codegraph" }));
1023
+ await ctx.extract.ts(extractTs({ source: sample, collection: "codeindex" }));
1024
+ await ctx.review.html(reviewValidity({ collection: "codeindex" }));
1000
1025
  });
1001
1026
  ```
1002
1027
 
1003
1028
  Custom phases are an orchestration escape hatch. Use `extractCustom()` instead
1004
- when project code needs to publish codegraph candidates. The supported runtime
1029
+ when project code needs to publish codeindex candidates. The supported runtime
1005
1030
  helpers are:
1006
1031
 
1007
1032
  - `ctx.ensureSources(...)` for repo source readiness.
@@ -6,14 +6,20 @@ mediaType: text/markdown
6
6
 
7
7
  # Close and build
8
8
 
9
- Close deterministically derives `knowledge/structure.yaml` from approved
10
- Markdown and the confirmed structure snapshots. It validates the rebuilt
11
- projection. When an approved page still points at a captured source asset,
9
+ Close deterministically reconciles approved Markdown, existing durable machine
10
+ metadata, and confirmed structure snapshots into `knowledge/structure.yaml`.
11
+ It then compacts repeated machine fields out of each Markdown page and validates
12
+ the hydrated result. When an approved page still points at a captured source asset,
12
13
  close may mechanically replace that target with its content-addressed
13
14
  `knowledge/assets` path; it does not rewrite reader-visible prose. Before
14
15
  removing the transient snapshots, it retains only each closed prose target's
15
16
  source, collection, and consumed snapshot hash under `source_inputs`.
16
17
 
18
+ Do not hand-edit, duplicate, or move fields between Markdown and
19
+ `structure.yaml`. The CLI owns compaction and hydration. A compact Markdown page
20
+ remains readable and keeps enough identity for projection diagnostics; complete
21
+ code and optimization metadata is intentionally not duplicated.
22
+
17
23
  Build runs only after close and verification are current. It writes declared
18
24
  packages under `dist/` and records an inventory receipt with added, updated,
19
25
  removed, and index changes.
@@ -26,11 +32,20 @@ package inventory. Revision sidecars are never emitted as separate knowledge.
26
32
  Run only the current route command, then evaluate again. A successful build
27
33
  means the currently declared scope is current; newly captured or newly declared
28
34
  targets can reopen earlier graph nodes.
35
+
36
+ The final completion summary must cover the built outputs, validation status,
37
+ knowledge scale, and unresolved issues. Add a compact `Review reports` section with every
38
+ exact HTML report URL or local report path that the user actually used for a
39
+ review decision in this conversation, together with its reviewed scope. Omit
40
+ the section when no report was user-reviewed. Do not reconstruct it by scanning
41
+ `.tmp`, invent a shareable URL, or classify fully managed or force approval as
42
+ user review.
29
43
  # Code-index audit record
30
44
 
31
- When a package selects approved `codegraph` pages, build requires the current
32
- batch-level Agent audit to be accepted. The complete report remains in the
33
- Context workspace at `knowledge/code-index-audit.json` and is not copied into
34
- `dist/` or uploaded with the package. `context-build-inventory.json` stores only
35
- the report digest, decision, and compact package summary needed to identify the
36
- audited build.
45
+ When a package selects approved `codeindex` pages, build requires the current
46
+ batch-level Agent audit to be accepted. The complete report and decision state
47
+ are runtime data below `.tmp/context-runtime/code-index-audit/`; deleting
48
+ `.tmp/` causes Context to recompute and re-audit them. They are not copied into
49
+ `dist/`, uploaded with the package, or committed as knowledge. The package
50
+ inventory stores only the report digest, decision, and compact summary needed
51
+ to identify the audited build.
@@ -27,6 +27,10 @@ selected package's public SDK/README before editing `src/index.ts`; never infer
27
27
  its API from bundled output. `moduleTypeEvidence` must identify the inspected
28
28
  paths that support the classification. An `unknown` unit or a unit with no
29
29
  classification evidence is an incomplete index plan.
30
+ Record exact source-relative Markdown paths read during classification in
31
+ `indexUnits[].documents`. Context inventories module Markdown independently:
32
+ root README or documentation entry files require complete reading, while other
33
+ related Markdown uses the reported Floor and Target coverage.
30
34
 
31
35
  For every custom extraction preview, Context probes source paths for known
32
36
  community structural capabilities: TypeScript symbols, React Router routes, Go
@@ -49,6 +53,15 @@ public-contract plan. Scan mode, repository collections, and custom extraction
49
53
  must declare their index units explicitly; an inferred plan is diagnostic only
50
54
  and cannot write candidates.
51
55
 
56
+ Every index unit must expose one inventory contract. Built-in parsers produce
57
+ it from AST and source traversal; a project adapter returns the same generic
58
+ shape. The inventory separates eligible/analyzed files and non-empty LOC,
59
+ discovered/read Markdown, discovered/analyzed/target/exported symbols, stable
60
+ entries and profile-selected boundaries, plus excluded files and reasons. JSON,
61
+ YAML, lockfiles and assets may be evidence but do not inflate source LOC.
62
+ Evidence-only adapter output is explicitly `unscorable` and cannot pass the
63
+ mechanical quality Gate as a complete module index.
64
+
52
65
  Extractor output shape must match the semantic plan. `extractTs()` projects one
53
66
  candidate page per selected symbol and assigns each source to one index unit;
54
67
  it is suitable for a deliberately granular public reference. Aggregated module
@@ -82,13 +95,17 @@ rerun the batch preview, then process exactly one pending extraction target and
82
95
  evaluate again. Do not add a second classification Gate after the page-count
83
96
  Gate; a plan revision returns through the same configuration step.
84
97
 
85
- A batch-total page warning and quality risks such as a thin aggregate are
86
- advisory only. They remain visible for cost and content-shape review but do not
87
- become a new Gate. Legal scale recovery includes narrowing `include`, excluding
88
- generated or mirrored directories, enabling `exportedOnly`, moving from a
89
- symbol catalog to an aggregated `extractCustom()` plan, or registering real
90
- child sources. Splitting one `extractTs()` source into overlapping units is not
91
- a valid workaround.
98
+ A batch-total page warning remains advisory. After extraction, independent
99
+ mechanical dimensions enforce source analysis, target-boundary coverage,
100
+ facts/explanation, evidence scope, implementation ratio, and page shape.
101
+ Aggregate custom candidates are rendered only from evidence-scoped `sections`;
102
+ free Markdown, empty optional sections, template instructions, and placeholders
103
+ cannot become reader-facing knowledge. A required Section without evidence is a
104
+ material/capability gap instead of an empty heading. Legal scale recovery
105
+ includes narrowing `include`, excluding generated or mirrored directories,
106
+ enabling `exportedOnly`, moving from a symbol catalog to an aggregated
107
+ `extractCustom()` plan, or registering real child sources. Splitting one
108
+ `extractTs()` source into overlapping units is not a valid workaround.
92
109
 
93
110
  Current previews are cached below `.tmp/context-runtime/extract/previews/` and
94
111
  formal extraction reuses their validated structural result. Cache identity is
@@ -97,6 +114,12 @@ locks, and the preview protocol. Deleting
97
114
  `.tmp` only causes a fresh preview. Existing approved knowledge is not
98
115
  retroactively rejected solely because it is large.
99
116
 
117
+ New workspaces write `knowledge/codeindex/**`. If an old workspace contains
118
+ legacy `knowledge/codegraph/**`, follow the Route-returned
119
+ `context migrate codeindex --format json` action. It rewrites formal collection
120
+ identities and invalidates derived extraction/audit state without requiring
121
+ `.tmp`. Never create a permanent dual-write or move the directory by hand.
122
+
100
123
  Do not open Review while another extraction target in the same batch remains.
101
124
  Unchanged approved or rejected symbols do not need another decision; new or
102
125
  changed candidates remain subject to the current Review policy.
@@ -148,10 +171,11 @@ empty or guessed graph.
148
171
 
149
172
  After every complete code-extraction batch, the Route produces one batch-level
150
173
  code-index audit. Mechanical signals cover content depth, evidence scope,
151
- declared-source coverage, and structured handoffs. They are review evidence,
152
- not an automatic numeric rejection: the Agent must inspect the affected pages
153
- and submit one `accept`, `revise`, or `request-input` decision for all index
154
- units together.
174
+ declared-source coverage, and structured handoffs. A dimension outside its
175
+ absolute bounds is a mechanical rejection and cannot be accepted. Advisory or
176
+ elevated signals inside those bounds remain review evidence: the Agent must
177
+ inspect the affected pages and submit one `accept`, `revise`, or
178
+ `request-input` decision for all index units together.
155
179
 
156
180
  Do not split this into one confirmation per module. In fully managed operation,
157
181
  real issues select `revise` and the Route returns through project configuration,
@@ -10,17 +10,48 @@ This Route is a required semantic review of the complete proposed code index.
10
10
  The CLI reports mechanical signals; the Agent reads the affected candidate
11
11
  content and evidence, compares registered sources with the user-confirmed
12
12
  scope, and decides whether the index is fit for its declared output profiles.
13
+ Reader metrics exclude Context lifecycle comments and evidence annotations.
14
+ Improve the source-backed knowledge itself; do not change Markdown syntax,
15
+ sentence count, or pagination solely to influence a mechanical counter.
13
16
 
14
- The report is not a numeric rejection. A signal may be a false positive, but
15
- it may not be ignored. Every elevated signal must receive an assessment tied
16
- to inspected content. Submit one `context.code-index-audit-decision.v1`
17
- payload for the complete batch.
17
+ The report contains no aggregate score. Every dimension is computed
18
+ independently with its observed value, floor, recommended target, ceiling,
19
+ mechanical score, uncovered identities, and legal repair actions. A dimension
20
+ outside its absolute bounds cannot be accepted or offset by another strong
21
+ dimension. Every elevated signal must receive an assessment tied to inspected
22
+ content. Submit one `context.code-index-audit-decision.v1` payload for the
23
+ complete batch.
24
+
25
+ Read the complete inventory before deciding. It separates eligible and
26
+ analyzed files/LOC, read documents, target and exported symbols, stable entries,
27
+ protocol boundaries, exclusions, and parser gaps. For each failed or
28
+ below-target dimension, use the returned uncovered identities, affected pages,
29
+ recommended template resources, and action vocabulary. Do not replace those
30
+ facts with an inferred file list.
31
+
32
+ For custom adapters, file and symbol identity arrays are complete denominators,
33
+ not samples: their lengths must match the declared counts, analyzed identities
34
+ must belong to eligible identities, and exported identities must belong to the
35
+ target-symbol set. For a single-source unit, the CLI independently enumerates
36
+ the represented language families plus Markdown/MDX after declared exclusions;
37
+ an adapter cannot make its ratio pass by reporting only hand-picked evidence
38
+ files. Conventional sibling page entries, Go route-register calls, and exported
39
+ operations from a declared Go handler source of truth are also independently
40
+ enumerated; include every discovered identity in the target-symbol and boundary
41
+ denominators even when one aggregate page explains them. Section evidence may
42
+ contain multiple files and may overlap
43
+ another Section when one fact crosses a boundary. It must not be reduced to one
44
+ arbitrary primary file, and every Section must not repeat the complete page
45
+ evidence set merely to satisfy coverage. Distinct structured relationships must
46
+ cite the concrete evidence for their own handoff instead of repeating one whole
47
+ page evidence set across every destination.
18
48
 
19
49
  ## Decisions
20
50
 
21
- - `accept`: the requested scope is represented and every real content-depth,
22
- evidence-scope, and relationship issue is resolved. An acceptable or
23
- non-applicable signal needs a concrete reason.
51
+ - `accept`: the requested scope is represented, every dimension is within its
52
+ absolute bounds, and every real content-depth, evidence-scope, template, and
53
+ relationship issue is resolved. A below-target dimension remains visible
54
+ and needs a concrete reason in ordinary operation.
24
55
  - `revise`: one or more real problems remain. Identify the affected units and
25
56
  describe changes to scope, aggregation, sections, evidence, or structured
26
57
  handoffs. The Route returns to `src/index.ts`, Preview, extraction, and a new
@@ -31,13 +62,22 @@ payload for the complete batch.
31
62
 
32
63
  ## Fully managed operation
33
64
 
34
- Fully managed authority does not auto-accept this audit. When a signal is a
35
- real problem, choose `revise` and continue the revision loop without asking the
36
- user. Repeat until the proposed index matches the requested scope and its
37
- module maps, contracts, and handoffs contain useful source-backed explanation.
38
- Pause only for unavailable material, source access, tool failure, or a
39
- concrete no-progress blocker.
65
+ Fully managed authority does not bypass the audit. When an absolute dimension
66
+ fails, choose a returned repair action and continue through configuration,
67
+ Preview, extraction, and audit without asking the user. Aim for the recommended
68
+ target instead of stopping immediately at the floor. The retry ledger is bound
69
+ to unit, source revision, profile, and problem fingerprint; superficial wording
70
+ changes do not reset it. After three unsuccessful revisions of the same
71
+ problem, Context combines all affected modules into one human-guidance Gate.
72
+ Pause earlier only for unavailable material, source access, or missing parser
73
+ capability.
40
74
 
41
75
  After each decision, briefly tell the user which decision was selected, the
42
76
  affected units, and the next Graph path. Do not stop a managed run merely to
43
77
  announce a successful automatic revision.
78
+
79
+ The current `context.code-index-audit-report.v2` is computed from proposed or
80
+ approved knowledge. Only its decision receipt and compact retry metrics stay
81
+ under `.tmp/context-runtime/code-index-audit/`. Package output records only the
82
+ selected report digest and decision; page metrics, exclusions, template
83
+ fingerprints, and repair history are never published.
@@ -47,3 +47,12 @@ asset links. If a selected local
47
47
  boundary is a documentation site rather than plain Markdown, use the
48
48
  Context-provided processor/configuration diagnostic; do not invent rendered
49
49
  text or scan outside the confirmed boundary.
50
+
51
+ For Lark reads, Context prefers the authenticated user identity. If that
52
+ identity is unavailable because its credential is missing, expired, or cannot
53
+ be refreshed, Context may retry the same registered source with the bot
54
+ identity. It does not switch identity after a permission or missing-scope
55
+ response. Once selected, the same identity is used for the document body and
56
+ all embedded resources. If `docs +fetch` lacks the required `--doc-format`
57
+ capability, follow the returned `lark-cli update` recovery and rerun the same
58
+ Route command; do not replace the capture with a hand-written export.