diff --git a/README.md b/README.md index 0085d44..fe87a3c 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,9 @@ Three conventions the library keeps are stricter than a reader might expect: through a sub-module's `go.mod`: pgx through `postgres`, the TOML parser through `sqlint`. - `sqltest` is a public package: the scripted driver the library's own tests run over is the one a consumer's tests run over too, so a unit test needs no database. -- Every `.sql` file declares its tier, standard or native, and a native file names the engine - feature it uses and the port to other engines. The port list of a code base is one search for - `--| tier: native`. +- Every statement and pattern declares its tier, standard or native, and a native file names + the engine feature it uses and the port to other engines. The port list of a code base is one + search for `--| tier: native`. ## Packages @@ -138,6 +138,13 @@ image pin and which carries its configuration and health check; `mise run curren pin behind its latest. `mise.toml` sets `SQLATE_DSN`, whose port follows the same variable. The integration tier is not part of CI. +The compose PostgreSQL reports healthy once it accepts TCP connections to the app database. The +probe goes over TCP, not the socket, because the first start's initialization runs a temporary +server on the socket alone, which would report ready before the real server starts. + +`GO_MODULES` in `mise.toml` lists the module directories, kept in sync with the `go.work` +use-list. + ## License [Apache License 2.0](LICENSE). diff --git a/STANDARDS.md b/STANDARDS.md index 61156c4..a4b16aa 100644 --- a/STANDARDS.md +++ b/STANDARDS.md @@ -3,7 +3,7 @@ The judgement calls the standards-reviewer applies to sqlate, beyond what `mise run check` enforces. - A change that alters documented behavior updates the guide, `README.md` and `docs/`, in the same change. -- `architecture/standards/go-elemental/principles/dependencies.md`: the bottom-up line and no provider in a base, across the three modules' `go.mod` files. +- `architecture/standards/go-elemental/principles/dependencies.md`: the three modules' `go.mod` files. - `architecture/standards/go-elemental/principles/tests-and-docs.md`: the doc.go inventory of every package, and the unit tier over `sqltest`. - `architecture/standards/go-elemental/principles/topology-and-naming.md`: the base module and the `postgres` and `sqlint` sub-modules, and their tags. - `architecture/standards/go-elemental/principles/release-and-ci.md`: the check, currency, and a changelog per module. @@ -14,5 +14,5 @@ The judgement calls the standards-reviewer applies to sqlate, beyond what `mise - `architecture/principles/service-tiers.md`: the `Dialect` boundary between the base module and each engine sub-module. - `architecture/principles/tool-beside-library.md`: the `sqlint` package and its command. - `architecture/principles/validation-first.md`: authored SQL, `sqlint.Load` and `migrate.New`. -- `architecture/principles/comments.md` governs Go source, tests, scripts, and every configuration file (TOML, YAML, `.gitignore`, Dockerfile, compose), not just exported API; a SQL file's header is its package documentation and its template metadata. -- `architecture/principles/context-architecture.md`: the guide and each `doc.go` are the homes. +- `architecture/principles/comments.md`: every comment; a `.sql` file's `--|` header is also its template metadata. +- `architecture/principles/context-architecture.md`: the guide (`README.md` and `docs/`) and each `doc.go`. diff --git a/compose/postgres/Dockerfile b/compose/postgres/Dockerfile index 9a44ace..95e75de 100644 --- a/compose/postgres/Dockerfile +++ b/compose/postgres/Dockerfile @@ -1,4 +1,4 @@ -# See docs/features.md +# See README.md FROM postgres:19.0-alpine ENV POSTGRES_USER=app \ diff --git a/context/README.md b/context/README.md index dc42188..5272235 100644 --- a/context/README.md +++ b/context/README.md @@ -13,8 +13,9 @@ It is a standalone library any Go project can adopt. The user guide is the repository's own: `README.md` is the index and `docs/` the documents it orders. The library is adjacent to the organization's Go Elemental standard, and the standard's -[catalog](https://github.com/standards-lab/architecture/blob/main/standards/go-elemental/README.md) names it as such. This context records only working knowledge the guide and -the code do not express. +[catalog](https://github.com/standards-lab/architecture/blob/main/standards/go-elemental/README.md) +names it as such. This context records only working knowledge the guide and the code do not +express. ## Capability map diff --git a/context/second-engine.md b/context/second-engine.md index faeb354..d4bbb98 100644 --- a/context/second-engine.md +++ b/context/second-engine.md @@ -5,7 +5,6 @@ roadmap tracks it as the backlog goal `second-providers` in `standards-lab/roadm The sub-module carries three parts of its own, each still open: -- a dialect: bind-parameter rendering, error classification, the migrate lock, the version - statement, and the keyset predicate, as `postgres/doc.go` lists them. +- a dialect: the parts `postgres/doc.go` lists, the `migrate.Catalog` implementation included. - a `sqlint.toml`. - an overlay for each library pattern the engine does not accept as written in standard SQL. diff --git a/docs/concepts.md b/docs/concepts.md index 7448b14..9e3aac7 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -22,9 +22,10 @@ SELECT id, code, name, version, created_at, updated_at FROM team ``` -`tier` is required on every file. `key` and `field` make this file a projection base, which a -collection read wraps as a query; they are explained below. A plain `--` comment in the header is prose, -skipped. The header ends at the first line that is neither blank, a comment, nor a declaration. +`tier` is required on every statement and pattern. `key` and `field` make this file a projection +base, which a collection read wraps as a query; they are explained below. A plain `--` comment in +the header is prose, skipped. The header ends at the first line that is neither blank, a comment, +nor a declaration. ## Parameters @@ -140,9 +141,9 @@ query.Publish("app", files, "patterns").As("shared") ## Tiers and the native declaration -Every file declares its tier. A standard file uses only standard SQL and runs on any engine. A -native file uses one engine's own feature, and its `native` declaration names the feature and -the port, the way the same effect is reached on other engines: +Every statement and pattern declares its tier. A standard file uses only standard SQL and runs on +any engine. A native file uses one engine's own feature, and its `native` declaration names the +feature and the port, the way the same effect is reached on other engines: ```sql --| tier: native diff --git a/docs/features.md b/docs/features.md index d2ac889..0580b88 100644 --- a/docs/features.md +++ b/docs/features.md @@ -100,7 +100,7 @@ The keys `query` and `migrate` accept: | `transaction` | migrations | `none`: the migration runs outside a transaction; `required` or absent keeps one. | | `key` | projection bases | The identity column and sort tie-breaker: one declared field, or several separated by commas (`id` or `org, id`), each named once. | | `returning` | statements | Optional, on a standard-tier `INSERT INTO` or `UPDATE` only: the name of the statement in the same directory that reads the changed row back. | -| `field` | projection bases | One per column a request may filter or sort by: ` `, with an optional trailing `not null`, matched case-insensitively, for a column that never holds a null. | +| `field` | projection bases | One per column a request may filter or sort by: ` `, with an optional trailing `not null`, matched case-insensitively, for a column that never holds a null; a misspelled suffix that leaves `not` or `null` in the type is a load error. | ## query: authored statements @@ -229,7 +229,8 @@ minted in the program, and the read finds the row by it. An entity's tags are its scan and binding contract, so a program writes neither scan functions nor argument literals. A field's column name is its `db` tag, else its `json` tag's name, else -the field name lowercased; `db:"-"` excludes it. +the field name lowercased; `db:"-"` excludes it. A base aliases its output columns to the +contract's names, so the `json` tag is the usual source and `db` the override. An untagged embedded struct flattens: its fields become columns of the outer type, as if declared there, so a read model that embeds a shared identity or audit type restates none of its @@ -313,9 +314,10 @@ trailing column, `sqlate_total`, which the scan never sees; a base may declare n name, in any case, and `Project` panics on one. A base that outputs an undeclared column of that name is refused when the page is read, as is a page whose last column is not the count. A scan that returns without calling `Scan` is an error, since the page's total would go unread, and a -scan given the wrong number of destinations is told the count of the columns it sees. The window reads every filtered row before paging, -where the plan under `TotalNone` can stop early along an index, so a caller walking a large -collection by cursor reads the total once and declines it after. +scan given the wrong number of destinations is told the count of the columns it sees. The window +reads every filtered row before paging, where the plan under `TotalNone` can stop early along an +index, so a caller walking a large collection by cursor reads the total once and declines it +after. The key makes the ordering total. After the caller's sorts, the read appends every key field the sorts do not name, in header order, so a composite key tie-breaks in the order its header @@ -334,8 +336,8 @@ before a contract change is refused. The hash is unkeyed and guards against acci forgery: a cursor's values re-enter the read only as bound parameters cast to the fields' types, so a forged cursor can at most select another page. A cursor also records the filters, so `Continue` under other filters than the page that issued it is refused as a `CursorMismatch`. -Filters with a value that has no JSON form, such as a float NaN, cannot be recorded, and their page reports `More` -without a `Next`. +Filters with a value that has no JSON form, such as a float NaN, cannot be recorded, and their +page reports `More` without a `Next`. Every error a request's declarations can cause unwraps to `ErrDirectives`, so a caller's check for a bad request is one `errors.Is`: @@ -636,9 +638,6 @@ agrees with its total when writes commit between the statement and the caller, w read as its own statement does not; that it agrees under concurrent writers; and that the counted page scans its base once under one window while the uncounted page keeps the key's index order. `mise run acceptance` runs them against a compose PostgreSQL and tears it down. -The compose PostgreSQL reports healthy once it accepts TCP connections to the app database. The -probe goes over TCP, not the socket, because the first start's initialization runs a temporary -server on the socket alone, which would report ready before the real server starts. ### pgtest: a test's throwaway database diff --git a/docs/glossary.md b/docs/glossary.md index 7e20945..505a272 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -11,8 +11,8 @@ SQL as written, never sent as written. - **Header**: a `.sql` file's leading `--|` declarations. The compiler reads the header and the engine never sees it. - **Declaration**: one `--| key: value` line of the header, such as `tier`, `native`, `port`, - `transaction`, `key`, or `field`. A long value folds onto following lines written - `--| [key]: more`. + `transaction`, `returning`, `alternate`, `key`, or `field`. A long value folds onto following + lines written `--| [key]: more`. - **Body**: what follows the header; what the engine receives. - **Tier**: the portability a file declares. A standard file uses only standard SQL and runs on any engine; a native file uses a feature only the named engine supports, and it names that diff --git a/scripts/currency.sh b/scripts/currency.sh index 695ee9d..d2bb086 100755 --- a/scripts/currency.sh +++ b/scripts/currency.sh @@ -3,11 +3,8 @@ # release, one line each, and exits non-zero when it reports any. It reads the # network and writes nothing. Run it through `mise run currency`. The actions it # checks are those of the project root's workflows and, when the repository nests -# the project in a subdirectory, of the git top-level's. -# -# Each scan captures its command's output in a variable before reading it, so -# under set -e a scan command that fails (a go list missing a go.sum entry) -# fails currency instead of reporting nothing. +# the project in a subdirectory, of the git top-level's. A scan command that fails +# fails currency. set -euo pipefail cd "$MISE_PROJECT_ROOT" export GOWORK=off