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
8 changes: 8 additions & 0 deletions pkgs/id/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkgs/id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
"crates/id-cli",
"crates/id-import-notion",
"crates/id-client",
"crates/id-pg",
]
# The vendored crates stay OUT of the workspace: as path dependencies inside
# this directory Cargo would otherwise treat them as members, and a member's
Expand All @@ -58,6 +59,7 @@ default-members = [
"crates/id-render",
"crates/id-cli",
"crates/id-import-notion",
"crates/id-pg",
"crates/id-client",
]

Expand Down
2 changes: 1 addition & 1 deletion pkgs/id/book/concepts/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Source: this chapter rests on the library survey (`survey/library.md`, the crate

## One workspace, one public surface

The system lives in `pkgs/id/` in the `developing-today/code` repository. The root `Cargo.toml` is two things at once: the package `id` at version `0.1.0` (edition 2024, rust-version 1.96) and the workspace root. The workspace has 17 members: the root package plus 16 crates under `pkgs/id/crates/`. Default members are 15: the root plus 14 crates. `id-native-shell` and `id-hw-shell` are members but not default members, so a plain `cargo build` in `pkgs/id/` never acquires the Bevy desktop dependencies or the hardware-shell code.
The system lives in `pkgs/id/` in the `developing-today/code` repository. The root `Cargo.toml` is two things at once: the package `id` at version `0.1.0` (edition 2024, rust-version 1.96) and the workspace root. The workspace has 20 members: the root package plus 19 crates under `pkgs/id/crates/`. Default members are 17: the root plus 16 crates. `id-native-shell`, `id-hw-shell`, and `id-tui-shell` are members but not default members, so a plain `cargo build` in `pkgs/id/` never acquires the Bevy desktop dependencies or the shell code.

Library consumers use one public surface: the root crate, imported as `id::`. The split crates are internal. A consumer who names a split crate directly uses an internal path, with two recorded exceptions: `id-config`, `id-currency-registry`, `id-render` and `id-import-notion` are not exposed at `id::` at all, so a consumer who wants them names those crates directly (library survey §2).

Expand Down
9 changes: 6 additions & 3 deletions pkgs/id/book/development/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ ID lives in the `developing-today/code` monorepo, in the directory `pkgs/id/`. T

There is no `src/bin/` directory and no `[[bin]]` section in any workspace `Cargo.toml`. The two binaries exist by Cargo's implicit `src/main.rs` rule: `id` from the root package, and `id-native-shell` from `crates/id-native-shell/src/main.rs`.

## The 16 crates
## The 19 crates

`crates/` holds the 16 sub-crates. The workspace has 17 members in total: the root plus these 16. `default-members` lists 15 packages — the root plus 14 crates. `id-native-shell` and `id-hw-shell` are members but not default members, so a plain `cargo build` in `pkgs/id/` never builds the desktop shell or the hardware shell.
`crates/` holds the 19 sub-crates. The workspace has 20 members in total: the root plus these 19. `default-members` lists 17 packages — the root plus 16 crates. `id-native-shell`, `id-hw-shell`, and `id-tui-shell` are members but not default members, so a plain `cargo build` in `pkgs/id/` never builds the shell crates.

| Crate | Role in one line |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -38,10 +38,13 @@ There is no `src/bin/` directory and no `[[bin]]` section in any workspace `Carg
| `id-currency-registry` | Currency control-plane registry: the ledger allocator, the account factory and the Postgres schema and migrations. |
| `id-render` | Rendering pipeline compiler core: parse and vocabulary validation of semantic markup. No dependents. |
| `id-import-notion` | Notion importer manifest and inventory primitives. No dependents. |
| `id-client` | Client-only Rust facade for the id native Android client v1 (slice 1 of #7938, #13403). |
| `id-pg` | Postgres-over-HTTP adapter (#5805): the PostgREST query translator and collection allowlist (design §3), slice #13760. No dependents yet. |
| `id-native-shell` | The Bevy native reference shell. Not a default member. |
| `id-hw-shell` | The ESP32-class hardware shell spike: one file, `src/lib.rs`, frame builders only, no binary. Not a default member. |
| `id-tui-shell` | The terminal (TUI) shell: the text-native world-session client on the F13.1 shell contract (#12818). Not a default member. |

Dependency direction runs downward to `id-core`. Nothing in the split family depends on the facade in production code; the two shells depend on the facade, and `id-store` dev-depends on it for tests. The full per-crate surface is [The crates](../library/crates.md).
Dependency direction runs downward to `id-core`. Nothing in the split family depends on the facade in production code; the two original shells depend on the facade, and `id-store` dev-depends on it for tests. The full per-crate surface is [The crates](../library/crates.md).

Two directories sit outside the workspace: `vendor/p2panda-sync` and `vendor/p2panda-encryption` are listed in the workspace `exclude` array and are consumed as path dependencies only.

Expand Down
16 changes: 8 additions & 8 deletions pkgs/id/book/getting-started/shape.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This chapter is the whole system on one page: the crates, the surfaces,
how a file moves, how a world runs, and where data lives. Every other
part of this book expands one section of this page.

## The workspace: a facade plus 16 crates

`pkgs/id/` is a Rust workspace of 17 packages: the root package `id`
version `0.1.0` (the facade) and 16 crates under `pkgs/id/crates/`.
Default members are 15 packages: the root plus 14 crates. The two shell
crates, `id-native-shell` and `id-hw-shell`, are workspace members but
not default members, so a plain `cargo build` in `pkgs/id/` never
acquires the Bevy desktop or hardware-shell dependencies. Two vendored
## The workspace: a facade plus 19 crates

`pkgs/id/` is a Rust workspace of 20 packages: the root package `id`
version `0.1.0` (the facade) and 19 crates under `pkgs/id/crates/`.
Default members are 17 packages: the root plus 16 crates. The three
shell crates, `id-native-shell`, `id-hw-shell`, and `id-tui-shell`, are
workspace members but not default members, so a plain `cargo build` in
`pkgs/id/` never acquires the Bevy desktop or shell dependencies. Two vendored
crates, `vendor/p2panda-sync` and `vendor/p2panda-encryption`, are
excluded from the workspace.

Expand Down
12 changes: 9 additions & 3 deletions pkgs/id/book/library/crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Source: primary sources are [pkgs/id/Cargo.toml](https://github.com/developing-today/code/blob/main/pkgs/id/Cargo.toml), [pkgs/id/src/lib.rs](https://github.com/developing-today/code/blob/main/pkgs/id/src/lib.rs), and the per-crate manifests and `lib.rs` files under [pkgs/id/crates/](https://github.com/developing-today/code/blob/main/pkgs/id/crates/). This chapter is complete without following those links; they record provenance only.

The `id` code lives in one Cargo workspace rooted at `pkgs/id/`. The workspace has 17 members: the root package `id` plus 16 crates under `pkgs/id/crates/`. Default members are 15: the root plus 14 crates. `id-native-shell` and `id-hw-shell` are workspace members but not default members, so a plain `cargo build` in `pkgs/id/` never acquires the Bevy desktop dependencies or the hardware-shell code. The 16 sub-crates declare 228 `pub mod` items in total across their `lib.rs` files; the root adds 26 modules of its own code plus about 90 re-exported modules (see [The id facade crate](facade.md)).
The `id` code lives in one Cargo workspace rooted at `pkgs/id/`. The workspace has 20 members: the root package `id` plus 19 crates under `pkgs/id/crates/`. Default members are 17: the root plus 16 crates. `id-native-shell`, `id-hw-shell`, and `id-tui-shell` are workspace members but not default members, so a plain `cargo build` in `pkgs/id/` never acquires the Bevy desktop dependencies or the shell code. The 19 sub-crates declare 247 `pub mod` items in total across their `lib.rs` files; the root adds 26 modules of its own code plus about 90 re-exported modules (see [The id facade crate](facade.md)).

The workspace is the product of a numbered split of one original crate, recorded in the crate doc headers as umbrella issue #3447: Phase 1 extracted `id-core` (#3447), step 1 extracted `id-caps` (#4403), steps 2a and 2b extracted `id-store` and `id-events` (#4405), step 3 extracted `id-sync` (#4406), step 4 extracted `id-groups` (#4407), step 5 extracted `id-worlds` (#4408), steps 6b and 6c extracted `id-directory` and `id-web` (#4409), and step 7b extracted `id-cli` (#4411). Four crates are not split products: `id-config` (slice 9111-01, #10178), `id-currency-registry` (F1 and F2 of #2062, #2317 and #2318), `id-render` (#7918, decision records #5849 and #5855), and `id-import-notion` (slice 1, #8419). The two shells are separate consumers, covered in [Guest apps and shells as consumers](guests-and-shells.md).
The workspace is the product of a numbered split of one original crate, recorded in the crate doc headers as umbrella issue #3447: Phase 1 extracted `id-core` (#3447), step 1 extracted `id-caps` (#4403), steps 2a and 2b extracted `id-store` and `id-events` (#4405), step 3 extracted `id-sync` (#4406), step 4 extracted `id-groups` (#4407), step 5 extracted `id-worlds` (#4408), steps 6b and 6c extracted `id-directory` and `id-web` (#4409), and step 7b extracted `id-cli` (#4411). Four crates are not split products: `id-config` (slice 9111-01, #10178), `id-currency-registry` (F1 and F2 of #2062, #2317 and #2318), `id-render` (#7918, decision records #5849 and #5855), and `id-import-notion` (slice 1, #8419); `id-client` (#13403), `id-tui-shell` (#12818), and `id-pg` (#13760) are likewise purpose-built rather than split products. The three shells are separate consumers, covered in [Guest apps and shells as consumers](guests-and-shells.md).

## Dependency direction

Expand All @@ -20,7 +20,7 @@ Production `[dependencies]` edges only; dev-dependencies are named where they ma
- `id-currency-registry` depends on nothing and its only production dependent is the facade.
- `id-render` and `id-import-notion` depend on nothing and have no dependents, but both are default members and both carry maintained integration test suites. ARCHITECTURE.md calls them candidates for removal or for documenting as unused; no code, manifest, or test marks either crate deprecated or slated for removal (disagreement LIB-11).

## The seventeen members
## The twenty members

**`id` (root, the facade).** Purpose: the published library surface and the `id` binary; the root `Cargo.toml` description, "A peer-to-peer file sharing CLI built with Iroh", predates the worlds, directory, and currency surface (disagreement LIB-13). Public modules: 26 modules of its own code in `pkgs/id/src/`, plus about 90 modules re-exported from sub-crates at `id::` paths. Key types and functions: `Cli`, `Command`, the `cmd_*` command functions, `open_store`, `StoreType`, `load_or_create_keypair`, and the constants `KEY_FILE`, `CLIENT_KEY_FILE`, `SERVE_LOCK`, `STORE_PATH`, and `META_ALPN`. Features: `default = ["sandbox", "world"]`, plus `sandbox`, `world`, `ssh`, `web`, `dht`, and `currency-poc-tb`. Dependents: `id-native-shell` and `id-hw-shell` in production; `id-store` dev-depends on it for tests. Full treatment: [The id facade crate](facade.md).

Expand Down Expand Up @@ -56,6 +56,12 @@ Production `[dependencies]` edges only; dev-dependencies are named where they ma

**`id-hw-shell` — 0 public modules.** Purpose: the ESP32-class hardware shell spike (more-shells v1 slice 3, #10929): the presence, journal-head, and confirm/act subset of the F13.1 shell contract. The whole crate is one `src/lib.rs` of 996 lines. Key types and functions: `CONTRACT_NAME = "shell"`, `CONTRACT_VERSION = 1`, `capability_statement()`, `HwShell`, `PresentedChoice`, `SelectableField`, and `HwError`. Features: none. Production dependency: the facade with `features = ["world"]`. Dependents: none; not a default member. Full treatment: [Guest apps and shells as consumers](guests-and-shells.md).

**`id-tui-shell` — 0 public modules.** Purpose: the terminal (TUI) shell for id (more-shells v2 slice 2, #12818): the text-native world-session client on the F13.1 shell contract. The whole crate is one `src/lib.rs` with no `pub mod` declarations; its surface is defined at the crate root. Dependents: none; it is a workspace member but not a default member. Full treatment: [Guest apps and shells as consumers](guests-and-shells.md).

**`id-client` — 1 public module.** Purpose: the client-only Rust facade for the id native Android client v1 (slice 1 of #7938, child #13403). Public modules: `session`. Dependents: none in the workspace; it is a default member.

**`id-pg` — 0 public modules.** Purpose: the Postgres-over-HTTP adapter's query translator and collection allowlist (design #5805, §3; slice #13760): it validates the data-shaped query object against the owner's allowlist and either produces the PostgREST request or refuses the query by the design's stable feature names, before any network call. The surface is re-exported at the crate root: `Translator` and `effective_ordering`; the query object (`Query`, `Target`, `SelectItem`, `FilterExpr`, `FilterLeaf`, `FilterOp`, `OrderKey`, `Pagination`, `CountPref`, `Method`, `Direction`); the allowlist (`CollectionAllowlist`, `ColumnDecl`, `DEFAULT_MAX_LIMIT`); the output (`PostgrestRequest`); and the refusal vocabulary (`Refusal`, `RefusalCode`, `Feature`). Features: none. Dependents: none yet; the sibling adapter slices — typed mapping (#13761), error mapping (#13762), and the read paths (#13763) — build on it.

## Embedding examples from real call sites

The shipped binary is itself a facade consumer: `pkgs/id/src/main.rs:10-13` imports `id::{Cli, Command, PeekOptions, PeersOptions, SearchOptions, ServeOptions, cmd_find, cmd_get_multi, cmd_gethash, cmd_id, cmd_list, cmd_migrate_tags, cmd_peek, cmd_peers, cmd_put_hash, cmd_put_multi, cmd_search, cmd_serve, cmd_show, cmd_tag, run_repl}`, and `pkgs/id/src/main.rs:202` calls `id::cli::normalize_args(std::env::args_os())`.
Expand Down
96 changes: 96 additions & 0 deletions pkgs/id/crates/id-pg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[package]
name = "id-pg"
version = "0.1.0"
edition = "2024"
rust-version = "1.96"
description = "Postgres-over-HTTP (PostgREST) query translator and collection allowlist for the id foreign data-store adapters (#5805; translator slice #13760)"
license = "MIT OR Apache-2.0"

# Slice #13760 of the Postgres-over-HTTP adapter design (#5805,
# doc/2026-11-23T20-55-00Z_design_id5805_postgres_http_adapter): the pure
# query translator. It accepts the data-shaped query object, validates it
# against the owner's collection allowlist (design section 3), and either
# produces the PostgREST request to send or refuses the query by stable
# feature name (section 3.2) before any network call. Transport, typed
# mapping (section 5.1), and the grantee error collapse (section 6) are the
# sibling slices #13763, #13761, and #13762; this crate is the allowlist
# layer those slices build on (design section 4, layer 1).

[dependencies]
serde = { version = "1", features = ["derive"] }

[dev-dependencies]
proptest = "1.12"

[lints.rust]
unsafe_code = "warn"
rust_2018_idioms = { level = "warn", priority = -1 }
rust_2024_compatibility = { level = "warn", priority = -1 }
missing_debug_implementations = "warn"
missing_docs = "warn"
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_lifetimes = "warn"
unused_qualifications = "warn"

[lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
cargo = { level = "warn", priority = -1 }
unwrap_used = "deny"
expect_used = "deny"
panic = "deny"
unimplemented = "deny"
todo = "deny"
dbg_macro = "deny"
print_stdout = "allow"
print_stderr = "allow"
clone_on_ref_ptr = "warn"
create_dir = "warn"
deref_by_slicing = "warn"
empty_structs_with_brackets = "warn"
filetype_is_file = "warn"
float_cmp_const = "warn"
fn_to_numeric_cast_any = "warn"
format_push_string = "warn"
get_unwrap = "warn"
if_then_some_else_none = "warn"
lossy_float_literal = "warn"
map_err_ignore = "warn"
mem_forget = "warn"
mixed_read_write_in_expression = "warn"
mutex_atomic = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
redundant_type_annotations = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_name_method = "warn"
self_named_module_files = "warn"
str_to_string = "warn"
string_add = "warn"
suspicious_xor_used_as_pow = "warn"
try_err = "warn"
undocumented_unsafe_blocks = "warn"
unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unneeded_field_pattern = "warn"
verbose_file_reads = "warn"
module_name_repetitions = "allow"
must_use_candidate = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
redundant_pub_crate = "allow"
significant_drop_tightening = "allow"
option_if_let_else = "allow"
multiple_crate_versions = "allow"
cargo_common_metadata = "allow"
too_many_lines = "allow"
too_many_arguments = "allow"
fn_params_excessive_bools = "allow"
struct_excessive_bools = "allow"
cognitive_complexity = "allow"
future_not_send = "allow"
assert_is_empty = "allow"
chunks_exact_to_as_chunks = "allow"
Loading