Skip to content

fix(deep-enrich): reset stale progress when manifest is newer than last run - #128

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
m0Nst3r873:worktree-fix-deep-enrich-stale-progress
Jul 3, 2026
Merged

fix(deep-enrich): reset stale progress when manifest is newer than last run#128
jeff-r2026 merged 2 commits into
Tencent:mainfrom
m0Nst3r873:worktree-fix-deep-enrich-stale-progress

Conversation

@m0Nst3r873

@m0Nst3r873 m0Nst3r873 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes deep-enrich producing empty MRs (only progress.json timestamp update) when running after teamai import --from-repo.

Root cause: autoPushViaMR calls checkoutMaster() after committing the import branch. The subsequent setImmediate-scheduled deep-enrich then runs against the master working tree, where:

  1. Old progress.json (phase="done") causes all generation phases to be skipped
  2. Evidence files reflect the old master state, not the freshly extracted data

Fix (two commits):

  1. deep-enrich.ts — Add stale progress guard: reset to "pending" when phase=done but either docs/ is empty or _manifest.json is newer than the progress timestamp. Defense-in-depth.

  2. import-repo.ts — Move deep-enrich from async setImmediate (after push) to synchronous execution (before push). This ensures:

    • Deep-enrich reads the freshly written evidence on disk
    • All content (extract + enrich) goes into a single MR instead of two
    • No branch/timing confusion between import and enrich phases

Test plan

  • npx tsc --noEmit passes
  • npx vitest run — 1590 tests pass
  • Manual: teamai import --from-repo <url> produces a single MR with both evidence and deep-enrich docs
  • Manual: re-running import on an already-enriched repo with stale progress.json correctly resets and regenerates

jaelgeng added 2 commits July 3, 2026 11:41
…st run

When import regenerates evidence (full rebuild), the old progress.json
may survive on the git branch that deep-enrich executes against (since
autoPushViaMR checks out master before deep-enrich runs in setImmediate).

The 'done' phase caused all generation phases to be skipped, producing
an MR with only a timestamp update in progress.json.

Now detect staleness via two signals:
- docs/ directory is empty (evidence was rebuilt but docs not regenerated)
- manifest.generatedAt > progress.startedAt (manifest is fresher)

Either condition resets progress to 'pending' so all phases re-execute.
…e single MR

Previously deep-enrich ran in setImmediate after autoPushViaMR had
already checked out master, causing it to:
1. Read stale evidence/progress from master instead of the freshly
   extracted data
2. Push a separate MR with incomplete/empty content

Move deep-enrich before the push step so:
- It executes against the actual freshly-written evidence on disk
- All content (extract + enrich) is committed into a single MR
- No timing/branch confusion between import and enrich phases

This eliminates the root cause; the stale progress guard in
deep-enrich.ts remains as defense-in-depth.
@m0Nst3r873
m0Nst3r873 force-pushed the worktree-fix-deep-enrich-stale-progress branch from 5770d82 to 8ca7e33 Compare July 3, 2026 03:43
@jeff-r2026
jeff-r2026 merged commit afb760a into Tencent:main Jul 3, 2026
7 checks passed
@hsuchifeng hsuchifeng mentioned this pull request Jul 3, 2026
3 tasks
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.

2 participants