Skip to content

Commit 8527cc4

Browse files
committed
Merge origin/fast/integration into fast/s2-db-typed
2 parents 74d32dc + 7e58fe9 commit 8527cc4

7 files changed

Lines changed: 78 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ jobs:
172172
run: |
173173
bun test/tools/reconnect_test.ts
174174
bun test/tools/thin_heartbeat_e2e.ts dist-js/linux-x64/backplane-serve
175+
# the phone bridge's thin rows, request privacy, transport, readiness
176+
# and flush (hermetic: no hub, build or network)
177+
- name: Phone bridge
178+
run: |
179+
bun test/tools/native_thin_rows_307265.mjs
180+
bun test/tools/native_thin_privacy_307265.mjs
181+
bun test/tools/native_thin_bridge_307265.mjs
182+
bun test/tools/mobile_readiness_test.ts
183+
bun test/tools/phone_flush_test.ts
175184
- uses: actions/setup-node@v4
176185
with:
177186
node-version: '24'

‎test/storedb_db_test.bend‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import Base
2+
import ./check.bend as C
3+
import ../src/core/storedb.bend as S
4+
import ../src/server/db.bend as D
5+
6+
# Values through SQLite and back (D.Db, bun:sqlite): text that reads like
7+
# a number stays the text it was, numbers land in INTEGER columns as
8+
# integers, and a delete finds the key it was given.
9+
10+
def handle(+r: String) -> String:
11+
String.drop(r, 3n)
12+
13+
def items(os: List<&2, S.Op>, acc: List<&2, List<&2, String>>) -> List<&2, List<&2, String>>:
14+
match os:
15+
case Nil{}:
16+
List.reverse(&2, List<&2, String>, acc)
17+
case o <> t:
18+
items(t, S.Sql.of(o) <> acc)
19+
20+
def row(rs: List<&2, List<&2, String>>) -> String:
21+
match rs:
22+
case r <> _:
23+
String.join(r, "|")
24+
case Nil{}:
25+
"<none>"
26+
27+
def main() -> IO(Unit):
28+
do IO<Unit>:
29+
o : String <- D.Db.open(":memory:")
30+
+h : String = handle(o)
31+
e : String <- D.Db.exec(h, S.Sdb.schema())
32+
C.Check.str("schema made", e, "ok")
33+
w : String <- D.Db.script(h, items([S.Put{"setting", ["#42", "#007", "0"]}, S.Put{"setting", ["plain", "007", "0"]},
34+
S.Put{"thread", ["#7", "p", "#007", "5", "6", "idle", "0", "0", "1", "0", "", "", "", "0", "{}"]},
35+
S.Put{"obj", ["mem", "#9", "\"#9\""]}, S.Put{"line", ["1", "0", "12", ""]}], Nil{}))
36+
C.Check.str("written", String.take(w, 2n), "ok")
37+
a : List<&2, List<&2, String>> <- D.Db.query(h, "SELECT k, v, typeof(v) FROM setting WHERE k = '#42'", [], 5)
38+
C.Check.str("#42 / #007 round-trip as text", row(a), "#42|#007|text")
39+
b : List<&2, List<&2, String>> <- D.Db.query(h, "SELECT v, typeof(v) FROM setting WHERE k = 'plain'", [], 5)
40+
C.Check.str("007 stays text in a TEXT column", row(b), "007|text")
41+
c : List<&2, List<&2, String>> <- D.Db.query(h, "SELECT id, title, created, typeof(created), pinned FROM thread", [], 5)
42+
C.Check.str("thread: text kept, numbers integers", row(c), "#7|#007|5|integer|1")
43+
l : List<&2, List<&2, String>> <- D.Db.query(h, "SELECT seq + 1, len, typeof(off) FROM line", [], 5)
44+
C.Check.str("line numbers are integers", row(l), "2|12|integer")
45+
d : String <- D.Db.script(h, items([S.Del{"setting", ["#42"]}, S.Del{"obj", ["mem", "#9"]}], Nil{}))
46+
C.Check.str("deleted", String.take(d, 2n), "ok")
47+
x : List<&2, List<&2, String>> <- D.Db.query(h, "SELECT count(*) FROM setting WHERE k = '#42'", [], 5)
48+
C.Check.str("delete by a #-key", row(x), "0")
49+
y : List<&2, List<&2, String>> <- D.Db.query(h, "SELECT count(*) FROM obj", [], 5)
50+
C.Check.str("obj delete by (domain, #-key)", row(y), "0")
51+
z : String <- D.Db.close(h)
52+
C.Check.str("closed", z, "ok")

‎test/tools/mobile_readiness_test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ var App={current:h=>h.cur,lean:h=>h,screen_list_in:()=>({hub:'A',sel:'A-thread'}
3030
var plain=x=>x,same=(a,b)=>a===b,liveNodes=()=>[];
3131
var recent={links:new Map(),overlays:()=>[],end:()=>[]};
3232
var commandList=cs=>cs;
33+
// a hub that is not on the thin view lane (the transport these checks cover)
34+
var thin={thin:()=>false,views:()=>null,drain:()=>({cmds:[],sync:[]}),inert:()=>false,receive(){},fail(){},disconnect(){}};
3335
var direct=(cmds,draw,updates=[])=>({cmds,draw,updates,screen:draw?JSON.parse(screenText()):null});
3436
${focus}
3537
${screen}

‎test/tools/native_thin_bridge_307265.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import fs from 'node:fs';
44
import os from 'node:os';
55
import path from 'node:path';
66
import { pathToFileURL } from 'node:url';
7+
// Hermetic by default: without the frozen review packet (build/phone-cache), check the repo's own sources.
8+
if(!process.env.BP_NATIVE_THIN_SOURCE_ROOT&&!fs.existsSync(path.join(process.cwd(),'build/phone-cache/native-thin-bridge-proposal-01')))process.env.BP_NATIVE_THIN_SOURCE_ROOT=process.cwd();
79
const root=process.cwd(), packet=path.join(root,'build/phone-cache/native-thin-bridge-proposal-01');
810
const stage=fs.mkdtempSync(path.join(os.tmpdir(),'bp-native-thin-js-307265-'));
911
for(const n of ['src/web/thin.js','src/web/thin-results.js','src/web/startup.js','src/web/mail-drafts.js']) {const q=path.join(stage,n);fs.mkdirSync(path.dirname(q),{recursive:true});fs.copyFileSync((process.env.BP_NATIVE_THIN_SOURCE_ROOT ? path.join(process.env.BP_NATIVE_THIN_SOURCE_ROOT,n) : path.join(packet,fs.existsSync(path.join(packet,'qualified-dependencies'))?'qualified-dependencies':'dependencies',n)),q);}

‎test/tools/native_thin_privacy_307265.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Focused source controls; real shared transport, stub pure Bend adapter. No build/runtime claim.
22
import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import assert from 'node:assert/strict';import {pathToFileURL} from 'node:url';
3+
// Hermetic by default: without the frozen review packet (build/phone-cache), check the repo's own sources.
4+
if(!process.env.BP_NATIVE_THIN_SOURCE_ROOT&&!fs.existsSync(path.join(process.cwd(),'build/phone-cache/native-thin-bridge-proposal-01')))process.env.BP_NATIVE_THIN_SOURCE_ROOT=process.cwd();
35
const root=process.env.BP_NATIVE_THIN_SOURCE_ROOT||process.cwd(),stage=fs.mkdtempSync(path.join(os.tmpdir(),'bp-native-privacy-307265-'));
46
const donor=process.env.BP_NATIVE_THIN_SOURCE_ROOT?root:path.join(root,'build/phone-cache/native-thin-bridge-proposal-01/qualified-dependencies');
57
for(const n of ['src/web/thin.js','src/web/thin-results.js','src/web/startup.js','src/web/mail-drafts.js']){const q=path.join(stage,n);fs.mkdirSync(path.dirname(q),{recursive:true});fs.copyFileSync(path.join(donor,n),q);}

‎test/tools/native_thin_rows_307265.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Focused source-only physical-row bound controls. No app/helper compilation.
22
import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import assert from 'node:assert/strict';import {pathToFileURL} from 'node:url';
3+
// Hermetic by default: without the frozen review packet (build/phone-cache), check the repo's own sources.
4+
if(!process.env.BP_NATIVE_THIN_SOURCE_ROOT&&!fs.existsSync(path.join(process.cwd(),'build/phone-cache/native-thin-bridge-proposal-01')))process.env.BP_NATIVE_THIN_SOURCE_ROOT=process.cwd();
35
const root=process.env.BP_NATIVE_THIN_SOURCE_ROOT||process.cwd(),stage=fs.mkdtempSync(path.join(os.tmpdir(),'bp-native-rows-307265-'));
46
const donor=process.env.BP_NATIVE_THIN_SOURCE_ROOT?root:path.join(root,'build/phone-cache/native-thin-bridge-proposal-01/qualified-dependencies');
57
for(const n of ['src/web/thin.js','src/web/thin-results.js','src/web/startup.js','src/web/mail-drafts.js']){const q=path.join(stage,n);fs.mkdirSync(path.dirname(q),{recursive:true});fs.copyFileSync(path.join(donor,n),q);}

‎test/tools/phone_flush_test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { readFileSync } from "node:fs";
33
import { strict as assert } from "node:assert";
44
const source = readFileSync("src/mobile/bridge.js", "utf8");
55
const out = source.slice(source.indexOf("function out("), source.indexOf("// a step's answer:"));
6+
// direct() builds every answer now (thin drain, kept drafts, deadline)
7+
const direct = source.slice(source.indexOf("function direct("), source.indexOf("function expired()"));
68
const start = source.indexOf(" flush(owe) {");
79
assert(start > 0, "bridge exposes an owed-screen flush");
810
const flush = source.slice(start, source.indexOf("\n },", start) + 5);
@@ -12,6 +14,13 @@ const harness = new Function(`
1214
const is = () => false, plain = x => x;
1315
const App = {screenj: () => ({version: ++renders})};
1416
const screenText = () => JSON.stringify(plain(App.screenj(hubs)));
17+
// what flush/out/direct read from the rest of bridge.js: no thin hub, no
18+
// expired calls or sync updates, nothing waiting for the foreground
19+
const thin = { drain: () => ({ cmds: [], sync: [] }), thin: () => false, views: () => null };
20+
const kept = {}, syncUpdates = [], recent = { links: new Map() };
21+
const expired = () => [], currentDeadline = () => 0, commandList = cmds => cmds ?? [];
22+
const foregroundHub = () => "", waitingForForeground = () => false, foregroundPresentation = () => false;
23+
${direct}
1524
${out}
1625
return {${flush}
1726
withhold() { owed = true; },

0 commit comments

Comments
 (0)