feat(task-023): improve generated context quality

This commit is contained in:
2026-06-04 09:42:05 +01:00
parent c72ad6995e
commit 152096d433
9 changed files with 191 additions and 17 deletions
+143
View File
@@ -292,6 +292,7 @@ class TestIntegration:
assert "context/product-brief.md" in result["generated"]
assert "context/project-brief.md" in result["generated"]
assert "context/risks.md" in result["generated"]
assert "context/company-context.md" in result["generated"] # Q-002 → company-context
assert "context/assumptions.md" not in result["generated"] # Q-008 is Low confidence
# Check that product-brief has filled sections
@@ -299,6 +300,11 @@ class TestIntegration:
assert "CLI tool for discovery workflow" in content
assert "Internal developers and small dev teams" in content
# Check company-context got users data from Q-002
company = (tmp_project / "context/company-context.md").read_text()
assert "## Customers / Users" in company
assert "Internal developers and small dev teams" in company
# Check that risks.md got a table row
risks = (tmp_project / "context/risks.md").read_text()
assert "| RISK-007 |" in risks
@@ -314,3 +320,140 @@ class TestIntegration:
result = (tmp_project / "context/infrastructure-context.md").read_text()
assert "Cloud provider details" in result # Original content preserved
class TestContextQuality:
"""Tests for TASK-023: improved context generation quality."""
def test_company_context_populated_from_users(self):
"""company-context.md should be populated when discovery answers include users/stakeholders."""
from pathlib import Path
import tempfile
import shutil
tmp_path = Path(tempfile.mkdtemp())
root = tmp_path / "testproject"
root.mkdir()
(root / "context").mkdir()
# Only Q-002 (users) - no other discovery data
(root / "context" / "discovery-log.md").write_text(
"# Discovery Log\n\n"
"| ID | Question | Answer | Confidence | Follow-up needed | Linked decision | Linked task | Date |\n"
"|---|---|---|---|---|---|---|---|\n"
'| Q-002 | Who is the user? | Internal dev teams and external customers | High | No | | | 2026-06-03 |\n',
encoding="utf-8",
)
from rdb_discovery.generate_context import generate_context_files
result = generate_context_files(root)
assert "context/company-context.md" in result["generated"]
assert "context/product-brief.md" in result["generated"]
company = (root / "context/company-context.md").read_text()
assert "## Customers / Users" in company
assert "Internal dev teams and external customers" in company
shutil.rmtree(tmp_path)
def test_agent_guidelines_gets_testing_preferences(self):
"""agent-guidelines.md should get Testing Preferences from testing discovery answers."""
from pathlib import Path
import tempfile
import shutil
tmp_path = Path(tempfile.mkdtemp())
root = tmp_path / "testproject"
root.mkdir()
(root / "context").mkdir()
# Only Q-009 (testing) - no agent tooling questions
(root / "context" / "discovery-log.md").write_text(
"# Discovery Log\n\n"
"| ID | Question | Answer | Confidence | Follow-up needed | Linked decision | Linked task | Date |\n"
"|---|---|---|---|---|---|---|---|\n"
'| Q-009 | How will we test it? | pytest with coverage, integration tests via docker-compose | Medium | No | | | 2026-06-03 |\n',
encoding="utf-8",
)
from rdb_discovery.generate_context import generate_context_files
result = generate_context_files(root)
assert "context/agent-guidelines.md" in result["generated"]
guidelines = (root / "context/agent-guidelines.md").read_text()
assert "## Testing Preferences" in guidelines
assert "pytest with coverage" in guidelines
shutil.rmtree(tmp_path)
def test_no_testing_answers_in_timeline(self):
"""Testing answers must not be mapped to Timeline & Milestones sections."""
from pathlib import Path
import tempfile
import shutil
tmp_path = Path(tempfile.mkdtemp())
root = tmp_path / "testproject"
root.mkdir()
(root / "context").mkdir()
# Only Q-009 (testing) - verify no timeline data appears
(root / "context" / "discovery-log.md").write_text(
"# Discovery Log\n\n"
"| ID | Question | Answer | Confidence | Follow-up needed | Linked decision | Linked task | Date |\n"
"|---|---|---|---|---|---|---|\n"
'| Q-009 | How will we test it? | pytest with coverage | High | No | | | 2026-06-03 |\n',
encoding="utf-8",
)
# Create project-brief.md that has a Timeline section already
(root / "context" / "project-brief.md").write_text(
"# Project Brief\n\n## Timeline & Milestones\n\nTBD\n",
encoding="utf-8",
)
from rdb_discovery.generate_context import generate_context_files
result = generate_context_files(root)
assert "context/project-brief.md" not in result["generated"]
timeline_content = (root / "context/project-brief.md").read_text()
# The Timeline section should remain as TBD (not filled with testing data)
assert "pytest with coverage" not in timeline_content
# Original TBD placeholder preserved
assert "TBD" in timeline_content
shutil.rmtree(tmp_path)
def test_repository_context_populated_from_dependencies(self):
"""repository-context.md should be populated when answers include dependencies."""
from pathlib import Path
import tempfile
import shutil
tmp_path = Path(tempfile.mkdtemp())
root = tmp_path / "testproject"
root.mkdir()
(root / "context").mkdir()
# Q-012 includes technology stack info that maps to repository dependencies
(root / "context" / "discovery-log.md").write_text(
"# Discovery Log\n\n"
"| ID | Question | Answer | Confidence | Follow-up needed | Linked decision | Linked task | Date |\n"
"|---|---|---|---|---|---|---|---|\n"
'| Q-012 | What is the technology stack, repository structure, and architecture approach? | Python 3.12, Typer, Rich; Docker; PostgreSQL | High | No | | | 2026-06-03 |\n',
encoding="utf-8",
)
from rdb_discovery.generate_context import generate_context_files
result = generate_context_files(root)
assert "context/repository-context.md" in result["generated"]
repo_ctx = (root / "context/repository-context.md").read_text()
assert "## Dependencies" in repo_ctx
assert "Python 3.12, Typer, Rich" in repo_ctx
shutil.rmtree(tmp_path)