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

Function orderRefusal

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

* The order of the statements, checked where the facts cannot check it. * * The fact check compares position by position, which catches a model that * moved a name or a number. It cannot catch two sentences that carry no fact * at all being swapped: both sides look identical to it, and the reade

(lines: readonly ReaderLine[], incoming: readonly string[])

Source from the content-addressed store, hash-verified

176 * sentence's words and almost none of a different sentence's.
177 */
178function orderRefusal(lines: readonly ReaderLine[], incoming: readonly string[]): string {
179 const built = lines.map((line) => wordSet(line.text));
180 for (let index = 0; index < incoming.length; index += 1) {
181 const rewritten = wordSet(incoming[index]);
182 const mine = overlap(rewritten, built[index]);
183 for (let other = 0; other < built.length; other += 1) {
184 if (other !== index && overlap(rewritten, built[other]) > mine) {
185 return `sentence ${index + 1} reads like the built sentence ${other + 1}, `
186 + 'so the statements came back in a different order';
187 }
188 }
189 }
190 return '';
191}
192
193/** Why one line was rejected, or the empty string when it was fine. */
194function lineRefusal(original: ReaderLine, incoming: string, index: number): string {

Callers 1

applyReaderRewriteFunction · 0.85

Calls 2

wordSetFunction · 0.85
overlapFunction · 0.70

Tested by

no test coverage detected