Harden the constrained-budget clamp: keep findings, honest flags, guaranteed note

Review follow-ups from Bugbot and Greptile on the clamp fix:

- The clamp retries with the short policy before dropping finding lines
  that fit beside it, and a grouped result that kept only a file header
  no longer counts as a fit.
- The full-footer session flag commits only when the full policy
  actually survived the clamp, so a downgraded emission does not mark
  the session as having seen a policy it never received.
- Render paths reserve room for a pending DESIGN.md staleness note, so
  it is delivered inside the budget on the first emission instead of
  deferring behind full emissions indefinitely.

AI-assisted (Cursor agent), directed and reviewed by @abdulwahabone.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-08-06 15:43:21 +05:00
co-authored by Cursor
parent 31027df81b
commit 328db604b2
3 changed files with 157 additions and 69 deletions
+6 -3
View File
@@ -20,6 +20,8 @@ import {
GENERATED_PATH,
SENSITIVE_PATH,
appendDesignSystemNoteOnce,
commitFooterShown,
designNoteReserve,
designSystemOptions,
footerModeForSession,
filterFindings,
@@ -346,8 +348,8 @@ async function detectProposedHtml(detector, content, filePath, scanOptions) {
}
}
function cursorBlockMessage(findings, filePath, config, cwd, footerMode) {
const rendered = renderTemplate(findings, filePath, config, { cwd, footer: footerMode });
function cursorBlockMessage(findings, filePath, config, cwd, footerMode, reserveChars) {
const rendered = renderTemplate(findings, filePath, config, { cwd, footer: footerMode, reserveChars });
const blocked = rendered.replace(
'[impeccable@1] Design hook findings requiring review',
'[impeccable@1] Impeccable design hook blocked this write before it landed. Design hook findings requiring review',
@@ -475,9 +477,10 @@ async function main() {
// policy: the full footer emits once per session, the short form after.
const footerMode = footerModeForSession(cache, sessionId);
const message = appendDesignSystemNoteOnce(
cursorBlockMessage(filtered, filePath, config, cwd, footerMode),
cursorBlockMessage(filtered, filePath, config, cwd, footerMode, designNoteReserve(scanOptions, cache, sessionId)),
scanOptions, cache, sessionId, config,
);
commitFooterShown(cache, sessionId, message);
const denial = bumpCursorDenial(cache, sessionId, filePath, filtered);
persistCache(cwd, cache);
if (denial.count > EDIT_COUNT_THRESHOLD) {