integrate threat-model.md into Phase 1 workflow#34
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR integrates a mandatory ChangesThreat-Model Integration for Phase 1
🎯 4 (Complex) | ⏱️ ~60 minutes Possibly Related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Coverage Report
Generated by pytest-cov on |
2ded8b5 to
2365428
Compare
c2bb8be to
1820425
Compare
1820425 to
7f481aa
Compare
- Add templates/threat-model.md with structured subsections - Create tools/phases/artifact_checks.py (shared phase validator) - Add thin check-phase-artifacts CLI wrapper in tools/codecome.py - Update completion.py: required artifacts, checklist, repair prompt - Rename Phase 1b prompt to phase-1b-recon.md (Detailed Reconnaissance) - Delete orphaned monolithic phase-1-recon.md - Add source-recon references (threat-model-checklist, security-controls-assets) - Update source-recon SKILL.md with threat-model sections - Update all phase prompts (1a/1b/1c/2/3) for threat-model consumption - Update templates (run-summary, target-recon) - Update gate logic (phase_1_gates, gates) for threat-model.md requirement - Add Phase 1b artifact auto-repair loop in phase_1.py - Update Makefile, AGENTS.md, and all docs - Add 48 tests covering templates, prompts, gates, CLI, and completion
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tools/phases/completion.py (1)
201-205:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winNormalize Phase 1 subphase IDs before selecting checklist content.
At Line 205, the detailed Phase 1 checklist is gated by
str(phase) == "1", but Phase 1b artifact auto-repair calls this path withphase="1b". That currently downgrades repair prompts to the generic fallback and omits the required threat-model heading checklist.Proposed fix
def phase_checklist_lines(phase: str, finding: str | None) -> list[str]: - if str(phase) == "1": + phase_key = str(phase) + if phase_key in ("1", "1a", "1b", "1c"): return [ f"Ensure all required Phase 1 notes exist under {_ITEMDB_NOTES_DIR}.", f"Ensure {NOTES_ROOT.relative_to(ROOT)}/threat-model.md has all required H1 headings: # Threat Model Summary, # Scope, # System model, # Assets and security objectives, # Attacker model, # Trust boundary summary, # Existing controls, # Abuse-path themes for Phase 2, # Risk calibration for review focus, # Open questions for the user, # Re-run prompt hints.", f"Ensure {NOTES_ROOT.relative_to(ROOT)}/file-risk-index.yml is present and consistent with interesting-files.md.", f"Ensure {NOTES_ROOT.relative_to(ROOT)}/sandbox-plan.md documents the Phase 1b outcome.", "If sandbox bootstrap succeeded, ensure sandbox/CODECOME-GENERATED.md exists; otherwise document the halt clearly in sandbox-plan.md.", ]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/phases/completion.py` around lines 201 - 205, The phase_checklist_lines function currently checks phase with str(phase) == "1", which misses subphase IDs like "1b"; update phase normalization inside phase_checklist_lines (or a small helper called from it) to map any Phase 1 subphase (e.g., strings starting with "1") to the base "1" before the selection logic so the detailed Phase 1 checklist (threat-model headings) is returned for "1", "1b", etc.; adjust the comparison to use the normalized value (for example normalize_phase = str(phase).strip().lower(); if normalize_phase.startswith("1"): normalize_phase = "1") and then use normalize_phase in the existing checks.
🧹 Nitpick comments (1)
tools/phases/artifact_checks.py (1)
50-50: ⚡ Quick winRemove unused regex constant.
_H1_REis defined but never used in the code. Only_STRICT_H1_RE(line 53) is actually referenced.♻️ Proposed cleanup
-_H1_RE = re.compile(r"^# (?!\s)", re.MULTILINE) - # Equivalent strict H1 regex: starts with "# " and is NOT followed by whitespace _STRICT_H1_RE = re.compile(r"^# [^\s]", re.MULTILINE)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/phases/artifact_checks.py` at line 50, Remove the unused regex constant _H1_RE from the module: delete the line defining _H1_RE = re.compile(r"^# (?!\s)", re.MULTILINE) and verify no other code references it (only _STRICT_H1_RE is used); keep imports intact and run tests/lint to ensure no remaining references.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.project/security-threat-model-phase1-plan.md:
- Around line 3-5: The "Status" section is stale and contradicts the PR; update
the text under "## Status" to reflect that the plan has been implemented and
tests are passing instead of saying the PR intentionally does not implement
changes; remove or replace the sentence "This PR intentionally does not
implement the changes yet" with a concise status like "Implemented — PR includes
plan changes; 609 tests passing (48 new)" and ensure wording matches the PR
description.
In `@docs/workflow.md`:
- Line 39: Update the parenthetical in docs/workflow.md to avoid calling `make
phase-1` "manually": rephrase to indicate `make phase-1` is the
automatic/recommended way to run Phase 1 and show the true manual alternative by
mentioning the individual opencode commands (e.g., `opencode run --agent recon
"$(cat prompts/phase-1a-profile.md)"`, `opencode run --agent recon "$(cat
prompts/phase-1b-recon.md)"`, `opencode run --agent recon "$(cat
prompts/phase-1c-sandbox.md)"`) and the prompt file names
(`prompts/phase-1a-profile.md`, `prompts/phase-1b-recon.md`,
`prompts/phase-1c-sandbox.md`) so readers clearly see which is automatic (`make
phase-1`) versus the manual invocation.
In `@tools/phases/artifact_checks.py`:
- Around line 301-349: check_phase_artifacts accepts phase_1a_start_time but
never forwards it to the per-phase checkers, so check_phase_1a_artifacts (and
its leak-detection cutoff) never receives the timestamp; update the dispatcher
loop that calls func = _CHECKERS[p] so it passes phase_1a_start_time through
(e.g., errors = func(allow_missing_generated=allow_missing_generated,
phase_1a_start_time=phase_1a_start_time)) and ensure the checker wrapper in
_CHECKERS and the target function check_phase_1a_artifacts accept that kwarg, or
if you prefer the alternate approach remove the unused phase_1a_start_time
parameter from check_phase_artifacts and document that check_phase_1a_artifacts
must be called directly when a cutoff is required.
---
Outside diff comments:
In `@tools/phases/completion.py`:
- Around line 201-205: The phase_checklist_lines function currently checks phase
with str(phase) == "1", which misses subphase IDs like "1b"; update phase
normalization inside phase_checklist_lines (or a small helper called from it) to
map any Phase 1 subphase (e.g., strings starting with "1") to the base "1"
before the selection logic so the detailed Phase 1 checklist (threat-model
headings) is returned for "1", "1b", etc.; adjust the comparison to use the
normalized value (for example normalize_phase = str(phase).strip().lower(); if
normalize_phase.startswith("1"): normalize_phase = "1") and then use
normalize_phase in the existing checks.
---
Nitpick comments:
In `@tools/phases/artifact_checks.py`:
- Line 50: Remove the unused regex constant _H1_RE from the module: delete the
line defining _H1_RE = re.compile(r"^# (?!\s)", re.MULTILINE) and verify no
other code references it (only _STRICT_H1_RE is used); keep imports intact and
run tests/lint to ensure no remaining references.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 01011bd5-d330-4581-88e3-125d7922b63f
📒 Files selected for processing (32)
.opencode/skills/source-recon/SKILL.md.opencode/skills/source-recon/references/security-controls-and-assets.md.opencode/skills/source-recon/references/threat-model-checklist.md.project/security-threat-model-phase1-plan.mdAGENTS.mdMakefileREADME.mddocs/development.mddocs/target-setup.mddocs/workflow.mdprompts/README.mdprompts/phase-1-recon.mdprompts/phase-1a-profile.mdprompts/phase-1b-recon.mdprompts/phase-1c-sandbox.mdprompts/phase-2-audit.mdprompts/phase-3-review.mdtemplates/run-summary.mdtemplates/target-recon.mdtemplates/threat-model.mdtests/test_phase_1_gates_threat_model.pytests/test_phase_1_prompts_threat_model.pytests/test_phase_1_threat_model_templates.pytests/test_phase_artifacts_cli.pytests/test_phase_completion_threat_model.pytools/codecome.pytools/codecome/harness.pytools/codecome/phase_1.pytools/phases/artifact_checks.pytools/phases/completion.pytools/phases/gates.pytools/phases/phase_1_gates.py
💤 Files with no reviewable changes (1)
- prompts/phase-1-recon.md
…sed regex, phase_1a_start_time forwarding, stale plan status, docs phrasing
|
[coderabbitai] Fixed all findings:
609 tests pass. |
Implements the plan at
.project/security-threat-model-phase1-plan.md.Summary
templates/threat-model.md— structured operational threat model produced by Phase 1btools/phases/artifact_checks.py— shared phase artifact validator with strict H1 heading checksthreat-model.mdinto Phase 2 and Phase 3 prompts, gates, and auto-repairAcceptance criteria
All 17 acceptance criteria from the plan are met. See
.project/security-threat-model-phase1-plan.md#acceptance-criteria.Verification
make frontmatterpassescheck-phase-artifacts --phase all --allow-missing-generated-artifactspassesmake checkpassesDeferred
Phase 4/5/6 consumption of
threat-model.mdtracked by #35, #36, #37.Summary by CodeRabbit
New Features
threat-model.mdartifact during detailed reconnaissance, documenting system model, assets, attacker model, controls, and attack path themes.check-phase-artifactscommand to validate phase-generated artifacts.Documentation