Skip to content

fix(recall): include pending local votes in index builds - #1276

Merged
SaulMoro merged 2 commits into
Tencent:mainfrom
MertensMing:codex/teamai-1233-local-votes
Oct 22, 2026
Merged

SaulMoro merged 2 commits into
Tencent:mainfrom
MertensMing:codex/teamai-1233-local-votes

Conversation

@MertensMing

Copy link
Copy Markdown
Contributor

Summary

Local feedback now affects the next index rebuild even when reporting is disabled or a push fails. Pull, recall rebuilds, contribute and scoped viz share confirmed team votes plus undelivered local deltas, including first-vote and HTTP cases.

The reader pins the reports origin commit, uses delivery IDs to avoid double-counting, and falls back to confirmed counts immediately when the votes lock is busy. Independent delivery snapshots and detached legacy YAML aliases prevent new feedback from mutating an old receipt and being lost. Upload, retry and confirmation/cleanup protocols are unchanged.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Test Plan

Verified head 8d1025b, rebased onto d60e68f, with Node 20.19.5:

  • npm run build
  • npx tsc --noEmit
  • npm run lint
  • 139 relevant unit/integration tests passed
  • Added regression tests for both delivery boundaries, legacy snapshots, lock recovery, HTTP, scope isolation and the real viz temporary-index build
  • After building, 5 real-CLI tests passed using:

npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/index-local-votes-1233.test.ts src/__tests__/e2e/votes-sync-retry-1027.test.ts --retry=0

The CLI tests use an isolated local Git origin. With reporting enabled, disabled or rejected, feedback followed by the first pull changes indexed votes from 0.3 to 1.3 and increases the numeric recall score; repeated pulls stay stable. They also verify lock-busy fallback/recovery, recall/contribute rebuilds, and #1027 push-failure retries. A post-receive hook holds the local votes lock after a real push to leave confirmation pending; after releasing it, new CLI feedback is retained on subsequent pulls (2.3). The hook never edits vote data.

Earlier full-suite testing had four timeouts that passed on serial rerun and one ZCode registered-entry assertion also reproduced on unmodified upstream 2aa8a8a. The full suite was not rerun on this final head; other providers and agents are left to CI.

Related Issues

Fixes #1233.

Notes for Reviewers

The small snapshot changes in votes.ts are needed to preserve new feedback while a delivered stage awaits confirmation. No new commands or changes to the delivery protocol. Adoption votes created after a rebuild remain for the next rebuild.

@github-actions

Copy link
Copy Markdown
  • [P2 non-blocking] src/votes.ts:573: Merging any local delta converts the current user’s entire legacy v1 file to v2. An unrelated legacy document previously scored as 1 then scores as 0.3, even when reporting is disabled and nothing was delivered. Preserve unchanged legacy documents’ scoring; the legacy regression test covers only another user’s file, so it misses this case.

The PR description documents sufficient testing, including representative built real-CLI runs. Its tested commit differs from the review head; under the review rules, that is a note, not a blocker.

Reviewed only the specified diff; 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.

@MertensMing Approving with notes. We built this head and main (d60e68f5), gave feedback against a local git team repo, and ran pull twice.

Build Reporting Index votes after the first pull, then the second
main disabled 0, 0
main enabled 0, 1
this head disabled 1, 1
this head enabled 1, 1

The new e2e test fails all 4 cases against main's build. The PR's three e2e files pass on this head, 34 tests.

[P2 non-blocking] In a --single-branch or shallow clone of the reports branch, the index drops the member's own last confirmed votes until the next fetch. readIndexVoteFiles (src/votes.ts:558) reads confirmed votes only from refs/remotes/origin/teamai-reports, and in such a clone a push does not move that ref. Once the pending deltas are confirmed and cleared, a rebuild that does not fetch first misses that batch. That covers the rebuild after contribute and the recall rebuild of a missing index. pull and viz fetch, so they are fine. We measured it: a full clone shows 2 votes (RELEVANT 6.7), and a single-branch clone on this head shows 1 (NOT_RELEVANT 1.9). Reading the reports worktree's HEAD^{commit} instead gave 2 votes in both clones, the #1233 repro still behaved, and the e2e files passed. Please check that HEAD cannot hold a commit whose deltas are still counted as pending before taking that route.

[P3 nit] The CI comment's legacy v1 conversion needs a v1 votes file for the same member on the reports branch, and any earlier sync would already have converted it. Delivery does the same conversion, so the index shows what delivery would produce.

[P3 nit] The parse-error log no longer names which votes file is corrupt. votesDir is still passed by four callers, but the build ignores it.

[P3 nit] The unconfirmed e2e case writes an extensionless hook that uses require. It fails when a package.json with "type": "module" sits above the test's temp directory.

The index read holds the votes lock while it reads each member's file. 200 member files took 990 ms, and a writer gives up after about 2.5 s, so this only matters for very large teams.

@SaulMoro
SaulMoro merged commit e45baeb into Tencent:main Oct 22, 2026
19 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
* fix(recall): include pending local votes in index builds

* test(recall): retain local votes in foreign checkout isolation case
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.

[bug] recall score can lag one pull behind a vote: the index rebuild reads votes before the delta is staged

3 participants