chore(sf): residual edits in auto-post-unit + auto-prompts

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-02 02:44:45 +02:00
parent effada2bb4
commit a4a9c70c65
2 changed files with 45 additions and 0 deletions

View file

@ -1540,6 +1540,38 @@ export async function postUnitPostVerification(
}
}
// ── Knowledge compounding (Mechanism 4) ──
// After milestone completion, distill high-confidence judgment-log entries
// into .sf/KNOWLEDGE.md so the next milestone benefits from them.
// Failure is always non-fatal.
if (s.currentUnit?.type === "complete-milestone") {
const milestoneIdForCompound = parseUnitId(s.currentUnit.id).milestone;
if (milestoneIdForCompound) {
try {
const { compoundLearningsIntoKnowledge } = await import(
"./knowledge-compounding.js"
);
const result = compoundLearningsIntoKnowledge(
s.basePath,
milestoneIdForCompound,
);
if (result.added > 0) {
debugLog("postUnit", {
phase: "knowledge-compounding",
milestoneId: milestoneIdForCompound,
added: result.added,
skipped: result.skipped,
});
}
} catch (err) {
debugLog("postUnit", {
phase: "knowledge-compounding",
error: (err as Error).message,
});
}
}
}
// ── Post-unit hooks ──
if (s.currentUnit && !s.stepMode) {
const hookUnit = checkPostUnitHooks(

View file

@ -1757,6 +1757,19 @@ export async function buildPlanMilestonePrompt(
`## Inlined Context (preloaded — do not re-read these files)\n\n${inlined.join("\n\n---\n\n")}`,
);
// Milestone framing check — surfaces anti-goal violations and vision-alignment
// concerns in the planning context. Non-blocking: the agent reads and decides.
let framingBlock = "";
try {
const { checkMilestoneFraming, formatFramingFindings } = await import(
"./milestone-framing-check.js"
);
const framingFindings = checkMilestoneFraming(base, mid);
framingBlock = formatFramingFindings(mid, framingFindings);
} catch {
// Non-fatal — framing check must never break milestone planning
}
const outputRelPath = relMilestoneFile(base, mid, "ROADMAP");
const researchOutputPath = join(
base,