fix(estimate): read-only estimation + collision-proof story-ID prefix#78
Merged
Conversation
…refix Ports the VXD fix (vortex-dispatch #82) — the same bug exists here. `nxd estimate` would crash on the second run of the year with "UNIQUE constraint failed: stories.id". Two causes: 1. Estimation ran the real planner, which persists STORY_CREATED into the project DB. An estimate is a read-only quote and must not write requirement/story rows. New Planner.PlanEphemeral runs the same decomposition with every event-store/projection write gated off; Estimator uses it. 2. Story IDs were namespaced by truncating the reqID to its first 8 chars. Estimate reqIDs ("est-YYYYMMDD-...") all collapsed to the constant "est-2026"; ULID reqIDs collided within ~256ms (a ULID's entropy is in its trailing chars). storyIDPrefix now hashes the full reqID (sha256, first 8 hex) for IDs >8 chars; short IDs stay verbatim. Offline-first core untouched — this is the planner/estimator only; no cloud providers or model-ID changes (those VXD changes are not applicable to NXD). Tests: storyIDPrefix uniqueness/determinism, PlanEphemeral persists nothing, estimator survives repeated submissions with zero stories leaked. Two integration tests updated to the new prefix scheme. Full suite green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the VXD fix (vortex-dispatch #82) — the identical bug exists in NXD's planner/estimator.
Problem
nxd estimatecrashes on the second run withUNIQUE constraint failed: stories.id:prefix[:8]— estimate reqIDs (est-YYYYMMDD-…) all collapse to the constantest-2026; ULID reqIDs collide within ~256ms.Fix
Planner.PlanEphemeral— same decomposition, all event-store/projection writes gated off.Estimatoruses it.storyIDPrefix(reqID)—≤8chars verbatim; longer →sha256(reqID)first 8 hex.Scope / offline-first
Planner + estimator only. No cloud providers, Codex, or Anthropic model-ID changes — those VXD changes are cloud-specific and deliberately not ported, keeping NXD's Ollama offline-first core intact.
Tests
storyIDPrefix uniqueness/determinism; PlanEphemeral persists nothing; estimator survives repeated submissions with zero stories leaked; 2 integration tests updated. Full suite green.