Skip to content

ci(lint): enable the anti-slop lint rules, and fix the 23 bugs they found - #1664

Merged
SaulMoro merged 155 commits into
Tencent:mainfrom
hz89Dev:ci/anti-slop-lint
Nov 2, 2026
Merged

SaulMoro merged 155 commits into
Tencent:mainfrom
hz89Dev:ci/anti-slop-lint

Conversation

@hz89Dev

@hz89Dev hz89Dev commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #836.

Turns on the last open item of #836, the anti-slop rules, plus two comment rules and a YAML rule. They run as part of npm run lint from this PR on, in the repository's one plugin, oxlint-plugin-teamai. Every hit in production code is fixed in this PR. There is no baseline and no suppression without a reason. Fixing the hits turned up 23 bugs, listed below.

#836 planned the rules one at a time, each starting as a warning count that must not go up. This PR turns them all on at once and fixes every hit instead, so nothing is left as a follow-up.

What lint checks now

Rule Source What it rejects, in production code
18 generic rules: teamai/no-unknown-parameters, no-unknown-returns, no-runtime-typeof, require-safety-comment-for-type-assertion, no-conditional-empty-object-spread, require-readable-spacing, … anti-slop at 13909c9e, vendored unchanged (MIT) in oxlint-plugin-teamai/anti-slop/ unknown passed around instead of parsed, typeof narrowing of file or API data, a cast with no SAFETY: note, ...(x ? { k } : {})
teamai/suppression-reason new an oxlint-disable / @ts-expect-error that does not say why
teamai/no-low-value-comments new a comment that only repeats the name below it, commented-out code, a TODO with no issue, a JSDoc type in TypeScript
teamai/yaml-parse new YAML.parse outside src/utils/yaml.ts, since it turns !!set, !!binary and !!timestamp into a Set, Buffer or Date
oxc/no-accumulating-spread oxlint a reducer that copies its accumulator each step

Every rule is an error. Tests are exempt from the anti-slop rules, because they build partial and malformed values on purpose. As the anti-slop install steps ask, lint skips the agent tooling directories a member's tools put in the checkout (.claude/, .cursor/, .agents/, …). .github/CONTRIBUTING.md shows what a hit looks like and how to fix it:

teamai(no-runtime-typeof): A `typeof` check narrows a representation without establishing its contract. Parse input at its I/O boundary, then branch on the domain value.
// before: the file's shape is assumed
const pid = typeof lock.pid === 'number' ? lock.pid : undefined;

// after: parsed once where it is read
const lock = LockSchema.safeParse(parseYaml(text));   // pid: z.number().optional()

A cast that stays says what checked it:

// SAFETY: username and skills are checked above. The other fields are optional and come from the stats push of this
// or another member's teamai, which writes them from a UserStats.
return { ...document, username: parsed.data.username, skills } as UserStats;

Bugs fixed (23)

Each was found while fixing a hit, on input that a member hand-edits or another tool writes. Every bug is in main today. Bugs 1–3, 13–15 and 18–23 each have a regression test that fails on main.

Names and null files (3)
# Input Before After
1 a hook payload naming the tool constructor (or toString, __proto__) the tool name became [Function Object] the name passes through unchanged
2 a link target docs/a&constructor;b.md the target read docs/afunction Object() { [native code] }b.md &constructor; is kept as written
3 a .claude-plugin/marketplace.json that is null, or lists a null plugin push crashed: Cannot read properties of null the file is skipped
Member-edited and foreign files read without trusting their shape (8)
# Input Before After
4 a Claude, Cursor, Copilot or ZCode hook file whose event is not a list ("Stop": {}) teamai pull warned Failed to reconcile hooks for claude: existing2.filter is not a function and delivered no hooks for that tool the file is left byte-identical, and the warning names the file and the key to fix
5 the same file, read by teamai hooks list or status crashed: entries.some is not a function reports the tool's hooks as missing
6 a Codex hooks.json whose event is not a list, or whose hooks is not an object silently replaced with teamai's entries, so the member's hooks were lost refused, and the file is left byte-identical
7 a Codex hooks.json with a null group, or an event that is not a list, during hook trust TypeError groups.findIndex is not a function the group is skipped; the other groups keep their trust position
8 a Hermes shell-hooks-allowlist.json with a null approval TypeError reading event the approval is kept and ignored
9 a project package.json with "packageManager": 1 TypeError split is not a function read as no declaration
10 ~/.teamai/local-agent/config.json with "endpoint": 1 TypeError endpoint.trim is not a function handled like an empty endpoint
11 a stats/<user>.yaml whose skill entry is null TypeError reading count in stats, team push, digest and pull that entry is dropped, and the rest of the file is kept
Other hits that were bugs (12)
# Where Before After
12 about 440 (e as Error).message sites a thrown non-Error printed undefined; push threw again on .message.replace prints String(e)
13 an agy hook payload naming the tool constructor, toString or __proto__ the tool name became an Object built-in the name passes through unchanged
14 a null line in pending-review.jsonl TypeError, and the whole load stopped the line is skipped
15 an MR or PR list reply with one element missing a field (mr-hint) the hint text showed undefined that MR is skipped, and the others still get a hint
16 a hook file whose entry is null, or whose command is a number Failed to reconcile hooks for claude: Cannot read properties of null / cmd.includes is not a function, and no hooks for that tool the entry is kept as the member's, and the hooks are updated
17 a held Claude hook entry with no string command recorded undefined as the command keeps the record's command
18 a cache-index entry missing size_bytes the size total became NaN the entry is dropped
19 workflow stats with a total that is not a number totals concatenated as strings reads as 0
20 a local-agent manifest.json with a null scope teamai uninstall stopped with Cannot read properties of null (reading 'rules') before it removed the local agent's rules the scope is skipped
21 a transcript line that is not an object, read for votes, or a Pi timestamp out of range TypeError / RangeError the line or field reads as absent
22 an AI module reply without a string domain (enrich-with-ai) wrote a component with no category the reply is dropped
23 a tool named constructor, toString or __proto__ in a hook payload bridged for OpenCode, OMP, Pi, OpenClaw, Kiro or Hermes constructor lost its tool_name, and __proto__ became {} the name passes through unchanged

Behavior changes

Files teamai writes give the same bytes as before, except the local files listed in the last row. The checks for that:

  • the real-CLI comparison below;
  • byte comparisons of workflow run records, votes files and stats files;
  • tests that load and save each file and expect the same bytes or key order, including the team's secrets.yaml, stats/<user>.yaml on the reports branch and ~/.teamai/models/managed.json.

The other changes affect only input that teamai does not write.

Input Before After
a field of the wrong type in a member-edited or foreign file, or an API reply passed through, or crashed later reads as absent; a broken list entry is skipped
a hook file whose hooks is null Claude and Copilot replaced it with teamai's hooks refused with the same message as a non-list event, and the file is kept
a YAML value tagged !!set, !!binary, !!timestamp or !!omap became a Set, Buffer, Date or Map, with a warning per value read as the mapping, string or list it is written as
a malformed agent.yaml targets or tool_extras (not a map from tool name to fields), _overlay.json or _dirs.json accepted as written; a bad tool_extras was dropped, or spread into the tool's file rejected with an error naming the field; pull skips that agent
a workspace binding in the local agent's config.json whose projectId is not a number used as written left out, and gone after the next save
a session archive meta.json missing a field every teamai version writes (a hand edit) read with the field absent that session is left out of index rebuilds and moves, and its restore fails
local files teamai rewrites: the IDE index.json, WorkBuddy session metadata, the workflow cache's teamRevision, skill.json's orchestrator, claim run files, session labels, the scorer cache pin, git-exclude-notices.json keys in the order they were added the same keys and values; known keys come first. Upvote ledger entries from older versions gain firstTs, which readers already took from ts

Review guide

The diff is mostly mechanical, and -w --ignore-blank-lines drops the require-readable-spacing blank lines:

git diff origin/main...HEAD -w --ignore-blank-lines -- . ':!oxlint-plugin-teamai/anti-slop'

That is 478 files, +20.9k / -8.4k, plus 5.1k lines of vendored rules. Each commit holds one rule, or one area for one rule, and its message says how it was checked. The fix: commits are the bugs above.

Evidence

On the head of this branch:

npm run lint        pass (oxlint --type-aware --deny-warnings, then the doc checks)
npm run typecheck   pass
npx vitest run      677 files passed, 1 skipped; 21273 tests passed, 24 skipped
npm run build       pass
npm run test:e2e    the scorer and benchmark files after merging main (#1665), score-delivered-run included: 6 files, 58 tests passed; earlier, 6 workflow and benchmark files, 190 passed, and benchmark-team-assets, 15 passed (the full E2E suite is left to CI)

Two E2E tests from main that failed on a slow runner are fixed here too. The first also fails on main's own CI. Both are test-only changes, and each was reproduced with a delay added to the built CLI, which was then rebuilt without it:

Test Cause Fix Reproduced with
benchmark-team-assets "resolves the clone's own install from a subdirectory…" The session-start hook's background pull still held the sync lock, so the test's teamai pull was skipped and exited 1 Wait for the hook's detached children before pulling The test's pull waits 2s and the background pass holds the lock 4s: red at main's version, green with the wait
benchmark-driver-contract "…the suite timeout settles the other not_run" The 15s suite deadline counts from the start, and the claude check reported after it (lease_cancelled) 40s deadline 3s added to every teamai workflow call: red at 15s, green at 40s (56s)

The same member session, run with the built CLI of main (8a84704) and of this branch, in a fresh HOME against a local team repo. The commands: init --agent claude --scope project, pull, status, list mcp, list skills, env list, doctor, hook-dispatch SessionStart / UserPromptSubmit / PostToolUse / Stop, recall flaky test, stats, pull, uninstall --force.

  • The delivered files and the project tree are identical after hooks and after uninstall.
  • The HOME tree differs only in the per-run workspace hash and git object names.
  • The transcript differs only in the index timings.

A member with their own Codex mcp_tool hook, with Codex 0.166.0 (init --agent codex --scope user, pull, doctor): main and this head both print Trusted 8 teamai hook(s) in Codex and Codex trusts the teamai hooks, and their transcripts are the same apart from timings and hashes.

The malformed Claude hook files from the table above, one teamai pull each, with the same two builds:

hooks.SessionStart in ~/.claude/settings.json main this branch
{} Failed to reconcile hooks for claude: existing2.filter is not a function …/settings.json: hooks.SessionStart is not a list, so teamai left the file as it is. Fix it, then run the command again.
"x" existing2.filter is not a function the same "is not a list" message
[null] Cannot read properties of null (reading 'description') Updated teamai hooks, and the null entry is kept
[{"hooks":[null]}] Cannot read properties of null (reading 'type') Updated teamai hooks
[{"matcher":1,"hooks":[{"command":2}]}] cmd.includes is not a function Updated teamai hooks

Not covered here:

  • The E2E suite and the provider × agent matrix are left to CI.
  • The vendored rules' own tests run on Node 22 and 24 only, because oxlint's RuleTester does not run on Node 20. Lint itself and the repository's rule tests run on Node 20 too.
  • teamai/no-module-mocking is on but cannot fire, because it only matches vi.mock / jest.mock, and tests are exempt.
  • Chinese strings in production code are not part of this change.
  • The vendored no-known-value-widening and no-unsafe-dictionary-type flag a type alias declared in the same file, but not the same alias imported from another file. They are left unchanged from upstream.

Merge Danger

Door: two-way. Every change is in code and lint config, and nothing migrates a file. A revert brings back the casts and the crashes above.

Blast Radius: wide. About 440 production files change, mostly by moving casts and typeof checks to schemas where files are read. Teamai's own writes give the same bytes. Input that teamai does not write may now read as absent, or be refused, where it used to pass through or crash. A new production file needs to pass these rules before it merges.

@hz89Dev hz89Dev changed the title ci(lint): enable the anti-slop and t3code lint rules, and fix the 22 bugs they found ci(lint): enable the anti-slop lint rules, and fix the 22 bugs they found Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident findings in the specified PR diff.

The PR description documents sufficient testing: lint, typecheck, unit tests, build, and representative real-CLI verification, including malformed hook-file cases. Deferring the full E2E suite and provider × agent matrix to CI is permitted by the review rules.

I only read the diff and trusted base criteria; 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.

The new rules are fine. This review looks for regressions, since the PR is mostly a cleanup. It covers the whole diff read with git diff -w --ignore-blank-lines against 02b8e9f6. Most hunks are behavior-preserving rewrites. A few sites change behavior that the PR does not list, and CI is red.

[P1 blocking] Lint & Test fails on Node 20

Lint & Test (Node 20 on ubuntu-latest) fails with 396 failures in oxlint-plugin-teamai/anti-slop.test.ts, every one with:

Error: `RuleTester` is not supported on 32-bit or big-endian systems, versions of NodeJS prior to v22.0.0…

The vendored upstream rule tests use RuleTester from oxlint/plugins-dev, and that needs Node 22. The package supports Node 20 and the CI matrix runs it, so this job stays red. Node 22 and 24 pass. Two possible fixes: skip that suite below Node 22 (describe.skipIf(Number(process.versions.node.split('.')[0]) < 22) around the imports), or run the anti-slop cases through ruleHarness like the other teamai/* rules.

The same job also failed workflow-local-driver.test.ts › "'cancel step then retry' never overlaps live attempts at max_parallel 1" (code: 'busy' instead of done). This PR does not touch that test or src/workflow/local-driver.ts, so it looks like timing flakiness. A rerun should confirm.

[P2 non-blocking] Files written with a new key order that the PR body does not list

The body says files teamai writes keep the same bytes, except the listed local files. Three more files are rewritten in schema key order, because a z.looseObject emits schema keys first. Values do not change.

  • src/resources/secrets.ts:107 readSecretsForEdit: re-parsing every entry reorders the team's committed secrets.yaml on each declare or remove, which makes a noisy diff in the team repo. Keeping the file's own order fixes it: isJsonObject(entry) ? [{ ...entry, ...declaration.data }] : [].
  • src/workflow/records.ts:613 MemberStatsSchema: stats/<user>.yaml on the reports branch is rewritten with username/workflows first.
  • src/models/switch.ts loadManifest: every untouched agent entry in ~/.teamai/models/managed.json gets filePath moved before previous on the next save. A falsy pending key, which the old loader kept, is now dropped.

Either keep the old order or add these to the "Behavior changes" table.

[P2 non-blocking] for_each over a null value now says "gives a null"

src/workflow/fan-out.ts:39 kindOf: a null value now falls through to jsonType(null) and prints a null. Before, it printed null. A missing path resolves to null, so this is the common failure case, and the text is stored in the run file. Fix:

if (value === undefined || value === null) return 'null';

[P2 non-blocking] Bug 1 is fixed in agy-hook-io.ts but not in src/bridged-team-hooks.ts

src/bridged-team-hooks.ts:209 still does bridge.tools[toolName] ?? toolName on the object literals in BRIDGES. For OpenCode, OMP, Pi, OpenClaw, Kiro and Hermes, a tool named constructor or toString loses tool_name, and __proto__ becomes {}. The same Map change as in agy-hook-io.ts fixes it.

[P3 nit] Smaller unlisted behavior changes

  • A hook payload with a numeric literal that overflows to Infinity now fails the stdin schema, and the whole payload reads as {}.
  • copilotRunsEntries and the shell copy COPILOT_RUNS_ENTRIES_SOURCE now disagree on an entry whose matcher is not a string.
  • Some readers now drop a whole list for one bad element, and the next write persists the empty list: the votes/deltas map in v2 votes files, components in _manifest.json (rebuild-wiki-index.ts), ingestedMrs in the source manifest, and mr-hint.ts.
  • local-agent.ts: a missing createdAt is filled with the current time. A workspace binding with a non-number projectId is dropped, then deleted on save.
  • utils/yaml.ts logLevel: 'error' also hides unrelated warnings, such as an unresolved custom tag in a member-edited file.
  • Bugs 13, 14, 15, 18, 19, 20, 21 and 22 have no regression test.

Checked and unchanged

  • Every error-message rewrite prints e.message for an Error, as before.
  • No test was weakened, and no existing teamai/* rule was narrowed.
  • The vendored anti-slop rules match the upstream commit named in UPSTREAM.md.
  • website/, tsup and vitest config changes are blank-line only, apart from the vendored-tests exclusion.
  • There are no workflow, package.json or lockfile changes.

CI review reported no findings. The macOS Lint & Test and the E2E shards were still running when this was written.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident findings in the specified PR diff.

The PR description documents sufficient testing: lint, typecheck, unit tests, build, and representative real-CLI verification, including malformed hook-file cases. Deferring the full E2E suite and provider × agent matrix to CI is permitted by the review rules.

I only read the diff and trusted base review criteria; I did not run, build, or install PR code.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident findings in the specified PR diff.

The PR description documents sufficient testing: lint, typecheck, unit tests, build, and representative real-CLI verification, including malformed hook-file cases. Deferring the full E2E suite and provider × agent matrix to CI is permitted by the review rules.

Earlier passes raised no findings, so none require resolution. I only read the diff and trusted base review criteria; I did not run, build, or install PR code.

@SaulMoro

SaulMoro commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

The blocking finding is fixed in 59f8a62: the vendored anti-slop suite now runs on Node 22 and 24 only, and CI is green at e0b8be7. Since #1663 landed, the branch conflicts with main and needs a rebase. The non-blocking points from the review are still open: the three files rewritten in a new key order, the "gives a null" message, and the bridged-team-hooks.ts lookup. Fix them or say why not, and I'll approve at the rebased head.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident findings in the specified PR diff.

The PR description documents sufficient testing: lint, typecheck, unit tests, build, and representative real-CLI verification, including malformed hook-file cases. Deferring the full E2E suite and provider × agent matrix to CI is permitted by the trusted review rules.

Earlier passes raised no findings, so none require resolution.

I only read the diff and trusted base review criteria; I did not run, build, or install PR code.

@SaulMoro

SaulMoro commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Thanks for the rebase. #1658 is about to land, and this branch conflicts with it in more than 20 files (src/pull.ts, src/hooks.ts, src/index.ts, the scorers and others). Please rebase once more after #1658 merges. I'll re-review the conflict resolutions and the four new commits at that head, then merge. The non-blocking points from the review are still open: the key reorders in secrets.yaml, the stats YAML and managed.json; the for_each "a null" message (fan-out.ts:40); and the plain-object lookup at bridged-team-hooks.ts:209. Fix them or say why not.

…ression reasons

Issue Tencent#836 leaves the anti-slop rules as its last open lint item. This
vendors every generic rule of dmmulroy/anti-slop (MIT) into the repo's
one lint plugin, as the upstream README recommends; they report as
teamai/<rule> and hold production code, not tests. oxlint imports
plugins with plain Node and CI lints on Node 20, so index.js loads the
TypeScript rules through scripts/typescript-loader.mjs.

The rules the code already passes are on now: no-module-mocking,
no-reduce-accumulator-copy, no-reflect-apply, no-reflect-get,
no-unknown-type-aliases, no-widen-then-assert, and oxc's
no-accumulating-spread. The one production Reflect.get, in
src/workflow/snapshot.ts, now reads the field from the value's own
entries. The commits after this one fix each remaining rule and turn it
on.

teamai/suppression-reason, adapted from t3code's
require-suppression-reason, fails a lint or TypeScript suppression that
does not say why, as CONTRIBUTING already asks; the 14 without a reason
now have one. The other t3code rules depend on Effect, React or the
mobile app.

Tested: npx vitest run oxlint-plugin-teamai (upstream rule cases plus the
suppression-reason cases); the workflow snapshot tests pass; npm run
typecheck; npm run lint, and oxlint on Node 20.19.5 loads the rules.
… for

`oxlint --fix` with only this rule on, over production code: blank lines
between top-level declarations, around multiline bindings, before
returns and control flow, and after blocks. Eight files had one-line
blocks such as `{ const parsed = X.safeParse(line); return ...; }` that
the fix would split mid-line, so those blocks are written out on separate
lines first. `git diff --ignore-blank-lines -w` shows only those eight.

Tested: npm run lint; npm run typecheck; npm run build; npx vitest run
(646 files, 20,399 tests).
The votes file was read with `as unknown as` casts and hand typeof checks
on its ride-along fields (upvote ledger, pending delivery record, delivered
sync ids). The v1 and v2 file types are now zod schemas in types.ts and the
file is parsed once where it is read: a malformed ride-along reads as
absent, a corrupt counter reads as 0, and unknown keys are kept on save.

Proof: votes-related unit tests (44 files, 1353 tests) pass; tsc passes.
HandDeclaredNamespacesShape is spread into the roles and projects resources
schemas; the name said its structure rather than its role.

Proof: tsc passes.
Modules that hold parsed JSON or YAML before a domain schema narrows it
typed it as Record<string, unknown> or unknown; JsonValue (zod's z.json())
gives them one named type to share.

Proof: tsc passes.
Shared inputs were read through casts and typeof checks in every caller.
Frontmatter gets a value type, fs exports errnoCode, and types.ts gains
HookPayloadSchema plus named types for its tables and resolutions.

Proof: frontmatter, fs-atomic-mode, fs-compare, tool-roots, webhook and webhook-formatters tests pass; tsc and lint on the batch report no hits.
The cwd, session id and tool-call helpers hand-checked each stdin field.
They now parse the payload once with the shared schema; a malformed field
still reads as absent.

Proof: hook-cwd, session-id, tool-call, hook-handlers and recall-attribution tests pass; tsc and lint on the batch report no hits.
… with schemas

Frontmatter fields, vote files and the reusable cache entries were cast and
checked with typeof. Schemas now keep the same accepted inputs and skip the
same malformed entries.

Proof: search-index, search-index-drop-all, search-index-incremental, search-index-learnings-roots, search-index-local-votes, search-index-multi, search-index-read-order, search-index-scoring and search-index-unreadable tests pass; tsc and lint on the batch report no hits.
… of casting

GitHub, GitLab, GitCode, TGit and CNB responses were cast to their expected
shapes. Each is parsed with a schema; optional fields that were skipped when
malformed still are, and error messages are unchanged.

Proof: gh-org, gh-org-errors, github-provider, github-mr-fetch, import-mr, workflow-pr-providers, gitlab-*, gitcode-provider, tgit-*, cnb-* and exec tests pass; tsc and lint on the batch report no hits.
…sting

tags.yaml, the import lock, the cache index, the partition config and iWiki
replies are parsed with schemas that read the same fields the casts did.
Error messages come from instanceof checks, and conditional spreads are
built in statements with the same key order.

Proof: branch-worktree-*, git, git-binary, jsonl-store, iwiki-*, redact, tags, import-lock, cache-*, partition, push-pending-pr, placement-records, learnings-*, reports-*, shell-profile, team-history, tool-names and local-agent tests pass; tsc and lint on the batch report no hits.
…f casts

Machine settings were read through hand-written typeof checks and
Record<string, unknown> casts. A loose mapping schema now gates each level,
member-setting keys come from the schema, and overlays are built in
statements, so the same files load to the same settings.

Proof: config-*, member-settings-overlay, init and pull tests pass; tsc and
lint on the batch report no hits.
…of casting

Skip reasons, delivered blobs and pre-placement paths were read back with
typeof checks and written through casts. A PushItem type names them, the
teamai.yaml packages check parses a mapping, and error messages use the
instanceof form the file already uses elsewhere.

Proof: push-* tests pass; tsc and lint on the batch report no hits.
reportedSegments re-validated each snapshot field with typeof. Stored
segments now go through a schema whose per-field catch keeps the old
zero and false fallbacks, and delta helpers return inferred or named types.

Proof: team-push-* and pull tests pass; tsc and lint on the batch report no
hits.
… casts

Checkout records, place selections and delivery selections were assembled
with conditional empty-object spreads. They are built in statements that add
each field only when present, and the registry handler casts live in three
helpers that state why each holds.

Proof: pull-* and post-pull tests pass; tsc and lint on the batch report no
hits.
The salvage of an invalid config, the local-agent manifest and hook files
were read through casts and typeof checks. Each is parsed with a schema that
skips what the old code skipped, and config objects are built in statements
that keep the key order init writes.

Proof: init*, uninstall and pull tests pass; tsc and lint on the batch report
no hits.
…sors

program.opts() and optsWithGlobals() take the option type as a type
argument, so the casts on each action go away. Option help is unchanged.

Proof: index-* tests and check-docs pass; tsc and lint on the batch report no
hits.
…d of casting

The ownership manifest, each agent's settings file and the recorded snapshots
are now parsed with zod at the point they are read, so the writers take typed
values and the hand-written record checks and casts go away. Error messages,
accepted files and written bytes stay the same.

Proof: model-switch, codebuddy-relocated-models, pull-agent-models,
agent-model-aliases and doctor-agent-models tests pass; tsc and lint on the
file report no hits.
…lies in statements

Tool events are parsed with zod field by field instead of narrowed with
typeof and casts, and readings, reports and launch env are assembled without
conditional empty-object spreads. Readings and reports keep the same fields.

Proof: tool-launch-call, tools, scorers-judge, scorers-judge-model,
votes-judge and workflow-local-tool-adapter tests pass; tsc and lint on the
files report no hits.
The benchmark suite, plan, trials, results, history and table code that
main added parses what it reads with schemas and builds what it writes
in statements, through definedFields, which keeps key order and leaves
undefined fields out. isLabelShaped is now isRecordableLabel, beside
isRecordableName.

Checked: npm run typecheck, npm run lint; benchmark, dashboard-benchmarks,
push-file and session-to-task tests pass; a harness running main's code
and this branch on the same suites, plans, records and tables gave the
same output.
…de main changed

The rebase onto the benchmark workflow change kept main's side of each
conflicting workflow file. This merges the branch's schema parsing and
statement-built objects back into them, keeps every new field of main
in the position main writes it, and fixes the hits in the new code. The
run file a handoff claim installs and the workflow cache keep main's key
order. The two docs-check tests that run it three times keep their 60s
timeout.

Checked: npm run typecheck, npm run lint, the full unit suite (678
files), npm run build.
@hz89Dev hz89Dev changed the title ci(lint): enable the anti-slop lint rules, and fix the 22 bugs they found ci(lint): enable the anti-slop lint rules, and fix the 23 bugs they found Nov 2, 2026
@hz89Dev

hz89Dev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

All items from the review are handled on the current head. Each fix has a test that fails without it.

[P1] Node 20. Fixed in 9c33f1d. anti-slop.test.ts runs the vendored RuleTester cases on Node 22 and later and reports a skip on Node 20. The workflow-local-driver busy case was the timing flake: it passed 80/80 locally, and this branch does not touch that lock.

[P2] Key order. Fixed for all three files. Each now spreads the parsed value over the entry it was read from:

  • secrets.yaml (env add --secret / env remove)
  • stats/<user>.yaml on the reports branch
  • managed.json agent entries

The falsy pending stays dropped. teamai deletes the key and never writes a falsy value, so only a hand edit can produce one, and it reads the same either way.

[P2] for_each over null. Fixed. It says gives null again.

[P2] Bridged tool names. Fixed in bridged-team-hooks.ts, which now maps only a name the table has (Object.hasOwn). It is listed as bug 23.

[P3] Smaller items.

  • 1e999 in a hook payload: the payload keeps its other fields, and that number reads as null, as JSON writes it.
  • Copilot matcher: copilotRunsEntries keeps an entry whose matcher is not text, as the shell guard does. The parity test has the case.
  • Lists:
    • ingestedMrs, _manifest.json components, the MR/PR replies and the hint cache now skip only the bad entry, through lenientList.
    • The v2 votes/deltas tables already drop a bad entry one at a time: voteTableSchema catches each value.
  • local-agent:
    • A missing createdAt reads as absent again, and the report leaves started_at out, as before.
    • A binding with a non-number projectId stays dropped. teamai writes it as a number, and the binding cannot report without one. It is now in the Behavior changes table.
  • parseYaml: it now drops only the YAML 1.1 tag warnings and prints every other one, such as Unresolved tag: !vault.
  • Regression tests: bugs 13–15 and 18–22 now each have one that fails on main.
    • Writing them showed that bug 20 was only half fixed: local-agent's own manifest loader still crashed on a null scope before uninstall reached it. That is fixed too.
    • Bug 13 was reworded. getAgentVersion and bundledShellFor already went through isToolId on main, so the bug is agy's tool table.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident findings in the specified PR diff.

The PR description documents sufficient testing, including build, lint, typecheck, unit tests, and representative real-CLI verification with malformed hook-file cases. Deferring the full E2E suite and provider × agent matrix to CI is permitted by the trusted review rules.

Earlier passes raised no findings, so none require resolution.

This was a read-only review; I did not run, build, or install PR code.

…fore pulling in the clone

The hook's background pass pulls too. On a slow runner it still held the
sync lock when the test's own pull ran, so that pull was skipped and exited 1.
Reproduced by delaying the test's pull and holding the lock in the background
pass; waiting for the hook's detached children passes under the same delays.
…r runs

The deadline counts from the start, and 15s left the plan, the baseline and
the claude trial no margin: on a slow runner the check reported after it and
was cancelled. 40s passes with 3s added to every workflow call, which fails
at 15s.
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] src/utils/search-index.ts:356 — List-form frontmatter such as ---\n- tag\n---\nBody now throws at LearningFrontmatterSchema.parse(data). Previously its metadata was ignored and its body remained indexable. The exception escapes entryFromMdFile and rejects the index workers’ Promise.all, aborting the rebuild. Use safeParse with empty metadata for non-object roots.

The PR description documents sufficient testing, including build and representative real-CLI verification. Deferring the full E2E suite and provider × agent matrix to CI is permitted.

Earlier passes raised no findings, so none require resolution. This was read-only; I did not run, build, or install PR code.

gray-matter returns the YAML root as it is, so frontmatter such as `- tag`
is a list. The learning frontmatter schema refused it, and the whole
workspace index failed to build, so recall found nothing. It now reads as
no metadata and the body is indexed, as before.

Checked with a learning holding `---\n- ops\n---`: recall printed
"could not build the workspace search index" before, and now gives the
same transcript as main.
@hz89Dev

hz89Dev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in bc734ae. The impact was larger than a P2: with one learning whose frontmatter was ---\n- ops\n---, teamai recall printed "Recall could not build the workspace search index" and found nothing. With the fix, the same session gives the same transcript as main.

  • LearningFrontmatterSchema now ends in .catch({}), so a root that is not a mapping reads as no metadata and the body is still indexed.
  • search-index.test.ts covers a list, a string and a null root. The list and string cases fail without the fix.
  • The other places that call matter(...).data directly already skip only the one file, or read as main does. The ones that use splitFrontmatter get {} for such a root.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident findings in the specified PR diff.

The earlier [P2 non-blocking] frontmatter finding is resolved: the schema now falls back to empty metadata for non-object roots, with regression tests covering lists, strings, and null.

The PR description documents sufficient testing, including build and representative real-CLI verification with malformed hook files. Deferring the full E2E suite and provider × agent matrix to CI is permitted.

This was a read-only review; 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.

Approving at bc734ae. Every finding from the earlier review is resolved:

  • Node 20: the vendored rule tests run on Node 22 and later, and report a skip below that.
  • Key order: secrets.yaml, stats/<user>.yaml and managed.json keep their own key order and every key. A script against the locked zod and yaml versions confirmed this.
  • for_each over null: it says "gives null" again.
  • Bridged tool names: bridged-team-hooks.ts maps only names its table has.
  • Lists: they skip only the bad entry.
  • parseYaml: it prints every warning except the YAML 1.1 tag ones, each exactly once.
  • List-form learning frontmatter: it is indexed with no metadata again, as on main.

I accept both declines, the falsy pending and the non-number projectId. The second is now in the Behavior changes table.

The rebase onto #1658 keeps its behavior: the token meter's message_delta merge, the workflow finally/from handling, and push --file/--path.

The two E2E fixes are test-only:

  • the suite deadline gets room for the trial the driver runs;
  • the clone pull waits for the hook's background pull. Main fails that one too.

CI is green at this head.

[P3 nit] src/models/switch.ts:238: the pending.prior entry in managed.json still comes back in schema key order. It only matters when recovering from a switch interrupted between two saves, and values do not change.

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

Before merging, I ran two more regression passes on bc734ae. Replacing my approval with this one finding.

Built-CLI comparison with main. The same 122 commands ran against main and this head, and every difference is a fix the PR lists:

  • init, pull, status, doctor, recall and every --help;
  • env and secrets;
  • hook dispatch, including malformed payloads;
  • a workflow with for_each;
  • broken hook, settings, managed.json and local-agent files.

Code sweep. It read every new .parse on data from outside teamai. It found this:

[P1 blocking] One mcp_tool hook makes Codex hook trust fail

src/codex-trust.ts:74-80 and :475-483: HookInfoSchema requires a command string, and listHooks throws AppServerError when any listed hook fails it. Codex 0.166.0 lists mcp_tool hooks with handlerType: "mcpTool" and no command. I captured this from a real codex app-server hooks/list reply, using a hooks.json that holds one command hook and one mcp_tool hook. Main returned both hooks and trusted teamai's own.

So for a member who has their own mcp_tool hook, this head behaves differently from main:

  • every teamai pull fails to trust teamai's Codex hooks, so Codex does not run them;
  • moved hooks lose their approvals, with only a warning;
  • doctor reports that it could not ask Codex.

It is not in the Behavior changes table. Prompt and agent hooks will take the same path once Codex supports them; it skips them today.

Fix: read each listed hook on its own and drop the ones that do not match, the same tolerance lenientList gives elsewhere. For example z.array(HookInfoSchema.nullable().catch(null)) and then filter the nulls. codex app-server generate-json-schema --out <dir> writes the reply schema (v2/HooksListResponse.json) to check against. A unit case with an mcpTool entry would pin this down.

[P3 nit]

  • agent.yaml: a tool_extras value that is not a map from tool name to fields now makes pull skip the agent. Main delivered the agent and ignored the bad value. Not in the Behavior changes table.
  • Session archive meta.json with a field missing now drops out of index rebuilds and moves, and fails a restore. Every teamai version writes those fields, so only a hand edit triggers it.
  • When pull refuses a hook file, doctor still suggests teamai hooks inject, which refuses the same file. The pull warning ("Fix it, then run the command again") is the one that helps.

…command

Codex 0.166 lists an mcp_tool hook with no command. hooks/list was read as
one strict list, so one such member hook made every trust pass fail: pull
left teamai's Codex hooks untrusted, moved hooks lost their approvals, and
doctor could not ask Codex. Each listed hook is now read on its own and one
without the fields teamai matches on is skipped; teamai writes only command
hooks.

The codex-trust case with a member mcp_tool hook trusted nothing before and
trusts every teamai hook now.
…rewrite

doctor told the member to run `teamai hooks inject` for a hook file whose
events are not lists, but inject refuses that file as pull does. The check
now gives pull's message, which names the file and the problem.

The doctor CLI case with `hooks.SessionStart: {}` gave the inject hint
before and gives pull's message now.
@hz89Dev

hz89Dev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@SaulMoro all four items are handled on 310b390.

[P1] mcp_tool hook and Codex trust. Fixed in c473de7. listHooks reads the reply through lenientList(HookInfoSchema), so a hook Codex lists without a command is skipped and the rest are trusted. teamai writes only command hooks. It still throws when the cwd's hooks are not a list.

  • Real CLI, Codex 0.166.0, with a member hooks.json holding one mcp_tool hook (init --agent codex --scope user, pull, doctor):
    • bc734ae printed Could not trust the teamai hooks in Codex (hooks/list: a listed hook has no key, command, …), and doctor said it could not ask Codex.
    • On 310b390 the transcript is the same as main's (Trusted 8 teamai hook(s) in Codex, Codex trusts the teamai hooks), apart from timings and hashes.
  • Test: codex-trust.test.ts has a case with a member mcp_tool hook. It trusted nothing before the fix.
  • Other readers: every hooks/list reader goes through listHooks, so moved approvals and doctor get the same fix. The build comparison only compares teamai's own hook ids.

[P3] doctor after pull refuses a hook file. Fixed in 310b390. The check now gives pull's message for that file, for example …/settings.json: hooks.SessionStart is not a list, so teamai left the file as it is. Fix it, then run the command again., instead of teamai hooks inject. It finds the problem the same way hooks.ts already lists unreadable hook files (hookEventsProblem with hookFormatOf). The doctor-cli E2E test has the case.

[P3] tool_extras, and session meta.json missing a field. Both are kept as they are and are now in the Behavior changes table.

  • On main, a tool_extras that was not a map was cast as is: it was dropped, or a string under a tool name was spread into that tool's file. Refusing the one agent, with the field named, seems better than delivering junk.
  • A meta.json missing a field is a hand edit, since every teamai version writes those fields.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident new findings in the specified PR diff.

The earlier [P2 non-blocking] frontmatter finding is resolved: non-object roots fall back to empty metadata, with regression tests for lists, strings, and null.

The PR description documents sufficient testing, including build and representative real-CLI verification with malformed hook files. Deferring the full E2E suite and provider × agent matrix to CI is permitted.

This was a read-only review; I did not run, build, or install PR code.

@SaulMoro

SaulMoro commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

The Codex mcp_tool fix (c473de7) and the doctor fix text (310b390) are right: listHooks now skips a hook it cannot read and throws only when the hooks are not a list, which matches main. I accept the two nits you kept; they are now in the Behavior changes table.

#1665 has landed, and this branch now conflicts with it in 17 files. Please rebase onto main and fix the anti-slop hits in #1665's code, as you did for #1658. This lands next, before #1666, which will rebase onto both.

Brings in Tencent#1665, which moved the benchmark check into src/workflow/check.ts
and check-run.ts and added scoring stages before the judge. Its new code is
written to the anti-slop rules: conditional spreads became assignments, with
the key order of every serialized object as main has it.

Checked: typecheck, lint, the unit suite (677 files, 21273 tests), and the
E2E files of the scorers and the benchmark, including main's new
score-delivered-run test (6 files, 58 tests).
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No confident new findings in the specified PR diff.

The earlier [P2 non-blocking] frontmatter finding is resolved: non-object roots fall back to empty metadata, with regression tests for lists, strings, and null.

The PR description documents sufficient testing, including build and representative real-CLI verification with malformed hook files. Deferring the full E2E suite and provider × agent matrix to CI is permitted by the trusted review rules.

This was a read-only review; 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.

Approving at 1e259ff.

  • The Codex mcp_tool regression is fixed in c473de7. listHooks skips a hook it cannot read, so teamai's hooks are trusted beside a member's mcp_tool hook, as on main.
  • doctor now names the fix pull gives for a hook file it will not rewrite (310b390).
  • The merge of main (1e259ff) keeps everything #1665 added: on-demand scoring judges the other scorers before it returns an error, the stage order is check, CI, protected paths, then judge, and CI reading, decidedBy, evidenceHash and the dashboard view are unchanged. It adds no schema to #1665's code.
  • I accept the two kept nits (tool_extras, session meta.json); both are now in the Behavior changes table.

Before this approval, a built-CLI comparison with main ran 122 commands, including corrupted hook, settings, secrets, frontmatter and local files. Every difference is a fix this PR lists. CI is green at this head.

@SaulMoro
SaulMoro merged commit 7d35325 into Tencent:main Nov 2, 2026
19 checks passed
@SaulMoro

SaulMoro commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Merging this one now. It is an important cleanup, and few pull requests are open right now, so landing it causes the fewest conflicts. #1666 rebases on top of it.

hz89Dev added a commit to hz89Dev/teamai-cli that referenced this pull request Nov 2, 2026
Main enabled the anti-slop rules (Tencent#1664) while this branch was open. Blank
lines go where require-readable-spacing asks, optional fields are left
undefined instead of spread in from an empty object, a learning's session is
read with a schema instead of typeof, and a suite task parses with parseYaml.

npm run lint, npx tsc --noEmit, npx vitest run (21310 pass) and the e2e files
for the team workspace, the self-improvement guide, PR delivery, git
conformance and push --file (55 pass) are green.
hz89Dev added a commit to hz89Dev/teamai-cli that referenced this pull request Nov 2, 2026
Main enabled the anti-slop rules (Tencent#1664) while this branch was open. Blank
lines go where require-readable-spacing asks, optional fields are left
undefined instead of spread in from an empty object, a learning's session is
read with a schema instead of typeof, and a suite task parses with parseYaml.

npm run lint, npx tsc --noEmit, npx vitest run (21310 pass) and the e2e files
for the team workspace, the self-improvement guide, PR delivery, git
conformance and push --file (55 pass) are green.
hz89Dev added a commit to hz89Dev/teamai-cli that referenced this pull request Nov 2, 2026
Main enabled the anti-slop rules (Tencent#1664) while this branch was open. Blank
lines go where require-readable-spacing asks, optional fields are left
undefined instead of spread in from an empty object, a learning's session is
read with a schema instead of typeof, and a suite task parses with parseYaml.

npm run lint, npx tsc --noEmit, npx vitest run (21310 pass) and the e2e files
for the team workspace, the self-improvement guide, PR delivery, git
conformance and push --file (55 pass) are green.
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.

oxlint rollout: bugs found in the baseline, and next rules to evaluate

3 participants