chore/dynamic risk docs - #6
Conversation
biuworks
commented
Aug 2, 2026
- feat: make assess/start behavior dynamic and clarify docs onboarding
- chore: apply remaining refactors, docs updates, and coverage tests
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49548464ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "policy_profile": policy.get("project", {}).get("governance_profile", DEFAULT_GOVERNANCE_PROFILE), | ||
| "requested_level": requested_level, |
There was a problem hiding this comment.
Emit schema-valid Change Records
Remove these fields or add them to change.schema.json: every playbook start now writes policy_profile and requested_level, but the Change Record schema has additionalProperties: false and defines neither property. Consequently the next check, finish, or hook rejects every newly created record with PBK-E005, breaking the documented daily workflow.
Useful? React with 👍 / 👎.
| for key in bool_keys: | ||
| if key in explicit_rules: | ||
| base_rules[key] = bool(explicit_rules[key]) | ||
| if "traceability_levels" in explicit_rules: | ||
| base_rules["traceability_levels"] = list(explicit_rules["traceability_levels"]) |
There was a problem hiding this comment.
Let the selected governance profile control its rules
Do not unconditionally replace profile rules with the policy's compatibility fields: policy.schema.json requires require_active_change, require_tests_for_production, and traceability_levels, so every valid policy enters these branches. For a policy produced from defaults/policy.yaml, selecting standard or strict still replaces the profile's true values and traceability levels with false/[]; therefore --profile strict and per-command --governance-profile strict silently omit the advertised Change, test, and traceability gates.
Useful? React with 👍 / 👎.
| for change_dir, record in active: | ||
| scoped_changed = [path for path in changed if matches(path, record["scope"])] |
There was a problem hiding this comment.
Validate only changes relevant to the current diff
Filter active records by the changed paths before performing per-change checks. With two non-overlapping active Changes, a diff scoped only to service A now also validates service B and, in merge mode, requires B to be verified; an unrelated draft T2 record can therefore fail A's check for missing traceability or status. This regresses the parallel-change isolation exercised by tests/test_parallel_changes.py.
Useful? React with 👍 / 👎.
| patch_path = _checkpoint_patch_path(root, args.checkpoint_id) | ||
| patch = patch_path.read_text(encoding="utf-8") if patch_path.is_file() else "" | ||
| if patch.strip(): | ||
| _ = _git_json(["git", "apply", "--reverse", "--whitespace=nowarn", str(patch_path)], root) |
There was a problem hiding this comment.
Apply checkpoint patches in the restoring direction
Restore the saved snapshot rather than reverse-applying it. If checkpoint changes were later reset, this command attempts to remove changes that are no longer present and fails; if they are still present, it removes the saved state instead of reconstructing it. Thus a dirty-worktree checkpoint cannot serve as the documented recovery anchor.
Useful? React with 👍 / 👎.
| policy = yaml.safe_load(resource_path("defaults", "policy.yaml").read_text(encoding="utf-8")) | ||
| policy["project"]["minimum_level"] = args.level | ||
| policy["project"]["documentation_language"] = args.language | ||
| policy["project"]["governance_profile"] = _normalize_governance_profile(args.profile) |
There was a problem hiding this comment.
Honor the requested documentation language
Assign args.language when building the initialized policy. The default resource contains zh-CN, and this function now updates only the level and profile, so playbook init --language en-US succeeds while writing documentation_language: zh-CN; downstream agents consequently receive the opposite documentation-language policy.
Useful? React with 👍 / 👎.
| if finding.code in {"PBK-E010", "PBK-E030"}: | ||
| target = root / finding.path | ||
| if ".." in Path(finding.path).parts or not finding.path.startswith(".playbook/changes/"): | ||
| if ".." in target.parts or not target.parent.as_posix().startswith(".playbook/changes/"): | ||
| continue |
There was a problem hiding this comment.
Compare fix targets using repository-relative paths
Perform this prefix check on finding.path or a path relative to root. Since target is formed as root / finding.path, target.parent.as_posix() is absolute and never starts with .playbook/changes/; every PBK-E010 or PBK-E030 therefore takes this continue, so playbook fix no longer creates any missing required artifact.
Useful? React with 👍 / 👎.