Repository navigation
fix(deep-enrich): retry missing AI docs after temporary failures - #491
Conversation
Resume from files on disk so a skipped AI phase does not stay stuck at phase done once deterministic graph markdown fills docs/. The public codebase --deep-enrich command reports incomplete work instead of complete true. Fixes Tencent#488.
|
Found a locally reproduced regression that I recommend fixing before merging: after a new code extraction, existing component and architecture documents are treated as complete indefinitely, even when they describe the previous code, and the CLI reports success. Tested PR HEAD: Cause and affected workflowdeep-enrich.ts L817–830 now skips component and architecture generation based only on file existence. This also removes the previous invalidation check for This affects running Minimal reproduction using the built CLI (no AI service needed)Run this from the PR checkout. The fixture represents the on-disk state after extraction updates the manifest while older documents and completed progress remain. This does not claim to run a full extraction against a live AI service. npm ci --ignore-scripts
npm run build
node --input-type=module <<'JS'
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'pr491-stale-'));
const evidence = path.join(root, 'teamwiki/evidence/code/demo');
fs.mkdirSync(path.join(evidence, 'docs'), { recursive: true });
fs.mkdirSync(path.join(evidence, '_review'), { recursive: true });
fs.writeFileSync(path.join(evidence, '_manifest.json'), JSON.stringify({
project: 'demo', generatedAt: '2026-09-11T00:00:00Z',
components: [{ slug: 'Auth', responsibilities: ['NEW OAuth flow'] }], edges: []
}));
fs.writeFileSync(path.join(evidence, '_review/progress.json'), JSON.stringify({
project: 'demo', phase: 'done', componentsDone: ['Auth'], componentsPending: [],
startedAt: '2026-01-01T00:00:00Z', updatedAt: '2026-01-01T00:00:00Z'
}));
fs.writeFileSync(path.join(evidence, 'docs/Auth.md'), '# OLD password flow');
fs.writeFileSync(path.join(evidence, 'docs/architecture.md'), '# OLD architecture');
const run = spawnSync(process.execPath, [
'dist/index.js', 'codebase', '--deep-enrich', '--project', 'demo',
'--output', root, '--json'
], { encoding: 'utf8' });
console.log(run.stdout);
console.log('exit code:', run.status);
assert.equal(run.status, 0);
assert.match(run.stdout, /"complete": true/);
assert.equal(fs.readFileSync(path.join(evidence, 'docs/Auth.md'), 'utf8'), '# OLD password flow');
assert.equal(fs.readFileSync(path.join(evidence, 'docs/architecture.md'), 'utf8'), '# OLD architecture');
console.log('REPRODUCED: success reported, both documents still contain old content.');
console.log('fixture:', root);
JSActual output from the built CLI, with paths and routine logs omitted: Exit code: Parent comparison and validation scopeSeparately, I ran the same fixture against the parent and PR implementations in Vitest, with the AI client returning fixed new text (no live LLM calls):
Please retain input-version invalidation alongside file-based resume: completed documents can be preserved when retrying failures for the same input, but a newer manifest should invalidate the corresponding old component/architecture documents (and G5). A regression test with existing documents plus an updated manifest would cover this case. |
File-based resume still retries missing docs for the same extract. A newer _manifest.json generatedAt now drops stale component, architecture, and G5 files so extract → deep-enrich regenerates them instead of reporting success with old content.
|
Thanks — that was a real regression from dropping the Pushed
Covered by two handler tests on |
…cent#491) * fix(deep-enrich): retry missing AI docs after temporary failures Resume from files on disk so a skipped AI phase does not stay stuck at phase done once deterministic graph markdown fills docs/. The public codebase --deep-enrich command reports incomplete work instead of complete true. Fixes Tencent#488. * fix(deep-enrich): invalidate AI docs when extract manifest is newer File-based resume still retries missing docs for the same extract. A newer _manifest.json generatedAt now drops stale component, architecture, and G5 files so extract → deep-enrich regenerates them instead of reporting success with old content.
Summary
A temporary AI failure during deep enrichment left component and architecture documents missing, but the engine still saved
phase: \"done\". The next run skipped the missing AI work because deterministic graph markdown keptdocs/nonempty, and the public command still reportedcomplete: true.Resume now treats files on disk as the source of truth: missing
docs/<slug>.mdanddocs/architecture.mdare retried, completed AI docs and G1/G2/G3 graph files are preserved, andteamai codebase --deep-enrichreports incomplete work in English instead of claiming full completion.Fixes #488.
Type of Change
Test Plan
npx tsc --noEmit— cleannpx vitest run src/__tests__/codebase-deep-enrich.test.ts src/__tests__/deep-enrich-graph-preserve.test.ts— 10/10 passed (AI client mocked; no live LLM)codebaseCmd --deep-enrichwith rejecting AI writes graph docs, omitsAuth.md/architecture.md, JSONcomplete: false; second call with recovered mocks writes those AI docs and keeps G1 unchangedcomplete: false/Deep enrichment incompletewith missing component and architecture docs listedAuth.mdis preserved when architecture generation still failsRelated Issues
Fixes #488. Related to #480 / #360 (does not close #360).
Notes for Reviewers
teamai codebase --deep-enrich --project <slug> --output <repo>.teamai deep-enrichis unchanged.process.exitCode = 1and printDeep enrichment incomplete.