fix(project-rules): qualify ad-hoc record identifiers
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02b22-9638-76d2-bbff-b7ea1770b118
This commit is contained in:
parent
fae2816199
commit
284e28112d
6 changed files with 83 additions and 15 deletions
|
|
@ -74,8 +74,15 @@ SUPPORTED_WP_STATUSES = set(SUPPORTED_WORKSTREAM_STATUSES)
|
|||
VALID_TASK_STATUSES = set(CANONICAL_TASK_STATUSES)
|
||||
VALID_TASK_PRIORITIES = {"low", "medium", "high", "critical"}
|
||||
|
||||
_WP_ID_RE = re.compile(r"^(?:[A-Z]+-WP-\d+|ADHOC-\d{4}-\d{2}-\d{2})$")
|
||||
_TASK_ID_RE = re.compile(r"^(?:[A-Z]+-WP-\d+|ADHOC-\d{4}-\d{2}-\d{2})-T\d+$")
|
||||
_PREFIX_RE = r"[A-Z][A-Z0-9]*(?:-[A-Z][A-Z0-9]*)*"
|
||||
_WP_ID_RE = re.compile(
|
||||
rf"^(?:{_PREFIX_RE}-WP-\d+|{_PREFIX_RE}-WP-ADHOC-\d{{4}}-\d{{2}}-\d{{2}}"
|
||||
r"|ADHOC-\d{4}-\d{2}-\d{2})$"
|
||||
)
|
||||
_TASK_ID_RE = re.compile(
|
||||
rf"^(?:{_PREFIX_RE}-WP-\d+|{_PREFIX_RE}-WP-ADHOC-\d{{4}}-\d{{2}}-\d{{2}}"
|
||||
r"|ADHOC-\d{4}-\d{2}-\d{2})-T\d+$"
|
||||
)
|
||||
_TASK_BLOCK_RE = re.compile(r"```task\s*\n(.*?)\n```", re.DOTALL)
|
||||
_ARCHIVED_WP_RE = re.compile(r"^\d{6}-(.+\.md)$")
|
||||
|
||||
|
|
@ -223,12 +230,18 @@ def _check_workplan_file(wp_file: Path, report: Report) -> dict | None:
|
|||
wp_id = str(meta.get("id", ""))
|
||||
if not _WP_ID_RE.match(wp_id):
|
||||
report.add(Level.FAIL, "frontmatter-id-format",
|
||||
f"id must match [A-Z]+-WP-\\d+ (e.g. CUST-WP-0001), got {wp_id!r}", fname)
|
||||
"id must be a numbered or repository-qualified ad-hoc "
|
||||
f"workplan id, got {wp_id!r}", fname)
|
||||
else:
|
||||
report.add(Level.PASS, "frontmatter-id-format", f"id={wp_id}", fname)
|
||||
|
||||
# filename prefix
|
||||
if wp_id and not canonical_fname.startswith(wp_id):
|
||||
adhoc_filename_id = Path(canonical_fname).stem
|
||||
qualified_adhoc_filename = (
|
||||
adhoc_filename_id.startswith("ADHOC-")
|
||||
and wp_id.endswith(f"-WP-{adhoc_filename_id}")
|
||||
)
|
||||
if wp_id and not canonical_fname.startswith(wp_id) and not qualified_adhoc_filename:
|
||||
report.add(Level.WARN, "filename-id-prefix",
|
||||
f"Filename should start with id '{wp_id}', got {fname!r}", fname)
|
||||
elif wp_id:
|
||||
|
|
@ -260,7 +273,7 @@ def _check_workplan_file(wp_file: Path, report: Report) -> dict | None:
|
|||
report.add(Level.FAIL, "task-id", "Missing 'id' field", tref)
|
||||
elif not _TASK_ID_RE.match(t_id):
|
||||
report.add(Level.WARN, "task-id-format",
|
||||
f"id {t_id!r} doesn't match [A-Z]+-WP-\\d+-T\\d+", tref)
|
||||
f"id {t_id!r} is not a canonical or grandfathered task id", tref)
|
||||
|
||||
t_status = str(task.get("status", ""))
|
||||
if not t_status:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue