Repository navigation
feat(recall): declared asset relations on recall hits, checked by review --branch (#1552 first slice) - #1629
Conversation
…iew --branch (Tencent#1552) A rule, a doc or a learning declares relations to other team assets in a `related:` frontmatter block; a local Markdown link to another asset becomes REFERENCES. Recall prints each visible relation as a Related: line after the hit's File: line (→ declared by the hit, ← declared by the other end, at most 5), without changing hits, order or scores. Relations resolve only inside the scope that owns them, and a teamwiki target resolves only when its page exists and its codebase is not withheld. teamai review --branch gains a relations check over every rule and doc in the branch tree: structural problems fail, a target that names no asset on the branch warns. teamai contribute prints the same findings as warnings and still publishes. - The link parser moves to utils/markdown-links.ts so review --branch and the relation derivation read links with one parser. - SEARCH_INDEX_VERSION 7 → 8: entries carry their team-tree path and their outgoing relations; an older index rebuilds on the next recall or pull. - Nothing is written to teamwiki/.indices/graph-index.json.
|
Findings
Testing |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Reviewed at 73d9577a with a built CLI on fresh team fixtures (teamwiki pages, a namespaced skill, learnings, related: blocks), against main. What works: Related: lines only add to the output, with hits, order, Score and --check identical to main on the same index; removing a relation drops the ← line after the next build; an index from the previous version rebuilds on the next recall; contribute warns and still publishes; malformed rows fail review --branch at their level; no conflict with #1628.
The acceptance criteria in the #1552 triage comment are not met in four places, three of which the automated review also reported (it rated 2–4 as P2; I rate them P1 because each is a listed criterion):
- [P1 blocking] A relation crosses scopes. With
inheritUserScopeand an empty project index, a user rule'sMAPS_TOprints as← MAPS_TOon a workspace teamwiki hit (src/recall.ts:491falls back to the user context). Criterion: "A relation to something this recall cannot see prints nothing … another scope's asset". Reproduced. - [P1 blocking] A namespaced skill does not resolve.
REFERENCES: skills/<namespace>/<skill>prints nothing, whilecontributeaccepts the same target: the dirs collector insrc/utils/search-index.tsstoresskills/<skill>, dropping the namespace. Criterion: "A namespaced skill and a namespaced learning resolve". Reproduced. - [P1 blocking] A bare relative link is dropped.
[overview](payments-overview.md)indocs/payments.mdprints nothing (src/asset-relations.tsonly resolves./and../). Criterion: a link "resolved from the file's tree path". Reproduced. - [P1 blocking] A link to a skill's
SKILL.mdis dropped, andreview --branchwarns thatskills/release/SKILL.md"names no team asset". The index key isskills/release; the link should canonicalize to it. Reproduced.
Also needed before merge:
- [P2 non-blocking] Namespaced learning ids are built with
path.join, so on Windows they hold backslashes and never match a relation target (read from the code; Windows not run).asset-relations.test.tsis not in the Windows test list, so CI would not catch it. - [P2 non-blocking]
docs/guide/sharing.mdand its Chinese page say a missing target failsreview --branch; the code (and the triage table) make it a warning with exit 0. - [P2 non-blocking] A
related:block that is invalid YAML (a duplicate key) makesreview --branchreport clean and drops the relations silently; the triage table expectsfail. - [P3 nit] The
codebaseDircollision the automated review describes is real in the code, but both production callers passundefined, so it cannot happen today.
@jeff-r2026 Your call once the four P1s are fixed.
- A hit with an explicit scope never borrows another scope's relation context: with an empty project index, a user rule's relation no longer prints on a workspace teamwiki hit. - Delivered skill source directories keep their namespace in the tree path (skills/pay/release), so a declaration targeting them resolves in recall. - A bare relative link destination (payments-overview.md) resolves against the linking file's directory; team-root paths stay absolute-in-tree. A link to a skill's SKILL.md canonicalizes to the skill directory, in declarations and in links. - Namespaced learning tree paths are posix even when path.join produced platform separators (Windows). - codebaseDir entries stay unaddressable by relations: the recursive collector only assigns a tree path when the caller names the team-tree prefix. - review --branch fails a related block that does not parse (a duplicate key), and contribute warns; a tolerated non-strict frontmatter with no related key stays silent. - Both sharing guides describe a missing target as a warning, matching the implemented behavior.
|
Review comments addressed in P1s
P2s
P3
Verification: |
|
Findings Earlier Findings Testing I only read the specified diff. I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Re-checked at 90c34e24 with a built CLI on the same fixtures. All four blocking points are resolved:
- A workspace teamwiki hit no longer shows a user rule's
← MAPS_TOwhen the project index is empty. - A namespaced skill (
skills/<namespace>/<skill>) resolves. - A bare relative link (
[overview](payments-overview.md)) resolves. - A link to a skill's
SKILL.mdresolves, andreview --branchno longer warns about a declaredskills/release/SKILL.md.
The non-blocking points are resolved too: both sharing guides now say a missing target is a warning (exit 0), and an unparseable related: block makes review --branch exit 1 while contribute still warns and publishes. The Windows learning-id fix is in the code but untested: no test feeds a backslash id, and asset-relations.test.ts is not on the Windows list. The automated review at this head reports no new findings. I added a real-CLI record of the fixed behavior to the description, since the existing one predates these fixes.
- [P2 non-blocking] The new
"related" could not be parsed; all of it is ignored.(review-branch.ts,contribute.ts) drops the parser's error, so the author has to find the bad line by hand. Appending the parser message would say which key or line. - [P3 nit]
skillDirTreePathdrops the namespace when a skill or namespace is itself namedskills; a stale duplicate JSDoc block remains insearch-index.ts.
@jeff-r2026 Your call: ready from my side.
The blocking points are resolved at 90c34e2.
…ngs, drop a stale docstring review --branch and contribute now name the offending key or line (e.g. "duplicated mapping key at line 4, column 3") instead of only saying the block could not be parsed. Also removes a leftover duplicate JSDoc block above collectRecursiveMdEntries.
|
Last two nits from the re-check addressed in
|
…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).
|
Findings Earlier Findings Testing I only read the specified diff. I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Re-checked at 65bcffe4. Both nits are addressed: the unparseable-related finding in review --branch and the contribute warning now carry the parser's first line, and the duplicated docstring on collectRecursiveMdEntries is gone. The e2e test checks the new message.
- [P3 nit] The two added
expectlines insrc/__tests__/relations-e2e.test.tsare not indented like the line above them.
@jeff-r2026 Your call: still ready from my side.
jeff-r2026
left a comment
There was a problem hiding this comment.
Verified at 65bcffe merged onto latest main (84b931d, after #1628 which also touches recall.ts): clean merge; tsc / lint / build pass; asset-relations + relations-e2e (built CLI) + recall-quality pass, and the 35 recall/search-index/review-branch/contribute test files pass (683 tests). The full suite's failures on this host are the same root-permission cases that fail on main (24 here vs 26 on main), none in changed code. An independent agent review found no blocking issues. Two non-blocking follow-ups: (1) an existing list-shaped related: [a.md] in a team doc makes every later review --branch fail, even on branches that never touched it — worth a warn or a release note; (2) skills/release/ with a trailing slash is not canonicalized like SKILL.md is. Approving.
…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).
… 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.
…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).
… 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.
…iew --branch (Tencent#1552 first slice) (Tencent#1629) * feat(recall): declared asset relations on recall hits, checked by review --branch (Tencent#1552) A rule, a doc or a learning declares relations to other team assets in a `related:` frontmatter block; a local Markdown link to another asset becomes REFERENCES. Recall prints each visible relation as a Related: line after the hit's File: line (→ declared by the hit, ← declared by the other end, at most 5), without changing hits, order or scores. Relations resolve only inside the scope that owns them, and a teamwiki target resolves only when its page exists and its codebase is not withheld. teamai review --branch gains a relations check over every rule and doc in the branch tree: structural problems fail, a target that names no asset on the branch warns. teamai contribute prints the same findings as warnings and still publishes. - The link parser moves to utils/markdown-links.ts so review --branch and the relation derivation read links with one parser. - SEARCH_INDEX_VERSION 7 → 8: entries carry their team-tree path and their outgoing relations; an older index rebuilds on the next recall or pull. - Nothing is written to teamwiki/.indices/graph-index.json. * fix(relations): address review on Tencent#1629 - A hit with an explicit scope never borrows another scope's relation context: with an empty project index, a user rule's relation no longer prints on a workspace teamwiki hit. - Delivered skill source directories keep their namespace in the tree path (skills/pay/release), so a declaration targeting them resolves in recall. - A bare relative link destination (payments-overview.md) resolves against the linking file's directory; team-root paths stay absolute-in-tree. A link to a skill's SKILL.md canonicalizes to the skill directory, in declarations and in links. - Namespaced learning tree paths are posix even when path.join produced platform separators (Windows). - codebaseDir entries stay unaddressable by relations: the recursive collector only assigns a tree path when the caller names the team-tree prefix. - review --branch fails a related block that does not parse (a duplicate key), and contribute warns; a tolerated non-strict frontmatter with no related key stays silent. - Both sharing guides describe a missing target as a warning, matching the implemented behavior. * fix(relations): append the parser detail to unparseable related findings, drop a stale docstring review --branch and contribute now name the offending key or line (e.g. "duplicated mapping key at line 4, column 3") instead of only saying the block could not be parsed. Also removes a leftover duplicate JSDoc block above collectRecursiveMdEntries. --------- Co-authored-by: wcf <[email protected]>
- A hit with an explicit scope never borrows another scope's relation context: with an empty project index, a user rule's relation no longer prints on a workspace teamwiki hit. - Delivered skill source directories keep their namespace in the tree path (skills/pay/release), so a declaration targeting them resolves in recall. - A bare relative link destination (payments-overview.md) resolves against the linking file's directory; team-root paths stay absolute-in-tree. A link to a skill's SKILL.md canonicalizes to the skill directory, in declarations and in links. - Namespaced learning tree paths are posix even when path.join produced platform separators (Windows). - codebaseDir entries stay unaddressable by relations: the recursive collector only assigns a tree path when the caller names the team-tree prefix. - review --branch fails a related block that does not parse (a duplicate key), and contribute warns; a tolerated non-strict frontmatter with no related key stays silent. - Both sharing guides describe a missing target as a warning, matching the implemented behavior.
Implements the first slice of #1552 exactly as triaged there: declared relations between a team's assets, shown on recall hits, and checked by
teamai review --branch/ warned byteamai contribute.What a team member sees
A rule, a doc or a learning declares relations in a
related:frontmatter block; a local Markdown link to another asset becomesREFERENCESon its own:teamai recallprints each visible relation as aRelated:line after the hit'sFile:line —→for a relation the hit declares,←for one the other end declares, declared before links, at most 5 per hit:Invalid declarations never become relations, wherever the file came from.
teamai review --branchfails them on rules and docs;teamai contributeprints the same findings as warnings and still publishes:Behavior contracts (from the triage spec)
MAPS_TO(teamwiki page),REFERENCES(any asset),SUPERSEDES/CONFLICTS_WITH(rule/doc/learning — a learning that disagrees with a rule declaresCONFLICTS_WITH, sincecontributepublishes without review). Skills and teamwiki pages are targets only.DEPENDS_ON/CONTAINS/IMPLEMENTScannot be declared on an asset.?? []).←line on B after the next index build, and nothing is cached.src/utils/markdown-links.tsso there is one link parser; a link resolves against the file's team-tree path (fromlearnings/<id>,../docs/x.mdisdocs/x.md). Links in skills are not read.Scoredo not change;--checkand--- Candidate change files ---are untouched. A relation whose other end this recall cannot see prints nothing.SEARCH_INDEX_VERSION7 → 8: entries carry their team-tree path (treePath) and outgoing relations; an index built by the previous version rebuilds on the next recall or pull (the per-file cache derivation includes the version).teamwiki/.indices/graph-index.json.teamai-recallsubagent carries at most 2Related:lines per kept entry (declared first) in Step 5; the LOW--checkshortcut is unchanged and carries none.Testing
src/__tests__/asset-relations.test.ts, 32 tests): the full malformed-input matrix, the declaration table per source kind, path normalization, link-derived relations, index storage, rendering order/dedup/cap, visibility (unresolved target, withheld codebase, unreadable withheld list), and byte-identical ranking output onceRelated:lines drop out.src/__tests__/relations-e2e.test.ts) drives the real CLI on a team repo built from the issue's example.npm run build,npx tsc --noEmit,npm run lint,npx vitest run asset-relations review-branch commands-reference contribute recall search-index scope— all pass.npx vitest runfull suite: 44 failures, all pre-existing/environmental (15s timeouts in workflow-handoff/gitlab network fixtures, one oxlint-plugin output-format fixture that also fails on a cleanorigin/maincheckout in isolation); the same files fail identically on cleanorigin/main. No new failures from this change. Extra providers/agents (gitlab/github matrix, Codex/CodeBuddy/OpenCode e2e) left to CI.Real-CLI verification (one representative run)
Built from the example in the triage comment,
teamai.yamlwith the team repo, project scope, recall run againstdist/index.js:Docs
docs/guide/knowledge.md+zh-CN:related:and theRelated:line.docs/guide/sharing.md+zh-CN: therelationscheck.skill-data/share/references/doc-template.md:## Related Skillsreplaced by arelated:frontmatter row (the import-MR prompts insrc/import-mr.tsare deliberately unchanged — they have no list of the team's assets).Closes the first slice of #1552. #1562, #1563 and #1564 remain the follow-ups per the triage.
Real-CLI record (reviewer)
Built from 90c34e2 (main base 78b6869): npm ci, npm run build, exit 0. Node v24.21.0.
Setup: team repo with rules/payments.md (MAPS_TO a teamwiki page; REFERENCES docs/payments-overview.md, skills/release, skills/pay/),
docs/payments-bare.md containing overview, skills/release/SKILL.md, skills/pay//SKILL.md, the teamwiki page.
Isolated HOME, empty GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM=1, TEAMAI_NONINTERACTIVE=1.
$ teamai pull exit 0
$ teamai recall "payments" exit 0
[1/5] [rules] payments [workspace]
Related: → MAPS_TO /teamwiki/evidence/code/pay/modules/.md
Related: → REFERENCES /docs/payments-overview.md
Related: → REFERENCES /skills/release/SKILL.md
Related: → REFERENCES /skills/pay//SKILL.md
[3/5] [docs] payments bare [workspace]
Related: → REFERENCES /docs/payments-overview.md
Scope: project scope, inheritUserScope: true, empty project index, user rule with MAPS_TO to the workspace teamwiki page.
$ teamai recall "payments" exit 0
[1/2] [rules] payments [user] Related: → MAPS_TO /teamwiki/evidence/code/pay/modules/.md
[2/2] [docs] [workspace] (no Related line)
Link only, no declaration: rules/payments.md links ../skills/release/SKILL.md
$ teamai recall "payments" exit 0
[1/1] [rules] payments [workspace]
Related: → REFERENCES /skills/release/SKILL.md
$ teamai review --branch fix/warn-only exit 0
! [relations] rules/payments.md: REFERENCES docs/no-such-doc.md names no team asset on this branch; this relation is ignored.
$ teamai review --branch fix/dupkey exit 1
✖ [relations] docs/payments-overview.md: "related" could not be parsed; all of it is ignored.