Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To move to 1.0, read the [migration guide](docs/site/migration/to-1-0.md).
## [Unreleased]

### Features Added
- `prismpm <module> <verb>` (#441): the Rust CLI groups its commands under the modules of `model/modules.toml`, as `prism-code` does: `prismpm images build|inspect|pull|push|verify|export-browser`, `prismpm verify check|attestation|signature|release|replay|model|conformance|acceptance|browser-publication`, `prismpm auth attest|sign|sign-evidence`, `prismpm system lock|update|fetch|authority|clean`, `prismpm containers run|status` and `prismpm client generate|completion|template`. Each group verb runs its flat command with the same arguments, output and result schema, and the flat commands stay. The table is the `[[group]]` rows of `model/commands.toml`: the model gate checks that each names a registered command, the CLI parses its groups from the same rows, and `CONTRACTS.md` lists them. `prismpm <module>` prints the module's verbs; an unknown verb is `PP1001`. A module that is also a command (`verify`) is a group only when the next word is one of its verbs.
- The developer view of #346 is a LexLean model (#347, experimental): `bindings/src/Foundation/Views/V1/Developer.lex.tex` declares the developer glossary once, each Docker-aligned term over the canonical term it names, the other words of the surface and the deprecated aliases. Its certified export runs in `cargo xtask check-developer-view` (part of `cargo xtask validate`), which checks every verb, flag, namespace and method of the `prism-code` surface against it and renders [docs/developer-glossary.md](docs/developer-glossary.md). Canonical model terms, schema identifiers, predicate URIs and error codes do not change; the renamed `prism-code` spellings are in its own changelog.
- `COMPLIANCE.md` shows the Rust runtime (#449, #298): `sdk/npm/conformance/runtimes.json` registers `prism-conformance-shim`, the npm conformance suite job builds it and runs the suite against it beside prism-code, and the matrix shows both runtimes passing all 24 `verify` checks. `prism.verify.pullClosure` makes every trust decision a pull needs, and signing moves to `auth` (`auth.identities.from`), so the pending `auth.mjs` to `attest.mjs` cut in `model/modules.toml` is made; see the prism-code CHANGELOG.
- `prismpm generate <path.holo> --lang <js|python|rust> --out <dir>` (#289, experimental): the Rust CLI writes the same bindings and typed client as `prism-code generate`, byte for byte apart from the generator each file header names, beside the same `prism-generate.json` record, and a run whose record and files are in place writes nothing. Every decision is the LexLean model `bindings/src/Foundation/Bindings/V1`: the new `Source.lex.tex` reads the WIT world and the model document into the code model (the WIT subset, the world's exports and memory, the application's class name, the numeric profile's operations), and `Generate.lex.tex` joins it to the JS, Python and Rust writers. `cargo xtask bindings-package` exports the three roots and vendors them into the crate, so the published `prismpm` carries them and the unpublished `prism-bindings` crate is gone. A holo generate cannot bind is `PP3201`; an output directory holding a file generate did not write is `PP3202`.
Expand Down
35 changes: 35 additions & 0 deletions CONTRACTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,38 @@ All JSON content uses UTF-8, sorted object keys, shortest canonical integers, no
| `verify-browser-publication` | `never` | `true` | `prismpm/browser-publication-integrity/2` |
| `verify-release` | `never` | `true` | `prismpm/signature-closure-result/1` |
| `verify-signature` | `verified-local-evidence` | `true` | `prismpm/signature-result/1` |

## Command groups

`prismpm <module> <verb>` runs the command beside it, with the same arguments, output and result schema (#441). The groups are named after the nine modules of `model/modules.toml`; the flat commands stay as aliases. A module that is also a command (`verify`) is a group only when the next word is one of its verbs.

| Group verb | Command |
| --- | --- |
| `prismpm auth attest` | `prismpm attest` |
| `prismpm auth sign` | `prismpm sign` |
| `prismpm auth sign-evidence` | `prismpm sign-evidence` |
| `prismpm client completion` | `prismpm completion` |
| `prismpm client generate` | `prismpm generate` |
| `prismpm client template` | `prismpm template` |
| `prismpm containers run` | `prismpm run` |
| `prismpm containers status` | `prismpm status` |
| `prismpm images build` | `prismpm build` |
| `prismpm images export-browser` | `prismpm export-browser` |
| `prismpm images inspect` | `prismpm inspect` |
| `prismpm images pull` | `prismpm pull` |
| `prismpm images push` | `prismpm push` |
| `prismpm images verify` | `prismpm check` |
| `prismpm system authority` | `prismpm authority` |
| `prismpm system clean` | `prismpm clean` |
| `prismpm system fetch` | `prismpm fetch` |
| `prismpm system lock` | `prismpm lock` |
| `prismpm system update` | `prismpm update` |
| `prismpm verify acceptance` | `prismpm replay-acceptance` |
| `prismpm verify attestation` | `prismpm verify-attestation` |
| `prismpm verify browser-publication` | `prismpm verify-browser-publication` |
| `prismpm verify check` | `prismpm check` |
| `prismpm verify conformance` | `prismpm conformance` |
| `prismpm verify model` | `prismpm verify` |
| `prismpm verify release` | `prismpm verify-release` |
| `prismpm verify replay` | `prismpm replay` |
| `prismpm verify signature` | `prismpm verify-signature` |
14 changes: 14 additions & 0 deletions crates/model/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,19 @@ pub fn render_contracts(model: &Model) -> String {
);
}
}
let _ = writeln!(w);
let _ = writeln!(w, "## Command groups");
let _ = writeln!(w);
let _ = writeln!(w, "`prismpm <module> <verb>` runs the command beside it, with the same arguments, output and result schema (#441). The groups are named after the nine modules of `model/modules.toml`; the flat commands stay as aliases. A module that is also a command (`verify`) is a group only when the next word is one of its verbs.");
let _ = writeln!(w);
let _ = writeln!(w, "| Group verb | Command |");
let _ = writeln!(w, "| --- | --- |");
for row in &model.commands.group {
let _ = writeln!(
w,
"| `prismpm {} {}` | `prismpm {}` |",
row.module, row.verb, row.command
);
}
out
}
20 changes: 20 additions & 0 deletions crates/model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,26 @@ pub fn repo_root() -> PathBuf {
mod tests {
use super::Model;

#[test]
fn command_groups_run_registered_commands_in_order() {
let model = Model::load_from_repo_root().expect("load repository model");
model.commands.check().expect("the committed groups hold");
assert!(!model.commands.group.is_empty());
let planted = |edit: fn(&mut super::Commands)| {
let mut commands = model.commands.clone();
edit(&mut commands);
commands.check().is_err()
};
assert!(planted(|c| c.group[0].command = "nonexistent".into()));
assert!(planted(|c| c.group[0].verb = "Upper".into()));
assert!(planted(|c| c.group[0].module = "-x".into()));
assert!(planted(|c| c.group.swap(0, 1)));
assert!(planted(|c| {
let first = c.group[0].clone();
c.group.insert(0, first);
}));
}

#[test]
fn control_coverage_counts_are_separate_and_fixed() {
let model = Model::load_from_repo_root().expect("load repository model");
Expand Down
50 changes: 50 additions & 0 deletions crates/model/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,21 @@ pub struct Commands {
pub spec: String,
/// Stable public command contracts.
pub command: Vec<CommandRow>,
/// Module groups (#441): `prismpm <module> <verb>` names a command above.
#[serde(default)]
pub group: Vec<CommandGroup>,
}

/// One group verb: `prismpm <module> <verb>` runs `prismpm <command>`.
#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct CommandGroup {
/// One of the nine modules of model/modules.toml.
pub module: String,
/// The verb under the module.
pub verb: String,
/// The command it runs: a command name, then any of its subcommands.
pub command: String,
}

/// One stable public command contract.
Expand Down Expand Up @@ -663,6 +678,41 @@ impl Commands {
"public command contract is incomplete or noncanonical".to_owned(),
));
}
self.check_groups(&names)
}

/// Group rows are sorted and unique by module and verb, use lowercase
/// kebab-case words, and run a registered command. A module that is also a
/// command keeps that command: its group verbs must not be the command's
/// own subcommands.
fn check_groups(&self, names: &[&str]) -> Result<(), ModelError> {
let word = |text: &str| {
!text.is_empty()
&& !text.starts_with('-')
&& !text.ends_with('-')
&& text.bytes().all(|b| b.is_ascii_lowercase() || b == b'-')
};
let bad = |row: &CommandGroup, why: &str| {
Err(ModelError::Inconsistent(format!(
"command group `{} {}` {why}",
row.module, row.verb
)))
};
let mut previous: Option<(&str, &str)> = None;
for row in &self.group {
let key = (row.module.as_str(), row.verb.as_str());
if previous.is_some_and(|previous| previous >= key) {
return bad(row, "is out of order or repeated");
}
previous = Some(key);
if !word(&row.module) || !word(&row.verb) {
return bad(row, "is not lowercase kebab-case");
}
let mut words = row.command.split(' ');
if !words.clone().all(word) || !words.next().is_some_and(|head| names.contains(&head)) {
return bad(row, "does not run a registered command");
}
}
Ok(())
}
}
Expand Down
Loading
Loading