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

address review (codex r5): skip a determiner in 'by the <time>' so it isn't read as an agent

[._.]/ Adam Eivy2669df5d3672
diff --git a/server/lib/editorial/proseTics.js b/server/lib/editorial/proseTics.js
index 4c29dd13a9..9b1940aa27 100644
--- a/server/lib/editorial/proseTics.js
+++ b/server/lib/editorial/proseTics.js
@@ -328,9 +328,13 @@ const NON_AGENT_BY = new Set([
'daybreak', 'then', 'now', 'today', 'tonight', 'tomorrow', 'yesterday',
]);
+// Determiners skipped when reading the head noun of a "by <…>" phrase, so
+// "by the morning" resolves to the temporal "morning", not the determiner.
+const BY_DETERMINERS = new Set(['the', 'a', 'an']);
+
// How far past the participle to look for a "by <agent>" phrase, allowing an
-// intervening adverb ("decorated elaborately by Mira").
-const PASSIVE_LOOKAHEAD = 3;
+// intervening adverb and a determiner ("decorated elaborately by the artist").
+const PASSIVE_LOOKAHEAD = 4;
// Whether the subject governing a be-verb at token index `i` is a setting noun.
// The subject is the token right before the be-verb ("the sky was", "her eyes
@@ -388,11 +392,13 @@ export function findPassiveVoice(text) {
}
// An explicit "by <agent>" (with an optional intervening adverb) is the
// unambiguous agentive passive — it wins over stative/mood classification.
- // The agent token must be inside the same-sentence window and must not be a
- // time phrase ("by morning"), which is not an agent.
+ // The agent must be inside the same-sentence window and must not be a time
+ // phrase ("by morning", "by the dawn"), which is not an agent — so skip a
+ // leading determiner to read the head noun.
const byPos = after.findIndex((t) => t.lower === 'by');
- const agentTok = byPos !== -1 ? after[byPos + 1] : undefined;
- const byAgent = !!agentTok && !NON_AGENT_BY.has(agentTok.lower);
+ const byObj = byPos === -1 ? [] : after.slice(byPos + 1);
+ const headTok = byObj[0] && BY_DETERMINERS.has(byObj[0].lower) ? byObj[1] : byObj[0];
+ const byAgent = !!headTok && !NON_AGENT_BY.has(headTok.lower);
let classification = 'weak';
if (!byAgent) {
// A mood image needs BOTH a setting subject AND an atmospheric rendering
diff --git a/server/lib/editorial/proseTics.test.js b/server/lib/editorial/proseTics.test.js
index 196795083f..73624d3060 100644
--- a/server/lib/editorial/proseTics.test.js
+++ b/server/lib/editorial/proseTics.test.js
@@ -194,6 +194,18 @@ describe('findPassiveVoice', () => {
expect(hit.classification).toBe('stative');
});
+ it('skips a determiner to spot a "by the <time>" phrase', () => {
+ const [hit] = findPassiveVoice('She was exhausted by the morning.');
+ expect(hit.byAgent).toBe(false);
+ expect(hit.classification).toBe('stative');
+ });
+
+ it('still treats "by the <agent>" as a real agent', () => {
+ const [hit] = findPassiveVoice('She was exhausted by the climb.');
+ expect(hit.byAgent).toBe(true);
+ expect(hit.classification).toBe('weak');
+ });
+
it('does not read a "by" from the next sentence as the agent', () => {
// "By morning" starts a new sentence — it must not flip the stative
// "was exhausted" into a weak by-agent passive.