Native command evaluation and classification
The native command evaluator turns a bounded command or pre-tool request into a trusted risk result. It parses the request, finds known capabilities, checks critical effects and secret movement, joins all decision floors, and returns a typed result that native enforcement can apply without re-parsing the command in Python. See native runtime authority for the trust boundary, native command-source programs for the catalog that supplies command capabilities, and guard decision and enforcement for the downstream use of the result.
Evaluation model
The evaluator separates command facts from decision policy. A canonical command describes what the parser can prove. Native classifiers add capability matches, critical floors, secret-read floors, data-flow findings, and positive proofs. The decision plane then joins these inputs and keeps the strongest required action.
The main result is a minimum action. allow means the native path proved a bounded safe form. warn permits execution with a warning. review, require-reapproval, sandbox-required, and block add stronger conditions. A minimum action is a floor for later enforcement. It is not an approval by itself.
The evaluation path has four broad stages:
- Parse the command and derive a stable security identity.
- Classify capabilities and direct critical effects.
- Inspect data flow and sensitive read risk.
- Compose factors, proofs, controls, and uncertainty into one decision.
This diagram shows how command text becomes a native enforcement floor.
flowchart LR
A[Raw hook or command request] --> B[Bounded extraction]
B --> C[Canonical command model]
C --> D[Capability observations]
C --> E[Critical effect floors]
C --> F[Secret read and data-flow findings]
D --> G[Decision factors]
E --> G
F --> G
G --> H[Controls and positive proofs]
H --> I[Effect decision]
I --> J[Typed native result]
Parsing model
Canonical command model
The canonical command model is the shared fact set for native matching. It records normalized text, shell dialect, transport, wrapper context, command segments, parser confidence, uncertainty, and path overrides. Its security identity hashes the command structure that matters to later evidence and approval binding. The model also carries the execution context needed to resolve a working directory, home path, and selected inherited settings.
The parser uses an exact model when it can prove the shell structure. It treats inert null-device redirects as part of the exact command while keeping real redirects uncertain. It can also read a sole command group, safe lists of top-level groups, bounded loops, arithmetic expansion, and bounded wrapper forms. Unsupported substitutions, parameter expansion, startup-shell options, unread scripts, unsupported redirects, size limits, and malformed quoting remain uncertain. An uncertain model is useful evidence of what could not be proved. It is not an allow proof.
References: rust/…/command_model.rs• L73-127 rust/…/command_model.rs• L131-221 rust/…/canonical_command.rs• L54-110 rust/…/parser_tests.rs• L12-47 rust/…/native_command_unmodeled_shapes.rs• L84-147 rust/…/native_command_unmodeled_tests.rs• L111-168
Command segments
The parser represents a compound shell request as ordered segments. Each segment keeps its executable, arguments, environment names, wrapper chain, execution context, and pipeline position. This lets a rule apply to the exact part of a compound command instead of treating the whole string as one opaque action.
Top-level separators, pipelines, background jobs, input redirects, null sinks, and command groups remain distinct. Quoting and escapes are read before argument proofs, so a quoted operator stays data while an unquoted operator changes execution. A safe result for one segment therefore cannot hide a risky neighboring segment or a data path that crosses a pipe. Bounded literal loops and safe control-flow shapes may be judged as the command list they produce. A dynamic loop or a shape that can run an unseen program remains uncertain.
References: rust/…/parser_segments.rs• L25-73 rust/…/parser_segments.rs• L130-317 rust/…/parser_shell_tokens.rs• L22-160 rust/…/parser_segment_shapes.rs• L46-181 rust/…/native_command_unmodeled_tests.rs• L680-744
Execution wrappers
Wrapper handling removes only prefixes whose effect is bounded and visible in the command text. Trusted env, command, time, timeout, and approved launcher forms expose the program behind them while retaining environment names and privilege context. sudo-like privilege changes remain part of the review identity.
Inline sh or bash -c text can be read when its options do not load startup files or change how the text is interpreted. Login, interactive, zsh, code-loading, and other widened modes remain blocked or uncertain because they can run code outside the submitted text. The recovery hint names plain bash -c only after native evaluation proves that spelling is the form Guard can inspect. Plain data filters, inert heredocs, and program-name lookups are stripped only when their bounded form cannot start another program.
References: rust/…/parser_wrappers.rs• L12-120 rust/…/parser_wrappers.rs• L123-183 rust/…/parser_wrappers.rs• L242-362 rust/…/native_command_unmodeled_shapes.rs• L47-148 rust/…/native_command_unmodeled_shapes.rs• L201-287 rust/…/native_command_controls_floor.rs• L141-168 rust/…/native_command_startup_shell_tests.rs• L31-46
Capability classification
Native capability observations
The packaged native program classifies a canonical command against typed command capabilities. It uses executable, argument, structured operand, package, pipeline, and specialized matchers. Compatibility capabilities cover rules that remain outside the declarative matcher form.
Matching is bounded and shared. The evaluator checks one deadline for the whole decision, reuses results for repeated matcher nodes, and records the segments that support each observation. Matcher contracts distinguish launcher options from command operands. They preserve -- boundaries, tolerate approved package-version forms, and treat unknown options conservatively when a rule requires fail-secure matching. A matcher failure or unsupported command context is an evaluation error or uncertainty. It does not become an empty successful match.
Safe variants and compatibility proofs are scoped to both a capability and the segments they cover. A recoverable or scratch-file removal can remove only its own destructive observation. A safe preview or read in one segment cannot erase a destructive sibling. Evidence is redacted to a small executable and segment record, and observation and evidence limits keep the result bounded.
References: rust/…/native_command_program_evaluation.rs• L5-99 rust/…/native_command_program_evaluation.rs• L105-169 rust/…/native_command_program_evaluation.rs• L173-235 rust/…/native_command_program_evaluation.rs• L239-333 rust/…/native_command_program_observations.rs• L65-188 rust/…/native_command_program_observations.rs• L218-247 rust/…/command_evaluation_compose.rs• L82-132
Capability floors
Each matched rule contributes a floor based on its ownership, severity, default mode, and whether it is required. Safe variants can remove a rule's effective coverage for the segments they prove safe. They do not remove coverage from other segments.
The catalog is the native metadata view that connects those observations to extensions, rules, permissions, action classes, and typed capabilities. It normalizes the same lookup surface used by the source catalog, preserves safe-variant metadata for evidence checks, and binds its catalog and program digests before native evaluation can use the packaged records. A digest mismatch makes the catalog unavailable instead of allowing metadata from a different program to authorize a command.
Control compilation resolves the packaged catalog against authenticated control layers before a request runs. It tracks active extensions, blocked extensions, blocked permissions, explicit permission enables, global lockdown, and the exact binding used for the receipt. A disabled owner remains a block even when another proof admits the command. A user Allow can settle only the bounded native reviews that its enabled permissions cover across every segment. It cannot clear fixed security floors or an unresolved evaluation error.
For a compound command, an enabled permission can cover its matching action when every other segment also passes its own native check. A later read does not lose its proof merely because an earlier contributed action needed the user's Allow. The same coverage is rechecked when a command enters a new worktree. It applies only to the action and paths that the Allow names. A path read, write, package action, or other unapproved step keeps its own floor. A disabled segment or global lockdown dominates the whole command regardless of its position.
Capability attribution and action authority remain separate. A compatibility match explains which known capability applies. The native floor and the active control state determine whether that capability needs review, approval, or a stronger action.
References: rust/…/native_command_catalog.rs• L50-162 rust/…/native_command_catalog.rs• L190-267 rust/…/native_command_catalog.rs• L269-353 rust/…/native_command_catalog.rs• L374-411 rust/…/native_command_controls.rs• L27-181 rust/…/native_command_controls.rs• L223-370 rust/…/native_command_controls.rs• L472-587 rust/…/native_command_controls_floor.rs• L27-60 rust/…/native_command_compound_controls_tests.rs• L26-86 rust/…/native_command_contributed_allow_tests.rs• L126-166 rust/…/native_command_contributed_allow_tests.rs• L268-327
Critical-floor classification
Critical effects
Critical-floor classification catches effects that must not depend on an optional catalog control. It covers destructive local actions, destructive remote actions, Guard self-protection changes, executable path drift, local package sources, dynamic or pipeline-sensitive reads, credential metadata, and selected cloud or system reads.
The classifier follows bounded launcher children and compound command context. A nested command can therefore raise the parent command's floor. Expansion limits, unknown destinations, and command forms that can load code raise a stronger floor when the evaluator cannot safely inspect the full launch chain.
Checkout destinations receive their own fixed screen. Git clone, init, submodule, and worktree operations are checked against the working directory and each proven directory change. Protected locations include Guard state, Git internals and hooks, harness configuration, auto-start locations, and other paths where a new checkout could be loaded without another review. A remote with no explicit destination is checked using the directory name Git would derive from the remote.
References: rust/…/critical_floor_rules.rs• L61-161 rust/…/command_critical_floors.rs• L23-157 rust/…/checkout_destination_floor.rs• L22-76 rust/…/checkout_destination_floor.rs• L154-271 rust/…/checkout_destination_repository.rs• L10-84
Critical-floor transport
The direct critical-floor path parses a script, produces critical factors, and reduces them through the same effect decision lattice used by full command evaluation. Its caller accepts only a known typed action. Missing, malformed, or conflicting native output becomes block rather than an implicit allow.
This path is intentionally monotonic. It can raise the required action, but it cannot use a positive command proof to erase a critical effect that the command model did not bind to a safe target or execution context.
References: rust/…/critical_floor_context.rs• L12-23 rust/…/command_critical_floors.rs• L217-238 tests/test_native_critical_floor.py• L14-46
Data-flow and secret-risk analysis
Shell data flow
The data-flow detector follows local sources through common shell paths to possible sinks. It first separates commands, pipes, redirects, substitutions, variables, and interpreter boundaries. It then checks sensitive path families and command forms that can move their contents outside the local boundary.
The detector reports typed critical signals for shell actions. It does not execute the command and it does not replace the canonical command model. Non-shell actions return no shell data-flow findings, so callers do not contact the data-flow native operation for unrelated action types.
References: rust/…/data_flow.rs• L28-169 rust/…/data_flow_rules.rs• L724-854 rust/…/data_flow_rules.rs• L1015-1199 tests/test_native_data_flow_transport.py• L130-140
Secret sources and sinks
Secret-risk analysis recognizes sensitive files, credential paths, token-bearing URLs, secret variables, and command substitutions. It then checks sinks such as HTTP upload, Python or Node network calls, DNS labels, webhooks, SCP, package publish, clipboard writes, and world-readable temporary files.
Each finding has critical severity and strong confidence. The result keeps a short reason and redacted evidence rather than returning command content or secret values. A failed pattern or unsafe parse is handled as a risk signal or an evaluation failure, not as proof that the flow is safe. Search and listing proofs also inspect hidden names, globs, links, recursive descendants, and bounded directory walks so a read cannot hide a sensitive entry behind shell expansion.
References: rust/…/data_flow_rules.rs• L474-648 rust/…/data_flow_rules.rs• L724-854 rust/…/data_flow_rules.rs• L1202-1384 rust/…/tree.rs• L42-157 rust/…/tree.rs• L364-473 rust/…/descendant.rs• L56-123
Secret-read floors
Direct secret reads and incomplete local-code inspection add a native review floor even when the command has another benign classification. A sensitive path produces critical.local-secret-read. A dynamic script or unresolved local execution path produces critical.local-script-execution.
These factors are review constraints, not positive proofs. The evaluator keeps secret-read factors when a syntax-only benign result cannot prove which file or executor will run.
References: rust/…/command_shell_read_factors.rs• L9-42 rust/…/command_evaluation_compose.rs• L249-325 rust/…/safe_reads.rs• L27-145
Pre-tool handling
Envelope extraction
Native pre-tool handling extracts command, tool, path, URL, package, prompt, and intent signals from the raw hook payload. It accepts supported aliases but rejects conflicting values. Bounded depth, key count, array size, string count, and command size protect the native boundary before semantic classification begins.
Malformed, ambiguous, or oversized input returns a typed block result. This keeps a payload-shape failure from becoming an unknown action that a harness might run.
References: rust/…/generic_extract.rs• L6-75 rust/…/generic_extract.rs• L146-240 rust/…/generic.rs• L224-384
Action classification
The evaluator maps extracted signals to an action type and operation. It handles command, file, package, MCP, network, process, browser, configuration, prompt, harness, and unknown actions through one typed result contract.
Structured targets remain independent evidence. A command can be explicitly benign while a separate file path is sensitive. In that case the structured risk keeps the result at review or above. This prevents a safe command spelling from authorizing a different effect carried in the same tool request.
Pre-tool projections make the same decision for the action that the sink will run. Package directory flags become an equivalent directory change. A virtual-environment activation, Git-config isolation, process substitution, redirect, bounded loop, or contained worktree chain is rejudged only when the projected command preserves the real execution meaning. Otherwise the original request keeps its safer result.
References: rust/…/generic_evaluate.rs• L7-181 rust/…/generic_result.rs• L22-65 rust/…/package_directory_flags.rs• L14-247 rust/…/control_flow_flatten_loop.rs• L15-117
Bounded read and write proofs
Searches, listings, file reads, edits, package queries, cluster reads, and data filters use bounded proofs for the effect they claim. The proof checks the real target, path context, shell expansion, and any local configuration that can add work. It does not turn a general-purpose tool into a safe tool merely because its name sounds read-only.
The same boundary covers pure filters. A jq filter must be a bounded function of the value already read. A sed script must only reshape standard input. Output filters such as head, tail, grep, rg, cut, and selected rejoined stages must open no extra file and must use only the forms the sink can run. Unknown flags, file operands, code loading, and unbounded scripts keep review.
References: rust/…/safe_reads.rs• L181-238 rust/…/safe_reads.rs• L479-565 rust/…/jq_filter.rs• L121-238 rust/…/contained_output_filters.rs• L62-121 rust/…/contained_output_filters.rs• L187-255 rust/…/contained_sed_script.rs• L22-42
Contained execution plans
Some reviewed commands can run in a protected workspace rather than stop for a user decision. Native classification creates the plan for the same core command, directory, output filters, sibling project, and worktree creation that the execution sink will use.
The plan is valid only for bounded shapes. A supported directory flag or output filter is peeled and re-authorized in its real directory. A git worktree add chain proves the add first, creates the checkout outside the sandbox, and judges the checks again against the new checkout. An unsupported peel is explicit, so the sink runs the original text as a whole in the sandbox instead of silently executing a different command. A contributed action allowed after entering the new worktree is still limited to the exact allowed action. A changed path, write, package step, or unrelated command keeps review.
This keeps classification and execution tied to one semantic plan. It also prevents a Python-side re-parser from dropping a redirect, sibling root, output stage, or checkout destination that native authority did not cover.
References: rust/…/contained_wrapper_plan.rs• L13-76 rust/…/contained_wrapper_plan.rs• L79-153 rust/…/contained_worktree_add.rs• L65-210 rust/…/native_command_contributed_allow_tests.rs• L268-327 rust/…/native_command_compound_launch_tests.rs• L63-121 rust/…/contained_output_filters_tests.rs• L128-225
Git execution context
Git reads have a separate context check because Git can run pagers, diff drivers, text converters, filters, credential readers, hooks, or partial-clone fetches from configuration. Native evaluation uses bounded, cleared-environment probes when the execution environment and paths are trusted.
The probe distinguishes three outcomes: inert, unanswered, and refused. An explicit user Allow can answer an unanswered question for the same checkout. It cannot approve a helper the probe found, a configuration it read but could not finish, an untrusted launch, or a read whose later steps can replace its program or configuration. Git output paths and checkout destinations are checked separately so a normal archive or sibling worktree can remain allowed without allowing writes into .git, hooks, harness state, or auto-start locations.
References: rust/…/git_helper_context.rs• L177-224 rust/…/git_config.rs• L36-121 rust/…/git_config.rs• L409-786 rust/…/git_probe.rs• L13-20 rust/…/git_read_after_allow.rs• L105-172 rust/…/git_output_target.rs• L12-157
Tool-specific read boundaries
Tool-specific proofs keep common read actions useful without treating their names as authority. Kubernetes proofs allow bounded cluster state but keep Secret reads, credential paths, raw API calls, plugins, local templates, and unsafe kubeconfig sources under review. GitHub permission observations require every permission a segment touches. Hidden home and repository listings allow names only when their bounded path and store screens clear.
The same rule applies to package settings and search patterns. An environment prefix is projected only when its value is a closed, inert setting. A jq, grep, rg, glob, or bracket pattern is safe only when its grammar and possible targets are bounded. An unknown option or path expansion keeps the native review.
References: rust/…/kubectl_reads.rs• L1-19 rust/…/kubectl_reads.rs• L166-234 rust/…/home_hidden_listing.rs• L26-117 rust/…/hidden_listing.rs• L168-246 rust/…/inert_tool_settings.rs• L91-145 rust/…/native_command_controls_floor.rs• L290-318
Pre-tool command decisions
For a command-bearing pre-tool request, native code parses and classifies the command before it evaluates the wider tool action. It blocks credential posting, destructive commands, Guard self-protection changes, and clear secret exfiltration. It allows only bounded exact-safe forms. Other commands receive review unless a separate proof or policy floor changes the result.
Search scopes, file reads, file writes, patch operations, task metadata, and selected tool-specific forms use their own bounded proofs. Git helper context receives a later check because a read-only Git command can still execute configured helpers. Package installs can avoid the package-code floor only in the narrow forms that disable lifecycle scripts and all other code-loading setup.
References: rust/…/generic.rs• L830-977 rust/…/generic.rs• L1023-1113 rust/…/package_scripts_disabled.rs• L32-97 rust/…/tests.rs• L1-80
Bounded evaluation output
Some tools evaluate code that can make other tool calls. Native handling releases their output as a known action only when the evaluator proves the bounded form. In OMP, bounded file reads, names-only listings, read-only language-server queries, proved shell calls, pure result reports, loopback browser checks, and proved read-only GitHub lookups retain their real action type and its installed floor.
This proof does not lower later controls. Output scans, intrinsic blocks, default policy, and harness policy still apply. An unproved cell returns to the safer fallback path, so evaluated code cannot hide a command, write, sensitive path, or network action behind a generic tool result.
References: rust/…/policy_enforcement_omp_eval.rs• L1-73 rust/…/policy_enforcement_omp_eval_output_tests.rs• L3-181 rust/…/policy_enforcement_omp_eval_output_tests.rs• L205-315 rust/…/policy_enforcement_omp_eval_output_tests.rs• L318-545
Pre-tool result contract
The native result states the authority, typed action, operation, decision, policy action, minimum action, reason code, reason, and whether the result is explicitly benign. allow and warn permit execution. Review, reapproval, sandbox, and block remain deny-style results until their owning continuation handles them.
The transport decoder rejects raw command, path, URL, or prompt fields in the result and rejects conflicting action values. The harness layer renders the typed result. It does not rebuild a weaker semantic result from the original payload.
References: rust/…/generic_result.rs• L42-99 tests/test_native_pretool_transport.py• L39-95 tests/test_rust_pretool_worker_authority_gate.py• L94-134
Decision composition
Evaluation factors
Full command evaluation combines native classification, capability evidence, critical floors, secret-read floors, contained-routine candidates, verified-read candidates, workspace-write candidates, workflow authorization, and active extension controls. Each input becomes a factor with a source, floor, reason, operation or segment reference, and optional proof.
The evaluator also keeps a baseline decision. This shows the result without authenticated control or permission proof. The current decision includes the accepted control layer and is the result used for native enforcement.
References: rust/…/command_evaluation_compose.rs• L51-62 rust/…/command_evaluation_compose.rs• L300-400 rust/…/command_evaluation_compose.rs• L447-489
Supply-chain evaluation inputs
Package evaluation can need registry metadata and a saved policy result before it can finish classification. Repeated reads of the same registry URL with the same media type share one caller-managed fetch during an evaluation. An unresolved fetch remains unresolved for replay instead of causing repeated network work.
The caller can provide a saved-policy result or request one when it is absent. Test-only overrides are accepted only through a dedicated resident opt-in and a small set of bounded, known fields. Invalid policy, authentication, entitlement, or registry fixture shapes are refused rather than treated as missing data.
References: rust/…/supply_chain_eval_seams.rs• L20-68 rust/…/supply_chain_eval_seams.rs• L70-167 rust/…/supply_chain_eval_seams_tests.rs• L27-62
Action lattice
The effect decision chooses the highest action floor across all factors and typed uncertainties. The action order is allow, warn, review, require-reapproval, sandbox-required, and block. Uncertainty has its own floor: partial or dynamic input needs review, budget or launch identity gaps need reapproval, and parser or boundary failures block.
An allow action also needs a valid proof route. The final disposition can therefore be silently verified, contained, or workflow-authorized. A stronger action always wins over a positive proof from another factor.
References: rust/…/effect_decision.rs• L32-78 rust/…/effect_decision.rs• L140-197 rust/…/effect_decision.rs• L639-740
Control effects
Active local-admin and signed-cloud controls can enable or disable catalog entries. An exact enabled permission can provide a bound positive proof for an eligible command rule. It cannot clear an intrinsic block, a secret-read floor, an unresolved critical effect, an unsafe structured target, or a disabled owner.
When control authority is unavailable, cataloged risk, destructive action, and workspace writes fail closed. The evaluator records the control failure as evidence and raises the minimum action when the affected risk class needs native authority. A deadline timeout can settle at review when no disabled owner could reach the unfinished command. It remains block when a disabled owner may be reached. Other evaluation failures remain block.
References: rust/…/native_command_controls.rs• L223-279 rust/…/native_command_controls.rs• L284-369 rust/…/native_command_controls.rs• L431-469 rust/…/native_command_controls_floor.rs• L63-110 rust/…/native_command_unmodeled_disabled_reach.rs• L25-125 rust/…/native_command_controls_precedence.rs• L80-137
Decision materialization
After the effect decision is built, the evaluator raises the materialized command floor to the stronger of the accumulated command floor and the decision action. It returns the security identity, parse confidence, controlling capability, matched rules, observations, decision plane, baseline decision, control resolution, and a digest of the observations.
This result is the native semantic record. A later bridge may render it for a harness or start an approval continuation, but it must preserve the minimum action and its controlling reasons.
References: rust/…/command_evaluation_compose.rs• L458-489 rust/…/command_evaluation.rs• L364-450 rust/…/native_command_controls.rs• L372-446
Offline evaluation batches
The offline batch path evaluates a bounded corpus through the same production parser, controls, and pre-tool evaluator used by runtime requests. It applies synthetic control layers only for comparison and reports zero executed target commands. The batch binds program, catalog, trust, and control digests so a comparison result still shows which native program and control view produced it.
The batch accepts bounded cases and optional path and execution context. It rejects duplicate or malformed case identities, unknown fields, contradictory authority inputs, and invalid first-install state. A never-enrolled binding models packaged first-party protection without creating a persisted approval or runtime receipt.
References: rust/…/native_command_source_evaluation_batch.rs• L9-149 rust/…/native_command_source_evaluation_batch.rs• L152-200 rust/…/native_command_source_evaluation_batch.rs• L213-269 rust/…/native_command_source_evaluation_batch.rs• L290-425
Resident enforcement proofs
When native enforcement must continue a reviewed action, the resident proves the action against the request it received. The proof can bind the reviewed command, its workspace and execution environment, the files it may read, the repository settings a Git action may use, and the rules that judged it. A hook review derives the review-binding and exact-action queries from one reviewed PreToolUse payload, then checks the receipt's policy binding once for both queries.
The hook review accepts an unbound result only when neither the verdict nor its receipt claims extension policy. If extension policy is present, the receipt must match the hook event and result and carry a valid rule digest, runtime identity, and command-extension uncertainty record. Malformed verdict facts or partial policy data make the query invalid. The exact-action query preserves object input as sorted key/value evidence and preserves non-object input as raw binding data so the launch cannot change its meaning.
The resident returns a token or a once-only refusal reason. A token is valid only when the request identity, launch state, command identity, workspace, policy binding, and proof budget match. Stable reasons cover missing command identity, mutable launchers, compound commands, Guard control, package actions, non-overridable floors, unproven launches, sensitive paths, broad scope, destructive commands, Git helper configuration, and unavailable script-delivery binding. A failed proof is not an allow result.
Authenticated grant tests show that a persistent grant can run across resident restarts, a once-only claim launches exactly once, a changed helper does not spend the saved claim, and an expired or tampered claim never opens the target. This keeps review continuation under the same native authority as the original classification.
References: rust/…/native_exact_action_op.rs• L1-7 rust/…/native_exact_action_op.rs• L100-130 rust/…/native_exact_action_op.rs• L184-227 rust/…/native_exact_action_op.rs• L259-400 rust/…/hook_review.rs• L26-175 rust/…/hook_review.rs• L177-244 rust/…/reasons.rs• L1-64 rust/…/bash_grant_tests.rs• L334-469
Parity evidence
Python and Rust decision parity
Parity fixtures show that the native evaluator preserves the established decision contract while Rust becomes the enforcement owner. The command-evaluation oracle compares the full evaluation payload for command cases. Effect-decision vectors compare the full decision-plane payload against the Python oracle.
These checks cover floors, reasons, proof routes, controlling matches, observations, uncertainty, and stable identity fields. A mismatch is evidence of contract drift. It is not a reason to use a weaker Python result at runtime.
References: rust/…/command_evaluation_tests.rs• L1-9 rust/…/command_evaluation_tests.rs• L168-271 rust/…/effect_decision_parity.rs• L1-41
Data-flow parity
The data-flow corpus compares ordered signal IDs and complete signal payloads for recorded vectors. Additional cases protect sensitive basename coverage and ensure malformed bracketed URLs do not panic the native detector.
The transport tests add a separate boundary guarantee. They bind the request ID and request digest, reject malformed result shapes, cap signal counts, and raise an error when the resident is unavailable. Python receives native signals. It does not evaluate the command again.
References: rust/…/data_flow_rules_parity.rs• L1-80 tests/test_native_data_flow_transport.py• L57-128
Offline program parity
Native source parity runs a baseline program and a candidate program through the same native evaluator with synthetic controls. It compares the complete result and raw declarative observations while ignoring only the program and control identity fields that are expected to change.
The offline result is a comparison record with zero target commands executed. Synthetic controls are not persisted, authenticated, or published. This gives release work evidence about behavior without creating runtime authority. The evaluation batch also preserves the production command model, observation binding, error evidence, and control precedence for each case.
References: rust/…/native_command_source_parity.rs• L26-65 rust/…/native_command_source_parity.rs• L67-164 rust/…/native_command_source_evaluation_batch.rs• L50-149
Runtime outcome evidence
Direct hook evaluation records each answer and defer outcome under the harness that produced it. The counters distinguish a normal answer from a workspace-unknown defer and from an unsupported harness path. This gives native enforcement evidence that outcome attribution remains separate across harness and workspace boundaries.
References: rust/…/hook_direct_counters_evaluate_tests.rs• L5-34 rust/…/hook_direct_counters_evaluate_tests.rs• L36-43
Change checklist
When these files or sections are changed, remember to consider these:
- Keep parser confidence, segment identity, group flattening, wrapper handling, environment names, path context, and security-identity hashing aligned with the native bridge and command-evaluation oracle.
- When a capability changes, update its packaged matcher or compatibility owner, rule floor, permission mapping, safe variants, and evidence projection as one contract.
- Keep the catalog metadata and compiled program bound by both digests. A catalog lookup or safe-variant change must remain compatible with the observations and control binding that consume it.
- Preserve matcher option contracts. Required flags, forbidden flags, option values, abbreviations, package versions, and
--boundaries must produce the same evidence in every caller. - Preserve the distinction between a capability observation and a critical floor. A new control must not weaken an intrinsic block or reapproval requirement.
- When a shell syntax or sensitive-path family changes, update segment extraction, secret-source matching, data-flow signals, redaction fields, and the native transport contract together.
- Keep pre-tool action inference, command delegation, structured-target checks, typed result fields, and harness rendering aligned. A new action must not cross the boundary as raw payload data.
- Keep every classifier projection aligned with the execution sink. Directory flags, contained wrappers, output filters, worktree-add chains, loop flattening, and rejected peel shapes must produce the same command and directory on both sides.
- Keep compound Allow coverage segment-scoped. A contributed action after a
cdor worktree entry must not gain access to a path, write, package step, or other action that the user did not allow. - Keep Git helper outcomes separate: inert, unanswered, and refused have different Allow behavior. Do not let a config overflow or partial probe become an unanswered question.
- Keep disabled-owner reach conservative for unmodeled commands, interpreters, expansions, wrappers, MCP tools, and delegated package checks. A timeout may be reviewable only when the disabled owner is outside the proven reach.
- Keep search, listing, hidden-path, glob, jq, sed, and tool-specific proofs bounded. A new safe form must not admit an extra file, link, plugin, template, environment value, or recursive descendant.
- Preserve the action lattice and uncertainty floors when adding a factor. Every permissive floor needs its matching proof route and binding digest.
- Keep exact-action tokens and review bindings tied to the same request digest, command identity, workspace, launch evidence, and policy binding. A proof change must not make an approval usable for a different action.
- Offline evaluation batches must remain non-authoritative. Synthetic controls, first-install state, case limits, production command models, and zero-execution claims must stay bound to the batch contract.
- Regenerate parity evidence only for an intentional behavior change. Review the changed observations, reasons, floors, and identity fields before accepting the new vectors.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The pre-tool payload is malformed, ambiguous, too deep, or too large. | Native pre-tool handling returns a block result before execution. | Bounded extraction rejects conflicting fields and enforces payload limits. |
| The parser returns uncertain input or cannot prove a wrapper, redirect, group, or launch identity. | The command cannot receive an exact-safe allow. It stays at review, reapproval, or block based on the uncertainty. | Parser confidence and typed uncertainty enter the decision plane. |
| A matcher reaches its deadline or evidence limit. | Capability evaluation fails closed instead of becoming an empty match. | Shared deadlines, memoized matching, and evidence caps return an owned native error. |
| Required catalog metadata is missing or the catalog and program digests differ. | Native control and evidence lookup fails closed rather than using metadata for another program. | Packaged catalog loading binds both digests before returning the catalog. |
A required or forbidden option is hidden by an unknown spelling, abbreviation, package version, or misplaced --. | A command can receive the wrong capability evidence or safe result. | Matcher contracts parse option boundaries conservatively and fail secure when configured. |
| A command deletes data, changes Guard protection, or performs a critical remote mutation. | The command receives a block floor. | Critical-floor rules run independently of optional extension controls. |
| A sensitive source reaches an HTTP, DNS, remote-copy, clipboard, package, or public collection sink. | The action receives a critical data-flow signal and cannot be treated as benign. | Source, pipe, substitution, variable, and sink analysis emits typed redacted findings. |
| A native exact-safe command also names a sensitive structured path. | The tool action remains at review or stronger. | Structured target risk is evaluated independently from command text. |
| A safe variant covers one segment of a compound command. | Another unsafe segment still contributes its floor. | Effective segment indexes are tracked per observation. |
A contributed action is allowed before a cd or new worktree changes its path meaning. | The action remains reviewed because its arguments can name a different file or output. | Entry context and action operands are compared against the same checkout and path state. |
| A checkout or directory destination cannot be resolved, follows an unsafe link, or names Git, hook, harness, or auto-start state. | The checkout receives a fixed floor that a permission cannot settle. | Destination checks compare lexical and resolved paths across every proven directory context. |
| Git configuration is missing, unreadable, over bound, or contains a helper. | The read stays reviewed unless the exact unanswered case is settled by the same user's Allow. | Cleared bounded probes distinguish unanswered from refused and preserve the distinction after memoization. |
| An unmodeled command can name a disabled program through an interpreter, expansion, wrapper, path, or MCP tool. | A timeout or uncertain check remains blocked because an administrator floor may be in reach. | Disabled-owner reach scans exact command shape, decoded names, and delegated tool ownership. |
| A contained wrapper or output filter is not proved as the sink's exact shape. | The sink refuses the peel or runs the whole command in the sandbox; it does not run an uncovered core. | Native and sink planning share the same bounded grammar and explicit refusal result. |
| A recursive listing or search reaches a hidden, credential-named, linked, or over-budget descendant. | The read keeps review. | Metadata-only walks bound depth and entries and screen each reachable descendant. |
| An evaluated tool call is not proved as a bounded read, listing, command, or result report. | Its output does not receive the lower action floor of the claimed tool type. | Native proof is required before output release. |
| A supply-chain metadata read repeats with the same URL and accept type. | The evaluation can exceed its deadline or duplicate caller egress work. | Per-evaluation caching reuses supplied documents and unresolved fetch state. |
| An offline batch carries an unknown field, duplicate case, contradictory authority, or too many cases. | The batch is rejected before it can produce misleading parity evidence. | Typed decoding, case limits, identity checks, and synthetic-binding validation fail closed. |
| An exact-action proof cannot bind the request, launch state, files, or policy identity. | A review continuation receives a once-only refusal instead of a usable token. | The resident recomputes the proof under a bounded budget and returns no token on failure. |
| A saved persistent grant is used after its bound helper changes, or a once-only claim is reused. | The launch is refused without spending the valid authority or changing the target. | The resident binds the launch to the reviewed artifact and consumes once-only authority only after validation. |
| A saved once-only claim is expired or its integrity record is tampered with. | No target launch occurs. | Authenticated claim lookup rejects the claim before the exact-action operation opens the target. |
| The hook verdict claims extension policy without a matching receipt, or its receipt does not bind the reviewed result. | Review-binding and exact-action queries are invalid. | Hook review checks the event, result, policy digests, runtime identity, and command-extension record together. |
| The native result has conflicting action fields, raw content, or an unbound command model. | The transport rejects the result and native enforcement remains fail-safe. | Typed decoding binds the result to the request and checks the full action lattice. |
| A parity vector changes without an intentional rule or parser change. | Release evidence shows native behavior drift. | Full command, effect, data-flow, and program parity comparisons fail on meaningful differences. |
Key files
| File | Why to read it |
|---|---|
| rust/…/command_model.rs | Defines canonical command facts, parser confidence, segments, and uncertainty. |
| rust/…/parser_segments.rs | Shows how shell text becomes ordered execution segments. |
| rust/…/parser_wrappers.rs | Shows which wrappers and inline shells remain inspectable. |
| rust/…/native_command_catalog.rs | Shows the digest-bound metadata catalog and its normalized rule, permission, action, and capability lookups. |
| rust/…/native_command_controls.rs | Shows control compilation, compound coverage, observation floors, explicit Allow coverage, and receipt binding. |
| rust/…/native_command_controls_floor.rs | Shows uncertainty, timeout, startup-shell, and home-redirect floors. |
| rust/…/native_command_program_observations.rs | Shows segment-scoped observations, safe variants, compatibility evidence, and redaction. |
| rust/…/native_command_unmodeled_disabled_reach.rs | Shows how uncertain commands retain disabled-owner floors. |
| rust/…/native_command_unmodeled_shapes.rs | Shows which bounded heredocs, filters, loops, and lookups do not hide execution. |
| rust/…/native_command_source_evaluation_batch.rs | Shows offline production evaluation with bounded synthetic controls and no target execution. |
| rust/…/generic.rs | Connects raw pre-tool envelopes, projections, command review, and typed results. |
| rust/…/safe_reads.rs | Shows how bounded file, filter, and path proofs share one read boundary. |
| rust/…/contained_wrapper_plan.rs | Shows how the classifier and execution sink share contained-command plans. |
| rust/…/contained_worktree_add.rs | Shows re-authorization around newly created linked worktrees. |
| rust/…/git_helper_context.rs | Shows Git helper classification and the unanswered-versus-refused distinction. |
| rust/…/git_config.rs | Shows bounded Git configuration and helper probes. |
| rust/…/checkout_destination_floor.rs | Shows fixed floors for unsafe checkout destinations. |
| rust/…/effect_decision.rs | Defines the action lattice, uncertainty floors, proof rules, and final disposition. |
| rust/…/native_exact_action_op.rs | Shows resident proof, review binding, launch evidence, and exact-action tokens. |
| rust/…/hook_review.rs | Derives the two resident queries from one hook review and validates policy binding. |
| rust/…/reasons.rs | Defines stable once-only refusal reasons and the one-proof-or-reason contract. |
| rust/…/bash_grant_tests.rs | Demonstrates persistent and once-only grant behavior under restart, mutation, expiry, and tampering. |
| rust/…/policy_enforcement_omp_eval.rs | Shows how bounded evaluated tool calls retain their real action type before output policy runs. |
| rust/…/effect_decision_parity.rs | Shows the decision-plane parity contract against the Python oracle. |
| rust/…/data_flow_rules_parity.rs | Shows data-flow signal parity and malformed-input safety evidence. |
| rust/…/native_command_source_parity.rs | Shows offline comparison of native programs without runtime authority. |
| rust/…/native_command_compound_controls_tests.rs | Shows compound permission coverage, denied-segment dominance, and path-context checks. |
| rust/…/native_command_contributed_allow_tests.rs | Shows contributed action Allow behavior across ordinary compounds and new worktrees. |
| rust/…/native_command_unmodeled_tests.rs | Shows parity evidence for unmodeled commands, bounded shell shapes, and disabled reach. |