Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep `of` out of the regex-start keyword set (#7945)

[._.]/ Adam Eivy0bebd778871f
diff --git a/server/lib/sourceScan.js b/server/lib/sourceScan.js
index ab57837e51..d5ef8d5511 100644
--- a/server/lib/sourceScan.js
+++ b/server/lib/sourceScan.js
@@ -40,9 +40,18 @@ export function blankComments(src) {
// never division, because a keyword cannot be an operand — `await /[)]/.test(s)`
// and `return /a/` both open a regex. Reading one as division blanked nothing,
// so the regex body's own brackets skewed the caller's bracket walk.
+//
+// RESERVED WORDS ONLY, and the two errors are not symmetrical. Missing a real
+// regex context restores the old behavior: the literal is read as division,
+// nothing is blanked, and the scan is conservative. Listing a word that can
+// also be an IDENTIFIER is corrupting: `const of = 4; f(of / n)` would lex the
+// division as a regex opener and blank the rest of the line, hiding whatever
+// came after it. So `of` — a contextual keyword and a legal identifier — is
+// deliberately absent, while `await` and `yield` are in: every source these
+// guards read is an ES module, where both are reserved.
const KEYWORDS_BEFORE_REGEX = new Set([
- 'await', 'case', 'delete', 'do', 'else', 'in', 'instanceof', 'new', 'of',
- 'return', 'throw', 'typeof', 'void', 'yield',
+ 'await', 'case', 'default', 'delete', 'do', 'else', 'extends', 'in',
+ 'instanceof', 'new', 'return', 'throw', 'typeof', 'void', 'yield',
]);
/**
diff --git a/server/logLevelConventions.test.js b/server/logLevelConventions.test.js
index 768117e757..aa83e193a7 100644
--- a/server/logLevelConventions.test.js
+++ b/server/logLevelConventions.test.js
@@ -264,6 +264,16 @@ describe('the failure-log recognizer', () => {
const ratio = total / count;
console.log(\`${CROSS_MARK} failed at \${ratio}\`);
`)).toHaveLength(1);
+ // `of` is a contextual keyword AND a legal identifier, so it must stay out
+ // of the keyword set: reading `of / n` as a regex opener blanks the rest of
+ // the line and the marker after it vanishes.
+ expect(findMislabeledFailureLogs(
+ `const of = 4; console.log(of / (count), \`${CROSS_MARK} failed\`);`,
+ )).toHaveLength(1);
+ // A property named after a keyword is a value, so the `/` after it divides.
+ expect(findMislabeledFailureLogs(
+ `console.log(limits.in / (count), \`${CROSS_MARK} failed\`);`,
+ )).toHaveLength(1);
});
// Bypass probe: the scan is only worth its runtime if a reintroduced