Repository navigation
ci(lint): move learnings path guard out of Vitest - #1601
Conversation
|
There was a problem hiding this comment.
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.
Resolved: Intentional accessor definitions are reported — No other confident findings in the scoped diff. |
There was a problem hiding this comment.
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.
|
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 The earlier accessor-boundary finding is already resolved in |
|
Addressed the blocking regex-parity finding in
Validated locally: |
Resolved: Intentional accessor definitions are reported — The current diff exempts allowlisted accessor files and honors explained No other confident findings in the scoped diff. |
|
Addressed the remaining review nits in
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. |
Resolved: Intentional accessor definitions are reported — The current diff exempts allowlisted accessor files and honors explained No other confident findings in the scoped diff. |
|
Updated the PR description with the requested representative built-CLI verification.
The rule-specific |
SaulMoro
left a comment
There was a problem hiding this comment.
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.
* 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
Summary
Move the existing learnings-root path guard from a source-scanning Vitest test into the repository's oxlint plugin.
teamai/learnings-roottooxlint-plugin-teamai;path.join/path.resolvelearnings roots;ruleHarnesscoverage for violations, unrelated paths, and intentional accessor definitions;learnings-path-guard.test.tsunchanged 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— passednpx vitest run oxlint-plugin-teamai/rules/learnings-root.test.ts --maxWorkers=2— 8 passed;ruleHarnessinvokes the actualoxlintbinary with the plugin loadednpx vitest run oxlint-plugin-teamai/rules/remove-delivered.test.ts --maxWorkers=2— 7 passednpm run build— passednpm run typecheck— passednpm run lint— passed, 0 warnings and 0 errorsgit diff --check— passednode dist/index.js --versionprinted0.22.0;node dist/index.js list --helpexited 0 and printed the command helpThe 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.