-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cache): invalidate cached responses when .intentrc changes #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,10 @@ type KeyInputs struct { | |
| BinariesFingerprint string | ||
| BackendIdentity string | ||
| PromptTemplateVersion string | ||
| // ProjectRCFingerprint captures .intentrc directives that are | ||
| // rendered into the system prompt. Whitespace-only content hashes | ||
| // to empty so users without a real project config keep today's key. | ||
| ProjectRCFingerprint string | ||
| // UserContextFingerprint captures any --context values that are | ||
| // injected into the system prompt. Order is preserved because the | ||
| // model sees them in order; see UserContextFingerprint. | ||
|
|
@@ -41,12 +45,26 @@ func Key(in KeyInputs) string { | |
| in.BinariesFingerprint, | ||
| in.BackendIdentity, | ||
| in.PromptTemplateVersion, | ||
| in.ProjectRCFingerprint, | ||
| in.UserContextFingerprint, | ||
| } | ||
| h := sha256.Sum256([]byte(strings.Join(parts, "\x1f"))) | ||
| return hex.EncodeToString(h[:]) | ||
| } | ||
|
|
||
| // ProjectRCFingerprint returns a stable fingerprint of .intentrc | ||
| // directives that are injected into the system prompt. Blank or | ||
| // whitespace-only content yields "" so the baseline cache key shape | ||
| // stays unchanged for repos without project directives. | ||
| func ProjectRCFingerprint(contents string) string { | ||
| trimmed := strings.TrimSpace(contents) | ||
| if trimmed == "" { | ||
| return "" | ||
| } | ||
| h := sha256.Sum256([]byte(trimmed)) | ||
|
Comment on lines
+60
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| return hex.EncodeToString(h[:8]) | ||
| } | ||
|
|
||
| // UserContextFingerprint returns a stable fingerprint of the ordered | ||
| // --context values forwarded into the system prompt. Order is preserved | ||
| // because the model sees the entries in order, and two orderings may | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
in.ProjectRCFingerprinttopartsunconditionally changes the serialized key payload for every request (an extra field separator is always inserted), so repositories without.intentrcno longer reuse pre-existing cache entries. That defeats the stated goal of keeping baseline behavior unchanged and causes a broad cache miss wave unrelated to directive changes.Useful? React with 👍 / 👎.