MCPcopy Create free account
hub / github.com/SethGammon/Citadel / verifyJsonlFile

Function verifyJsonlFile

core/telemetry/integrity.js:150–193  ·  view source on GitHub ↗
(filePath, options = {})

Source from the content-addressed store, hash-verified

148}
149
150function verifyJsonlFile(filePath, options = {}) {
151 const summary = {
152 file: filePath,
153 exists: fs.existsSync(filePath),
154 total: 0,
155 verified: 0,
156 signed: 0,
157 legacy: 0,
158 tampered: [],
159 invalid: [],
160 signatureWarnings: [],
161 };
162
163 if (!summary.exists) return summary;
164
165 const lines = fs.readFileSync(filePath, 'utf8').split(/\r?\n/).filter(Boolean);
166 for (let index = 0; index < lines.length; index++) {
167 summary.total++;
168 let record;
169 try {
170 record = JSON.parse(lines[index]);
171 } catch (error) {
172 summary.invalid.push({ lineNumber: index + 1, reason: `invalid JSON: ${error.message}` });
173 continue;
174 }
175
176 const result = verifyRecord(record, options);
177 if (result.status === 'verified' || result.status === 'verified-signed') {
178 summary.verified++;
179 if (result.status === 'verified-signed') summary.signed++;
180 } else if (result.status === 'legacy') {
181 summary.legacy++;
182 } else if (result.status === 'tampered') {
183 summary.tampered.push({ lineNumber: index + 1, event_id: record.event_id || null, reason: result.reason });
184 } else if (result.status === 'verified-unsigned-key-missing' || result.status === 'signature-unsupported') {
185 summary.verified++;
186 summary.signatureWarnings.push({ lineNumber: index + 1, event_id: record.event_id || null, reason: result.reason });
187 } else {
188 summary.invalid.push({ lineNumber: index + 1, reason: result.reason });
189 }
190 }
191
192 return summary;
193}
194
195function collectJsonlFiles(projectRoot) {
196 const roots = [

Callers 2

verifyProjectTelemetryFunction · 0.85

Calls 1

verifyRecordFunction · 0.85

Tested by

no test coverage detected