Skip to content

Commit e052b19

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-qrn7nl
2 parents 7df9a7d + ea62933 commit e052b19

38 files changed

Lines changed: 3080 additions & 79 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/metadata': patch
3+
'@objectstack/metadata-protocol': patch
4+
---
5+
6+
fix(metadata): a `sys_metadata_history` snapshot no longer stores what a connector save drains from the live row
7+
8+
Clause-②: yes (narrowing)
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no authoring door accepts or refuses anything it did not before. Only the body a history row stores for a new write changes; existing history rows are left as they are, so there is nothing for a migration to rewrite and no tombstone. -->
12+
13+
**BREAKING** for a reader of raw `sys_metadata_history` rows that expected a connector snapshot to hold an undeclared `auth` key. No door serves one: the history read exit already withheld it.
14+
15+
A connector row stored before the instance-auth shapes went strict can hold a value under an `auth` key its kind does not declare. A save of the served form drains that key from the live row, but a history snapshot is a second copy of the body at rest, and nothing stopped a new snapshot from keeping it: a revert to an older version wrote it into a fresh `revert` snapshot, and a write that no door re-judged did too. Now:
16+
17+
- **Both history writers store the snapshot through one helper**, `historySnapshotBody`, published as `@objectstack/metadata/history-snapshot`: `SysMetadataRepository.put` in `@objectstack/metadata-protocol` (behind the `/meta` save door, publish and revert) and `DatabaseLoader` in `@objectstack/metadata`.
18+
- **What it leaves out is the type's redactor's own answer**: every position named in `notCarriedForwardKeys`, the same answer the save's carry-forward drains by. For a connector those are its undeclared `auth` keys and the undeclared keys inside an object `retryConfig`. Nothing in the helper names a key or a type.
19+
- **Every other body is stored as written, byte for byte.** That covers every type whose redactor marks no such position, and every type with no redactor. The history row's `checksum` keeps naming the live row's stamp, and the history read exit (`redactStoredMetadataRow(s)`) is unchanged.
20+
21+
History rows written before this change are not rewritten here. A one-time scrub follows separately, after a read-only count.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/plugin-audit': patch
4+
---
5+
6+
feat(plugin-auth, plugin-audit): a sign-in the IP allow-list refuses leaves one `login_failed` row in the audit log, bounded per client address
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
A sign-in refused by the ADR-0069 D5 IP allow-list used to leave nothing in `sys_audit_log`: the deployment's list answered `403 IP_NOT_ALLOWED` with only a once-per-process operator line, and an organization's own list refused the session silently. Both now write a `login_failed` row with `metadata.reason: "IP_NOT_ALLOWED"`, `metadata.rule: "ip_allow_list"`, `metadata.endpoint` and `metadata.attempts`, and the client address and user agent in `ip_address` / `user_agent`:
12+
13+
- **The deployment's list** refuses before any account is resolved. Its row names the account when the request's `email` resolves to one (the password sign-in's own account lookup), and is written with no account otherwise. Only `/sign-in/*` endpoints are recorded; a refused session read or sign-out is not a sign-in. The row is written off the response path, so the refusal's status, body and timing do not depend on whether the address names an account.
14+
- **An organization's own list** refuses when the session is created. Its row names the account and the organization (`tenant_id`). A refused switch of the active organization is not a sign-in and writes no row.
15+
16+
The rows are bounded so a scanner cannot flood the table: per client address, in a 10-minute window from its first refusal, only the 1st, 10th and 100th refusal write a row (`attempts` 1, 10, 100); across all addresses, at most 1000 rows per 10-minute window, with one operator `warn` line in a window once the cap drops a row. The bound is held in each server process, so N replicas write up to N times as many rows. No row carries the submitted identifier or the password.
17+
18+
`@objectstack/plugin-audit`'s `AuthSessionAuditEvent.userId` and `@objectstack/plugin-auth`'s `AuthEventAuditSurface` event `userId` are now optional: a `login_failed` with no `userId` is written with `user_id` and `record_id` null (a row about no record, read under the ledger's own grant, platform administrators only when it names no organization). Any other event without a `userId` still writes nothing. `AuthManager.resolveRefusedSignInAccountId(email)` is new: the account a refused sign-in names, used only for that row. A sink registered on the `audit` service slot now receives `login_failed` events with no `userId`, so a custom sink must accept one. The exported `signInFailureEventFor` now answers `null` for `reason: 'IP_NOT_ALLOWED'`, because the door that refused the sign-in writes that row itself.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/cloud-connection': patch
3+
---
4+
5+
feat(cloud-connection)!: the marketplace catalog list filters by business function, industry, solution type and maturity on the server, and the `?category=` filter is retired
6+
7+
Clause-②: no (narrowing) — the facets are declared by the published `MarketplaceSearchRequestSchema` (`businessFunctions`, `industries`, `solutionTypes`, `maturity`), so implementing them widens no contract; refusing the retired `?category=` filter, and a facet the catalog cannot answer, narrows what the proxy honours. No export, type or error code of the package is added.
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export or type of the package changes: the catalog list door reads query-string names the spec already declares and refuses one the spec already retired, with the spec's own prescription. Nothing at rest records a catalog query, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**The facet filters.** `GET /api/v1/marketplace/packages` reads `businessFunctions`, `industries` and `solutionTypes`, each one comma-separated value (`?businessFunctions=sales,marketing`), and `maturity`, one value. Values inside one facet are OR-ed, facets are AND-ed with each other, with `maturity` and with `q`, and `limit` / `offset` page the filtered set, so `total` counts every matching listing. A listing that declares no solution type is the spec's default `app`, and one that declares no maturity is `stable`. On the public snapshot path (`OS_MARKETPLACE_PUBLIC_BASE_URL`) the proxy filters and pages the snapshot itself; on the cloud path it forwards the query string to the cloud unchanged, as before.
13+
14+
**BREAKING** accept-set narrowing at the catalog list (`@objectstack/cloud-connection`).
15+
16+
- **Before.** `?category=crm` filtered the public snapshot by the listing's retired `category` column.
17+
- **Now.** `?category=` is refused with `400` and the spec's retirement prescription for `MarketplaceSearchRequest.category` (`retiredCategoryGuidance`, the text a parse of `MarketplaceSearchRequestSchema` gives the same key), on the snapshot and the cloud path alike, before either is asked. A facet value the spec does not declare (`?businessFunctions=crm`), a facet supplied twice (`?industries=retail&industries=logistics`) and a facet naming no value (`?solutionTypes=`) are refused with `400` and `{ "success": false, "error": { "code": "VALIDATION_ERROR", "message" } }` before the snapshot or the cloud is asked; the message names the parameter and the values it takes.
18+
- **Who moves.** Nothing in the workspace sends `?category=` or a facet today; the Console filters the loaded catalog itself. A script still sending `?category=` gets the 400 instead of a filtered list.
19+
20+
**The remedy.** Replace `?category=X` with the facet that says what you mean (`?businessFunctions=`, `?industries=`, `?solutionTypes=`), and send several values of one facet as one comma-separated value.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol): the cached `/meta` item read answers the item's own change time as `lastModified`, never the time of the read
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The cached by-name read (`getMetaItemCached`, the default `GET /api/v1/meta/:type/:name`) used to answer `lastModified` as the time of the read, so the `Last-Modified` header changed on every read of an unchanged item while its ETag stayed the same.
11+
12+
- **An item served from a stored `sys_metadata` row** answers that row's `updated_at`: the time of the save or publish that last wrote it. Two reads of the unchanged item answer the same `Last-Modified`; a save or a publish moves it.
13+
- **An item no stored row serves** (a definition shipped in code or loaded from a file) has no known change time. It answers no `lastModified`, and the door sends no `Last-Modified` header.
14+
- **Unchanged.** The ETag, `Cache-Control: private, no-cache` and the `304` on `If-None-Match`. `If-Modified-Since` still never answers a `304`. The by-name read's response envelope is byte-for-byte as before.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/plugin-hono-server': patch
3+
---
4+
5+
fix(plugin-hono-server): a graceful `close()` no longer cuts off a response that has ended but is still being sent to a slow client
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
When `HonoHttpServer.close()` started, Node's own `server.close()` released idle keep-alive connections first thing, and counted a response as done as soon as it had called `end()`, before its bytes were sent. A large response still flushing to a slow client at that moment was destroyed mid-body, so the client got a truncated download. The release of idle connections now waits until no ended response is still flushing; each such response closes its own connection once every byte has been sent, and idle connections are released right after. The drain window still force-closes whatever outlasts it.

‎content/docs/kernel/runtime-services/audit-service.mdx‎

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The slot's entire surface is one method:
2929
```ts
3030
services.audit.recordAuthEvent(event: {
3131
action: 'login' | 'logout' | 'login_failed' | 'account_locked';
32-
userId: string;
32+
userId?: string;
3333
sessionId?: string;
3434
organizationId?: string;
3535
ipAddress?: string;
@@ -46,11 +46,17 @@ services.audit.recordAuthEvent(event: {
4646
hands over an **event** (what happened) rather than a row (what to store).
4747
- `login` / `logout` are **session events**: a sign-in that minted a session, and a
4848
sign-out.
49-
- `login_failed` / `account_locked` are **account events**: a refused password sign-in
50-
that named an existing account, and the refused sign-in that stamped the account
49+
- `login_failed` / `account_locked` are **account events**: a refused sign-in — a
50+
password sign-in that named an existing account, or any `/sign-in/*` request the IP
51+
allow-list refused (ADR-0069 D5) — and the refused sign-in that stamped the account
5152
lockout (`lockoutThreshold`, ADR-0069 D2). They exist without any session.
52-
- **`userId`** is required and must be a real `sys_user` id — it lands on the strict
53-
`user_id` lookup. On an account event it is the account the sign-in named.
53+
- **`userId`** must be a real `sys_user` id when given — it lands on the strict `user_id`
54+
lookup. On an account event it is the account the sign-in named. Every event names one
55+
except a `login_failed` refused before any account could be resolved: the deployment's
56+
IP allow-list refuses ahead of better-auth, and the identifier the request carried may
57+
name no account. That row is written with `user_id` and `record_id` null — a row about
58+
no record, read under the ledger's own grant — and still carries the client address and
59+
the rule. Any other event without a `userId` writes nothing.
5460
- **`sessionId`** lands on `record_id`, with `object_name` set to `sys_session`, so the
5561
ledger row is navigable to the session it describes. An account event names its account
5662
instead — `object_name` `sys_user` and `record_id` the account's id — and does not read
@@ -67,9 +73,23 @@ services.audit.recordAuthEvent(event: {
6773
because a refused attempt authenticated nobody.
6874
- **`context`** is free-form and is serialized into `metadata`, e.g. the endpoint that
6975
produced the event (`/sign-in/email`, `/sign-out`). On an account event it is the
70-
endpoint, the refusal's machine code (`reason`, e.g. `INVALID_EMAIL_OR_PASSWORD` or
71-
`ACCOUNT_LOCKED`) and, for `account_locked`, the lock's `locked_until` and `threshold`.
72-
It never carries the attempted credential.
76+
endpoint, the refusal's machine code (`reason`, e.g. `INVALID_EMAIL_OR_PASSWORD`,
77+
`ACCOUNT_LOCKED` or `IP_NOT_ALLOWED`) and, for `account_locked`, the lock's `locked_until`
78+
and `threshold`. It never carries the attempted credential.
79+
- A sign-in an authentication **policy** holds or refuses also names the policy, in
80+
`rule`. A sign-in held by enforced MFA (ADR-0069 D3) is not refused — the session is
81+
minted — so its own `login` row carries `reason: 'MFA_REQUIRED'` and
82+
`rule: 'mfa_required'`. A sign-in the IP allow-list refuses (ADR-0069 D5), by the
83+
deployment's list or by the organization's own list when the session is created, is a
84+
`login_failed` with `reason: 'IP_NOT_ALLOWED'`, `rule: 'ip_allow_list'` and
85+
`attempts`, below; the organization's refusal also names the organization. A refused
86+
switch of the active organization is not a sign-in and writes no row.
87+
- IP allow-list rows are **bounded** so a scanner cannot flood the ledger: per client
88+
address, in a 10-minute window from its first refusal, only the 1st, 10th and 100th
89+
refusal write a row, carrying that count as `attempts`; across all addresses, at most
90+
1000 rows per 10-minute window, with one operator `warn` line in a window once the cap
91+
drops a row. The bound is held in each server process, so N replicas write up to N
92+
times as many rows.
7393

7494
## Notes
7595

@@ -80,8 +100,9 @@ services.audit.recordAuthEvent(event: {
80100
reference from the moment the plugin initializes.
81101
- `@objectstack/plugin-auth` is the only in-repo consumer. It resolves the slot lazily
82102
through a locally-declared structural surface and calls it from the session lifecycle
83-
and from the password sign-in outcome, so neither package depends on the other. A
84-
sign-in identifier that resolves to no account produces no call.
103+
and from the sign-in outcomes, so neither package depends on the other. A password
104+
sign-in whose identifier resolves to no account produces no call; an IP allow-list
105+
refusal produces one with no `userId`.
85106

86107
## Typical Errors
87108

@@ -98,8 +119,9 @@ caller's side:
98119
`error` line, once. The sign-in was answered exactly as it would have been without the
99120
ledger, so the shipped `auth_events` list view and the system-overview widgets keep
100121
showing an empty, healthy-looking screen.
101-
- The call **silently no-ops** when no data engine resolves, or when `userId` is absent.
102-
A caller that passes an event without a subject records nothing and is told nothing.
122+
- The call **silently no-ops** when no data engine resolves, or when `userId` is absent on
123+
any event but `login_failed`. A caller that passes such an event records nothing and is
124+
told nothing.
103125
- The most common cause of a failing insert is a datasource split rather than a broken
104126
write: `sys_audit_log` carries an ADR-0057 `audit` lifecycle class, which routes it to a
105127
dedicated `telemetry` datasource whenever one is registered — `os dev` provisions one by

0 commit comments

Comments
 (0)