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): let the closing comment refine the generic not_planned decline

[._.]/ Adam Eivy55706fc3e2a7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 8fb86d0d2c..bc6511c4fa 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -26,7 +26,7 @@
- [issue-2689] **Layered Intelligence now tells its reasoner *why* each recently-rejected proposal was turned down, so it stops re-filing known failure patterns.** The loop's self-check already listed the proposals it filed recently that are still suppressed and warned "do NOT re-propose these" — but it named only their dedup slugs, so the reasoner could avoid an exact duplicate yet re-file the very same idea, worded differently, that had already been declined for being out of scope or missing context. Each named proposal now carries the reason it was closed ("— previously closed: outside the app's scope"), read straight from the rejection diagnosis the loop already records, so the reasoner sees the specific failure pattern and can route around it rather than repeating it. Costs no extra AI calls and no extra tracker reads; a proposal that was closed with no recorded reason is simply left unannotated rather than guessed at.
-- [issue-2748] **Layered Intelligence now reads the closing comment to work out why a proposal was declined, not just the label.** When a proposal is closed with no diagnostic label and no machine-readable close reason — a human just typed "this is out of scope" or "can't reproduce, too vague" and closed it (the common case on GitLab/Jira, and often on GitHub too) — the loop now scans that closing comment with a deterministic keyword pass and maps it onto the same taxonomy (out of scope / missing context / quality), so the rationale reaches the feedback loop instead of being recorded as an undiagnosed "no recorded reason". It stays a last-resort signal: an explicit label or close reason still wins, because free text is noisier than something a human deliberately applied. Costs no extra AI calls and no extra tracker reads — the comment text rides along in the issue list the loop already fetches — and nothing about how records are stored changes, so older installs pick this up on the next run with no migration.
+- [issue-2748] **Layered Intelligence now reads the closing comment to work out *why* a proposal was declined, not just that it was.** GitHub records a rejected proposal only as "closed as not planned" — declined, but with no cause — so the loop's most common rejection reason was the generic "the user declined it", which tells the reasoner nothing to route around. When such a close carries a comment that states the cause ("this is out of scope", "can't reproduce, too vague", "low-quality proposal"), the loop now scans that comment with a deterministic keyword pass and sharpens the generic decline into the specific taxonomy token (out of scope / missing context / quality). A specific signal still wins — an explicit label, or a specific close reason like duplicate, outranks the comment, because free text is noisier than something a human deliberately applied — and the comment only ever refines the *reason*, never the merged/rejected outcome, so it can't move the merge rate. Costs no extra AI calls and no extra tracker reads (the comment text rides along in the issue list the loop already fetches), and nothing about how records are stored changes, so older installs re-diagnose their history on the next run with no migration.
- [issue-2689] **Layered Intelligence now diagnoses *why* its proposals were turned down, instead of parroting the tracker back at itself.** When a filed proposal is closed unmerged, it's classified against a fixed vocabulary — duplicate, declined, out of scope, missing context, quality, environment blocker, and more — read from the issue's close reason and its labels, and stored alongside the outcome. The loop's feedback block used to tell it "common rejection reasons: not_planned", which restates the outcome rather than explaining it; it now reads "already tracked elsewhere (2); the user declined it (1)". A proposal closed with nothing to explain it is recorded as an explicit unknown and counted, so "3 of 4 closed with no recorded reason" is reported to the loop as the blind spot it is — never dressed up as a real diagnosis, and never allowed to read as "nothing was ever rejected". Rejections the loop hasn't classified yet are reported as their own separate count rather than being folded in with the ones it examined and couldn't explain, because the two have different remedies. Merged proposals never acquire a rejection reason, which matters for Jira- and PLAN.md-backed apps whose trackers report no close reason at all and whose ordinary close *is* a merge. Costs no extra AI calls and no extra tracker reads — every reason is derived from issue data the loop already fetches — and rejection history recorded before this upgrade is re-diagnosed on the next run rather than needing a reset.
diff --git a/server/services/layeredIntelligenceOutcomes.test.js b/server/services/layeredIntelligenceOutcomes.test.js
index bcc8b7f1e8..1f701d7503 100644
--- a/server/services/layeredIntelligenceOutcomes.test.js
+++ b/server/services/layeredIntelligenceOutcomes.test.js
@@ -287,14 +287,33 @@ describe('reconcileOutcomes', () => {
expect((await rowsBySlug())['mystery'].rejectionReason).toBe('duplicate');
});
- it('lets a real close reason outrank a conflicting closing comment (#2748)', async () => {
- // The comment scan is the WEAKEST signal: an explicit not_planned close reason
- // must still win over prose that would otherwise say scope-mismatch.
- await recordFiledProposal({ appId: 'app-1', slug: 'prose-scope' }, store);
+ it('lets a specific close reason outrank a conflicting closing comment (#2748)', async () => {
+ // A SPECIFIC close reason (duplicate) wins over prose that would otherwise say
+ // scope-mismatch — free text is the noisier signal.
+ await recordFiledProposal({ appId: 'app-1', slug: 'prose-dupe' }, store);
const updated = await reconcileOutcomes({
appId: 'app-1',
existingIssues: [{
- slug: 'prose-scope',
+ slug: 'prose-dupe',
+ state: 'closed',
+ stateReason: 'duplicate',
+ closingComment: 'Appreciate it, but this is out of scope for the app.',
+ closedAt: '2026-07-01T00:00:00Z'
+ }]
+ }, store);
+ expect(updated).toBe(1);
+ expect((await rowsBySlug())['prose-dupe'].rejectionReason).toBe('duplicate');
+ });
+
+ it('refines a generic not_planned decline from the closing comment (#2748)', async () => {
+ // The primary reachable case: deriveOutcome hands a GitHub rejection a
+ // not_planned reason (→ rejected, user-rejected), and the comment sharpens
+ // the WHY. The outcome stays rejected, so the merge rate is unaffected.
+ await recordFiledProposal({ appId: 'app-1', slug: 'refine-me' }, store);
+ const updated = await reconcileOutcomes({
+ appId: 'app-1',
+ existingIssues: [{
+ slug: 'refine-me',
state: 'closed',
stateReason: 'not_planned',
closingComment: 'Appreciate it, but this is out of scope for the app.',
@@ -302,7 +321,9 @@ describe('reconcileOutcomes', () => {
}]
}, store);
expect(updated).toBe(1);
- expect((await rowsBySlug())['prose-scope'].rejectionReason).toBe('user-rejected');
+ const row = (await rowsBySlug())['refine-me'];
+ expect(row.outcome).toBe('rejected');
+ expect(row.rejectionReason).toBe('scope-mismatch');
});
it('lets the closing comment diagnose a close that carries no other signal (#2748)', async () => {
diff --git a/server/services/layeredIntelligenceRejections.js b/server/services/layeredIntelligenceRejections.js
index 967bca2d80..e562a66c4b 100644
--- a/server/services/layeredIntelligenceRejections.js
+++ b/server/services/layeredIntelligenceRejections.js
@@ -160,6 +160,14 @@ const STATE_REASON_REASONS = new Map(Object.entries({
'duplicate': 'duplicate'
}));
+// Diagnoses that name only THAT a proposal was declined, not WHY — GitHub's
+// generic `not_planned` close. A specific closing-comment rationale is allowed to
+// refine one of these into a precise taxonomy token (not_planned + "out of scope"
+// → scope-mismatch); a SPECIFIC close reason (duplicate) is never refined. The
+// refinement changes only the reason token, never the OUTCOME (deriveOutcome has
+// already fixed that), so the merge rate the reasoner calibrates on is untouched.
+const GENERIC_REJECTION_REASONS = new Set(['user-rejected']);
+
// Closing-comment keyword pass (#2748). Some closures state their rationale only in
// prose — a human declines in a comment without applying a matching label or (on
// glab/jira) any close reason at all. This is a DETERMINISTIC keyword/heuristic
@@ -249,10 +257,19 @@ export function classifyClosingComment(text) {
* asks for — "how much of our rejection history is undiagnosed" — so it must
* never be silently dressed up as a real reason.
*
- * Signal precedence (most authoritative first): a human-applied label, then the
- * tracker's close reason, then the deterministic closing-comment keyword pass
- * (#2748). Explicit signals a human/agent deliberately set outrank a prose
- * heuristic, so the comment scan only decides an otherwise-undiagnosed close.
+ * Signal precedence (most authoritative first):
+ * 1. a human-applied label (the most deliberate signal);
+ * 2. a SPECIFIC tracker close reason (duplicate);
+ * 3. the deterministic closing-comment keyword pass (#2748);
+ * 4. a GENERIC tracker close reason (GitHub `not_planned` → user-rejected: it
+ * says the proposal was declined, but not why).
+ * The comment sits BELOW a label/specific reason but ABOVE the generic decline, so
+ * a prose rationale REFINES a bare not_planned into a precise token instead of
+ * being shadowed by it — the refinement changes only the reason, never the
+ * outcome deriveOutcome already fixed, so it can't move the merge rate. The comment
+ * NEVER overrides the merged fallback (deriveOutcome runs first and never reaches
+ * here for a merge), so the reasonless-close-reads-as-merged gap the module header
+ * documents is untouched by this pass.
*
* Deterministic and total: same inputs always yield the same token.
*/
@@ -260,22 +277,25 @@ export function classifyRejection({ outcome = null, stateReason = null, labels =
// Only a resolved, non-merged proposal has a rejection to explain.
if (outcome !== 'rejected' && outcome !== 'abandoned') return null;
- // A human-applied label is the most specific signal available; first match wins
- // in the tracker's own label order.
+ // 1. A human-applied label is the most specific signal available; first match
+ // wins in the tracker's own label order.
for (const label of Array.isArray(labels) ? labels : []) {
const hit = LABEL_REASONS.get(normalizeToken(label));
if (hit) return hit;
}
- // The tracker's own close reason (GitHub only) outranks free-text prose.
+ // 2. A SPECIFIC tracker close reason (duplicate) outranks free-text prose.
const stateHit = STATE_REASON_REASONS.get(normalizeToken(stateReason));
- if (stateHit) return stateHit;
+ if (stateHit && !GENERIC_REJECTION_REASONS.has(stateHit)) return stateHit;
- // Last resort before the honest unknown: scan the closing-comment prose for a
- // rationale a human stated without a matching label/close reason.
+ // 3. The closing-comment keyword pass — refines a generic decline, or diagnoses a
+ // close whose (abandoned) reason isn't otherwise recognized.
const commentHit = classifyClosingComment(closingComment);
if (commentHit) return commentHit;
+ // 4. The generic close reason, when the comment named nothing specific.
+ if (stateHit) return stateHit;
+
return UNKNOWN_REJECTION_REASON;
}
diff --git a/server/services/layeredIntelligenceRejections.test.js b/server/services/layeredIntelligenceRejections.test.js
index b35faa745d..39e1a59c71 100644
--- a/server/services/layeredIntelligenceRejections.test.js
+++ b/server/services/layeredIntelligenceRejections.test.js
@@ -134,18 +134,41 @@ describe('classifyRejection', () => {
})).toBe('missing-context');
});
- it('lets a label and a close reason both outrank a conflicting closing comment', () => {
- // Free text is noisier than a deliberately-applied signal, so it must never
- // override one — it only decides an otherwise-undiagnosed close.
+ it('lets a label and a SPECIFIC close reason outrank a conflicting closing comment', () => {
+ // Free text is noisier than a deliberately-applied signal, so a label and a
+ // specific close reason (duplicate) both win over the comment.
expect(classifyRejection({
outcome: 'rejected',
labels: ['duplicate'],
closingComment: 'this is out of scope'
})).toBe('duplicate');
+ expect(classifyRejection({
+ outcome: 'abandoned',
+ stateReason: 'duplicate',
+ closingComment: 'low quality proposal'
+ })).toBe('duplicate');
+ });
+
+ it('lets a specific closing comment REFINE the generic not_planned decline (#2748)', () => {
+ // not_planned says the proposal was declined but not WHY. A prose rationale
+ // sharpens that generic decline into a precise taxonomy token — the primary
+ // reachable case, since deriveOutcome hands most GitHub rejections a not_planned
+ // reason. The outcome is unchanged, so this can't move the merge rate.
expect(classifyRejection({
outcome: 'rejected',
stateReason: 'not_planned',
closingComment: 'low quality proposal'
+ })).toBe('quality-issue');
+ expect(classifyRejection({
+ outcome: 'rejected',
+ stateReason: 'not_planned',
+ closingComment: 'Appreciate it, but this is out of scope for the app.'
+ })).toBe('scope-mismatch');
+ // With no specific rationale in the comment, the generic decline stands.
+ expect(classifyRejection({
+ outcome: 'rejected',
+ stateReason: 'not_planned',
+ closingComment: 'Closing this out, thanks.'
})).toBe('user-rejected');
});