HumboldtJoker commited on
Commit
0de09b5
·
verified ·
1 Parent(s): d2a02c2

Clean up nested duplicate: v2/v2/skills/test_runner.py

Browse files
Files changed (1) hide show
  1. v2/v2/skills/test_runner.py +0 -87
v2/v2/skills/test_runner.py DELETED
@@ -1,87 +0,0 @@
1
- """Test runner chip — verify the draft instead of asserting it works.
2
-
3
- Pulls fenced TS/JS blocks out of the model's draft and syntax-checks
4
- them with tsc; when the campus repo is present, can also run a targeted
5
- workspace typecheck. The result is a verification artifact the
6
- discipline gate uses: verified code can earn HIGH confidence, unverified
7
- code is explicitly labeled as such.
8
- """
9
-
10
- from kintsugi_core import (
11
- BaseSkillChip,
12
- EFEWeights,
13
- SkillCapability,
14
- SkillContext,
15
- SkillDomain,
16
- SkillRequest,
17
- SkillResponse,
18
- )
19
- from tools.test_tools import TestTools, extract_code_blocks
20
-
21
- MAX_BLOCKS = 3
22
-
23
-
24
- class TestRunnerChip(BaseSkillChip):
25
- name = "test_runner"
26
- description = "Syntax-check and test generated code"
27
- version = "2.0.0"
28
- domain = SkillDomain.OPERATIONS
29
- efe_weights = EFEWeights(
30
- mission_alignment=0.15, stakeholder_benefit=0.25,
31
- resource_efficiency=0.20, transparency=0.30, equity=0.10,
32
- )
33
- capabilities = [SkillCapability.EXECUTE_SHELL]
34
-
35
- def __init__(self, test_tools: TestTools | None = None):
36
- super().__init__()
37
- self.test_tools = test_tools or TestTools()
38
-
39
- async def handle(self, request: SkillRequest,
40
- context: SkillContext) -> SkillResponse:
41
- session = context.metadata.get("session")
42
- draft_artifact = request.parameters.get("draft") or {}
43
- draft_text = (
44
- draft_artifact.get("text", "")
45
- if isinstance(draft_artifact, dict) else str(draft_artifact)
46
- )
47
-
48
- blocks = [
49
- b for b in extract_code_blocks(draft_text)
50
- if b["lang"] in ("ts", "tsx", "typescript", "js", "javascript", "")
51
- and b["code"].strip()
52
- ][:MAX_BLOCKS]
53
-
54
- checks = []
55
- for block in blocks:
56
- lang = "ts" if block["lang"] in ("", "ts", "tsx", "typescript") else "js"
57
- result = self.test_tools.syntax_check_snippet(block["code"], lang)
58
- checks.append({
59
- "lang": lang,
60
- "available": result.available,
61
- "passed": result.passed,
62
- "command": result.command,
63
- "output": result.output[:1500],
64
- "snippet_head": block["code"][:120],
65
- })
66
- if session and result.available:
67
- session.record_evidence(
68
- "verification",
69
- f"{result.command}: {'pass' if result.passed else 'FAIL'}",
70
- self.name,
71
- )
72
-
73
- ran = [c for c in checks if c["available"]]
74
- failed = [c for c in ran if not c["passed"]]
75
- report = {
76
- "code_blocks_found": len(blocks),
77
- "checks_run": len(ran),
78
- "checks_failed": len(failed),
79
- "tooling_available": bool(ran) or not blocks,
80
- "checks": checks,
81
- }
82
- summary = (
83
- f"{len(blocks)} code block(s); {len(ran)} checked, "
84
- f"{len(failed)} failed"
85
- if blocks else "no code blocks in draft — nothing to verify"
86
- )
87
- return SkillResponse(content=summary, success=True, data=report)