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

Function lineRefusal

graph-ui/src/twin/reader-rewrite.ts:194–218  ·  view source on GitHub ↗

Why one line was rejected, or the empty string when it was fine.

(original: ReaderLine, incoming: string, index: number)

Source from the content-addressed store, hash-verified

192
193/** Why one line was rejected, or the empty string when it was fine. */
194function lineRefusal(original: ReaderLine, incoming: string, index: number): string {
195 const where = `sentence ${index + 1}`;
196 if (incoming.trim().length === 0) {
197 return `${where} came back empty`;
198 }
199 if (incoming.length > lengthCeiling(original.text)) {
200 return `${where} came back ${incoming.length} characters long, over the ceiling of `
201 + `${lengthCeiling(original.text)} for a sentence of ${original.text.length}`;
202 }
203 const got = factsOf(incoming);
204 const want = original.facts;
205 for (let at = 0; at < Math.max(want.length, got.length); at += 1) {
206 if (want[at] === got[at]) {
207 continue;
208 }
209 if (want[at] === undefined) {
210 return `${where} added "${got[at]}", which is not in the sentence it was given`;
211 }
212 if (got[at] === undefined) {
213 return `${where} dropped "${want[at]}"`;
214 }
215 return `${where} says "${got[at]}" where the built sentence says "${want[at]}"`;
216 }
217 return '';
218}
219
220/**
221 * Put a model answer back onto the level's sentences, or refuse with a reason.

Callers 1

applyReaderRewriteFunction · 0.85

Calls 2

lengthCeilingFunction · 0.85
factsOfFunction · 0.70

Tested by

no test coverage detected