docs: add W3C-style usage specification#537
Open
davidslater wants to merge 1 commit into
Open
Conversation
Add specs/usage-spec.md covering binary distribution, CLI invocation, artifact input contract, result output contract, exit codes, status reporting, report-result subcommand, conclude subcommand, self-correction retry, integration patterns, and security considerations. Update README.md to reference both specifications. Closes #383 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: David Slater <12449447+davidslater@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new W3C-style Usage Specification for integrating with the threat-detect CLI (installation, invocation, artifacts layout, result output, subcommands, and integration patterns), and updates the README to link to it alongside the existing behavior-focused spec.
Changes:
- Add
specs/usage-spec.mddefining the CLI usage/integration contract (US-01 through US-63). - Update
README.mdto reference both the Threat Detection spec (behavior) and the new Usage spec (integration/operations).
Show a summary per file
| File | Description |
|---|---|
| specs/usage-spec.md | New usage/integration specification for threat-detect, including subcommand contracts (report-result, conclude) and status/output semantics. |
| README.md | Adds links/descriptions for both W3C-style specs (behavior + usage). |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 6
- Review effort level: Low
| | `--prompt-injection` | bool | Yes | Whether prompt injection was detected | | ||
| | `--secret-leak` | bool | Yes | Whether secret leaks were detected | | ||
| | `--malicious-patch` | bool | Yes | Whether malicious patches were detected | | ||
| | `--reason` | string | Repeatable | Reason for a detected threat (one per flag) | |
| |------|---------| | ||
| | 0 | Result successfully recorded (or already recorded) | | ||
| | 2 | Invalid or missing required flags, or logic violation | | ||
| | 3 | Configuration error (`THREAT_DETECTION_RESULT_FILE` unset) | |
Comment on lines
+206
to
+207
| **US-21**: When any threat field is `true`, the `reasons` array MUST contain | ||
| at least one entry explaining the finding. |
Comment on lines
+332
to
+337
| **US-37**: On successful recording, the subcommand MUST print to stdout: | ||
|
|
||
| ``` | ||
| THREAT_DETECTION_RESULT_RECORDED: analysis complete; stop now and produce no further output. | ||
| ``` | ||
|
|
Comment on lines
+338
to
+344
| **US-38**: On validation or write errors, the subcommand MUST print to both | ||
| stdout and stderr: | ||
|
|
||
| ``` | ||
| THREAT_DETECTION_RESULT_ERROR: <reason>. Re-run threat_detection_result with corrected values. | ||
| ``` | ||
|
|
Comment on lines
+214
to
+216
| **US-23**: When `--output <path>` is specified, the result JSON MUST be | ||
| written to the given file path with permissions `0600`. No output MUST be | ||
| written to stdout in this case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
specs/usage-spec.md— a W3C-style usage specification to simplify integration with thethreat-detectCLI. Updates the README to reference both specs.Closes #383
What's in the spec
The usage specification (63 normative requirements, US-01 through US-63) covers:
THREAT_DETECTION_STATUS:line, reason values, wrapper guidancereport-resultconcludeRelationship to existing spec
The companion threat-detection-spec.md covers detection behavior (threat categories, engine config, custom prompts). This new spec covers usage — how to install, invoke, and integrate with the detector. Cross-references are included in both directions.