From 07ee27b03e904636a0d15e67887864edef2f9d24 Mon Sep 17 00:00:00 2001 From: robbond Date: Tue, 2 Jun 2026 07:48:22 +0100 Subject: [PATCH] docs: add task for agent prompt generation --- PROJECT_STATE.md | 2 +- TASKS.md | 14 ++++- tests/test_discovery.py | 120 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 tests/test_discovery.py diff --git a/PROJECT_STATE.md b/PROJECT_STATE.md index 2e0e44a..bc59037 100644 --- a/PROJECT_STATE.md +++ b/PROJECT_STATE.md @@ -4,7 +4,7 @@ Current Stage: BUILDING Previous Stage: BOOTSTRAP_READY Next Stage: REVIEW_READY -Current Task: TASK-003 +Current Task: TASK-004 Active Branch: main Last Updated: 2026-06-02 diff --git a/TASKS.md b/TASKS.md index feb1766..6e2831b 100644 --- a/TASKS.md +++ b/TASKS.md @@ -40,7 +40,7 @@ Acceptance Criteria: ## TASK-003 — Improve discovery workflow -Status: Todo +Status: Done Goal: Improve `rdb discover` so it records structured answers into the discovery ledger. @@ -60,3 +60,15 @@ Acceptance Criteria: - Preserve existing discovery history - Add/update tests - Update RUN_LOG.md + +## TASK-004 — Implement ask-more command + +Status: Todo + +Goal: Add a command that finds weak answers and asks deeper follow-up questions. + +Acceptance Criteria: + +- command reads discovery-log.md +- low-confidence answers are detected +- follow-up answers are appended to discovery-log.md diff --git a/tests/test_discovery.py b/tests/test_discovery.py new file mode 100644 index 0000000..3cd2d96 --- /dev/null +++ b/tests/test_discovery.py @@ -0,0 +1,120 @@ +from pathlib import Path + +import rdb_discovery.discovery as discovery_mod + + +def test_core_questions_returns_10_items() -> None: + questions = discovery_mod.core_questions() + assert len(questions) == 10 + + +def test_append_creates_file_when_missing(tmp_path: Path) -> None: + log_path = tmp_path / "context" / "discovery-log.md" + assert not log_path.exists() + + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-001", + question="What problem are we solving?", + answer="A great app", + confidence="High", + follow_up_needed="No", + ) + + assert log_path.exists() + + +def test_append_records_all_fields(tmp_path: Path) -> None: + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-001", + question="What problem are we solving?", + answer="A great app", + confidence="High", + follow_up_needed="No", + ) + + content = (tmp_path / "context" / "discovery-log.md").read_text(encoding="utf-8") + assert "| Q-001 |" in content + assert "What problem are we solving?" in content + assert "A great app" in content + assert "High" in content + assert "No" in content + + +def test_append_escapes_pipe_in_answer(tmp_path: Path) -> None: + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-001", + question="What | is this?", + answer="A | B", + confidence="High", + follow_up_needed="No", + ) + + content = (tmp_path / "context" / "discovery-log.md").read_text(encoding="utf-8") + # Piped answers should be escaped so the table row doesn't break + assert "\\|" in content + + +def test_append_escapes_newline_in_answer(tmp_path: Path) -> None: + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-001", + question="Multi\nline?", + answer="A\nB\nC", + confidence="High", + follow_up_needed="No", + ) + + content = (tmp_path / "context" / "discovery-log.md").read_text(encoding="utf-8") + # Data rows should each be a single line — no embedded newlines + data_lines = [l for l in content.splitlines() if l.startswith("| Q-")] + assert len(data_lines) == 1 + assert "\n" not in data_lines[0] + + +def test_append_preserves_existing_history(tmp_path: Path) -> None: + log_path = tmp_path / "context" / "discovery-log.md" + + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-001", + question="First?", + answer="Ans 1", + confidence="High", + follow_up_needed="No", + ) + + assert log_path.read_text(encoding="utf-8").count("Ans 1") == 1 + + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-002", + question="Second?", + answer="Ans 2", + confidence="Low", + follow_up_needed="Yes", + ) + + content = log_path.read_text(encoding="utf-8") + assert "Ans 1" in content + assert "Ans 2" in content + # Two data rows, not one + data_rows = [l for l in content.splitlines() if l.startswith("| Q-")] + assert len(data_rows) == 2 + + +def test_header_is_written_on_create(tmp_path: Path) -> None: + discovery_mod.append_discovery_answer( + tmp_path, + question_id="Q-001", + question="Test?", + answer="T", + confidence="High", + follow_up_needed="No", + ) + + content = (tmp_path / "context" / "discovery-log.md").read_text(encoding="utf-8") + assert "# Discovery Log" in content + assert "| ID | Question | Answer | Confidence | Follow-up needed | Linked decision | Linked task | Date |" in content