# Security ## What sisi runs, and when sisi's end-of-turn hook and `sisi verify` run shell commands. The commands come from the `checks` and `invariants` of the project's `.sisi/contract.json`. A contract in a repository you cloned is therefore code written by someone else, and it is treated as such. - A project's contract runs only after the project is trusted on this machine. `sisi contract init` trusts the project it creates; anything else needs an explicit `sisi contract trust`, which you should run after reading `.sisi/contract.json`. - In an untrusted project, `sisi verify` refuses to run (exit 3) and the end-of-turn gate lets the turn end without running anything. - The list of trusted projects is `trusted.json` in your personal data folder. `sisi contract untrust` removes a project. - Every check has a time limit. After a few send-backs in a row the gate lets the agent through and marks the result unverified, so a broken check cannot hold a session forever. ## What learning can change, and who decides A learning cycle can install checks, rules and risk patterns that shape later sessions. What it may do alone is limited, and the rest waits for you: - A mechanism a cycle installs carries its learning's id and the scope that learning has earned (its own project, unless it was seen in two units in two projects, or you stated it at user scope). Nothing the cycle file claims about scope or project is trusted: a request for more only makes the change wait. - These always wait for you: more scope than earned, a shell command that was not seen to fail and then pass in its own trusted project, a risk pattern that lowers a profile, any replaced or disabled rule, and rule text or a library entry from a learning confined to one project. Protected rules (`canon/protected.json`) cannot be changed by a cycle or by `sisi overlay` at all, and if that file cannot be read, no rule can be changed. - A cycle file is untrusted input, and `sisi cycle check` never executes anything from it. `sisi cycle apply` replays a command check only in a repository on the trust list, only between two commits taken from the learning's own record (its unit's start and closing commits, or the ones stored with the finding; never from the file), only if the command names a path that differs between the two trees, and only inside an exported copy of each commit's tree: no `.git` directory (the command cannot read history), an environment of `PATH`, `HOME` (an empty directory) and `LANG` only (none of the caller's credentials or tokens), a time limit, and the copy deleted afterwards. A learning with no recorded commits cannot be validated: its command check waits for you as `unvalidated`. What this does not do: the replayed command still runs as you, with your file permissions, and sisi does not sandbox it; which is why a command that was not seen to fail and then pass waits for you. `sisi approve` lists every waiting change in full (the exact command, the pattern and profile, the rule text as a diff). Deciding one takes two layers: - The before-tool hook refuses any shell command an agent runs whose text invokes `sisi approve` with an argument, however it is wrapped (`script`, `sh -c`, `env`, `expect`, a path to the launcher, `python -m sisi`, quotes and backslashes inside the words), for main threads and workers alike, and tells the agent that approval is yours alone and to show you the command to run yourself. The plain listing (`sisi approve` with no arguments) is allowed. The hook fails open on an error, so it is a guard, not a wall: a command built from pieces, from a variable or from an encoded string is not recognised by its text. - `sisi approve ID --yes|--no` itself prints the whole action and a short random word on the controlling terminal device (`/dev/tty`, never standard input) and decides only when that word is typed back there. A process with no controlling terminal is refused; so is one whose terminal returns the wrong word or nothing. This is the typed word, and it is what `script -qec "sisi approve ID --yes" /dev/null