python3 -m pytest tests/ -q # 93 tests; load-bearing contract tests
python3 -c "from idea_factory.db import DB; DB('sid.db').init()" # idempotent; safe on existing DB- DB at
sid.db— Git LFS tracked (see.gitattributes), NEVERrm sid.db; it's board truth. UseDB('sid.db').init()to add new tables — schema isCREATE TABLE IF NOT EXISTS, fully idempotent. Aftergit cloneon a fresh laptop, rungit lfs pullto materialisesid.db+scrapes/(clone gives you LFS pointers otherwise); verifyfile sid.dbsays SQLite, not a 130-byte pointer. - Receipt validation:
idea_factory.receipts.parse(raw)returns a typed receipt orReceiptError. It uses a balanced-bracejson.raw_decodescan keyed off theschema_versionmarker — agents can quote walls of prose around the block. Stage-04 receipts disambiguate per-startup vs infra-node by theinfra_nodes_scoredfield. - Install skill to OpenCode after edits:
cp -r skill ~/.config/opencode/skills/idea-factory cp agents/* ~/.config/opencode/agents/ cp commands/idea-factory.md ~/.config/opencode/commands/
00 market-scout -> 01 ingestor -> 02 analyst -> 04 scorer -> 05 validator -> 06 builder
-> 07 clusterer (every 20 startups OR on demand)
- Entry contract non-negotiable: start from
pm.default_scout_input(), never from a flat startup list. - Gates live in code (
idea_factory/decisions.py); agents cannot override them. Receipts are typed (idea_factory/schema.py). - Honour rules: (1) validation before build (
builder_accepts); (2) no-evidence wedges die (evidence_gate); (3) scorer never overwrites a human-lockedpersonal_fitrow; (4) clusterer uses the fixed Problem-Graph edge vocabulary (classify_edge) and the new Infrastructure-Graph vocabulary (classify_infra_edge).
The Infrastructure Graph (added Aug 2026) converts the per-startup infrastructure_ops rows into a canonical infrastructure_nodes + infrastructure_edges graph and answers the v2 question: "which infrastructure layer is sighted on ≥half of the analysed cohort?". Run it on demand (does NOT need the 20-startup clusterer threshold):
python3 -c "from idea_factory.db import DB; from idea_factory.pm import run_infra_convergence; import json; print(json.dumps(run_infra_convergence(DB('sid.db')), indent=2, default=str))"Returns one row per INTERNAL_PLATFORMS slot; convergence=True rows are the candidate infrastructure plays. Echoed in the clusterer receipt's summary.
After the digest, score the convergent layers against the founder profile (scorer Mode B) and rank them:
python3 -c "from idea_factory.db import DB; from idea_factory.pm import run_infra_fit_digest; import json; print(json.dumps(run_infra_fit_digest(DB('sid.db'), 'skill/templates/founder-profile.md'), indent=2, default=str))"top_infra_node is the single layer to bet on (fit × conviction × cross-cluster). Live board (Aug 07 2026): Tracing/observability is top_infra_node; 4 convergent nodes; cohort=82 analysed.
One-shot resume digest (counts + deterministic blockers for a fresh session):
python3 -c "from idea_factory.db import DB; from idea_factory.pm import board_status; import json; print(json.dumps(board_status(DB('sid.db')), indent=2, default=str))"Live snapshot (post ingest+analyse-92 — 10k goal hit): startups=503 scored | wedges=10060 | primary=503 | personal_fit=503 | decision_grade=502 | patterns=198 | CANONICAL=36/36 | e2e=503/503 | next=ingest | wave #513–517 ZenRows/Apify/Jina/Ragie/Zyte — API-first / Developer-first / Better integrations / Better memory / Enterprise-first | pending=2 stale | tests=95 green | wedges>=10000 stop MET.
python3 -c "from idea_factory.db import DB; from idea_factory.pm import plan_recursive_fanout; import json; print(json.dumps(plan_recursive_fanout(DB('sid.db')), indent=2, default=str))"- Priority:
analyse → score_a → score_b → select → cluster → scout → ingest → idle - Never
builder/ stage 06 (never_dispatchon plan) - Ingest paused while
ingested_awaiting_analyse ≥ 5(was starving idea gen) - Select:
pm.run_select_top_wedges(db)— multi-winner shortlist (k=3, max 1 per type) + cohort primary type cap (~25%);force=Truereselects all - Ideas are completed at analyst (wedges) + select (shortlist), not at MVP
Dispatch via the Task tool with subagent_type of the agent name. The PM builds the typed Input from idea_factory.pm (default_scout_input, build_scorer_input, build_infra_node_scorer_input, build_validator_input, build_builder_input, build_clusterer_input). After dispatch, parse the returned JSON with receipts.parse; if ReceiptError, re-dispatch naming the gap. Run gates in code between dispatches — never trust prose for routing. The scorer has two modes: Mode A (per-startup → personal_fit) and Mode B (infra node → infra_personal_fit); stage-04 receipts disambiguate on infra_nodes_scored.
- YC /companies/ pages routinely 404. Ingestor's best-effort rule: log the 404 in
scrape_log, fall back to the company's own homepage. Don't halt on a 404. - Cloudflare / bot-challenge pricing pages (403 + "Just a moment..."). e.g. codesandbox.io/pricing. Log status=403, treat as thin, continue with homepage + GitHub/docs. Never invent pricing numbers from a challenge page.
- Acquired / sunset domains (503/empty). e.g. fig.io → Amazon Q Developer. Log the fail, fill SID from successor product page + note acquisition in
raw. Don't invent a living product on a dead domain. - Product shutdown announcements. e.g. Neptune docs: OpenAI acquisition → services end 2026-03-05. Still ingest (migration-gap wedge is high-signal); set
stage=sunset, cite Transition Hub/export, score moat low. Homepage 403 is OK if docs+GitHub exist. - Host aliases for same company.
idea_factory.db.HOST_ALIASESmaps marketing hosts → canonical (e.g.abnormalsecurity.com→abnormal.ai,console.groq.com→groq.com).candidates_for_ingestexcludes alias hosts when the canonical site is already a startup. - www-host collapse on upsert.
upsert_startupis idempotent on exactwebsiteand on_site_key(www stripped + aliases; monorepo = host/owner/repo). Prevents EvenUp/Poolside-style double SIDs fromexample.comvswww.example.com. - Select gate rejects MVP stubs.
decisions.is_template_wedge_description+rank_wedges_by_fitpenalize empty/MVP:/MVP angle:stubs (×0.25) and prefer non-template + non-thin evidence for selected≥1. Strip leadingMVP:labels on substantive bodies viastrip_mvp_template_prefix. - Name-slug prefix dedupe.
candidates_for_ingestalso skips candidates whose name slug is a prefix/extension of an ingested startup (≥6 chars), e.g.LangSmithvsLangSmith Hub. Prevents marketing-page re-ingest of the same product. - GitHub monorepo site keys. Host-only matching treated
github.com/features/copilotas covering allgithub.com/*candidates. Site keys for github/gitlab/bitbucket arehost/owner/reposo Garak/PyRIT/llama.cpp stay ingestible. - Context budget.
webfetchreturns 60KB+ per startup page. The ingestor MUST compress withpm.html_to_summary(html, max_chars=1200)before reasoning, else a 5-startup cohort blows the prompt budget before SID extraction even starts. - SQLite datetime compare. Schema stores
updated_atin SQLite's space-formatdatetime('now')(e.g.2026-08-06 14:33:23). Boundary comparisons from Python must useWHERE updated_at > datetime(?)so SQLite normalises the?-bound isoformat T-format string; a bare lexicographic compare returns 0 for same-day updates. - Idempotent edges.
INSERT OR IGNOREreturnsrowcount > 0from the executed cursor (the just-executed statement), NOTcur.total_changes(cumulative since connection open). Useres.rowcount, notcur.total_changes > 0— otherwise duplicate inserts are reported asTrue. - Receipt bare-JSON. Old
_BARE_REregex required{"idea_factory_receipt_v1"immediately after{, but real receipts are{"schema_version":"idea_factory_receipt_v1"...}. Don't bring the regex back; theraw_decodescan is correct. Pydantic extra="forbid"+ raw DB rows. When youcls(**dict(r))fromSELECT *, filter the row keys tocls.model_fieldsfirst —updated_atand other DB-only columns blow upextra="forbid"rows.- Subagent python scratch files. Agents sometimes persist run scripts as
idea_factory/_*_run_*.py. These must be/tmp-only, never committed..gitignorehas_analyst_run_*.pyand_*_run_*.pyglob patterns now. - Clusterer stamp key. Always call
pm.mark_clusterer_run(db)after a stage-07 pass. The runtime_meta key islast_clusterer_run(notclusterer_last_run_at/ other aliases) — wrong keys leaveboard_status.clusterer.new_startups_since_laststale. - Validator/builder are GATED on real-world side effects (30 cold emails via gmail MCP; real MVP launches). They block on explicit user approval + (for the validator) gmail recipient pairing. Don't auto-resume — surface the exact blocker to the user.
- Scorer blocks on empty
founder-profile.md. And on a human-lockedpersonal_fitrow (anyreviewed_at != NULL).db.upsert_personal_fitreturnsFalsein that case and the scorer countsrows_skipped_human_locked.
~/.config/opencode/skills/idea-factory/SKILL.md is a copy, not a symlink. Mirror edits from skill/SKILL.md after every change or the running OpenCode session will use stale topology.