Doenexecutor memory research
Prompt 10
take the next step using data from the live build-doen project (postgresql://[redacted]
Claude
I'll look at what human decisions exist in build-doen beyond the 15 escalations. Accepted or rejected proposals and spec items could each become a replay question.
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select relname, n_live_tup from pg_stat_user_tables order by 2 desc" | head -30; psql "$U" -Atc "select count(*), sum((i.archived_at is null)::int) from initiatives i where project_id='build-doen'; select state,count(*) from initiatives where project_id='build-doen' group by 1;"
Result
_migrations|0
projects|0
specs|0
memory|0
initiatives|0
llm_cost_log|0
memory_correction_reviews|0
dismissed_spec_loops|0
decisions|0

107|83
draft|19
building|4
complete|84
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select jsonb_object_keys(doc) k, count(*) from specs s join initiatives i on i.id=s.initiative_id where i.project_id='build-doen' group by 1 order by 2 desc"; echo; psql "$U" -Atc "select k, count(*) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'acceptance_criteria') c, jsonb_object_keys(c) k where i.project_id='build-doen' group by 1 order by 2 desc"
Result
intent|107
state|107
constraints|107
initiative_id|107
discretion|107
id|107
acceptance|107
title|107
version|107
initiative_type|93
shaping_status|88
original_description|88
Tool call: Bash
export U='postgresql://[redacted]'; for f in acceptance constraints discretion; do echo "== $f"; psql "$U" -Atc "select k, count(*) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'$f') c, jsonb_object_keys(c) k where i.project_id='build-doen' group by 1 order by 2 desc"; done; psql "$U" -Atc "select c->>'status', c->>'provenance', count(*) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'constraints'||s.doc->'discretion'||s.doc->'acceptance') c where i.project_id='build-doen' group by 1,2 order by 3 desc"
Result
== acceptance
text|789
confirmed_at|789
created_at|789
status|789
id|789
verify|789
provenance|789
feedback|763
verdict|763
verification_status|763
evidence|763
advisor_classification_reason|690
advisor_preliminary_verdict|690
advisor_preliminary_notes|690
advisor_classification|690
approved_by|607
revision_count|451

== constraints
provenance|1002
confirmed_at|1002
created_at|1002
status|1002
id|1002
text|1002
advisor_classification_reason|880
advisor_classification|880

== discretion
provenance|728
confirmed_at|728
created_at|728
status|728
id|728
text|728
advisor_classification_reason|619
advisor_classification|619
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select c->>'status', c->>'provenance', count(*) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'constraints'||(s.doc->'discretion')||(s.doc->'acceptance')) c where i.project_id='build-doen' group by 1,2 order by 3 desc"; psql "$U" -Atc "select c->>'verification_status', c->>'approved_by', count(*) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'acceptance') c where i.project_id='build-doen' group by 1,2 order by 3 desc limit 12"; psql "$U" -Atc "select count(*), count(learnings), count(outcome) from memory m join initiatives i on i.id=m.initiative_id where project_id='build-doen'"
Result
confirmed|ai_confirmed_by_human|1916
proposed|ai_proposed|365
confirmed|human|201
proposed|human|29
retired|ai_confirmed_by_human|7
retired|human|1

verified|advisor|303
verified|human|179
pending||131
verified||114
evidence_submitted||36
||26

85|61|65
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select c->>'approved_by', coalesce((c->>'revision_count')::int,0)>0, c->'verify'->>'kind', count(*) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'acceptance') c where i.project_id='build-doen' and c->>'verification_status'='verified' group by 1,2,3 order by 1,3,2"; psql "$U" -Atc "select jsonb_typeof(c->'feedback'), left(c->>'feedback',300), left(c->>'verdict',200), c->>'revision_count' from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'acceptance') c where i.project_id='build-doen' and (c->>'revision_count')::int>0 and c->>'approved_by'='human' limit 4"
Result
advisor|f|behavior|28
advisor|f|metric|4
advisor|f|test|271
human|f|behavior|49
human|f|human_judgment|57
human|f|metric|13
human|f|test|60
|f|behavior|57
|f|human_judgment|13
|f|metric|1
|f|test|43
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select c->>'revision_count', count(*), sum((coalesce(c->>'feedback','')<>'')::int) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'acceptance') c where i.project_id='build-doen' group by 1"; psql "$U" -Atc "select left(c->>'feedback',250) from specs s join initiatives i on i.id=s.initiative_id, jsonb_array_elements(s.doc->'acceptance') c where i.project_id='build-doen' and coalesce(c->>'feedback','')<>'' limit 5"; grep -n "revision_count\|feedback" docs/data-model.md | head
Result
|338|0
0|451|0


2 matches in 1 files:

docs/data-model.md:12:`heuristic_merge_proposals`, `citation_feedback_events`, `extraction_failures...
docs/data-model.md:325:| `feedback` | `str \| None` | `None` | Human note when verdict is `changes_r...
Claude
I'm looking for human decisions in build-doen beyond the 15 escalations. The spec items carry no verdict history and no rejections, so I'm checking the learn records next.
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select k, count(*) from memory m join initiatives i on i.id=m.initiative_id, jsonb_object_keys(m.outcome) k where project_id='build-doen' group by 1"; psql "$U" -Atc "select left(m.outcome->>'learning_approvals',500) from memory m join initiatives i on i.id=m.initiative_id where project_id='build-doen' and m.outcome ? 'learning_approvals' and jsonb_array_length(m.outcome->'learning_approvals')>0 limit 2"; psql "$U" -Atc "select count(*) from decisions d join initiatives i on i.id=d.initiative_id where project_id='build-doen'; select status, (payload->>'chosen' = any(array(select jsonb_array_elements_text(payload->'options')))), retired_at is null, count(*) from decisions d join initiatives i on i.id=d.initiative_id where project_id='build-doen' group by 1,2,3"
Result
metrics|46
rationale_claims|64
learning_approvals|61
conclusion|3

[{"text": "When two entry points (HTTP and MCP) need divergent response-timing contracts, isolate the shared computation into a pure function first — then each path can call it synchronously or fire it as a background task without duplicating evaluation logic.", "approved_by": "auto"}, {"text": "Designing for graceful degradation at the protocol boundary (returning HTTP 200 with null verdict fields on LLM failure) prevents the caller from being blocked by infrastructure instability without requi
[{"text": "Normalising the combined retrieval score to [0,1] before exposing it on the result model preserves a stable, interpretable contract for downstream consumers even when the underlying scoring formula changes.", "approved_by": "auto"}, {"text": "Maintain the tsvector column as a generated or trigger-updated column rather than computing it at query time — this keeps write-time cost predictable and ensures GIN index freshness without application-layer coordination.", "approved_by": "auto"}

24
resolved|f|t|9
resolved|t|t|15
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select a->>'approved_by', a ? 'rejected', count(*) from memory m join initiatives i on i.id=m.initiative_id, jsonb_array_elements(m.outcome->'learning_approvals') a where project_id='build-doen' group by 1,2"; psql "$U" -Atc "select jsonb_object_keys(a), count(*) from memory m join initiatives i on i.id=m.initiative_id, jsonb_array_elements(m.outcome->'learning_approvals') a where project_id='build-doen' group by 1"; psql "$U" -Atc "select left(payload->>'question',120), payload->'options', left(payload->>'chosen',200) from decisions d join initiatives i on i.id=d.initiative_id where project_id='build-doen' and not (payload->>'chosen' = any(array(select jsonb_array_elements_text(payload->'options'))))" | cut -c1-500
Result
auto|f|174
human|f|1

approved_by|175
text|175

When an initiative is partially redundant with one initiative AND partially conflicting with another, what verdict shoul|["One dominant verdict (pick the stronger signal, e.g., 'conflicting' wins over 'redundant')", "List both verdicts separately (e.g., 'redundant with X, conflicting with Y')", "Escalate to a fourth verdict type like 'complex' or 'mixed'"]|Proceed with listing both verdicts separately and citing the specific conflicting and redundant initiatives, so the user receives a transpare
Should detected spec loops be surfaced only on the project dashboard, or also inline on the relevant initiative pages?|["Dashboard only (v1)", "Dashboard plus inline on initiative pages"]|Proceed with Dashboard only (v1) as recommended — the spec explicitly grants latitude here, and the executor's rationale (simpler dismissal state, dashboard as primary aggregation point) is sound with
What cosine-similarity threshold should define 'substantially rewritten' for heuristic-grounded spec items at the start-|["0.75 — conservative: light edits and paraphrases count as survived; only clear content changes count as removed (recommended)", "0.85 — stricter: moderate paraphrase already counts as removed", "0.60 — very lenient: only near-total rewrites count as removed"]|Set the threshold to 0.75 as recommended, and document it alongside the rationale (conservative: light edits and para
What semantic overlap threshold distinguishes 'redundant' (substantially overlaps) from merely 'related' (shares some sc|["Strict: >80% intent overlap is redundant", "Moderate: >60% intent overlap is redundant", "Lenient: >40% intent overlap is redundant", "Leave to evaluator judgment: let the LLM assess based on specific intent content"]|Proceed with the executor's recommendation — use evaluator judgment with a prompt that flags high-confidence redundancy cases and surfaces close calls to the h
How should 'same identifiable domain' be determined for criteria-domain spec loops? What makes two criteria from differe|["Exact criterion text match", "Semantic similarity (keyword/embedding-based)", "Manual domain tags on criteria (requires schema change)", "Broader category tag (e.g., 'API', 'Performance', 'Security')"]|Proceed with exact criterion text match for v1 criteria-domain loop detection — it satisfies the no-false-positives constraint and mirrors the approved approach for decision-t
Should importance_validation.py's newly-binary gate (proceed / needs-human-look) be served by Jev instead of the current|["Migrate to Jev, matching the BD-90/91/92/93 pattern", "Keep on StructuredLLM — do not migrate to Jev"]|Keep on StructuredLLM. Every existing Jev use in this codebase (review.py, learn.py's intent classification, discretion_auditor.py, shaping.py) is a single categorical choice over a fixed rubric for o
Work Unit 1 (type-inference Jev migration): how should a low-confidence Jev classification be handled at create_spec tim|["Proceed with Jev's best-guess choice regardless of confidence, and emit a structured server-log warning when confidence is below the configured threshold — gives an operator a way to notice a pattern of uncertain classifications via logs, without inventing new schema, a new queue, or blocking spec creation", "Proceed with Jev's best-guess choice regardless of confidence with
Work Unit 1 (type-inference Jev migration): should a BD-91-style before/after comparison be run via the offline flywheel|["Live-eval-only: measure both paths on the existing frozen 8-fixture set directly in test_type_inference.py; skip a separate offline-bench comparison", "Also run a BD-91-style comparison through the offline flywheel bench against a larger corpus before cutover"]|Live-eval-only. BD-91's heavier bench-based comparison was warranted because heuristic-dedup classification depende
Acceptance criterion item_1608847eb98d requires test_generalization_eval.py to be "a required CI check" whose failure "b|["A — Create a GitHub Actions workflow running test_generalization_eval.py as a required check.", "B — A documented local pre-ship gate: a Makefile target whose output is submitted as evidence.", "C — Split it: move the deterministic part of over-generalisation detection into backend/tests/bench (cassette-replayed, no live model) so it runs in the default suite and genuinely g
Tool call: Bash
export U='postgresql://[redacted]'; psql "$U" -Atc "select column_name from information_schema.columns where table_name='initiatives'" | tr '\n' ' '; echo; psql "$U" -Atc "select state, archived_at is not null, count(*) from initiatives where project_id='build-doen' group by 1,2"; psql "$U" -Atc "select id, state, left(title,80), archived_at::date from initiatives where project_id='build-doen' and archived_at is not null order by seq" | head -30
Result
id created_at title updated_at project_id state seq archived_at archived_reason initiative_type learn_draft research_findings recorded_ref recorded_undone_at  
complete|f|83
building|t|4
complete|t|1
draft|t|19

BD-2|building|Add Learn Stage to Initiative Lifecycle|2026-05-30
BD-3|complete|Edit Work Units in Draft Mode|2026-05-30
BD-4|draft|Criteria-as-Tracking, Remove Work Units|2026-05-30
BD-17|building|Compound Knowledge Flywheel: Heuristics, Uncertainty, and Incremental Evolution|2026-06-04
BD-18|draft|Explore Interface Modalities for Doen|2026-06-05
BD-19|draft|Guided Product Discovery on the Project Page|2026-06-06
BD-21|draft|Consolidate Project Page to Conversation-First Discovery|2026-06-09
BD-27|building|Initiatives Side Panel Layout|2026-06-13
BD-29|building|Discovery-First Project Page|2026-06-13
BD-42|draft|Domain-Routed Heuristic Retrieval|2026-06-24
BD-45|draft|Sequence and Gate the Four get_context Retrieval Drafts|2026-06-24
BD-50|draft|Spec Friction Classification|2026-06-25
BD-53|draft|Project Brief & Repo Bootstrap|2026-06-26
BD-56|draft|Significance Throttle, Confidence Decay, and Regime Tagging for Heuristic Distil|2026-06-30
BD-66|draft|Tasks List Alongside Initiatives|2026-07-05
BD-72|draft|Item-Level Credit & Split Dismissal Scoring|2026-07-08
BD-75|draft|Replace Single-Linkage Clustering with Complete-Linkage (Clique) Clustering in M|2026-07-08
BD-81|draft|Labels as Friction Radar|2026-09-11
BD-82|draft|Measure Whether Heuristic Guardrails Reduce Rework|2026-09-11
BD-88|draft|Heuristic Generalization Proposals + Project-Specificity Scoping|2026-09-14
BD-98|draft|Fix Dream-Phase Schedule Durability and Observability|2026-09-28
BD-99|draft|Surface Memory Audit Backlog on Grounding|2026-09-28
BD-100|draft|Narrow Retirement Gate and Drain Stranded Queues|2026-09-28
BD-106|draft|Drain Proposals Stranded by Project Archival|2026-10-05
Tool call: Bash
cd /Users/edobalvers/Develop/ehtb/doen/backend; grep -n "def \|class " app/providers/embeddings.py; export U='postgresql://[redacted]'; psql "$U" -Atc "select count(archived_reason) from initiatives where project_id='build-doen' and archived_at is not null; select left(archived_reason,150) from initiatives where archived_reason is not null and project_id='build-doen' limit 5"
Result
7 matches in 7 files:

27:0:
32:0:list[str]) -> list[list[float]]: ...
35:0:
39:0:
59:0:list[str]) -> list[list[float]]:
85:0:
app/providers/embeddings.py:44:def __init__(
24
rejected
archived
archived
rejected
rejected
Tool call: Bash
cd /Users/edobalvers/Develop/ehtb/doen/backend; sed -n 25,95p app/providers/embeddings.py
Result
@runtime_checkable
class EmbeddingProvider(Protocol):
    """text in, vector out. `dimension` must match the specs' vector(N) column."""

    dimension: int

    async def embed(self, texts: list[str]) -> list[list[float]]: ...


class EmbeddingError(RuntimeError):
    """A provider could not produce embeddings (missing key, API error, bad shape)."""


class OpenAICompatibleEmbeddings:
    """Any OpenAI-compatible /embeddings endpoint. One short-lived httpx client per
    batch — embedding is infrequent and async/best-effort, so a pooled client isn't
    worth the lifecycle."""

    def __init__(
        self,
        *,
        api_key: str = LLM_API_KEY,
        model: str = EMBEDDING_MODEL,
        dimension: int = EMBEDDING_DIM,
        base_url: str = LLM_BASE_URL,
        timeout: float = 30.0,
    ) -> None:
        self.api_key = api_key
        self.model = model
        self.dimension = dimension
        self.base_url = base_url.rstrip("/")
        self.timeout = timeout

    async def embed(self, texts: list[str]) -> list[list[float]]:
        if not texts:
            return []
        if not self.api_key:
            raise EmbeddingError(
                "LLM_API_KEY is not set — cannot generate embeddings. "
                "Export it (or add it to backend/.env) to enable the default provider."
… (22 more lines)
Claude
Now the code changes: a second case kind (initiative built or dropped), free-text answers mapped to options, cases merged in resolution order, embeddings for initiatives, and a majority floor.
Tool call: Bash
cd /Users/edobalvers/Develop/ehtb/doen/backend; cat > app/prompts/memory-replay-map-choice.txt <<'EOF'
You label a benchmark. A person answered a product question in their own words instead of picking
an option verbatim. Say which option their answer amounts to. Answer 0 when it matches none of
them, or combines several so that no single option is what they chose.
EOF
python3 - <<'EOF'
p='app/measure_memory_replay.py'; s=open(p).read()
def rep(a,b):
    global s
    assert a in s, a[:60]; s=s.replace(a,b,1)

rep('''DEPENDENCY = _prompt("dependency")''','''DEPENDENCY = _prompt("dependency")
MAP_CHOICE = _prompt("map-choice")

# The second source (2026-11-27): whether a proposed initiative was built to completion or dropped
# (archived first). It is the person's call about what is worth building, made once per initiative.
INITIATIVE_QUESTION = (
    "This initiative was proposed in the project. Did the person build it through to completion, "
    "or drop it before completion?")
BUILT, DROPPED = "Built it through to completion", "Dropped it (archived before completion)"''')

rep('''   AND d.payload->>'chosen' = ANY(ARRAY(SELECT jsonb_array_elements_text(d.payload->'options')))
   AND ($1::text IS NULL OR i.project_id = $1)
 ORDER BY i.project_id, d.resolved_at
"""''','''   AND d.payload->>'chosen' IS NOT NULL
   AND ($1::text IS NULL OR i.project_id = $1)
 ORDER BY i.project_id, d.resolved_at
"""

# Resolved initiatives: complete, or archived. Recorded work is born complete and is no decision.
… (168 more lines)
Result
627:        if missing and "search" in "".join(arms) + ("promoted" if "promoted" in arms else ""):
Tool call: Bash
cd /Users/edobalvers/Develop/ehtb/doen/backend; python3 - <<'EOF'
p='app/measure_memory_replay.py'; s=open(p).read()
s=s.replace('''if missing and "search" in "".join(arms) + ("promoted" if "promoted" in arms else ""):''','''if missing and any(a in arms for a in ("search", "promoted", "wiki")):''')
s=s.replace('''d.payload, d.embedding::text AS emb''','''d.payload, d.resolved_at, d.embedding::text AS emb''')
s=s.replace('''                resolved_at=str(p.get("resolved_at") or ""))''','''                resolved_at=row["resolved_at"].isoformat() if row["resolved_at"] else "")''')
open(p,'w').write(s)
EOF
cat >> tests/test_measure_memory_replay.py <<'EOF'


def test_free_text_answers_map_to_an_option_or_drop():
    a, b = _case(0), _case(1)
    a.chosen, b.chosen = "go with gamma, it is simpler", "something else entirely"
    labels = {"map:p0": 3, "map:p1": 0}
    kept = m.apply_mapping([a, b, _case(2)], labels)
    assert [c.id for c in kept] == ["p0", "p2"]
    assert kept[0].chosen == "gamma" and "simpler" in kept[0].rationale


def test_initiative_case_hides_the_outcome_in_the_question():
    from datetime import datetime, timezone
    row = {"id": "BD-9", "project_id": "p", "title": "T", "intent": "", "spec_intent": "do x",
           "description": None, "state": "draft", "archived_at": datetime.now(timezone.utc),
           "archived_reason": "superseded", "resolved_at": datetime.now(timezone.utc), "summary": None}
    c = m.initiative_case(row)
    assert c.kind == "initiative" and c.chosen == m.DROPPED
    assert "superseded" not in c.question and "superseded" in c.rationale


def test_majority_floor_and_per_kind_summary():
… (8 more lines)
Result
12 passed, 1 warning in 0.17s
0 errors, 0 warnings, 0 informations
Claude
All 12 tests pass and pyright is clean. Starting the build-doen run: both sources, all arms, 3 seeds, in the background.
Tool call: Bash
cd /Users/edobalvers/Develop/ehtb/doen/backend; S=/private/tmp/claude-501/-Users-edobalvers-Develop-ehtb-doen/116ce532-20d2-4e57-8d02-e6e82d949a5b/scratchpad; DATABASE_URL='postgresql://[redacted]' DOEN_LIVE_LLM=1 uv run python -m app.measure_memory_replay --project build-doen --source all --model openai/gpt-6-luna --runs 3 --labels $S/labels-bd.json --out $S/replay-bd.json 2>&1 | tail -5
Result
Command running in background with ID: bhmpt3ael. Output is being written to: /private/tmp/claude-501/-Users-edobalvers-Develop-ehtb-doen/116ce532-20d2-4e57-8d02-e6e82d949a5b/tasks/bhmpt3ael.output. You will be notified when it completes — do not poll that file or sleep while waiting. Read the file only if the user asks for progress, or if you need a line it prints before you can go on, such as a server's ready line or port.
Session cwd remains /Users/edobalvers/Develop/ehtb/doen/backend; directory changes made by the backgrounded command do not apply to subsequent commands.
Tool call: Bash
cd /Users/edobalvers/Develop/ehtb/doen; git add backend/app/measure_memory_replay.py backend/app/prompts/memory-replay-map-choice.txt backend/tests/test_measure_memory_replay.py && git commit -qm "feat: replay a second source — whether each initiative was built or dropped — and map free-text answers to options

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>" && git log --oneline -1
Result
ok 3 files changed, 145 insertions(+), 15 deletions(-)
ok
157bfb89 feat: replay a second source — whether each initiative was built or dropped — and map free-text answers to o...
Claude
I've extended the eval to build-doen's own history, committed it as `157bfb89` (not pushed), and started the live run in the background. It covers all arms, 3 seeds and up to 131 questions.

The new questions come from two places in the live database:
- **Escalations:** all 24. 15 were answered by picking an option. The other 9 were answered in the person's own words, so a judge maps each answer to the option it amounts to and caches the mapping. Answers that match no single option are dropped.
- **Initiatives:** 107 resolved ones, each asking "was this built or dropped?" The question shows only what existed at proposal time: the title and what it set out to do. The outcome (what it delivered, or the archive reason) appears only as feedback after the prediction. 83 were built and 24 dropped, so I added a majority floor: always answering "built" scores about 0.78.

All questions are replayed together in the order they were resolved, and results are reported per kind. So the memory can learn from both kinds of decision.

Three other sources turned out unusable:
- **Spec items:** 1,916 AI proposals were confirmed by a person, but rejections were never stored, so there's nothing negative to learn from.
- **Criterion verdicts:** they keep no history of requested changes.
- **Learn-record approvals:** 174 of 175 were approved automatically, not by a person.

I'll write up the results when the run finishes.
Every decision is recorded with what was ruled out and why. That record is the evidence.