MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / main

Function main

scripts/fungrim/guard-census.ts:127–307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125}
126
127function main(): void {
128 const corpus = loadCorpus(DATA_DIR);
129 const ce = createEngine(corpus.declarations);
130
131 // CE emits console noise (compilation fallbacks for shell heads, assume
132 // internal errors that are caught and rethrown...). Keep the census
133 // output readable.
134 const savedWarn = console.warn;
135 const savedError = console.error;
136 const savedInfo = console.info;
137 console.warn = () => {};
138 console.error = () => {};
139 console.info = () => {};
140
141 const byLevel = new Map<string, LevelStats>();
142 const perEntry: Record<
143 string,
144 { guardLevel: string; outcome: EntryOutcome; ms: number }
145 > = {};
146
147 let processed = 0;
148 const t0 = Date.now();
149
150 try {
151 for (const e of corpus.entries) {
152 if (e.assumptions === null || e.assumptions === undefined) continue;
153
154 let stats = byLevel.get(e.guardLevel);
155 if (!stats) {
156 stats = newLevelStats();
157 byLevel.set(e.guardLevel, stats);
158 }
159 stats.entries += 1;
160 processed += 1;
161
162 const start = Date.now();
163 let outcome: EntryOutcome;
164 try {
165 outcome = classifyEntry(ce, e);
166 } catch {
167 outcome = 'assume-threw';
168 }
169 const ms = Date.now() - start;
170 if (ms > TIME_GUARD_MS) outcome = 'timeout';
171
172 perEntry[`${e.topic}/${e.id}`] = {
173 guardLevel: e.guardLevel,
174 outcome,
175 ms,
176 };
177
178 const assumeFailures: EntryOutcome[] = [
179 'not-a-predicate',
180 'contradiction',
181 'internal-error',
182 'assume-threw',
183 ];
184 if (!assumeFailures.includes(outcome) && outcome !== 'timeout')

Callers 1

guard-census.tsFile · 0.70

Calls 14

loadCorpusFunction · 0.90
createEngineFunction · 0.90
newLevelStatsFunction · 0.85
classifyEntryFunction · 0.85
toFixedMethod · 0.80
pctFunction · 0.70
getMethod · 0.65
setMethod · 0.65
hasMethod · 0.65
keysMethod · 0.65
logMethod · 0.65
entriesMethod · 0.65

Tested by

no test coverage detected