You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`--prompt-template` — Path to custom prompt template
61
61
-`--output` — Path to write JSON result (defaults to stdout)
62
+
-`--triage` — Enable fast Phase 1 structured-output triage. Default: `true`
63
+
-`--reflect-url` — `api-proxy``/reflect` base URL for structured-output calls. Default: `http://127.0.0.1:8080/reflect`
64
+
-`--triage-model` — Model override for Phase 1 `/reflect` triage
65
+
-`--triage-max-bytes` — Maximum bytes per artifact to inline during triage
66
+
-`--triage-retries` — Retries for malformed structured-output responses
62
67
-`--version` — Print version and exit
63
68
69
+
`--reflect-url` can also be supplied with `THREAT_DETECTION_REFLECT_URL`,
70
+
`API_PROXY_REFLECT_URL`, or `REFLECT_URL`. By default, `threat-detect` first
71
+
tries a non-agentic `/reflect` call with a strict JSON schema matching the result
72
+
contract. An all-false valid triage result exits successfully without the full
73
+
detector. Threats, uncertainty, unsupported models, proxy errors, or malformed
74
+
responses fail safe into the full detector. The full detector preserves the
75
+
existing CLI engine behavior and prefers `/reflect` structured output when a
76
+
schema-capable model is available.
77
+
64
78
**Exit codes:**
65
79
-`0` — Safe (no threats detected)
66
80
-`1` — Threat detected
@@ -131,13 +145,13 @@ The extraction staging model is:
131
145
- Stage 3: `github/gh-aw` integration
132
146
133
147
Stage 1 is functionally represented in this repository.
134
-
The standalone Go CLI, artifact reader, prompt builder, result parser, engine abstraction, W3C-style specification, unit tests, CI, Dockerfile, and release workflow are present.
148
+
The standalone Go CLI, artifact reader, prompt builder, two-phase `/reflect` triage, result parser, engine abstraction, W3C-style specification, unit tests, CI, Dockerfile, and release workflow are present.
135
149
Remaining work involves integration with `github/gh-aw` and production hardening of the container runtime in Stage 2/3, not additional JavaScript porting in this repository.
136
150
137
151
Decisions for the unresolved extraction questions:
138
152
139
153
-**JavaScript scripts**: detection setup and result parsing are implemented in Go here; the old GitHub Actions JavaScript scripts should not be needed once `gh-aw` switches to the container contract.
140
-
-**Engine CLIs**: do not bundle Copilot, Claude, or Codex CLIs into the detector image. The detector invokes the selected engine CLI from `PATH` and forwards the `--model` value. Production `gh-aw` integration should install or provide the selected engine CLI in the detection job, then run the pinned detector binary extracted from the detector image in that same runner/AWF environment. This keeps the image small, avoids runtime installation inside the image, and reuses the existing engine installation/authentication path.
154
+
-**Engine CLIs and `/reflect`**: do not bundle Copilot, Claude, or Codex CLIs into the detector image. The detector invokes the selected engine CLI from `PATH` and forwards the `--model` value when full CLI analysis is needed. When `--reflect-url` is configured, the detector can call `api-proxy` directly for structured-output triage and schema-capable full analysis before falling back to CLI behavior. Production `gh-aw` integration should install or provide the selected engine CLI in the detection job, then run the pinned detector binary extracted from the detector image in that same runner/AWF environment. This keeps the image small, avoids runtime installation inside the image, and reuses the existing engine installation/authentication path.
141
155
-**Custom steps**: custom `threat-detection.steps` remain orchestrator-owned. They should run before or after the container in the `gh-aw` job rather than being passed into this container as arbitrary scripts.
142
156
-**Backward compatibility**: do not ship a long-lived dual-mode compatibility window. Stage 3 should switch `gh-aw` to the pinned detector image path after Stage 4 validation passes; users that need inline detection can pin an older `gh-aw` release. A temporary internal fallback is acceptable during implementation only, but should not become a documented public feature flag unless Stage 4 exposes a blocking compatibility issue.
143
157
-**Ollama/LlamaGuard**: keep this as a custom-step pattern unless a dedicated image variant is explicitly required.
fullDetectionCorrectionSummaryFormat="Your previous response did not contain a valid %s JSON object"
37
+
fullDetectionCorrectionInstructionFormat="Return exactly one corrected result line using the required %s prefix."
34
38
)
35
39
36
40
funcmain() {
@@ -42,18 +46,28 @@ func run() int {
42
46
deferstop()
43
47
44
48
var (
45
-
engineIDstring
46
-
modelstring
47
-
promptFilestring
48
-
outputJSONstring
49
-
versionbool
49
+
engineIDstring
50
+
modelstring
51
+
promptFilestring
52
+
outputJSONstring
53
+
versionbool
54
+
triagebool
55
+
reflectURLstring
56
+
triageModelstring
57
+
triageMaxBytesint
58
+
triageRetriesint
50
59
)
51
60
52
61
flag.StringVar(&engineID, "engine", "", "AI engine to use (copilot, claude, codex)")
53
62
flag.StringVar(&model, "model", "", "Model to use for detection")
54
63
flag.StringVar(&promptFile, "prompt-template", "", "Path to custom prompt template (defaults to built-in)")
55
64
flag.StringVar(&outputJSON, "output", "", "Path to write JSON result (defaults to stdout)")
56
65
flag.BoolVar(&version, "version", false, "Print version and exit")
66
+
flag.BoolVar(&triage, "triage", envBool("THREAT_DETECTION_TRIAGE", true), "Run Phase 1 structured-output triage before full detection (env: THREAT_DETECTION_TRIAGE)")
67
+
flag.StringVar(&reflectURL, "reflect-url", envFirstOrDefault(engine.DefaultReflectURL, "THREAT_DETECTION_REFLECT_URL", "API_PROXY_REFLECT_URL", "REFLECT_URL"), "api-proxy reflect base URL")
68
+
flag.StringVar(&triageModel, "triage-model", os.Getenv("THREAT_DETECTION_TRIAGE_MODEL"), "Model to use for reflect triage")
69
+
flag.IntVar(&triageMaxBytes, "triage-max-bytes", envInt("THREAT_DETECTION_TRIAGE_MAX_BYTES", detector.DefaultTriageMaxBytes()), "Maximum bytes per artifact to inline for triage")
70
+
flag.IntVar(&triageRetries, "triage-retries", envInt("THREAT_DETECTION_TRIAGE_RETRIES", 1), "Retries for malformed structured outputs")
0 commit comments