fix: dedup a promoted instinct in the inject block#105
Merged
Conversation
When a project instinct and a global instinct share the same ID (the project->global promotion case), Build now emits only the project version and suppresses the global twin, matching ECC's project-overrides-global precedence. The merge runs before the confidence floor, so a below-floor project instinct still shadows its promoted global copy instead of letting the stale global version resurface. Tests: TestBuild_ProjectShadowsGlobalOnIDCollision (shared deduped, global-only kept) and TestBuild_BelowFloorProjectStillShadowsGlobal (below-floor project still shadows, neither injected).
ikeikeikeike
commented
Jul 14, 2026
| // letting the stale global copy resurface. | ||
| projectIDs := make(map[string]bool, len(project)) | ||
| for _, in := range project { | ||
| projectIDs[in.ID] = true |
Member
Author
There was a problem hiding this comment.
projectIDs[in.ID] = true is recorded unconditionally, before the confidence-floor check. Session evaluation (internal/session/evaluate.go) only ever adjusts confidence for the project-scope instinct file; the promoted global twin (internal/cli/instinct_promote.go) is never touched by it. So once a promoted project instinct independently decays below MinConfidence (e.g. after a correction), this line still shadows its still-valid, higher-confidence global twin — the promoted knowledge silently stops appearing in the inject block, with no error or log.
Fix: only record the shadow when the project instinct itself clears the floor (i.e. is actually part of the pool). Pushing that change now.
… twin Session evaluation (internal/session/evaluate.go) only ever adjusts confidence for the project-scope instinct file; the promoted global twin (internal/cli/instinct_promote.go) is never touched by it. The previous merge recorded a project ID's shadow unconditionally, before the confidence-floor check, so a promoted project instinct that independently decays below MinConfidence (e.g. after a correction) still suppressed its still-valid, higher-confidence global twin -- the promoted knowledge would silently stop appearing in the inject block, with no error or log. Only record the shadow when the project instinct itself clears the floor (i.e. is actually part of the pool). Renamed TestBuild_BelowFloorProjectStillShadowsGlobal to TestBuild_BelowFloorProjectDoesNotShadowGlobal to assert the corrected behavior: the global twin still injects. Found by code review on PR #105.
4 tasks
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.
Why
The UserPromptSubmit inject block double-listed an instinct once it was promoted project->global: the project copy and the promoted global twin (same ID) both rendered as separate lines.
What
inject.Buildnow merges by ID before the confidence floor — a project instinct shadows the same-ID global one, so only the project version is injected (ECC's project-overrides-global precedence). Running the merge before the floor means a below-floor project instinct still suppresses its promoted global twin instead of letting the stale global copy resurface.Tests
TestBuild_ProjectShadowsGlobalOnIDCollision— shared ID deduped, global-only instinct still kept.TestBuild_BelowFloorProjectStillShadowsGlobal— below-floor project shadows its global twin (neither injected).go test ./internal/inject/+golangci-lintgreen.