Skip to content

feat(recall): declared asset relations on recall hits, checked by review --branch (#1552 first slice) - #1629

Merged
jeff-r2026 merged 3 commits into
Tencent:mainfrom
Walternater:feat-1552-asset-relations
Oct 31, 2026
Merged

jeff-r2026 merged 3 commits into
Tencent:mainfrom
Walternater:feat-1552-asset-relations

Conversation

@Walternater

@Walternater Walternater commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

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 by teamai 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 becomes REFERENCES on its own:

---
related:
  MAPS_TO: teamwiki/evidence/code/pay/modules/ledger-receipts.md
  REFERENCES: [docs/payments-overview.md, skills/release]
---

teamai recall prints each visible relation as a Related: line after the hit's File: line — → for a relation the hit declares, ← for one the other end declares, declared before links, at most 5 per hit:

 [1/3] [rules] payments [workspace]
 File: …/team-repo/rules/payments.md
+Related: → MAPS_TO …/team-repo/teamwiki/evidence/code/pay/modules/ledger-receipts.md
+Related: → REFERENCES …/team-repo/docs/payments-overview.md
+Related: → REFERENCES …/team-repo/skills/release/SKILL.md

 [3/3] [docs] ledger-receipts [workspace]
 File: …/team-repo/teamwiki/evidence/code/pay/modules/ledger-receipts.md
+Related: ← MAPS_TO …/team-repo/rules/payments.md

Invalid declarations never become relations, wherever the file came from. teamai review --branch fails them on rules and docs; teamai contribute prints the same findings as warnings and still publishes:

✖ [relations] rules/payments.md: "GOVERNS" is not a relation. Use MAPS_TO, REFERENCES, SUPERSEDES or CONFLICTS_WITH.
✖ [relations] rules/payments.md: IMPLEMENTS relates code to code and cannot be declared on a rule. Use MAPS_TO, REFERENCES, SUPERSEDES or CONFLICTS_WITH.
! [relations] rules/payments.md: REFERENCES docs/payment-overview.md names no team asset on this branch; this relation is ignored.

Behavior contracts (from the triage spec)

  • Four declarable relations only: MAPS_TO (teamwiki page), REFERENCES (any asset), SUPERSEDES / CONFLICTS_WITH (rule/doc/learning — a learning that disagrees with a rule declares CONFLICTS_WITH, since contribute publishes without review). Skills and teamwiki pages are targets only. DEPENDS_ON / CONTAINS / IMPLEMENTS cannot be declared on an asset.
  • Edge direction reads "from RELATION to", matching the code graph.
  • Keys match in any case; a list gives one relation per path; the same relation+target shows once, two different relations to the same target both show.
  • A relation stays inside its owner: it resolves only within the scope it comes from, only against assets that scope's index holds, after workspace shadowing applies. A teamwiki target resolves only when the page exists and its codebase is not withheld; when the withheld list cannot be read, no teamwiki target resolves (never ?? []).
  • Incoming relations are derived at query time from the outgoing ones stored on index entries — removing a relation on A removes the ← line on B after the next index build, and nothing is cached.
  • Declared beats link between the same two assets in the same direction. Links are read with the existing parser, moved to src/utils/markdown-links.ts so there is one link parser; a link resolves against the file's team-tree path (from learnings/<id>, ../docs/x.md is docs/x.md). Links in skills are not read.
  • Hits, their order and Score do not change; --check and --- Candidate change files --- are untouched. A relation whose other end this recall cannot see prints nothing.
  • SEARCH_INDEX_VERSION 7 → 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).
  • Nothing is written to teamwiki/.indices/graph-index.json.
  • The teamai-recall subagent carries at most 2 Related: lines per kept entry (declared first) in Step 5; the LOW --check shortcut is unchanged and carries none.

Testing

  • New unit tests (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 once Related: lines drop out.
  • New e2e (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 run full 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 clean origin/main checkout in isolation); the same files fail identically on clean origin/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.yaml with the team repo, project scope, recall run against dist/index.js:

$ teamai recall "payments ledger"
--- [teamai:recall:start] --- (3 results) run=f065570f-a219-41b2-af3b-722344bf4fbf

[1/3] [rules] payments [workspace]
Author: unknown | Date: unknown | Score: 5.5
Matched: payments | Missing: ledger
File: /tmp/teamai-relations-record-JyBl/team-repo/rules/payments.md
Related: → MAPS_TO /tmp/teamai-relations-record-JyBl/team-repo/teamwiki/evidence/code/pay/modules/ledger-receipts.md
Related: → REFERENCES /tmp/teamai-relations-record-JyBl/team-repo/docs/payments-overview.md
Related: → REFERENCES /tmp/teamai-relations-record-JyBl/team-repo/skills/release/SKILL.md

[2/3] [docs] payments overview [workspace]
Author: unknown | Date: unknown | Score: 2.4
Matched: payments | Missing: ledger
File: /tmp/teamai-relations-record-JyBl/team-repo/docs/payments-overview.md
Related: ← REFERENCES /tmp/teamai-relations-record-JyBl/team-repo/rules/payments.md

[3/3] [docs] ledger-receipts [workspace]
Author: unknown | Date: unknown | Score: 2.4
File: /tmp/teamai-relations-record-JyBl/team-repo/teamwiki/evidence/code/pay/modules/ledger-receipts.md
Related: ← MAPS_TO /tmp/teamai-relations-record-JyBl/team-repo/rules/payments.md
Snippet: --- title: ledger-receipts --- # Ledger receipts module

--- [teamai:recall:end] ---
$ teamai recall --check "payments ledger"
RELEVANT score=5.5 threshold=4.0 title="payments" matched=payments missing=ledger
$ teamai contribute --file ledger-timeout.md --title "Ledger receipt write times out at 3s"
⚠ related: a learning cannot SUPERSEDES a rule (rules/payments.md). Use CONFLICTS_WITH; this relation is ignored.
⚠ related: REFERENCES docs/payment-overview.md names no team asset; this relation is ignored.
✔ Contributed: learnings/ledger-receipt-write-times-out-at-3s-2026-10-31-vm0igb.md
ℹ Your session knowledge has been shared with the team.
$ teamai review --branch fix/payments
[review] branch fix/payments: 2 fail, 1 warn, 0 info
  ✖ [relations] rules/payments.md: "GOVERNS" is not a relation. Use MAPS_TO, REFERENCES, SUPERSEDES or CONFLICTS_WITH.
  ✖ [relations] rules/payments.md: IMPLEMENTS relates code to code and cannot be declared on a rule. Use MAPS_TO, REFERENCES, SUPERSEDES or CONFLICTS_WITH.
  ! [relations] rules/payments.md: REFERENCES docs/payment-overview.md names no team asset on this branch; this relation is ignored.
(exit 1)

Docs

  • docs/guide/knowledge.md + zh-CN: related: and the Related: line.
  • docs/guide/sharing.md + zh-CN: the relations check.
  • skill-data/share/references/doc-template.md: ## Related Skills replaced by a related: frontmatter row (the import-MR prompts in src/import-mr.ts are 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.

…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.
@github-actions

Copy link
Copy Markdown

Findings

  • [P1 blocking] src/recall.ts:491 — With inheritUserScope: true, an empty project index produces no project relation context. Project teamwiki hits then fall back to the user context, so a user rule targeting the same wiki path appears as an incoming relation on an unrelated project page. Do not fall back when a hit has an explicit scope.
  • [P2 non-blocking] src/utils/search-index.ts:849 — The explicit skill-directory collector loses namespaces: /repo/skills/pay/release becomes skills/release. A declaration targeting skills/pay/release therefore disappears from recall even when that skill is indexed. Preserve its team-tree directory path.
  • [P2 non-blocking] src/asset-relations.ts:207 — Ordinary relative links without ./ are dropped. For example, [overview](overview.md) in docs/payments.md never resolves to docs/overview.md. Resolve bare relative destinations against the source directory while preserving supported team-root paths.
  • [P2 non-blocking] src/asset-relations.ts:107 — A Markdown link to ../skills/release/SKILL.md normalizes to skills/release/SKILL, but the indexed skill’s key is skills/release. Consequently, links to actual skill entry files never become visible relations. Canonicalize /SKILL.md to the skill directory.
  • [P2 non-blocking] src/utils/search-index.ts:745 — Namespaced learning IDs use path.join(ns, rel), so Windows stores paths such as learnings/pay\timeout. Relation targets normalize to forward slashes and cannot match those entries. Convert the stored treePath to POSIX separators.
  • [P2 non-blocking] src/utils/search-index.ts:767 — codebaseDir also invokes this collector with type docs, contrary to the new comment. Local codebase pages receive team-asset paths such as docs/a.md; when a team doc has the same path, the later codebase entry overwrites it in byTreePath, making relations point outside the team tree. Keep these entries unaddressable as team assets.
  • [P3 nit] docs/guide/sharing.md:90 — Both sharing guides say a nonexistent target makes branch review fail, but parseRelatedBlock explicitly reports it as a warning. Correct both language versions to describe the implemented behavior.

Testing
The PR description documents sufficient testing, including representative built real-CLI runs. No missing-e2e finding applies. I only read the specified diff; I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. [P1 blocking] A relation crosses scopes. With inheritUserScope and an empty project index, a user rule's MAPS_TO prints as ← MAPS_TO on a workspace teamwiki hit (src/recall.ts:491 falls back to the user context). Criterion: "A relation to something this recall cannot see prints nothing … another scope's asset". Reproduced.
  2. [P1 blocking] A namespaced skill does not resolve. REFERENCES: skills/<namespace>/<skill> prints nothing, while contribute accepts the same target: the dirs collector in src/utils/search-index.ts stores skills/<skill>, dropping the namespace. Criterion: "A namespaced skill and a namespaced learning resolve". Reproduced.
  3. [P1 blocking] A bare relative link is dropped. [overview](payments-overview.md) in docs/payments.md prints nothing (src/asset-relations.ts only resolves ./ and ../). Criterion: a link "resolved from the file's tree path". Reproduced.
  4. [P1 blocking] A link to a skill's SKILL.md is dropped, and review --branch warns that skills/release/SKILL.md "names no team asset". The index key is skills/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.ts is not in the Windows test list, so CI would not catch it.
  • [P2 non-blocking] docs/guide/sharing.md and its Chinese page say a missing target fails review --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) makes review --branch report clean and drops the relations silently; the triage table expects fail.
  • [P3 nit] The codebaseDir collision the automated review describes is real in the code, but both production callers pass undefined, 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.
@Walternater

Copy link
Copy Markdown
Collaborator Author

Review comments addressed in 90c34e24 (pushed):

P1s

  1. Scope cross — formatResults no longer falls back to another scope's context for a hit with an explicit scope. An empty project index means the project scope sees nothing; a user rule's MAPS_TO no longer prints on a workspace teamwiki hit. Covered by a new unit test (project hit + only user ctx → no Related: line).
  2. Namespaced skill — delivered skill source directories now keep their namespace in the tree path (skills/pay/release), computed from the source path's skills/ root in collectSkillDirEntries. Verified in the e2e (a declared REFERENCES: skills/pay/deploy prints).
  3. Bare relative links — a destination without a team-root prefix now resolves against the linking file's directory ([overview](payments-overview.md) in docs/payments.md → docs/payments-overview.md); team-root paths stay as written.
  4. SKILL.md links — normalizeTargetPath canonicalizes skills/<dir>/SKILL.md to skills/<dir>, for declarations and links; review --branch accepts the same target.

P2s

  • Namespaced learning tree paths are posix even when path.join produced platform separators (Windows) — fixed in the tree-path callback, leaving the entry id untouched.
  • Both sharing guides now say a missing target is a warning; only an out-of-table relation fails.
  • A related: block that does not parse (a duplicate key) now fails review --branch and warns in contribute. A tolerated non-strict frontmatter with no related: key (an unquoted glob, [bug] Team rules miss most tools: each tool's own rules format, else a file only it reads, else a hook or extension in project scope #946) stays silent — verified gray-matter throws on both duplicate keys and unquoted globs, so the check keys on whether the block actually declares related:.

P3

  • codebaseDir entries now stay unaddressable: the recursive collector only assigns a tree path when the caller names the team-tree prefix.

Verification: npx tsc --noEmit, npm run lint, npm run build; unit tests asset-relations review-branch contribute recall-format search-index (371 passed); e2e relations-e2e (4 tests, real CLI) all pass, including the new namespaced-skill and duplicate-key cases.

@github-actions

Copy link
Copy Markdown

Findings
No new findings confidently supported by the current diff.

Earlier Findings
All seven earlier findings are resolved: scope-context fallback, namespaced skill paths, bare relative links, SKILL.md canonicalization, Windows learning paths, local codebase-doc isolation, and warning wording in both sharing guides.

Testing
The PR description documents sufficient testing, including representative built real-CLI runs. No missing-e2e finding applies; the additional provider/agent matrix is explicitly deferred to CI.

I only read the specified diff. I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_TO when 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.md resolves, and review --branch no longer warns about a declared skills/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] skillDirTreePath drops the namespace when a skill or namespace is itself named skills; a stale duplicate JSDoc block remains in search-index.ts.

@jeff-r2026 Your call: ready from my side.

…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.
@Walternater

Copy link
Copy Markdown
Collaborator Author

Last two nits from the re-check addressed in 65bcffe4:

  • The unparseable-related findings in review --branch and contribute now append the parser's first line, so the author sees the offending key or line: "related" could not be parsed (duplicated mapping key at line 4, column 3); all of it is ignored.
  • The stale duplicate JSDoc above collectRecursiveMdEntries is removed.

tsc / lint / build clean; asset-relations review-branch contribute (198 tests) and the relations-e2e real-CLI suite pass. Ready for @jeff-r2026.

Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Oct 31, 2026
…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).
@github-actions

Copy link
Copy Markdown

Findings
No new findings confidently supported by the specified diff.

Earlier Findings
All seven earlier findings remain resolved: scope-context fallback, namespaced skill paths, bare relative links, SKILL.md canonicalization, Windows learning paths, local codebase-doc isolation, and warning wording in both sharing guides.

Testing
The PR description documents sufficient testing, including representative built real-CLI runs. No missing-e2e finding applies. Additional provider/agent coverage is explicitly deferred to CI; the older-commit record is not blocking.

I only read the specified diff. I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 expect lines in src/__tests__/relations-e2e.test.ts are not indented like the line above them.

@jeff-r2026 Your call: still ready from my side.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jeff-r2026
jeff-r2026 merged commit 791da07 into Tencent:main Oct 31, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 1, 2026
…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).
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 1, 2026
… 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.
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…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).
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
… 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.
Walternater added a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…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]>
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants