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

require a numeric value before flagging a positional key in a generated manifest

[._.]/ Adam Eivyea404b7e3157
diff --git a/server/lib/generatedManifests.test.js b/server/lib/generatedManifests.test.js
index 5bf71ae6d4..d9835e86fb 100644
--- a/server/lib/generatedManifests.test.js
+++ b/server/lib/generatedManifests.test.js
@@ -39,6 +39,13 @@ const POSITIONAL_KEYS = new Set([
'loc', 'position',
]);
+// A position is always a number. Several of these key names have perfectly
+// good non-positional uses with a non-numeric value — a `column` naming a
+// Postgres column, a `position` holding `"left"` — and rejecting those would
+// make this guard block manifests it has no quarrel with.
+const isPositionalValue = (value) => typeof value === 'number'
+ || (typeof value === 'string' && /^\d+$/.test(value.trim()));
+
// A `path/to/file.js:412` (optionally `:8` for a column) pointer smuggled into
// a string, which is how a positional reference survives dropping the key.
const SOURCE_POINTER_RE = /[\w./-]+\.(?:js|jsx|mjs|cjs|ts|tsx|json|md):\d+(?::\d+)?/;
@@ -51,7 +58,7 @@ export const findPositionalReferences = (value, path = '$') => {
if (value && typeof value === 'object') {
return Object.entries(value).flatMap(([key, entry]) => {
const child = `${path}.${key}`;
- if (POSITIONAL_KEYS.has(key) && (typeof entry === 'number' || typeof entry === 'string')) {
+ if (POSITIONAL_KEYS.has(key) && isPositionalValue(entry)) {
return [`${child} — positional key "${key}"`];
}
return findPositionalReferences(entry, child);
@@ -103,8 +110,15 @@ describe('checked-in generated manifests', () => {
.toEqual(['$.sources[0] — file:line pointer in "server/routes/a.js:412"']);
expect(findPositionalReferences({ at: { startLine: 3, endLine: 9 } }))
.toHaveLength(2);
- // Plain file paths and ordinary counts are what a manifest SHOULD contain.
+ // A numeric string is still a position — dropping the type doesn't help.
+ expect(findPositionalReferences({ loc: { line: '412' } }))
+ .toEqual(['$.loc.line — positional key "line"']);
+ // Plain file paths and ordinary counts are what a manifest SHOULD contain,
+ // and a positional-sounding key holding a non-numeric value is not a
+ // position at all — a Postgres column name, a layout side.
expect(findPositionalReferences({ sources: ['server/routes/a.js'], stats: { operations: 2153 } }))
.toEqual([]);
+ expect(findPositionalReferences({ column: 'user_id', position: 'left' }))
+ .toEqual([]);
});
});