Skip to content

Latest commit

 

History

History
304 lines (256 loc) · 13.2 KB

ai-code-verification.md

File metadata and controls

304 lines (256 loc) · 13.2 KB

AI Code Verification Coverage

skylos verify checks generated or edited source code before an agent hands it to review. By default it uses deterministic static analysis: Skylos does not execute target code, invoke package managers or compilers, call an LLM judge, or query a network service for local/workspace API verification.

Add --type-check to explicitly run the project's installed type checker and include its diagnostics. Add --profile to see slow phases and functions inside Skylos's scanner. Both are available to CLI users; neither option is specific to an agent integration.

This command has a narrower purpose than skylos defend:

  • skylos verify: did the edited code contain a proven AI-code defect, did its Python behavior change from Git HEAD, and did applicable checks complete?
  • skylos defend: does an agent implementation contain expected static guardrails before deployment?

Neither command currently proves the runtime behavior of a running agent.

For path targets, Python behavior comparison runs automatically alongside the existing checks:

skylos verify app.py
skylos verify .

Skylos uses Git HEAD as the baseline and discovers affected functions. The terminal report explains what changed and its possible impact. Pipes, --stdin, and saved output retain JSON with the same explanations. The JSON behavior result also records modeled differences and comparisons that could not be completed. A difference needs review: Skylos cannot infer whether the change was intentional. See Python behavior comparison for the supported model and its limits. Stdin verification retains its existing checks; it does not compare the provided source with Git.

Verify a repository, file, or range:

skylos verify . --file src/app.py --range 40:75 --project-context

For a directory such as ., the AI-defect scan covers the selected tree. The separate behavior result models supported Python working-tree changes against Git HEAD; it is not the scope selector for the AI-defect scan. Dependency hallucination checks are enabled for path targets and can query package registries; use --no-dependency-hallucinations to disable those lookups.

Security and secret findings

skylos verify and MCP verify_change also run the security (danger) and secrets scanners on the selected file and range, for path and --stdin targets alike. A finding only counts when it overlaps the selected file/--range:

Category Rules Included
security SKY-D* HIGH and CRITICAL severities, e.g. command injection, SQL injection, unsafe deserialization
secret SKY-S* Hard-coded credentials such as AWS keys, tokens, and private keys

Either category fails verification (exit 1), the same as an AI-code finding. Security findings use vibe_category: "security_vulnerability"; secret findings use vibe_category: "leaked_secret". Secret findings never carry the secret value. The message ends with a masked preview, and a secret object holds only the provider and that preview:

{
  "rule_id": "SKY-S101",
  "category": "secret",
  "vibe_category": "leaked_secret",
  "severity": "CRITICAL",
  "message": "Potential aws_access_key_id secret detected (redacted: AKIA…DFGH)",
  "secret": {"provider": "aws_access_key_id", "preview": "AKIA…DFGH"}
}

Every response includes security_checks_enabled. To get the earlier AI-code-only verdict, pass --no-security on the CLI, "include_security_findings": false in a --stdin manifest, or include_security_findings=false to the MCP tool. The response then reports security_checks_enabled: false.

Status and exit codes

Schema-version-2 responses use three statuses:

Status Exit Meaning
pass 0 No verified findings, every applicable expected check completed, and no behavior comparison requires review
fail 1 At least one verified AI-code, security, or secret finding exists
incomplete 2 No finding exists, but a check was unsupported, skipped, uncertain, or missing, or a modeled behavior change needs review

incomplete means a requested proof could not be established, such as a missing local TS/JS import, computed namespace member, unsupported language-local API check, or parser surface that Skylos could not prove.

Findings take precedence over incomplete coverage. --no-fail changes the process exit code to 0, but does not change the JSON status.

--no-behavior skips the Git behavior comparison, so the verdict comes from findings and check coverage alone; a comparison that cannot model a change (for example module-level assignments) can then never turn pass into incomplete.

Changed lines since a ref: --diff

skylos verify --diff              # everything changed since HEAD
skylos verify --diff origin/main  # commits after origin/main + staged + unstaged
skylos verify src --diff HEAD~3   # limit to a subdirectory

--diff [REF] (default HEAD) verifies every line changed since REF: commits after it, staged and unstaged edits, and untracked (not ignored) files. Findings outside the changed lines are dropped, range.file is the repo-relative path, and target.diff lists the files checked. The behavior comparison is not run in this mode. It cannot be combined with --stdin, --file, --range or --project-context. At most 200 files are checked; more makes the result incomplete. Per-file check coverage and structural contract scope are retained in the diff response, so an incomplete package inspection or external API limitation is still visible when findings are filtered to changed lines.

Output formats

--format auto (default) prints the human report on a terminal and JSON otherwise. --format json / --format human force one. --format short prints one line per finding (file:line RULE [SEVERITY] message, at most 25) and a final PASS|FAIL|INCOMPLETE: summary line, which suits agents and scripts better than the full JSON. range.file is always relative to the Git root of the target (or to the target directory outside Git).

Behavior comparison reports unavailable when no Git HEAD can be read, and unchanged when no relevant Python change needs comparison. These do not alter the result of the existing checks. Neither status claims behavior was proved equivalent.

Local API verification support

The local/workspace API suite currently has deterministic proof for:

Language Check ID Scope
Python python_local_api_reference Repo-local imported references with statically resolvable module surfaces
TypeScript / JavaScript typescript_local_api_surface Local and workspace imports, exports, namespaces, re-exports, and CommonJS surfaces
Go go_workspace_api_surface Exported selectors from local modules, workspaces, and local replacements
Java java_workspace_api_surface Explicitly attributable local types and statically knowable members

For TypeScript and JavaScript, imports from declared third-party dependencies and recognized Node built-ins are outside this local API check. The check reports their count in out_of_scope_references and can pass without proving those external APIs. A missing relative import, unresolved workspace package, local path alias, or unknown bare import still makes the check incomplete. Human and short reports say External API references unverified: N, including when an unrelated finding fails the run. JSON includes the same limitation in coverage.limitations; a complete local check does not prove external APIs.

When dependency hallucination checks are enabled, the installed-Python check python_installed_api_signature inspects imported allowlisted packages in the environment running Skylos. Missing, malformed, or truncated package member metadata is reported as incomplete coverage, with module names and reasons in unchecked_modules. It cannot produce a missing-API finding without positive metadata. If there are no findings, incomplete inspection exits 2. This check is scoped to installed package metadata; it does not execute target code or prove arbitrary external behavior.

Route contracts check required decorator or dependency names structurally. contract_checks records matched routes and explicitly reports authentication_behavior: "not_verified". A matching decorator, including one that simply returns its input function, does not establish that authentication or authorization is enforced.

PHP, Rust, Dart, C#, Kotlin, and Shell retain their existing static-analysis coverage; C++ currently has only narrow file-local dead-code detection. Deterministic local/workspace API proof is not implemented for any of those languages. Their expected checks are emitted as unsupported and skylos verify reports incomplete rather than silently claiming a complete proof.

Coverage object

When AI verification runs, the response includes an coverage object:

{
  "schema_version": 1,
  "state": "incomplete",
  "detected_languages": ["go", "php"],
  "expected_checks": [
    {
      "id": "go_workspace_api_surface",
      "languages": ["go"],
      "applicable_files": 2,
      "capability": "local_workspace_api_surface",
      "support": "supported"
    },
    {
      "id": "php_workspace_api_surface",
      "languages": ["php"],
      "applicable_files": 1,
      "capability": "local_workspace_api_surface",
      "support": "unsupported",
      "reason": "local_api_verification_not_implemented"
    }
  ],
  "missing_checks": [],
  "language_support": [
    {
      "language": "go",
      "capability": "local_workspace_api_surface",
      "status": "supported",
      "check_id": "go_workspace_api_surface"
    },
    {
      "language": "php",
      "capability": "local_workspace_api_surface",
      "status": "unsupported",
      "check_id": "php_workspace_api_surface",
      "reason": "local_api_verification_not_implemented"
    }
  ],
  "completed_checks": ["go_workspace_api_surface"],
  "skipped_checks": [
    {
      "id": "php_workspace_api_surface",
      "reasons": ["unsupported_capability"]
    }
  ],
  "checks": [
    {
      "id": "go_workspace_api_surface",
      "status": "completed",
      "outcome": "pass",
      "references": 1,
      "verified_references": 1,
      "skipped_references": 0,
      "finding_count": 0
    },
    {
      "id": "php_workspace_api_surface",
      "status": "skipped",
      "outcome": "incomplete",
      "references": 0,
      "verified_references": 0,
      "skipped_references": 0,
      "finding_count": 0,
      "reasons": [{"code": "unsupported_capability", "count": 1}]
    }
  ]
}

Fields have these meanings:

  • state: complete only when every applicable expected proof completed; otherwise incomplete.
  • detected_languages: canonical source-language labels found in the selected scan files.
  • expected_checks: the required proof universe derived from those files, including explicit support state.
  • missing_checks: supported checks that were expected but produced no record.
  • language_support: one support record per detected language and capability.
  • completed_checks: check IDs whose detector completed, including detectors that completed with verified findings.
  • skipped_checks: skipped check IDs and deterministic reason codes.
  • checks: reconciled check records with reference, finding, and skip counts.

Malformed or duplicate detector records are reconciled conservatively. They add malformed_check_record or duplicate_check_record reasons and keep coverage incomplete instead of allowing the last record to silently win.

Inline skylos: ignore comments are explicit waivers. A waived finding is removed from the failure count, but its check records suppressed_findings and a finding_suppressed reason so the resulting pass is not silent. Project-level rule disables remain incomplete because the required detector did not run.

The TypeScript/JavaScript languages share one check record when both are present. A repository with no applicable source files has no expected checks and remains complete.

Conservative proof rules

SKY-L012 remains the common hallucinated-reference rule across languages. Findings add metadata.language and metadata.reference_kind rather than creating language-specific rule IDs.

Skylos reports a finding only when the relevant local API surface is complete. Parser failures, wildcard ownership, build-conditional Go surfaces, ambiguous packages or Java types, generated/inherited Java members, shadowed qualifiers, and unsupported instance-type inference produce incomplete coverage instead of a critical finding or a false pass.

Java proof is also bounded by source set, nearest build/source module, member kind, and visibility. Test fixtures or unrelated modules cannot prove a production reference; nested-type and protected cross-package cases remain incomplete when inheritance or ownership cannot be established statically. File-scoped Go and Java scans carry exclude_folders into workspace discovery; excluded workspace paths therefore cannot supply evidence. Python imports that resolve to local modules outside the selected subtree are reported as local_import_outside_scan incompleteness rather than being trusted or treated as external.