Skip to main content

Module formal_ai_policy

Module formal_ai_policy 

Source
Expand description

Bounds and effect policy of the experimental --use-formal-ai mode (issue #255). Mirrors js/src/lib/formal-ai-policy.js.

Formal AI owns the interpretation of a natural-language request and picks the tool calls; start owns the permission to run them. Every tool call is a POSIX command line that start tokenizes itself and runs as an argv vector, never through a shell, so a call that needs shell syntax (pipes, redirects, substitutions, globs, variables) is refused instead of being interpreted.

Structs§

BoundSpec
One START_FORMAL_AI_* bound: environment variable, default and range.
Bounds
Resolved bounds of one run.
Decision
Decision about one tool call.
EffectDiff
Differences between two fingerprints.
Fingerprint
Bounded fingerprint of a directory tree (names, types, sizes, mtimes).
PolicyContext
What a read observed, so a later change may name it.
Tokenized
Words of a command line and the shell syntax it would have needed.
Verification
Result of reading a change back from the filesystem.

Constants§

BOUND_DEFAULTS
EFFECT_MODES
EXIT_BUDGET
Step, tool, time or retry budget exhausted.
EXIT_CONFIG
Invalid START_FORMAL_AI_* bound.
EXIT_PROTOCOL
Malformed response, unknown tool or unverified effect.
EXIT_REFUSED
A tool call was refused by the effect policy.
EXIT_UNAVAILABLE
No qualified Formal AI runtime could be resolved.
EXIT_UNSUPPORTED
Formal AI reported that it did not understand the task.
EXIT_USAGE
Request text or option combination rejected.
READ_PROGRAMS
WRITE_PROGRAMS

Functions§

diff_fingerprints
evaluate_command
Decide whether a tool call may run.
fingerprint
Bounded breadth-first fingerprint of the working directory; .git is listed but not descended into.
operands
Path-like operands of a call (values of --opt=value included).
record_observation
Remember what a read call observed, so a later change may name it.
resolve_bounds
Resolve the bounds from the process environment.
resolve_bounds_with
Resolve the bounds of one run from START_FORMAL_AI_* variables read through get. An invalid value is an error (exit status EXIT_CONFIG).
tokenize_command
Split a command line with POSIX quoting rules. Characters that would make a shell do more than split words are reported instead of honoured.
verify_change
Read the result of a successful change back from the filesystem.
workspace_path
Normalized workspace-relative path of an operand, or None outside it.