tools tier

tools-fleet-db

Fleet database credential and role-topology tooling (Sprint 3.1). Verifies stored credentials against PostgreSQL SCRAM verifiers offline, so a pg_hba change can be proven safe before it is made.

Fleet database credential and role-topology tooling (Sprint 3.1). Verifies stored credentials against PostgreSQL SCRAM verifiers offline, so a pg_hba change can be proven safe before it is made.

Tiertools
Roleunclassified (baselined)
Pathcrates/tools/fleet-db
Edition2021
Targetscutover, fleet-backup, verify-credentials, tools_fleet_db, scram, topology
Public items17 across 2 modules
Tests24

What it is for

This crate does not document itself. No //! block on its entry point. The facts below are complete; the reason this crate exists is not written down anywhere, and belongs in src/lib.rs rather than here.

Capabilities

scram (other)

Offline verification of a candidate password against PostgreSQL's stored

Item
fn parse_verifier(raw : & str) -> Result <ScramVerifier, VerifierError>
fn is_ascii_password(candidate : & str) -> bool

ScramVerifier

Offline verification of a candidate password against PostgreSQL's stored

Item
pub struct ScramVerifier

VerifierError

Offline verification of a candidate password against PostgreSQL's stored

Item
pub enum VerifierError
VerifierError :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
fn verify_password(raw_verifier : & str, candidate : & str) -> Result <bool, VerifierError>

topology (other)

Role naming and ownership-transfer SQL (Sprint 3.1, US-3.1.2; ADR 0025 §1, §4).

Item
pub const MAX_IDENTIFIER_BYTES: usize
fn ownership_transfer_sql(new_owner : & str, objects : & DbObject,) -> Result <Vec <String>, RoleError>

DbObject

Role naming and ownership-transfer SQL (Sprint 3.1, US-3.1.2; ADR 0025 §1, §4).

Item
pub struct DbObject

ObjectKind

Role naming and ownership-transfer SQL (Sprint 3.1, US-3.1.2; ADR 0025 §1, §4).

Item
pub enum ObjectKind
ObjectKind :: fn alter_verb(self) -> & 'static str

RoleError

Role naming and ownership-transfer SQL (Sprint 3.1, US-3.1.2; ADR 0025 §1, §4).

Item
pub enum RoleError
RoleError :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
fn owner_role(db : & str) -> Result <String, RoleError>
fn app_role(db : & str) -> Result <String, RoleError>

Roles

Role naming and ownership-transfer SQL (Sprint 3.1, US-3.1.2; ADR 0025 §1, §4).

Item
pub struct Roles
fn derive_roles(db : & str) -> Result <Roles, RoleError>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

tools_fleet_db

flowchart TD
  n_tools_fleet_db["tools_fleet_db"]
  n_tools_fleet_db --> n_scram["scram"]
  n_tools_fleet_db --> n_topology["topology"]

Public surface

`scram`

ItemWhat it is
pub enum VerifierErrorWhy a stored verifier could not be checked
VerifierError :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct ScramVerifierA decoded pg_authid.rolpassword.
fn parse_verifier(raw : & str) -> Result <ScramVerifier, VerifierError>Decode SCRAM-SHA-256$<iter>:<salt>$<StoredKey>:<ServerKey>
fn verify_password(raw_verifier : & str, candidate : & str) -> Result <bool, VerifierError>Does candidate reproduce this stored verifier? Ok(true) means the password is the one the cluster stores
fn is_ascii_password(candidate : & str) -> boolIs this password safe to check offline? SASLprep only matters for non-ASCII input; the caller should surface a warning rather than report a confident mismatch for such a password.

`topology`

ItemWhat it is
pub const MAX_IDENTIFIER_BYTES: usizePostgreSQL's identifier length limit
pub enum RoleErrorWhy a name cannot be used.
RoleError :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct RolesThe role pair for one database.
fn derive_roles(db : & str) -> Result <Roles, RoleError>Derive both roles for a database, validating the derived names
fn owner_role(db : & str) -> Result <String, RoleError><db>_owner, validated
fn app_role(db : & str) -> Result <String, RoleError><db>_app, validated
pub enum ObjectKindThe object classes whose ownership must move, each with its own ALTER verb.
ObjectKind :: fn alter_verb(self) -> & 'static strThe ALTER <kind> verb
pub struct DbObjectOne object enumerated from the target database.
fn ownership_transfer_sql(new_owner : & str, objects : & DbObject,) -> Result <Vec <String>, RoleError>Generate the per-object ownership transfer

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into infrastructure.

Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)tools
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/tools/fleet-db
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_tools["tools"] --> n_infrastructure["infrastructure"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`infrastructure-backup`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
anyhow^1noalways
base64^0.22noalways
clap^4derive, envnoalways
hmac^0.12noalways
sha2^0.10noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
tokio^1fullnoalways

Development, in this workspace.

CrateTierOptionalOnly on
`tools-cli-conformance`toolsnoalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_tools_corpus["tools-corpus"] -->|uses| SELF
  SELF["tools-fleet-db"]
  SELF -->|development| n_tools_cli_conformance["tools-cli-conformance"]
  SELF -->|runtime| n_infrastructure_backup["infrastructure-backup"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
bincutover`src/bin/cutover.rs`
binfleet-backup`src/bin/fleet-backup.rs`
binverify-credentials`src/bin/verify-credentials.rs`
libtools_fleet_db`src/lib.rs`
testscram`tests/scram.rs`
testtopology`tests/topology.rs`

Error model

Error typeNamed by
RoleErrorapp_role, derive_roles, owner_role, ownership_transfer_sql
VerifierErrorparse_verifier, verify_password

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
HOMEsrc/bin/verify-credentials.rs

1 workspace crate depends on this one: tools-corpus.

Verification

KindCount
Unit tests3
Integration tests21
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
scram500
topology903

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1517
Public modules with a //! block22
pie showData
    title Public items with rustdoc
    "Documented" : 15
    "No rustdoc detected" : 2

Metrics

MetricValue
Rust source files6
Source lines1174
Code lines759
Public API items17
Public modules2
Tests24
Examples0
Cargo features0
Direct runtime dependencies8
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 1
    "enum" : 3
    "function" : 7
    "method" : 3
    "struct" : 3
pie showData
    title Rust source composition
    "Code" : 759
    "Blank or comment" : 415

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All tools · Manual