Skip to content

Commit e1e7573

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/issue-24905-v18-upgrade-checklist
2 parents 95f5a04 + a7199ef commit e1e7573

39 files changed

Lines changed: 1247 additions & 239 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/lint': patch
4+
'@objectstack/objectql': patch
5+
'@objectstack/runtime': patch
6+
'@objectstack/plugin-security': patch
7+
'@objectstack/plugin-sharing': patch
8+
'@objectstack/plugin-webhooks': patch
9+
'@objectstack/service-automation': patch
10+
'@objectstack/service-messaging': patch
11+
'@objectstack/service-storage': patch
12+
---
13+
14+
fix: no shipped text says the SQL driver reads organization-less rows, and the in-memory HTTP outbox no longer does
15+
16+
Clause-②: no (one fix and texts: the in-memory HTTP outbox's `redeliver()` now answers as `SqlHttpOutbox` already did; no accept set, served body or error code of a shipped composition moves)
17+
18+
ADR-0131 D8 retired the driver's `OR organization_id IS NULL` arm. Several shipped texts still described it as the live tenant predicate. They now state the current rule: the tenant term is `organization_id = :tenant`, or `IN (:tenants)` under the `group` posture, and nothing else. No tenant-scoped read reaches an organization-less row on a tenant table.
19+
20+
- **`@objectstack/service-messaging` — fix.** `MemoryHttpOutbox.redeliver()` no longer lets a tenant-scoped caller replay a row with no organization. It answers `RESOURCE_NOT_FOUND`, as `SqlHttpOutbox` does through the driver's tenant scope (ADR-0131 D8: no layer has a NULL arm). A caller with no tenant is still unscoped. No shipped composition constructs the in-memory outbox; the messaging plugin always builds `SqlHttpOutbox`. Code that embeds `MemoryHttpOutbox` directly sees the change.
21+
- **`@objectstack/service-automation`.** The `[http]` node's warning for a durable callout with no organization no longer says the `sys_http_delivery` row is "a global row every organization's redeliver door can reach". It now says no organization's redeliver door reaches that row.
22+
- **`@objectstack/objectql`.** The `sys_record_share` entry of the platform-object tenancy inventory carries an updated `evidence` text.
23+
- **`@objectstack/lint`.** `os explain unique/legacy-organization-composite` now says that a new row carries its organization wherever the organization object is registered. A composition that registers no organization object still writes rows whose organization column is NULL.
24+
- **`@objectstack/spec`.** The TSDoc of `SharingRuleRow` no longer calls it a 1-to-1 stored shape: `deploymentWide` has no `sys_sharing_rule` column. The TSDoc of `DriverOptions.tenantIds` and of the events `organizationId` member describe the predicate without a NULL arm.
25+
- **The other packages.** Code comments only.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/platform-objects': minor
3+
---
4+
5+
fix(platform-objects): a team record no longer lists Sessions with "Sign out other devices" (#24765)
6+
7+
Clause-②: no (narrowing)
8+
9+
<!-- adr-0087: not-required (no-migration-prescription) One shipped object field gains `relatedList: false`, a key it was always free to set. No spec key, authorable spelling, export, type or stored shape is added, removed or renamed, and no stored row or column is read or rewritten, so `objectstack migrate meta` has nothing to rewrite. What narrows is one derived related list on a team's served detail page. The other categories are closed on facts: the package publishes (not unpublished); no ADR-0087 id covers this field (not already-registered); and the change is metadata on a shipped object, not an interface, a type or an export (not runtime-interface-only, type-surface-only or runtime-export-retired). -->
10+
11+
**BREAKING** for a reader of a team's derived related lists only: Setup → Teams → a team → Related no longer lists *Sessions*. Shipped as `minor` under the launch-window convention for accept-set narrowings.
12+
13+
- **Before.** `sys_session.active_team_id` is a lookup to `sys_team` that did not set `relatedList: false`, so every team record derived a Sessions related list. That list carried the session list's only toolbar action, "Sign out other devices", whose confirmation reads "Sign out of every other device where you're currently logged in?". The action signs out the administrator's own other sessions, not the team's.
14+
- **Now.** `active_team_id` sets `relatedList: false`, so a team record derives no Sessions list. A team's Members and Invitations lists are unchanged.
15+
- **Unchanged.** The `active_team_id` field, its lookup to `sys_team`, its label and its column: better-auth still writes `activeTeamId` there. A user record's Sessions tab (keyed on `user_id`), where "Sign out other devices" belongs, and the action itself.
16+
17+
**What to do.** Nothing. No team-scoped session action existed to lose.

‎.claude/hooks/guard-main-checkout-bash.selftest.sh‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,35 @@ expect allow "$(printf "grep '#' README.md <<EOF\nsed -i 's/a/b/' pkg/x.ts\nEOF\
304304
expect block "$(printf "cat > /tmp/n.md <<'EOF'\n# it's a note, don't strip me\nEOF\nsed -i s/a/b/ pkg/x.ts\n")"
305305
expect allow "$(printf "cat > /tmp/n.md <<'EOF'\n# it's a note, don't strip me\nEOF\ngit status\n")"
306306

307+
echo "== a \$(…) inside \"…\" is its own quoting context (#24812) =="
308+
CWD="$MAIN"
309+
# The measured false blocks: a `"` inside the substitution was read as CLOSING the outer string,
310+
# so the `>` in a quoted JSON body became a redirect and the fragment after it a write target.
311+
# Pure reads — nothing is written.
312+
expect allow 'echo "a $(curl -d "{\"c\":\"x > 1\"}" http://h)"'
313+
expect allow "echo \"a \$(curl -d '{\"c\":\"x > 1\"}' http://h)\""
314+
expect allow 'echo "a `curl -d "{\"c\":\"x > 1\"}" http://h`"' # the backtick spelling
315+
# Recall is untouched: a real write beside a quoted substitution still blocks — in the same
316+
# command, behind a separator, and inside a sed -i script — and so does the card's control.
317+
expect block 'echo hi > out.txt'
318+
expect block 'echo "a $(curl -d "{\"c\":\"x > 1\"}" http://h)" > pkg/x.ts'
319+
expect block 'X="$(git rev-parse HEAD)" ; sed -i s/a/b/ pkg/x.ts'
320+
expect block 'sed -i "s/a/$(date +%F)/" pkg/x.ts'
321+
# The fail-OPEN mirror: one `"` in the body used to leave the outer string hanging, so the
322+
# separator behind it went inert and the real write rode through as text.
323+
expect block "echo \"\$(printf '\"')\" ; sed -i s/a/b/ pkg/x.ts"
324+
expect block "echo \"\$(echo \"\$(printf '\"')\")\" ; sed -i s/a/b/ pkg/x.ts" # nested
325+
# The heredoc scan reads the body the same way: the ` #` inside it is no comment, so the
326+
# introducer behind it is found and the body stays prose.
327+
expect allow "$(printf 'echo "$(echo " #")" <<EOF\nsed -i s/a/b/ pkg/x.ts\nEOF\n')"
328+
307329
echo "== shapes this guard deliberately does NOT claim (documented fail-open) =="
308330
CWD="$MAIN"
309331
expect allow "bash -c \"sed -i s/a/b/ $MAIN/pkg/x.ts\""
310332
expect allow 'echo pkg/x.ts | xargs sed -i s/a/b/'
311333
expect allow 'node -e "fs.writeFileSync(\"pkg/x.ts\", \"y\")"'
312334
expect allow 'python3 -c "open(\"pkg/x.ts\",\"w\").write(\"y\")"'
335+
expect allow 'echo "$(sed -i s/a/b/ pkg/x.ts)"' # a QUOTED $(…) body is one inert word
313336
expect allow 'sed -i s/a/b/ $SOMEDIR/x.ts'
314337
expect allow 'sed -i s/a/b/ pkg/*.ts'
315338

‎.claude/hooks/guard-main-checkout-bash.sh‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
#
3939
# Fails open, deliberately, on:
4040
# - wrapped invocations: bash -c '…', xargs, ssh host '…', make, a shell script that
41-
# writes (the target is one indirection away from any token this hook can see);
41+
# writes, a command inside a QUOTED "$(…)" (the target is one indirection away from any
42+
# token this hook can see);
4243
# - programs whose writes live inside their own source text: python -c "open(p,'w')",
4344
# node -e, awk > (the target is not a shell token, so there is nothing to read);
4445
# - any target containing an expansion or glob ($VAR, `…`, $(…), *, ?, ~) — unresolvable
@@ -51,6 +52,8 @@
5152
# Writing ABOUT the ban must never trip the ban (#4890's lesson). Four layers:
5253
# 1. quote-aware segmentation + tokenisation — a `>` or a `sed -i` inside '…' or "…" is
5354
# literal text, so `grep -n "sed -i" .claude/` and `echo "never sed -i in main"` pass;
55+
# a `$(…)` or backtick inside "…" is a quoting context of its own, so a `"` in its body
56+
# nests instead of closing the outer string (subst_end(), shared by every pass);
5457
# 2. heredoc bodies are stripped before analysis — the LINES of a `cat > /tmp/notes <<EOF`
5558
# body are documentation, not commands, and segmentation alone (which splits on
5659
# newlines) would happily read them as such;
@@ -118,6 +121,48 @@ fi
118121

119122
[ -n "$cmd" ] || exit 0
120123

124+
# --- a command substitution inside "…" is its own quoting context ---------------------
125+
# Inside "…", `$(` or a backtick opens a NEW quoting context: a `"` in the body starts a string
126+
# of its own and does not close the outer one. Each scanner below used to read that `"` as the
127+
# closer, so the rest of the body became bare shell, and a `>` in a quoted curl body was taken
128+
# for a redirect whose "target" was the next fragment — a false BLOCK (#24812). All three
129+
# quote-aware scanners hand such a body to this ONE function, so they agree on where it ends.
130+
#
131+
# subst_end S I: S[I] is the `$` of a `$(`, or a backtick, met inside "…". Sets SUBST_END to
132+
# the index of the character that closes the substitution, reading the body with its own
133+
# quotes, escapes and nested `(…)` / `$(…)` / backticks; when the input ends first, to the
134+
# last index — the rest is one inert run (bash refuses such a command anyway). The body is
135+
# kept verbatim as part of the word, so a target holding it still fails open on its `$`.
136+
# Boundary: a `(` or `)` bash would not count (a `case` pattern, a comment) moves the end —
137+
# too early, and the rest is read as it was before this function existed; too late, and the
138+
# text swallowed with the body is inert, i.e. fails open.
139+
SUBST_END=0
140+
subst_end() {
141+
local s="$1" i="$2" n=${#1} st ch top
142+
if [ "${s:i:1}" = '`' ]; then st='`'; else st=')' ; i=$((i + 1)); fi
143+
for ((i = i + 1; i < n; i++)); do
144+
ch="${s:i:1}" ; top="${st:${#st}-1:1}"
145+
if [ "$top" = "'" ]; then [ "$ch" = "'" ] && st="${st%?}"; continue; fi
146+
if [ "$ch" = '\' ]; then i=$((i + 1)); continue; fi
147+
if [ "$top" = '"' ]; then
148+
case "$ch" in
149+
'"') st="${st%?}" ;;
150+
'`') st+='`' ;;
151+
'$') if [ "${s:i+1:1}" = '(' ]; then st+=')' ; i=$((i + 1)); fi ;;
152+
esac
153+
continue
154+
fi
155+
case "$ch" in
156+
"'" | '"') st+="$ch" ;;
157+
'(') st+=')' ;;
158+
')') [ "$top" = ')' ] && st="${st%?}" ;;
159+
'`') if [ "$top" = '`' ]; then st="${st%?}"; else st+='`'; fi ;;
160+
esac
161+
if [ -z "$st" ]; then SUBST_END=$i; return; fi
162+
done
163+
SUBST_END=$((n - 1))
164+
}
165+
121166
# --- heredoc bodies are text, not commands ---------------------------------------------
122167
# `cat > /tmp/notes.md <<EOF` … `EOF` carries prose over several lines. Segmentation splits
123168
# on newlines, so without this pass a documented example inside the body ("sed -i … main
@@ -148,6 +193,9 @@ strip_line_comment() {
148193
ch="${s:i:1}"
149194
if [ -n "$q" ]; then
150195
if [ "$q" = '"' ] && [ "$ch" = '\' ] && [ $((i + 1)) -lt "$n" ]; then i=$((i + 1)); continue; fi
196+
if [ "$q" = '"' ] && { [ "$ch" = '`' ] || [ "${s:i:2}" = '$(' ]; }; then
197+
subst_end "$s" "$i" ; i=$SUBST_END ; continue
198+
fi
151199
[ "$ch" = "$q" ] && q=""
152200
continue
153201
fi
@@ -217,6 +265,9 @@ split_segments() {
217265
seg+="$ch" ; i=$((i + 1)) ; seg+="${s:i:1}" ; continue ;;
218266
esac
219267
fi
268+
if [ "$q" = '"' ] && { [ "$ch" = '`' ] || [ "${s:i:2}" = '$(' ]; }; then
269+
subst_end "$s" "$i" ; seg+="${s:i:SUBST_END-i+1}" ; i=$SUBST_END ; continue
270+
fi
220271
seg+="$ch"
221272
[ "$ch" = "$q" ] && q=""
222273
continue
@@ -274,6 +325,9 @@ tokenize() {
274325
i=$((i + 1)) ; tok+="${s:i:1}" ; have=1 ; continue ;;
275326
esac
276327
fi
328+
if [ "$q" = '"' ] && { [ "$ch" = '`' ] || [ "${s:i:2}" = '$(' ]; }; then
329+
subst_end "$s" "$i" ; tok+="${s:i:SUBST_END-i+1}" ; i=$SUBST_END ; have=1 ; continue
330+
fi
277331
if [ "$ch" = "$q" ]; then q=""; else tok+="$ch"; fi
278332
have=1
279333
continue

‎content/docs/deployment/cli.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,12 +1797,12 @@ this report reads. Half of what it can tell you does not survive that:
17971797
17981798
| Reported | Survives the repair? |
17991799
| :--- | :--- |
1800-
| **The duplicates themselves** — every value held across two partitions, with the id, organization and creation time of each holder | **Yes.** The repair deliberately refuses to adopt a row whose identifier is already taken in the destination partition, so those rows keep `organization_id = NULL` and stay visible |
1801-
| **The live condition** — an object still running a global counter beside an organization-scoped one, and therefore about to mint more duplicates | **No.** The repair merges the two counters and deletes the global one. Once that has happened, this line can never be produced again |
1800+
| **The duplicates themselves** — every value held across two partitions, with the id, organization and creation time of each holder | **Yes.** The repair deliberately refuses to adopt a row whose identifier is already taken in the destination partition, so those rows keep `organization_id = NULL` and stay findable by this report |
1801+
| **The live condition** — an object still holding a global counter beside an organization-scoped one: the record of which counter minted the duplicates above. Under 17.x it also forecast more; since the counter refuses an organization-less row on a tenant table wherever the organization object is registered, nothing mints from the global counter there | **No.** The repair merges the two counters and deletes the global one. Once that has happened, this line can never be produced again |
18021802
18031803
Running it afterwards is still worth doing — the inventory is what you act on,
1804-
and it is complete either way. What you cannot recover is the forward-looking
1805-
half.
1804+
and it is complete either way. What you cannot recover is the counter
1805+
evidence.
18061806
18071807
A deployment holding **more than one organization** is skipped by that repair
18081808
rather than guessed at: there is no derivable answer to which organization owns

‎content/docs/deployment/seed-tenancy-repair.mdx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,9 @@ Be precise about what is lost, because the two halves behave differently:
302302
| | Survives the repair? |
303303
| :--- | :--- |
304304
| The inventory of identifiers **already** minted twice | **Yes.** Colliding rows deliberately keep `organization_id = NULL`, so they remain in two partitions and remain findable. |
305-
| The **live condition** — an install still holding a `__global__` counter beside an organization-scoped one, i.e. *about to mint more* | **No.** The repair deletes that counter row. Once it has run, this condition can never be produced again. |
305+
| The **live condition** — an install still holding a `__global__` counter beside an organization-scoped one: the record of which counter minted the duplicates. Under 17.x it also forecast more; since the counter refuses an organization-less row on a tenant table wherever the organization object is registered, nothing mints from that counter there | **No.** The repair deletes that counter row. Once it has run, this condition can never be produced again. |
306306

307-
The live condition is the only forward-looking line in the report, and it is the
308-
perishable one. On a deployment you have not yet restarted since discovering the
307+
The live condition is the perishable line in the report. On a deployment you have not yet restarted since discovering the
309308
problem, run the report first.
310309

311310
`os migrate duplicates` writes no row: it boots read-only, declares itself out

‎content/docs/protocol/objectql/schema.mdx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,13 @@ stays valid indefinitely; `'organization'` is simply the preferred spelling in
606606
new code.
607607

608608
**The organization key part is NULL-safe.** It materializes as
609-
`COALESCE(organization_id, '__global__')`, so rows carrying no organization —
610-
platform rows, and *every* row on a single-organization deployment — form one
611-
platform bucket that is unique among itself. A plain `(organization_id, field)`
609+
`COALESCE(organization_id, '__global__')`, so rows carrying no organization
610+
form one bucket that is unique among itself. Wherever the organization object
611+
is registered, a tenant table holds no such row (ADR-0131: every write is
612+
stamped with its organization — on a single-organization deployment, the
613+
Default Organization); the bucket is for a composition that registers no
614+
organization object, and for residue an uncertified pre-18.x database still
615+
holds. A plain `(organization_id, field)`
612616
composite would enforce nothing on those rows, because SQL `UNIQUE` treats every
613617
`NULL` as distinct. The value stored in the column is still `NULL`; the sentinel
614618
exists only inside the index key, so `WHERE organization_id = '__global__'`

0 commit comments

Comments
 (0)