Skip to content

test(relations): cover a learning that lives in the learnings worktree - #1729

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
Walternater:test/relations-worktree-learning
Nov 5, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
Walternater:test/relations-worktree-learning

Conversation

@Walternater

Copy link
Copy Markdown
Collaborator

What

Adds the first of the follow-ups #1552 left when it closed: a relation whose source learning lives in the teamai-learnings worktree, rather than under repo.localPath.

One case in relations-e2e.test.ts, plus the fixture that builds the worktree.

Why

SaulMoro's closing comment on #1552 listed several paths enforced in code with no test of their own:

  • a link whose source learning lives in the learnings worktree
  • a link from a skill
  • a target that is not delivered or is shadowed
  • the shape-only check review --branch does on learnings/ targets
  • import with a cell outside the table

Adding the cases above to relations-e2e.test.ts is left as a follow-up

This is the first row. It is the one with the most machinery behind it: learnings publish to an orphan teamai-learnings branch checked out in a worktree beside the team clone, so a relation declared there resolves against a checkout that is not the one repo.localPath names.

The case

The test writes learnings/alpha/ledger-timeout.md into that worktree, declaring REFERENCES: rules/payments.md, and asks recall for payments ledger:

Related: ← REFERENCES …/team-repo/rules/payments.md

The ← on the rule's own hit is what proves the source resolved: the relation started from a learning in the worktree, and the other end answered for it. Without the worktree being read, nothing points back.

Verification

vitest run --config vitest.e2e.config.ts src/__tests__/relations-e2e.test.ts — 6 passed (the 5 existing cases plus this one).

npm run typecheck and npm run lint pass.

The fixture builds the worktree the way teamai init does — an orphan branch with no team files, then git worktree add beside the clone — and returns early when pull already made one, which it does for a non-HTTP team. The commit tolerates a retry that finds its learning already on the branch, so the case is re-runnable.

Limitations

  • One of the five follow-up rows. The other four (skill links, undelivered or shadowed targets, the learnings/ shape check, import cells) are still untested.
  • The learning is asserted as a source, which is what the follow-up names. It does not assert the learning also comes back as a hit of its own: the recall index is built during pull, and a learning added to the branch afterwards is not in it until the index is rebuilt. That is a separate behaviour, not part of this row.
  • The case writes into the sandbox's worktree directly rather than through teamai contribute, so it tests the relation resolution and not the publish path.

Refs #1552

🤖 Generated with Claude Code

Closing Tencent#1552 left one follow-up: several relation paths are enforced in code
with no test of their own, and the first is a link whose *source* learning
lives in the `teamai-learnings` worktree rather than under `repo.localPath`.

The case writes a learning there, declares `REFERENCES: rules/payments.md`,
and asks recall for the rule: the rule's hit answers `←` for it, which is only
true if the source resolved against the worktree checkout.

The fixture builds that worktree the way `teamai init` does — an orphan
branch, then a worktree beside the clone — and the commit is tolerant of a
retry that finds its learning already on the branch.

Refs Tencent#1552

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

No findings in the specified diff.

This is a tests-only change. The PR description records six passing E2E cases, typecheck, and lint; no additional real-CLI verification record is required.

I only read the diff and trusted base review rules. I did not run, build, or install anything from the PR.

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

Approving at 8ccb12e6. This covers the first #1552 follow-up row: a relation whose source learning lives in the teamai-learnings worktree. The assertion checks the right thing. The ← REFERENCES on the rule's hit only appears if recall read the learning from the worktree, not from repo.localPath. The fixture builds the worktree the way init does, as an orphan branch beside the clone, and the commit helper tolerates a retry that finds the learning already committed. Since this changes tests only, no real-CLI record is needed.

CI review. It reported no findings. I agree.

[P3 nit] 'learnings-wt' is spelled out in the test. Importing LEARNINGS_WORKTREE_DIRNAME from src/types.ts would keep it pointed at the directory teamai actually uses if that name ever changes. This is optional.

I'll merge once CI is green at this head.

@SaulMoro
SaulMoro merged commit b1329c4 into Tencent:main Nov 5, 2026
18 checks passed
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