feat(template): SRCP v1 standards, job_context/finish gold sample (v1.0.38, platform-kit 1.2.0)
All checks were successful
技能自动化发布 / release (push) Successful in 4s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-12 12:27:44 +08:00
parent 3bc15d1241
commit 6f958ded28
14 changed files with 270 additions and 127 deletions

View File

@@ -41,6 +41,9 @@ POLICY_IDS = (
"POLICY-LOGGING-003",
"POLICY-LOGGING-004",
"POLICY-LOGGING-005",
"POLICY-CONTROL-001",
"POLICY-CONTROL-002",
"POLICY-CONTROL-003",
)
STRUCTURE_PATHS = (
@@ -619,6 +622,65 @@ class TestPolicyLogging005(unittest.TestCase):
)
class TestPolicyControl001(unittest.TestCase):
def test_no_util_progress_module(self) -> None:
skill_root = get_skill_root()
path = os.path.join(skill_root, "scripts", "util", "progress.py")
self.assertFalse(
os.path.isfile(path),
msg=_policy_msg(
"POLICY-CONTROL-001",
"development/LOGGING.md §2.5; development/RPA.md §0.1",
"scripts/util/progress.py must not exist",
),
)
class TestPolicyControl002(unittest.TestCase):
def test_task_service_uses_job_context_and_finish(self) -> None:
skill_root = get_skill_root()
path = os.path.join(skill_root, "scripts", "service", "task_service.py")
text = _read_text(path)
rel = _rel(skill_root, path)
missing: list[str] = []
if "job_context(" not in text:
missing.append("job_context(")
if "finish(" not in text:
missing.append("finish(")
self.assertEqual(
missing,
[],
msg=_policy_msg(
"POLICY-CONTROL-002",
"development/LOGGING.md §2.5、§7",
f"{rel} missing: " + ", ".join(missing),
),
)
class TestPolicyControl003(unittest.TestCase):
def test_service_layer_has_no_bare_asyncio_sleep(self) -> None:
skill_root = get_skill_root()
offenders: list[str] = []
for path in _walk_files(skill_root, "scripts/service", suffix=".py"):
rel = _rel(skill_root, path)
for lineno, line in enumerate(_read_text(path).splitlines(), 1):
stripped = line.strip()
if not stripped or stripped.startswith("#"):
continue
if "asyncio.sleep" in stripped:
offenders.append(f"{rel}:{lineno}: {stripped}")
self.assertEqual(
offenders,
[],
msg=_policy_msg(
"POLICY-CONTROL-003",
"development/RPA.md §0.1",
"use interruptible_sleep instead:\n" + "\n".join(offenders),
),
)
class TestPolicyDocs001(unittest.TestCase):
def test_policy_matrix_exists_and_lists_policy_ids(self) -> None:
skill_root = get_skill_root()