MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / refusalReason

Function refusalReason

graph-ui/src/pseudocode/refine.ts:87–105  ·  view source on GitHub ↗
(document: PseudocodeDocument, answer: string)

Source from the content-addressed store, hash-verified

85 * name which one fired.
86 */
87export function refusalReason(document: PseudocodeDocument, answer: string): string {
88 const incoming = refinedLines(unfence(answer));
89 if (incoming.length === 0) {
90 return REFINE_REASON_EMPTY;
91 }
92 if (incoming.length !== document.lines.length) {
93 return `${REFINE_REASON_COUNT} (${incoming.length} instead of ${document.lines.length})`;
94 }
95 for (let index = 0; index < document.lines.length; index++) {
96 const expected = document.lines[index].order;
97 const actual = leadingNumberOf(incoming[index]);
98 if (expected !== actual) {
99 return `${REFINE_REASON_NUMBERS} (line ${index + 1}: expected `
100 + `${expected === undefined ? 'no number' : expected} and got `
101 + `${actual === undefined ? 'no number' : actual})`;
102 }
103 }
104 return 'the rewrite did not map onto the block it was built from';
105}
106
107/**
108 * Put a model answer back onto the block, or refuse with a reason.

Callers 2

refine.test.tsFile · 0.90
applyRefinementFunction · 0.85

Calls 3

leadingNumberOfFunction · 0.90
refinedLinesFunction · 0.85
unfenceFunction · 0.85

Tested by

no test coverage detected