fix(memory): distinguish incomplete reads from missing records

Independent local Codex review PASS at 73b07f8d17, no P0/P1. Independent 66 tests and strict validation of 810 skills passed. CI run 34683976362 passed; all 48 current checks green. Incomplete memory reads fail closed with safe MCP diagnostics; canonical guidance synchronized across harness skill copies. Rollback: revert this squash commit. No deployment or installation claim.
This commit is contained in:
Affaan Mustafa
2026-09-12 05:52:29 -04:00
committed by GitHub
parent b6ddd13a9f
commit 90ef62cb1d
8 changed files with 222 additions and 2 deletions
+5
View File
@@ -659,6 +659,11 @@ function readMemoryById(id, options = {}) {
? validateSlug(options.targetHarness, 'target harness')
: null;
const loaded = readMemoryFiles(options);
if (loaded.truncated || loaded.invalidFileCount > 0) {
const error = new Error('Memory lookup is incomplete. Inspect the authorized vault before retrying.');
error.code = 'ECC_MEMORY_INCOMPLETE';
throw error;
}
const matches = loaded.entries
.filter(entry => entry.memory.id === memoryId)
.filter(entry => (
+10 -1
View File
@@ -210,6 +210,15 @@ function textResult(payload) {
}
function toolFailure(code, error) {
if (code === 'MEMORY_READ_FAILED' && error?.code === 'ECC_MEMORY_INCOMPLETE') {
return {
...textResult({ error: {
code: 'MEMORY_READ_INCOMPLETE',
message: 'Memory lookup is incomplete. Inspect the authorized vault before retrying.',
} }),
isError: true,
};
}
const suspectedSecret = error instanceof Error
&& error.message.toLowerCase().includes('suspected secret');
const message = suspectedSecret
@@ -217,7 +226,7 @@ function toolFailure(code, error) {
: {
MEMORY_WRITE_REJECTED: 'Memory write was rejected by validation.',
MEMORY_SEARCH_FAILED: 'Memory search failed validation.',
MEMORY_READ_FAILED: 'Memory was not found or is not visible to this harness.',
MEMORY_READ_FAILED: 'Memory could not be read. It may be missing, not visible, or invalid.',
MEMORY_DOCTOR_FAILED: 'Memory doctor could not inspect the authorized vault.',
}[code] || 'Memory operation failed.';
return {