Skip to content

feat: warm re-scan / no re-interrogation on iteration (reuse CodeKB + prior answers) #1122

Description

@SaRedfiche

Problem

On any iteration over an existing workspace/intent, AI-DLC re-runs a cold Initialization scan and re-interrogates the user with questions they already answered. A customer reported a 45-minute re-scan that re-asked answered questions for what was ultimately an 11-line fix. This is the "reuse prior workspace understanding" half of the last-30% iteration gap.

What already exists (verified against source)

The code-understanding side is largely built and should be reused, not rebuilt:

  • Durable space-level CodeKB store aidlc/spaces/<space>/codekb/<repo>/ (core/tools/aidlc-lib.ts codekbDir).
  • Git-tree-hash freshness fingerprint (codekbScopeFingerprint / codekbSourceFingerprint) and a scope_version:1 freshness block in reverse-engineering-timestamp.md.
  • A CURRENT/STALE/... verdict (codekb-scope-diff) + a reuse gate in the reverse-engineering stage (Reuse / Full rescan / Focused scan), so the --rescan full escape hatch effectively exists already as "Full rescan".
  • propagateStageInvalidation (core/tools/aidlc-validity.ts) already marks downstream artifacts stale/needs-revalidation without resetting completed stages (feat: project and propagate stale stage results #716 mechanism).

The two real gaps

  1. Per-file delta, not store-wide. The freshness verdict today is whole-scope CURRENT/STALE — one changed file flips the entire store STALE with no changed-file set, so there is no "re-scan only what changed". Add a delta computation (git diff of the store's recorded generation vs HEAD, on the existing fingerprint seam) that returns the changed-file set, and make the reverse-engineering developer brief accept it.
  2. Answered questions are not persisted as reusable Q→A pairs at all. QUESTION_ANSWERED events are write-only audit rows read back only for within-attempt authorization — never to pre-fill a later run. A durable, provenance-stamped answer store + a pre-fill reader (invoked before a stage's question fences) is a from-scratch component. Surface "reused N prior answers"; a changed question or changed code must re-ask rather than silently reuse.

Acceptance

  • A second workflow over the same repo/intent completes Initialization by scanning only changed files and reports the cache hit + delta.
  • Questions answered in the first run are not re-asked; the run reports how many prior answers were reused.
  • --rescan full bypasses the cache and re-scans everything.

Notes

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions