For any code that parses/normalizes strings or aggregates structured events, require deterministic, complete, and bounded logic:
Example (quote-aware normalization pattern):
export function normalizeNulRedirects(command: string): string {
if (process.platform !== "win32") return command;
let out = "";
let inSingle = false;
let inDouble = false;
for (let i = 0; i < command.length; i++) {
const ch = command[i];
if (ch === "'" && !inDouble) inSingle = !inSingle;
else if (ch === '"' && !inSingle) {
const escaped = (() => {
let bs = 0;
for (let k = i - 1; k >= 0 && command[k] === "\\"; k--) bs++;
return bs % 2 === 1;
})();
if (!escaped) inDouble = !inDouble;
}
out += ch;
// Only rewrite redirects when not inside quotes (bounded, deterministic)
// if (!inSingle && !inDouble && matchesNulRedirectAt(i, command)) { ... }
}
return out;
}
Apply the same standard to metrics aggregation: ensure guards don’t accidentally skip new contributors (e.g., treat any entry type with usage as a candidate for token/cost accumulation).
Enter the URL of a public GitHub repository