Skip to content

ci(lint): move learnings path guard out of Vitest - #1601

Merged
jeff-r2026 merged 4 commits into
Tencent:mainfrom
huong8373tt-beep:teamai-cli-1590
Oct 31, 2026
Merged

jeff-r2026 merged 4 commits into
Tencent:mainfrom
huong8373tt-beep:teamai-cli-1590

Conversation

@huong8373tt-beep

@huong8373tt-beep huong8373tt-beep commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Move the existing learnings-root path guard from a source-scanning Vitest test into the repository's oxlint plugin.

  • add teamai/learnings-root to oxlint-plugin-teamai;
  • preserve the existing allow/deny boundary and detect manual path.join / path.resolve learnings roots;
  • add focused ruleHarness coverage for violations, unrelated paths, and intentional accessor definitions;
  • keep the existing learnings-path-guard.test.ts unchanged in this first slice so the migration has an independent parity check.

This is the first small slice of #1590. It does not change TeamAI CLI runtime behavior or delete the broader static-test suite.

Validation

  • npx vitest run src/__tests__/learnings-path-guard.test.ts --maxWorkers=2 — passed
  • npx vitest run oxlint-plugin-teamai/rules/learnings-root.test.ts --maxWorkers=2 — 8 passed; ruleHarness invokes the actual oxlint binary with the plugin loaded
  • npx vitest run oxlint-plugin-teamai/rules/remove-delivered.test.ts --maxWorkers=2 — 7 passed
  • npm run build — passed
  • npm run typecheck — passed
  • npm run lint — passed, 0 warnings and 0 errors
  • git diff --check — passed
  • Built CLI smoke test: node dist/index.js --version printed 0.22.0; node dist/index.js list --help exited 0 and printed the command help

The built-CLI smoke test is the representative real-CLI verification for this lint-tooling-only slice. It does not change a TeamAI CLI runtime path, and the new rule is not enabled repository-wide in this slice. The later slice that enables the rule will validate the full lint command with this rule active.

Related

Refs #1590

Disclosure

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Intentional accessor definitions are still reported — oxlint-plugin-teamai/rules/learnings-root.js:17 exempts only test files. The path.join(..., 'learnings') in the new valid case for src/utils/learnings-roots.ts matches the violation handler; neither its filename nor its learnings-root ok comment is exempted. This contradicts the promised allow/deny boundary and the added test.

  • [P1 blocking] Required real-CLI verification is missing — The description explicitly omits a real-CLI run despite changing executable plugin code. The trusted “Code Review Rules” require an end-to-end / real-CLI record for changes beyond docs-only or tests-only; the listed unit tests and lint check do not document a representative TeamAI CLI run.

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

Moving this guard into the oxlint plugin is a good first slice of #1590. Two things need fixing before it can land.

[P1 blocking] CI is red: typecheck fails on the new rule. All six Lint & Test jobs stop at oxlint-plugin-teamai/rules/learnings-root.js(5,29): error TS7006: Parameter 'node' implicitly has an 'any' type. The plugin's JS is type-checked, so isLearningsSegment needs a JSDoc @param type, as in ../utils.js, or its check can move inline into the handler, where defineRule types node. Because typecheck stops the job, the new rule tests have not run in CI yet.

[P1 blocking] The allow list and the opt-out comment are not ported, so the "intentional root definitions" case should fail. From reading the rule: it skips only src/__tests__/. path.join(getKnowledgeDir(config), 'learnings') in a fixture at src/utils/learnings-roots.ts still matches the CallExpression handler, and neither that file nor the // learnings-root ok: comment exempts it. The Vitest guard this replaces allows five files (utils/learnings-roots.ts, utils/learnings-publish.ts, utils/pending-learnings.ts, types.ts, init.ts), plus a line that carries, or follows, // learnings-root ok: <reason>. The rule needs the same boundary, for example with isOneOf from ../utils.js and a check of the comments around the node. Otherwise the parity this slice promises does not hold.

[P2 non-blocking] teamai/learnings-root is registered in the plugin but not turned on in .oxlintrc.json, so npm run lint passing says nothing about it yet. That is fine for a first slice that keeps the Vitest guard as the parity check, but please say so in the description, and turn it on in the slice that deletes learnings-path-guard.test.ts.

[P3 nit] The CI review's real-CLI finding does not apply here: this changes lint tooling only, not CLI behaviour, and the rule harness already runs the real oxlint. The two new files have no newline at end of file.

@jeff-r2026 Your call: this touches the lint setup, so it's yours once the two blocking items are fixed.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Required real-CLI verification is still missing — The PR adds executable lint-plugin code, so it is not docs-only or tests-only. The trusted “Code Review Rules” explicitly require an end-to-end / real-CLI verification record for such changes. The description lists unit tests and lint but explicitly omits that record. Document one representative real-CLI run; a full provider × agent matrix is unnecessary.

Resolved: Intentional accessor definitions are reported — oxlint-plugin-teamai/rules/learnings-root.js:24 now exempts the allowlisted accessor files, and line 32 honors learnings-root ok comments. The earlier finding no longer applies.

No other confident findings in the scoped diff.

@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-review at 962b65e. The allow list and the // learnings-root ok: opt-out are ported now, and the untyped helper that broke typecheck is gone. One new blocking problem comes from moving to whole-line regexes.

[P1 blocking] ABSOLUTE_SUFFIX (/\/learnings\b/) flags every import of the learnings modules. \b matches between learnings and -, so these lines on main all match:

src/contribute.ts:20   import { indexableLearningsRoots } from './utils/learnings-roots.js';
src/index.ts:1709      const { syncLockPath } = await import('./utils/learnings-publish.js');
src/init.ts:18         import { learningsBranch } from './utils/learnings-branch.js';

I checked the two regexes against these lines with node -e and they report all three. The Vitest guard does not flag them: it only matches '/learnings' as a whole quoted string or ${x}/learnings followed by a quote, comma or paren. So the rule cannot be turned on as it is, and the parity this slice claims does not hold. MANUAL_ROOT's \blearnings\b has the same widening, for example path.join(dir, 'learnings-index.json'). Please match the old patterns exactly, or go back to the AST checks from the first commit and add the allow list and comment check to them. Add an import … from './utils/learnings-roots.js' case to rule.valid.

[P2 non-blocking] The rule now reports once per file, on Program, with every offending line joined into one message. A per-line oxlint-disable-next-line can no longer target one call, and the editor marks the top of the file instead of the line. Reporting each line with a loc, or each AST node, keeps both working.

[P3 nit] The earlier notes stand: the description should say the rule is not yet enabled in .oxlintrc.json, and the new files have no newline at end of file. CI at this head was still queued when I checked.

@jeff-r2026 Your call once the blocking item is fixed.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Addressed the remaining review finding in the PR description. This is lint-tooling-only: it does not change a TeamAI CLI runtime path. The focused ruleHarness test runs the actual oxlint binary with teamai/learnings-root loaded, which is the representative integration check for this slice; the repository-wide npm run lint check remains documented as well. The description now states that boundary explicitly and removes the earlier ambiguous wording.

The earlier accessor-boundary finding is already resolved in 962b65e2: the allowlist and learnings-root ok: escape hatch are both retained.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Addressed the blocking regex-parity finding in 8d2a2ff5.

  • Restored AST-level reporting at each path.join / path.resolve call or dynamic template literal, rather than scanning whole lines from Program.
  • This preserves per-line locations and normal oxlint-disable-next-line behavior.
  • The rule now matches the original guard boundary: a literal learnings or /learnings argument, or a dynamic template whose final quasi is exactly /learnings; imports such as ./utils/learnings-roots.js and names such as learnings-index.json are not reported.
  • Retained the five-file allowlist and the same-line/preceding-line learnings-root ok: escape hatch.
  • Added focused regressions for accessor imports, similarly named files, and an opt-out outside the allowlist.

Validated locally:

npx vitest run oxlint-plugin-teamai/rules/learnings-root.test.ts  # 8 passed
npm run typecheck
npm run lint  # 0 warnings, 0 errors
git diff --check

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Required real-CLI verification is still missing — oxlint-plugin-teamai/rules/learnings-root.js:1 adds executable plugin code, so this is neither docs-only nor tests-only. The trusted Code Review Rules explicitly require an end-to-end / real-CLI record for such changes. The description documents an actual oxlint integration check, but no representative TeamAI CLI run. Document one; a full provider × agent matrix is unnecessary.

Resolved: Intentional accessor definitions are reported — The current diff exempts allowlisted accessor files and honors explained learnings-root ok exceptions.

No other confident findings in the scoped diff.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Addressed the remaining review nits in d193a33d:

  • Added final newlines to both new plugin files.
  • Rebuilt the CLI with npm run build successfully.
  • Ran the built CLI directly: node dist/index.js --version → 0.22.0; node dist/index.js list --help exited 0 and printed the command help.
  • The rule-specific integration coverage remains npx vitest run oxlint-plugin-teamai/rules/learnings-root.test.ts --maxWorkers=2 → 8 passed; it invokes the actual oxlint binary with the plugin loaded.
  • npm run typecheck passed.
  • npm run lint passed with 0 warnings and 0 errors.
  • git diff --check passed.

The CLI smoke run is a representative built-CLI check; this slice does not change a runtime command path or enable the rule repository-wide.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Required real-CLI verification is still missing — oxlint-plugin-teamai/rules/learnings-root.js:1 adds executable plugin code, so the diff is neither docs-only nor tests-only. The trusted Code Review Rules require an end-to-end / real-CLI record for such changes. The description records an oxlint integration check, but no representative TeamAI CLI run. Document one; a full provider × agent matrix is unnecessary.

Resolved: Intentional accessor definitions are reported — The current diff exempts allowlisted accessor files and honors explained learnings-root ok exceptions.

No other confident findings in the scoped diff.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Updated the PR description with the requested representative built-CLI verification.

  • npm run build passed
  • node dist/index.js --version printed 0.22.0
  • node dist/index.js list --help exited 0 and printed the command help

The rule-specific ruleHarness test also runs the actual oxlint binary with teamai/learnings-root loaded (8 passed). This slice is lint-tooling-only and does not change a TeamAI CLI runtime path; the new rule is intentionally not enabled repository-wide until the follow-up slice.

@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-review at d193a33. The blocking item is fixed: the rule is back to AST checks, with the allow list and the // learnings-root ok: comment, so an import … from './utils/learnings-roots.js' and path.join(base, 'learnings-index.json') no longer match. Both have a rule.valid case. Each offending call is now reported on its own node, so a per-line disable works again.

[P3 nit] The Vitest guard also flags a bare '/learnings' string anywhere on a line. The rule only flags it as a path.join / path.resolve argument or at the end of a template. That is narrower, and probably what the guard meant; worth saying in the slice that removes the Vitest test. The real-CLI point in the CI review does not apply to lint tooling. The new files end with a newline now. CI is green at this head.

@jeff-r2026 Your call: this one is 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 on latest main (313341f) merged with #1593/#1602/#1591: npm ci, tsc, lint (0/0), build pass; oxlint-plugin-teamai rule tests and learnings-path-guard.test.ts pass. The rule is not enabled yet, as the body says.

@jeff-r2026
jeff-r2026 merged commit 8567110 into Tencent:main Oct 31, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
* lint: move learnings path guard into oxlint

* fix(lint): preserve learnings root guard coverage

* fix(lint): report learnings roots at call sites

* style(lint): terminate learnings rule files with newline
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