Repository navigation
feat(relations): derived rule-path edges and reconcile candidates (#1563) - #1636
Conversation
3251bd8 to
3a25235
Compare
…ncent#1563) Part 1 — a rule's paths: glob that matches the source: files of exactly one visible codebase's page derives a MAPS_TO edge in each direction when recall renders the pages it already loaded; the edges are never stored. A glob matching pages in two codebases is ambiguous and gives no edge, a withheld codebase's page never matches, and a declared relation to the same page wins. Glob matching is a small in-repo matcher (**, *, ?). Part 2 — teamai codebase --reconcile --dry-run also prints relation candidates: every rule and doc in the team clone becomes an input to the same term match as the product pages, proposed always from a rule or doc (never from a teamwiki page) with the matched term and confidence. It writes nothing; a candidate shows in recall only after a person copies it into the asset's related: frontmatter, in a PR review --branch checks. A standalone --output tree holds no rules or docs and proposes nothing. Stacked on the Tencent#1552 first slice (Tencent#1629).
3a25235 to
5a844df
Compare
The testing description is sufficient: it records build/lint/type checks, targeted suites, and representative real-CLI verification covering both features and dry-run cleanliness. No additional provider × agent matrix is required. I did not run, build, or install anything from the PR. |
… glob, document both (Tencent#1636 review) - Derived edges are computed and kept per scope, so a user rule's paths glob can never mark a workspace rule or page: a relation stays inside its owner, the same fix Tencent#1629 made for declared relations. - Ambiguity is judged per glob, not over a rule's whole glob list: two globs matching two different codebases are two certain edges, not one ambiguous pair that silences both. - The bilingual knowledge guide documents the reconcile --dry-run candidates and the derived rule-path relations.
Resolved earlier findings: ambiguity is now checked per glob, and both language versions of the knowledge guide document the new behavior. The testing description is sufficient: it records targeted tests and representative real-CLI verification, including dry-run cleanliness. No additional provider × agent matrix is required. I did not run, build, or install anything from the PR. |
…run record Ports the Tencent#1636 review fix into the stats consumption path: edges from computeDerivedRelations are per scope and per glob, so the run line's related refs and the printed lines can no longer attach a user rule's glob match to another scope's hit.
|
Codex review addressed in
Verification: |
Edge buckets were scope-local, but every scope still matched against the combined page list: with the same teamwiki page path in the user and workspace clones, a page of one scope could produce an edge to the other scope's copy. Pages now keep their hit's scope, and a bucket matches only its own pages (a page without a scope matches everywhere, for direct callers).
|
No new findings in the specified diff. Resolved earlier findings:
The PR description documents sufficient testing, including representative real-CLI verification of both features and dry-run cleanliness. No additional provider × agent matrix is required. I only read the diff; I did not run, build, or install anything from the PR. |
|
Codex re-review addressed in |
…ery hits Review on Tencent#1636: - computeDerivedRelations no longer takes the recall results. Each RelationContext now carries collectCodePages(teamwikiRoot, withheld): the source: files of every teamwiki/evidence/code/<slug>/ page in the scope's own wiki clone, filtered by the withheld list. A query that returns only one of two same-glob pages can no longer flip a certain edge into ambiguity, and a rule hit shows its -> MAPS_TO even when the page is not a hit. withheld === null (namespaces unreadable) hides every page, matching how declared teamwiki/ targets resolve. - entryRuleGlobs expands braces with expandBraces, the same pass the rule renderers run, so paths: ["src/{pay,other}/**"] derives edges. - knowledge.md/sharing.md (+ zh) mention that a Related: -> MAPS_TO pair can be derived, not only declared. Verified: tsc, lint, build clean; asset-relations + recall-attribution + lint-asset-graph + viz unit suites and the 5 real-CLI relations e2e pass.
|
Both P1s fixed at [P1] Derived edges depend on query results. Rewritten. [P1] Brace globs derive nothing. Fixed exactly as suggested: [P2] Docs. [P2] [P3] Reconcile candidates. Noted; the candidates mirror what the clone knows, so this is inherent to reading the delivered wiki. Happy to address separately if it ever misleads a member. Verified: tsc / lint / build clean; |
|
No new findings in the specified diff. Resolved earlier findings:
The PR description documents sufficient testing, including representative real-CLI verification of both features and dry-run cleanliness. No additional provider × agent matrix is required. I only read the diff; I did not run, build, or install anything from the PR. |
Reviewed at
@jeff-r2026 Your call once the two blocking items are settled; #1637 builds on this one. |
Re-checked at
@jeff-r2026 Your call. |
- knowledge-reconciler.ts: toPosix sits below the import blocks again and the Phase 3 line is split — both spots came from this branch, not earlier (Tencent#1636 review). - collectCodePages is skipped when no rule in scope has paths:, saving the ~65 ms walk for teams without scoped rules (Tencent#1636 review). - knowledge.md (+ zh): the Related: line sentence says "a relation from the hit", covering derived MAPS_TO pairs too (Tencent#1636 review). Verified: tsc, lint, build clean; asset-relations + recall-attribution (218 tests) pass.
|
No new findings in the specified diff. Resolved earlier findings:
The PR description documents sufficient testing, including representative real-CLI verification of both features and dry-run cleanliness. No additional provider × agent matrix is required. I only read the diff; I did not run, build, or install anything from the PR. |
Read at @jeff-r2026 Your call; #1637 builds on this one and needs a rebase onto it. |
…e onto Tencent#1636's page pool Rebased onto Tencent#1636's collectCodePages pool; SaulMoro's re-check on Tencent#1637: - codebase-wiki-lint prints the new not-checked line in English (AGENTS.md: no Chinese in CLI output). - WikiLintReport documents that graphHealth can be null in every mode, standalone --output included: graph-index.json missing or corrupt means "not checked", never a measured 0%; scripts reading graphHealth.connectivity must handle null. - formatResults delegates relation rendering to resultsRelations (which owns the derived-edge computation now); two leftovers from the rebase removed. Verified: tsc, lint, build clean; lint-asset-graph + recall-attribution + viz + asset-relations (270 tests) and the 5 real-CLI relations-e2e pass.
|
Fixed at
Verified: tsc / lint / build clean; |
|
Friendly nudge @jeff-r2026 — this one looks ready from our side:
This is the base of the stack: #1637 (#1562) rebases onto main once this squashes. Anything still holding it up? |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at 4c08fb4. Both parts of #1563 are met as the #1552 triage scopes them:
- Rule
paths:become derivedMAPS_TOedges to the code pages whosesource:they match, each with its basis. The edges are computed over the whole scope, not the hit list, and brace globs expand. codebase --reconcile --dry-runproposes relation candidates, and they become relations only once a person accepts them in a PR.
Everything we raised earlier is resolved: derived edges from the hit list, brace expansion, and the reconciler cleanups. CI is green at this head. The CI review has nothing open.
#1637 builds on this one. Once this merges, please rebase it onto main.
…e onto Tencent#1636's page pool Rebased onto Tencent#1636's collectCodePages pool; SaulMoro's re-check on Tencent#1637: - codebase-wiki-lint prints the new not-checked line in English (AGENTS.md: no Chinese in CLI output). - WikiLintReport documents that graphHealth can be null in every mode, standalone --output included: graph-index.json missing or corrupt means "not checked", never a measured 0%; scripts reading graphHealth.connectivity must handle null. - formatResults delegates relation rendering to resultsRelations (which owns the derived-edge computation now); two leftovers from the rebase removed. Verified: tsc, lint, build clean; lint-asset-graph + recall-attribution + viz + asset-relations (270 tests) and the 5 real-CLI relations-e2e pass.
… glob, document both (Tencent#1636 review) - Derived edges are computed and kept per scope, so a user rule's paths glob can never mark a workspace rule or page: a relation stays inside its owner, the same fix Tencent#1629 made for declared relations. - Ambiguity is judged per glob, not over a rule's whole glob list: two globs matching two different codebases are two certain edges, not one ambiguous pair that silences both. - The bilingual knowledge guide documents the reconcile --dry-run candidates and the derived rule-path relations.
…ery hits Review on Tencent#1636: - computeDerivedRelations no longer takes the recall results. Each RelationContext now carries collectCodePages(teamwikiRoot, withheld): the source: files of every teamwiki/evidence/code/<slug>/ page in the scope's own wiki clone, filtered by the withheld list. A query that returns only one of two same-glob pages can no longer flip a certain edge into ambiguity, and a rule hit shows its -> MAPS_TO even when the page is not a hit. withheld === null (namespaces unreadable) hides every page, matching how declared teamwiki/ targets resolve. - entryRuleGlobs expands braces with expandBraces, the same pass the rule renderers run, so paths: ["src/{pay,other}/**"] derives edges. - knowledge.md/sharing.md (+ zh) mention that a Related: -> MAPS_TO pair can be derived, not only declared. Verified: tsc, lint, build clean; asset-relations + recall-attribution + lint-asset-graph + viz unit suites and the 5 real-CLI relations e2e pass.
- knowledge-reconciler.ts: toPosix sits below the import blocks again and the Phase 3 line is split — both spots came from this branch, not earlier (Tencent#1636 review). - collectCodePages is skipped when no rule in scope has paths:, saving the ~65 ms walk for teams without scoped rules (Tencent#1636 review). - knowledge.md (+ zh): the Related: line sentence says "a relation from the hit", covering derived MAPS_TO pairs too (Tencent#1636 review). Verified: tsc, lint, build clean; asset-relations + recall-attribution (218 tests) pass.
…ncent#1636) Rule `paths:` globs that match a code page's `source:` become derived `MAPS_TO` edges, each with its basis. `codebase --reconcile --dry-run` proposes relation candidates, and a person accepts them in a pull request. Closes Tencent#1563
…e onto Tencent#1636's page pool Rebased onto Tencent#1636's collectCodePages pool; SaulMoro's re-check on Tencent#1637: - codebase-wiki-lint prints the new not-checked line in English (AGENTS.md: no Chinese in CLI output). - WikiLintReport documents that graphHealth can be null in every mode, standalone --output included: graph-index.json missing or corrupt means "not checked", never a measured 0%; scripts reading graphHealth.connectivity must handle null. - formatResults delegates relation rendering to resultsRelations (which owns the derived-edge computation now); two leftovers from the rebase removed. Verified: tsc, lint, build clean; lint-asset-graph + recall-attribution + viz + asset-relations (270 tests) and the 5 real-CLI relations-e2e pass.
… for in the relations and read-gates code `oxlint --fix` with only this rule on, over the files Tencent#1636, Tencent#1637 and
…unchecked casts From Tencent#1636 and Tencent#1637: - a code page's `source:` field is parsed with a schema (one path or a list, other entries name nothing) instead of typeof; - readdirSync with an encoding returns string[], and Map iterators already type `.next().value`, so their casts go; - the run line leaves `related` undefined, which the JSONL writer drops, instead of spreading an empty object; - the health view's partial LocalConfig carries a SAFETY note naming the fields its readers use. Proof: tsc and npm run lint pass; the recall, asset-relations and viz tests pass.
… for in the relations and read-gates code `oxlint --fix` with only this rule on, over the files Tencent#1636, Tencent#1637 and
…unchecked casts From Tencent#1636 and Tencent#1637: - a code page's `source:` field is parsed with a schema (one path or a list, other entries name nothing) instead of typeof; - readdirSync with an encoding returns string[], and Map iterators already type `.next().value`, so their casts go; - the run line leaves `related` undefined, which the JSONL writer drops, instead of spreading an empty object; - the health view's partial LocalConfig carries a SAFETY note naming the fields its readers use. Proof: tsc and npm run lint pass; the recall, asset-relations and viz tests pass.
Implements both parts of #1563: relations the team does not write by hand, each with an explicit basis.
Part 1 — rule
paths:become MAPS_TO edgesTwo fields already name the same files: a rule's
paths:globs and a code page'ssource:frontmatter. When a glob matches a page's source, that is an edge, not a guess from names.MAPS_TOedge in each direction (the rule hit shows→, the page hit shows←).src/utils/glob.ts:**crossing any depth,*within a segment,?); no new dependency.Part 2 — proposed relations, accepted by PR
teamai codebase --reconcile --dry-runnow also prints relation candidates: every rule and doc in the team clone becomes an input to the same term match the product pages already use (knowledge-reconciler), proposed always from a rule or doc, never from a teamwiki page, with the matched term and confidence. It writes nothing; a candidate shows in recall only after a person copies it into the asset'srelated:frontmatter, in an ordinary PR thatreview --branchchecks. No new command or flag. A standalone--outputtree holds no rules or docs and proposes nothing.The candidates are also part of the
--jsonresult asrelationCandidates;ReconcileResultgained that field.Testing
npx tsc --noEmit,npm run lint,npm run buildclean.matchGlobsemantics (segment wildcards,**at any depth including zero, leading./); derived-edge rules (one codebase both directions, two codebases none, no match none, declared wins);relationCandidates(doc and rule proposals, never from a teamwiki page, nothing for a standalone output tree). 46 tests inasset-relations+relation-candidates.relations-e2e, 5 tests): derived edges render on both ends throughteamai recall;--reconcile --dry-runprints the candidate above andgit statusin the clone is unchanged.Notes
source:read happen at recall time over files already on disk; nothing is cached across runs.Refs #1563 (closes it once both parts land). #1552 keeps the umbrella.
Review rounds landed (Codex + SaulMoro): derived edges are judged per scope against the scope's own visible page pool (
collectCodePages, enumerated from the wiki clone, withheld-aware) instead of the query's hits, so every query derives the same edges; braces inpaths:expand exactly as the rule renderers expand them; the page pool is skipped when no rule in scope haspaths:;knowledge-reconciler.tskeeps its original import and line shape; knowledge/sharing guides (+ zh) state that aRelated: → MAPS_TO/← MAPS_TOpair can also be derived, not only declared.