@githolon/runtime 0.113.1 → 0.113.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,12 @@
4
4
  03248bc7c77ccc8d57679b45d21b0d614c17c4bd3868acb1c91bb83dd2bcf58f adapter/kernel_execution_desk.ts
5
5
  0428fb43c2875c495874c4fb26a79a7eee04aed744466ce0313cd28118b1671c platform-shells/node/node_custody_filesystem.ts
6
6
  052eb91130bab10cdbb01335957751fa5f187b94687a5242bd262e62a6dfba31 peer-office/src/runtime/replica_follow_state.ts
7
+ 056f5dd72c5f930463326cc8817e53474607a45d52debcb2a515b6f142438576 peer-office/package/package.json
7
8
  05cc75d3ab961d813beede39a2afa7b3ce899968c4ca88eff298b6636ef55d5a adapter/proto/nomos/runtime/v2/application_desk_pb.js
8
9
  0611319c199a2ce589514261275562f691b9c3b4778b4903389bae618952350f peer-office/src/runtime/kernel_queries.ts
9
10
  062ccf10c0501529b87e93598d27769304e2077de7cc9cc7c7b93efdabab9762 peer-office/src/runtime/read_authentication.ts
10
11
  063a8e43056578ecec6ba95eb1a9f28d8b704daea2260ef2943840def1cf9526 node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.js
11
12
  06525d62b18918913a7fe7981204fba9e1f70369cc2aa785851caae39f546de3 node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.js
12
- 073fdbe5a86f289aa546aaa7e4b3658d8aa69f74baba8780a8af69e3a7c69750 peer-office/src/peer_office.ts
13
13
  082f4f24399a3f7dc46465903f825c0287a81f4cf8a17ccd96c4bf556ad3d7cb platform-shells/browser/runtime_fetch.ts
14
14
  09a24ed660112991f8105d8c0c2c250617b6ad99f6a12afe2d39b8a9305289ec peer-office/src/runtime/session_directory.ts
15
15
  0a687d73d1754114045dd64ab0125af437945ed11b1302753b1c3c46793a014b peer-office/src/runtime/replica_follow_lane.ts
@@ -35,7 +35,6 @@
35
35
  16d6522ee4ecf4a91c4d29357ebc874844c266f2ae89ef2a92ec2d391f3762e9 node_modules/is-unsafe/src/contexts/sql-strict.js
36
36
  17b0d228dd20748bd5fa03164478198c813214e4fa5d8f1650705128a954f0bd adapter/wasi_custody_filesystem.ts
37
37
  1963a804a9cfe7d44a76b2c476817639b939d7e93828da865cab40fe9ba536fa adapter/custody-transport.ts
38
- 198d9850ef7cf6f9d54cbec0ad6c168e6cc29a5a5f19a6366bfc537c0b021edc peer-office/src/runtime/read_maintenance_desk.ts
39
38
  19a320ee1d4c811af432f1b9d511d5cd840c0fc8bbca74a455a81836fe6c4d1f peer-office/src/runtime/workspace_sync_dependencies.ts
40
39
  1a5d9fd32360e2cec4adbee9e56221fb26def66bb9d122e0b5745cebc963d92e node_modules/xml-naming/src/index.js
41
40
  1a873dadab0fdef771d16b70d3ad318018dbf5c185337519f230064da4e7ea8a adapter/proto/nomos/kernel/v1/kernel_pb.js
@@ -54,11 +53,9 @@
54
53
  208a47278c60cd0f3470c58e981fdd2995d7ce1024cef9caebe208f6a9b291ae adapter/proto/nomos/runtime/v2/law_desk_pb.js
55
54
  20d82153da53012f461d67c21673fdf84dc2d9c62cb7339f95288d375e4ba23b peer-office/src/runtime/background_paper_slots.ts
56
55
  22a2b398e7c3fcbfc171080a6288c710522bf1baf5f56e63f5bdcfbaaf7757b7 node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js
57
- 24bc816455f9aef9c1d3d91724a59936014dabb732083d7833c197f8371251f2 peer-office/src/runtime/subscription_manager.ts
58
56
  24f5eb575e633b68771328cc12fa6fde751ecc5f2700a6f52ea325938dc94342 node_modules/is-unsafe/src/index.js
59
57
  25c033d29ed62a510d8c43054ec238776bcba0949808cb6054df5cbea951ddf7 adapter/proto/nomos/runtime/v2/interaction_desk_pb.js
60
58
  25d57b7e880708c04738087de674a8c98092e5bfd39d5193cdb63a2f1e33871e node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js
61
- 268188e466adbd048097b01170ada3ae7f6650769d1484614eb871e73dc9a67c platform-shells/browser/worker_entry.ts
62
59
  27cd18d5bc8e1fa9ccc4d7e1322b2ca864023e8c268304b4f795a8ad9a222fd8 adapter/amortized_memory_file.ts
63
60
  27d164987aeae0cffae136eaa84ff39ca6efd9c07018dce4b63f0d352d3d855b adapter/proto/nomos/runtime/v2/maintenance_desk_pb.js
64
61
  286c659a8f940c313077afe8a00c0dc128d4a138edf6d9a4519f29538b58c94f node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
@@ -72,16 +69,18 @@
72
69
  2f1340ab32dce314f41638b7ee6d0368b974e3302983154b815a6d49a6dfb63b node_modules/@nodable/entities/src/all-entities.js
73
70
  30b48d6f01b36d491c79f60f73170e0efb2bab6ac68a5285b88e81e940a9ddc8 peer-office/src/runtime/recovery_desk.ts
74
71
  31765c70a6b4d88ceb34921c8cfacede363a2e8cdf5ede663f7bf8fcfcbc4330 peer-office/package/runner/shims.js
72
+ 31f10d01fe72c8cd679fbda5cd393fbbaeced53f035dfd06e9e657f60c291019 platform-shells/browser/peer.ts
75
73
  330dd51c5ed866affe7ab19e38cad9fb9204847a51cc86e932c02771bcfcd702 node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js
76
74
  3321bab1c56461419b77491bd28cd08a3bec451426b2e021007189b51a1c4f13 adapter/proto/nomos/runtime/v2/framework_pb.js
77
75
  33917d22c20458fce8ef7e3a4fca8f51af8ace4508e6a435870b3ad61ea2eab4 peer-office/src/git_read_lease.ts
78
76
  33e7d6bdd22396057d3f8db92384079f7ec2fda4b3582709de2d43fccacc4a9c node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.js
79
77
  34f8712de2bd30a2cb8366d8cfdcde466d979f1a28ac0d78f7547341b01f6c57 adapter/proto/nomos/kernel/v1/progress_pb.js
80
- 386b0d2f0777fc0200ba882e60eea492fe057e991e5d437c135cf146b29e4fab platform-shells/browser/worker_page_entry.ts
78
+ 3586d9b52efc73c3cf40a427a09b4e091a52655942979a2b24b13cd6e8baea83 peer-office/src/peer_office.ts
81
79
  3a90933569db7e42ec2ed3b77509c29d1ab75f6eb078f53fe5d1ac6d239d231e peer-office/src/runtime/peer_background_scheduler.ts
82
80
  3c092b8d4185badd23ecf4552434d05aa541b0cd0d534781d687db55260d5da8 adapter/proto/nomos/runtime/v2/sealing_desk_pb.js
83
81
  3c98fa838c05abcfd8dfda1128f2d1fca9b196a371fe9751abbd8f4c3b9d04ec node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js
84
82
  3d05089a8c1008f20e06da9907eec7f8824f871edfc95e907c15dc8e2bdf43e7 node_modules/@bufbuild/protobuf/dist/esm/extensions.js
83
+ 3e5e0540872bcfb39a59047a1b1d1f5942e9de12f0a834e81912c6670a8e1269 platform-shells/browser/worker_page_entry.ts
85
84
  3eef60b7d08402d6a0b9427fde0308878929398918f09747833fd9a06ea3fa7d workspace-discovery/src/http.ts
86
85
  3fa38ca64538032d871cd44da41bf6a6ad2eb133b6b8ebc2d8b4d33615b00dcf peer-office/src/reception/application_session_pipe.ts
87
86
  3fade4f9262d10e39f346b57a7f08d03641e0ebd75556d087f6319f6c6003a24 peer-office/src/runtime/sha256.ts
@@ -98,6 +97,7 @@
98
97
  48b8a92448c21da157755c24058a1522d62389815254bd43858e27fc200cc793 peer-office/src/runtime/retention_observer.ts
99
98
  497ee51559f8769c47defb7679dd516b5736c22c433bc857a19e8ccd9593c842 node_modules/is-unsafe/src/contexts/xml.js
100
99
  4b96aaeb5ac5986cf802cbf22b975c656682d22a38248160c96fc2ded5644869 node_modules/@bjorn3/browser_wasi_shim/dist/fs_opfs.js
100
+ 4bb63a465e91fd7af727cd3b4c06ea2caa7aa1b92e9ae9b2b60beee037cd3256 platform-shells/browser/custody_store.ts
101
101
  4d5b4d0e3a8b3bfa4535e85a2182446f05f32e179dffba00e07422da84cbdb69 node_modules/fast-xml-builder/src/orderedJs2Xml.js
102
102
  4de8a60302e6ab22ef5607ee88ab6dd6559221fb8620780fb874a1dcf3000d06 node_modules/is-unsafe/src/contexts/sql.js
103
103
  4f177e43f1ac36dc25b2b6a44970c97918091416bd15722b65ac938256bda687 node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
@@ -129,6 +129,7 @@
129
129
  63a928e5632cca54994a7fdde23c44db762fdc3df6afba4677fe4fdc3101b98f adapter/proto/nomos/runtime/v2/observability_desk_pb.js
130
130
  64256c9570f2d73851f8b7e1a47ccee787120ca13b862b317d46c1bdb128f06c adapter/custody_paths.ts
131
131
  666242642051bff6e5bff6d2697b774fe518b78461bde4e0bdb497592cd56d95 peer-office/package/src/nominal_value.ts
132
+ 68fbb966cea063ed495d2b11117742a6829f4328ebd20fda06cb0a10358ad38c peer-office/src/runtime/subscription_manager.ts
132
133
  692c6542af574ad4ec2882ae9591db3be7635e7721b43af13158a5397f537ebb adapter/git_placement_custody.ts
133
134
  6b3d69203397fa63fa4d5d38a216de18193e128ee4843630531ef1e6232b3448 adapter/memory_custody_filesystem.ts
134
135
  6cfa5fe6f17219f03e2650dec635934cff6601dbee72f188bbd2874a9d1d4523 platform-shells/shared/credential_effects.ts
@@ -154,6 +155,7 @@
154
155
  7ec79572a67e1764cd0e93fe2c49d696cd179836293f62e5f50c54e01d6af242 peer-office/src/runtime/provider_origins.ts
155
156
  812a2077e073564d6470b8fda8ac0d20ecaaf75ddb1594d55d28acc2da8a1a71 node_modules/@nodable/entities/src/EntityEncoder.js
156
157
  81539d21eb82b21f6bab3b84d0b7296cb240532e0314c303d06799a1f5fe4e81 adapter/proto/nomos/runtime/v2/residency_desk_pb.js
158
+ 815a6dca44ffad90e4394a2e745c65a86e2abace4ac51aece9c8bf29144bc383 peer-office/src/runtime/placement_desk.ts
157
159
  8265b7063f35842f61f48c693eb9c740f07949284fb589380b6795dd88dd5ff1 peer-office/src/runtime/replica_follow_controller.ts
158
160
  829eadd8a1a441d25be0cb93b00e16a0d0c20fd294db95d8f2ed87e6954b7182 node_modules/base64-js/index.js
159
161
  836d6535b507906f82129a7cae5b1cbd42efaef969f18b13675b39ba7cb5ebcb peer-office/src/runtime/birth_custody_desk.ts
@@ -165,7 +167,6 @@
165
167
  85dbc9e0ee784d9ff8b55452644e00bf7058e32355aab974f8b71d7d85772324 node_modules/@bjorn3/browser_wasi_shim/dist/fs_mem.js
166
168
  8682a066cf855574abf093eb0c0aec93399a9ea135b9641977c5cec90b1400a8 node_modules/@bufbuild/protobuf/dist/esm/index.js
167
169
  870ccd88a5d51e35ef8cbc59e7f2a35d31defc87aded9c06023ae57838851901 node_modules/fast-xml-parser/src/util.js
168
- 87638f7663a5d68c42da568452aabebd8b4340f6a72fecf982ca56bfb02e3911 peer-office/package/package.json
169
170
  87be44002a7340bb0c13167b3815625ea25a3f60aaa4254015fed35b1b0044f1 peer-office/src/runtime/application_readiness_desk.ts
170
171
  89f8c8a3ca87eacd6d1787156d8a950ce0e3ad85894ed94140f4c696ee142147 node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js
171
172
  8a2735fc5e9f2acbdb75d0c6e622afd4f1dd57bc1700137774e5cf8836971b25 peer-office/src/runtime/remote_generated_offer.ts
@@ -209,6 +210,7 @@ a91848ee180529e2a60c05dfb9584cad19cd4e1c6f391fdb76a938bcae4c0328 node_modules/@
209
210
  a9a2aefe743f0243ae1adb3acdd3db6cdb671b744b5f83235cc4e0be905f1a5b peer-office/package/src/typescript_application_desk.public.d.ts
210
211
  aa39c85046ef2b8cd9f7d825eefb502e382e9107b39c9110297f8b84f63f6011 peer-office/src/runtime/replica_inventory_desk.ts
211
212
  aa6349944f16d71986273ecfc8e552bfece3d61d5641e526c0ceabf3f154fdaf peer-office/src/runtime/application_desk.ts
213
+ aabbcb3d691d6ea517811feae5049f094a3a8ffeb14d8332137c8d7a033093e1 peer-office/package/runner/build.ts
212
214
  ab43714f566a6ccd988cc3a30810d857552dbd14d0f060934907fb4bba1000f0 peer-office/package/src/admission_decision.ts
213
215
  ab80eeeafd4d89a5daaf5d2e00fb471cc6b53fa90776750ca3ad82df482d7c3f peer-office/src/runtime/peer_lifecycle.ts
214
216
  ad3de46df125304b2a61c2fa5537b0e519635997d99686a76119b38cf260963f adapter/proto/nomos/runtime/v2/identity_desk_pb.js
@@ -217,13 +219,13 @@ b07e6f28e18bcf30df86fd71007976ad01ecee7ed45dcc91ec7c2ee5d7184088 peer-office/sr
217
219
  b09ee99807e1edeb746b4a4a1e41519edaff1fed9f71a170bc15e8835af93e25 node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js
218
220
  b1db7ea18d82851f6f19f0ce9c1e718bf64556425e7723cca5ba213b8558ac2d peer-office/src/runtime/peer_maintenance_scheduler.ts
219
221
  b2510e5dcadaccb131d63fd3900ab17f85f54c9c6e2178400ceb1eace6ca552a peer-office/src/runtime/kernel_port.ts
222
+ b29d03c7242a44fa4e6b8ee5c8e9279965c328baf5f97b314272c5fefad855b2 platform-shells/browser/worker_entry.ts
220
223
  b4932f38ab2f4b89fbdd4458944591cbea052ef40180a2b64475ee44891e62e1 platform-shells/shared/with_workspace_discovery.ts
221
224
  b4c474e617f91b74f99322f19561ad699933becf7efe73f0582da94db1bec465 node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js
222
225
  b68312b9501ba96f45496f3f30db62c158a127bbb00d7e8ff081b2d741218497 adapter/git_custody_desk.ts
223
226
  b683cb36f7b9eacef4270428f7875d3211d84dd851eb226f6a3030a166ca9fa9 peer-office/src/reception/tally_read.ts
224
227
  b6d7539356e92bfa257edd790e8d5d697167205b7154106e8758455cc3483e82 runtime/osgi_repository.ts
225
228
  b82bb05bb957bb59990dda51bb60ed8b9f656cc090312295ea0958e4cd52bdb7 peer-office/src/runtime/device_recovery_journal.ts
226
- b95daa723d0b62946657a5dbaef9a2b14150a1cbd504102b95650b53cbf48c36 peer-office/package/runner/build.ts
227
229
  ba7223ebf0eea2f078ba83f0128830f7cd07224c57d7e61251541c1c17e83009 peer-office/src/runtime/workspace_effect_delivery.ts
228
230
  bb8e81020a9cbf3f8562c196fa5609ef5dec911e0981920c7d05de67769c79d4 peer-office/src/runtime/credential_failure.ts
229
231
  bcc5325758b3b940384c7bf2a7132874421989c2561a59dc49c4ef0b88c352dc node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js
@@ -265,6 +267,7 @@ d4b90e97ac754d086a6ec26756bb2d5cff563396434f16aee3ae34d913d756b9 node_modules/@
265
267
  d4ecef7a571afb93de1f62b0e6877237febace34d5487687a8b7c92bc3234a19 peer-office/src/runtime/identity_recovery_desk.ts
266
268
  d730efb4ee5b52c492c1d04859568461a4efbfa7474048afa5f8f776a3b6d55b node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js
267
269
  d851f0d85aa051c8f7880855f4af21b56507afdaebfc99623693eda933df7726 peer-office/src/runtime/residency_pins.ts
270
+ d8f3407bb4a3d5ecd382eea801bab684c8b9345a2aa6e41f9033fad11c4a1750 peer-office/src/runtime/shell_contract.ts
268
271
  da6362509cb895cc68dc6c050f3a59ed47d2ee009108e2093e2905e0171efe9c peer-office/src/runtime/custody_retention_plan.ts
269
272
  db05a3f19bc575c1ed771fc6882af337a49cde7bd469181f3acc772d1a76df3e node_modules/@bufbuild/protobuf/dist/esm/to-json.js
270
273
  db61a17ab4dbb3514b676cd93cc702fe62a6582d5ec292725f1ada20dfbc1f72 peer-office/src/runtime/custody_replacement.ts
@@ -273,10 +276,11 @@ deaa25227d669aa3fbe99174275588dcc175de648ae6623fddf11d6ae69d7f67 platform-shell
273
276
  dff6af323ca5f9c73dd06120879fcd5f561d22a8a7fd36d3317e564ae4e10e3b platform-shells/shared/kernel_work_accounting.ts
274
277
  e20a132033f105a29db1cfdb3d85bbadbb7206b9a7e3336bcb030a63d66b4ab2 node_modules/is-unsafe/src/contexts/nosql.js
275
278
  e2133d7e0f0ce5491a3e9bd560e9e47db2243a6a9f762be89c82e027d99d278e peer-office/src/runtime/credential_sessions.ts
279
+ e2f82db2565bd1e8766c9220c7cde9cdb39023a861f6a8f24e14a6a0fb0bd62d peer-office/src/runtime/read_maintenance_desk.ts
276
280
  e394b7a580a2853949ec937d742b54fd8169029a5d10a3e4e521b984c60adb6d peer-office/src/runtime/identity_desk.ts
277
281
  e411cf95c1c0c7063b863a08ad568d61044069f9338028eace56e362029ad3a7 peer-office/src/runtime/residency_desk.ts
278
282
  e45a879696cd2e7b692aa282677abf216297c1d129135e914b8a76fd0cbe15bd peer-office/src/reception/generated_offer_counter.ts
279
- e73558ce46f5e55526015696d299aad8188825bbd1e09deb8ea22b181c3f253a platform-shells/browser/custody_store.ts
283
+ e4a9e97abd58f2989428d7ed6fd771315a72c696ce0b65bdc938e477772f1edd peer-office/src/runtime/http_origin.ts
280
284
  eb9e106e81226ab9547882079e7fd6a9d885d2c71ba78784f7edaa7db61bb941 node_modules/is-unsafe/src/contexts/svg.js
281
285
  ebbf22c6979f6b2b05c580922e7dd197f4f4a246d504d4c0cc8e64778f12d4ed node_modules/path-expression-matcher/src/index.js
282
286
  ece435d3784d928d02bff4d015b7cb686f8c06de8536ff9f8ebc38a8f403a3be node_modules/@bjorn3/browser_wasi_shim/dist/strace.js
@@ -284,7 +288,6 @@ eda289d9ef0e979fe77a578ffbbf8012cadcfec4629b66cd98c27d6229a9f020 node_modules/@
284
288
  efce20f9f127263ca66d855115e01b37af0afb8b8baafeba7dcc2e0834e99e4f node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.js
285
289
  f23513db2fea432df6121956d9bab4761dabf8034b6eba8988452104dba1783e adapter/proto/nomos/runtime/v2/records_desk_pb.js
286
290
  f3b9324922e08cffcc4c7ae3c6e08454f62e187a37404df31a00160cddf34d77 node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js
287
- f4eb625c1c0ebee8e5863b6958706af4635ca58d1d2544ae2b465e75060ba12c peer-office/src/runtime/placement_desk.ts
288
291
  f50218256bfd061c59b454fbaf8ca304f1799b1d0d09b0f7851ba2420e1129ca adapter/kernel_failure.ts
289
292
  f585f26c6fa18af890c32d00fbb00fbfd05b9c7217419b6fe8675bdcee264140 node_modules/fast-xml-builder/src/util.js
290
293
  f5f56922916f3b22e72a37521c5ca915506b8b205fe28e89a1986dbce15d4b47 node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js
@@ -293,7 +296,6 @@ f8b97660653e1826c51166d4700d079d2fc89dd923ee522706b11297e06f3165 node_modules/@
293
296
  f8c6a9b031489dfc1573e7a669e4860223ddeedc0007db5dbf5878a14249776d node_modules/anynum/anynum.js
294
297
  fa2838d141fba0e8ee5bd2197956c3f6b1d23668be2c8841a585614ea7051f99 node_modules/@nodable/entities/src/entityTries.js
295
298
  fbc88bbf3cea189f0494b0949049ffeac334b8c5015ebfc988217f2fcdb3262b node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.js
296
- fd3a6108238dacd441a475c62baf64f78698918ed566eb53796a261010a094fe platform-shells/browser/peer.ts
297
299
  fe1678ab1c98db7387bea6892ec10a90a06a8e2ed01efb1ee577c3d155e4a395 node_modules/is-unsafe/src/contexts/log.js
298
300
  fe3e2b20c1ebb57c3b390c8f685ad1e04e6f493517fa7e432f4351bb77a1a4d0 node_modules/ieee754/index.js
299
301
  ff7cd9328539ca7bea898b6074d796b32e5600ab35e357d0ca050f068260b2b6 peer-office/src/runtime/application_compatibility_posture.ts
@@ -7018,6 +7018,31 @@ var NomosRuntimeComponent = (() => {
7018
7018
  }
7019
7019
  };
7020
7020
 
7021
+ // ../src/runtime/http_origin.ts
7022
+ var AUTHORITY = /^([a-z][a-z0-9+.-]*):\/\/([^/?#]*)/i;
7023
+ var DEFAULT_PORTS = { http: "80", https: "443" };
7024
+ function httpOrigin(url) {
7025
+ const match = AUTHORITY.exec(url.trim());
7026
+ if (!match) return void 0;
7027
+ const scheme = match[1].toLowerCase();
7028
+ if (scheme !== "http" && scheme !== "https") return void 0;
7029
+ const authority = match[2];
7030
+ const hostAndPort = authority.slice(authority.lastIndexOf("@") + 1);
7031
+ const ipv6 = /^(\[[0-9a-f:.]+\])(?::(\d*))?$/i.exec(hostAndPort);
7032
+ const named = /^([^:[\]\s]+)(?::(\d*))?$/.exec(hostAndPort);
7033
+ const parts = ipv6 ?? named;
7034
+ if (!parts) return void 0;
7035
+ const host = parts[1].toLowerCase();
7036
+ if (host.length === 0 || /[\s<>^`{|}%\\]/.test(host)) return void 0;
7037
+ let port = parts[2] ?? "";
7038
+ if (port !== "") {
7039
+ const value = Number(port);
7040
+ if (!Number.isInteger(value) || value > 65535) return void 0;
7041
+ port = String(value);
7042
+ }
7043
+ return port === "" || port === DEFAULT_PORTS[scheme] ? `${scheme}://${host}` : `${scheme}://${host}:${port}`;
7044
+ }
7045
+
7021
7046
  // ../src/git_read_lease.ts
7022
7047
  var GIT_READ_LEASE_MEDIA_TYPE = "application/vnd.nomos.git-read-lease+protobuf";
7023
7048
  function decodeGitReadLease(bytes, workspace, nowUnixSeconds = BigInt(Math.floor(Date.now() / 1e3))) {
@@ -7351,14 +7376,7 @@ var NomosRuntimeComponent = (() => {
7351
7376
  ...servedOrigin === void 0 ? {} : { servedOrigin }
7352
7377
  });
7353
7378
  };
7354
- var originOf2 = (url) => {
7355
- try {
7356
- const parsed = new URL(url);
7357
- return parsed.protocol === "https:" || parsed.protocol === "http:" ? parsed.origin : void 0;
7358
- } catch {
7359
- return void 0;
7360
- }
7361
- };
7379
+ var originOf2 = httpOrigin;
7362
7380
  var ReplicaPlacementDirectiveKind = Object.freeze({
7363
7381
  None: "none",
7364
7382
  Cache: "cache",
@@ -13103,7 +13121,10 @@ var NomosRuntimeComponent = (() => {
13103
13121
  ...background ? { background } : {},
13104
13122
  ...awaited || existing?.awaited ? { awaited: true } : {},
13105
13123
  failures: existing?.failures ?? 0,
13106
- retryNotBeforeNanoseconds: 0n
13124
+ // A foreground read may retry at once. Upkeep owed by a write or a sync keeps any back-off
13125
+ // it is already serving: otherwise every write retried a failing upkeep immediately, and a
13126
+ // workspace whose upkeep could not succeed retried on every write (CAP-693).
13127
+ retryNotBeforeNanoseconds: isReadDemand ? 0n : existing?.retryNotBeforeNanoseconds ?? 0n
13107
13128
  });
13108
13129
  if (isReadDemand && (!existing?.read || existing.read.owedByAdvance)) {
13109
13130
  const entries = [...this.#pending.entries()];
@@ -13722,18 +13743,17 @@ var NomosRuntimeComponent = (() => {
13722
13743
  #requestReadMaintenance;
13723
13744
  #clock;
13724
13745
  #subscriptions = /* @__PURE__ */ new Map();
13725
- /** Watches owed a re-read, drained one query group per turn when a turn scheduler is given. */
13746
+ /** Watches owed a re-read, drained one query group per office turn (see [drainOwedTurn]). */
13726
13747
  #owed = /* @__PURE__ */ new Set();
13727
- #nextTurn;
13728
- #draining = false;
13748
+ #deferRefreshes;
13729
13749
  #sequence = 0n;
13730
- constructor(queries, sessions, events, requestReadMaintenance, clock, nextTurn) {
13750
+ constructor(queries, sessions, events, requestReadMaintenance, clock, deferRefreshes = false) {
13731
13751
  this.#queries = queries;
13732
13752
  this.#sessions = sessions;
13733
13753
  this.#events = events;
13734
13754
  this.#requestReadMaintenance = requestReadMaintenance;
13735
13755
  this.#clock = clock;
13736
- this.#nextTurn = nextTurn;
13756
+ this.#deferRefreshes = deferRefreshes;
13737
13757
  }
13738
13758
  start(request, command) {
13739
13759
  if (!command.subscriptionId) throw new Error("watch requires a subscription identity");
@@ -13839,34 +13859,33 @@ var NomosRuntimeComponent = (() => {
13839
13859
  * or replace current authorization. Each watch still owns its delivery state.
13840
13860
  */
13841
13861
  #refreshMatching(matches, cause) {
13842
- if (this.#nextTurn && !cause) {
13862
+ if (this.#deferRefreshes && !cause) {
13843
13863
  for (const [id, subscription] of this.#subscriptions) {
13844
13864
  if (subscription.request.query && matches(subscription)) this.#owed.add(id);
13845
13865
  }
13846
- this.#drain();
13847
13866
  return;
13848
13867
  }
13849
13868
  this.#refreshGroups(this.#groups(matches), cause);
13850
13869
  }
13851
- #drain() {
13852
- if (this.#draining || this.#owed.size === 0) return;
13853
- this.#draining = true;
13854
- this.#nextTurn(() => {
13855
- this.#draining = false;
13856
- if (this.#owed.size === 0) return;
13857
- const first = this.#owed.values().next().value;
13858
- const lead = this.#subscriptions.get(first);
13859
- if (!lead?.request.query) {
13860
- this.#owed.delete(first);
13861
- } else {
13862
- const declaration = toBinary(QueryRequestSchema, lead.request.query);
13863
- const session = lead.request.session;
13864
- const group = this.#groups((subscription) => subscription.request.session === session && this.#owed.has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
13865
- for (const each of group) for (const watch of each.watches) this.#owed.delete(watch.request.subscriptionId);
13866
- this.#refreshGroups(group);
13867
- }
13868
- this.#drain();
13869
- });
13870
+ /** Whether any watch is owed a re-read: the office's next drive() is due at once. */
13871
+ get owesRefresh() {
13872
+ return this.#owed.size > 0;
13873
+ }
13874
+ /** One office turn of owed re-reads: the first owed watch's query group. False when none was owed. */
13875
+ drainOwedTurn() {
13876
+ if (this.#owed.size === 0) return false;
13877
+ const first = this.#owed.values().next().value;
13878
+ const lead = this.#subscriptions.get(first);
13879
+ if (!lead?.request.query) {
13880
+ this.#owed.delete(first);
13881
+ return true;
13882
+ }
13883
+ const declaration = toBinary(QueryRequestSchema, lead.request.query);
13884
+ const session = lead.request.session;
13885
+ const group = this.#groups((subscription) => subscription.request.session === session && this.#owed.has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
13886
+ for (const each of group) for (const watch of each.watches) this.#owed.delete(watch.request.subscriptionId);
13887
+ this.#refreshGroups(group);
13888
+ return true;
13870
13889
  }
13871
13890
  #groups(matches) {
13872
13891
  const groups = [];
@@ -13990,6 +14009,38 @@ var NomosRuntimeComponent = (() => {
13990
14009
  });
13991
14010
  }
13992
14011
 
14012
+ // ../src/runtime/shell_contract.ts
14013
+ var SHELL_CONTRACT_V1 = Object.freeze({
14014
+ version: 1,
14015
+ /** Host globals beyond ECMAScript 2022, which every shell supplies. */
14016
+ host: Object.freeze(["TextEncoder", "TextDecoder", "queueMicrotask", "console"]),
14017
+ /** Nomos bridges a native bootstrap installs for the ports it hands to peerOffice.open. */
14018
+ bridges: Object.freeze([
14019
+ "__nomosKernel",
14020
+ "__nomosCredentialVault",
14021
+ "__nomosProfile",
14022
+ "__nomosObservations",
14023
+ "__nomosCustodyStorage",
14024
+ "__nomosPeerDeskStore",
14025
+ "__nomosSyncDiagnostic",
14026
+ "__nomosShellContract"
14027
+ ]),
14028
+ /** Globals the runtime may only probe: used behind their own `typeof` test, never bare. */
14029
+ probed: Object.freeze(["process", "Deno", "Bun", "define"])
14030
+ });
14031
+ var SHELL_CONTRACT_V2 = Object.freeze({ ...SHELL_CONTRACT_V1, version: 2 });
14032
+ var SHELL_CONTRACT_MINIMUM = 1;
14033
+ function declaredShellContract(scope = globalThis) {
14034
+ const declared = scope.__nomosShellContract;
14035
+ return declared === void 0 ? 1 : Number(declared);
14036
+ }
14037
+ function assertShellContract(scope = globalThis) {
14038
+ const declared = declaredShellContract(scope);
14039
+ if (!Number.isInteger(declared) || declared < SHELL_CONTRACT_MINIMUM) {
14040
+ throw new Error(`nomos.runtime.shell_contract_unsupported: this runtime needs shell contract ${SHELL_CONTRACT_MINIMUM} or later; the shell declares ${String(declared)}`);
14041
+ }
14042
+ }
14043
+
13993
14044
  // ../src/runtime/replica_follow_state.ts
13994
14045
  var ReplicaFollowPhase = Object.freeze({
13995
14046
  Desired: "desired",
@@ -21930,10 +21981,9 @@ var NomosRuntimeComponent = (() => {
21930
21981
  this.#trace,
21931
21982
  (session) => this.#readMaintenance.schedule(session, ReadMaintenanceCause.READ_DEBT),
21932
21983
  observations,
21933
- // An interactive peer keeps its thread responsive while watches catch up.
21934
- this.#interactivePeer ? (run2) => {
21935
- setTimeout(run2, 0);
21936
- } : void 0
21984
+ // An interactive peer keeps its thread responsive while watches catch up: owed re-reads
21985
+ // wait for its drive() turns.
21986
+ this.#interactivePeer
21937
21987
  );
21938
21988
  this.#application = new ApplicationDesk({
21939
21989
  onAdmitted: (session) => {
@@ -22340,7 +22390,9 @@ var NomosRuntimeComponent = (() => {
22340
22390
  * mirrors queue/backoff state.
22341
22391
  */
22342
22392
  drive() {
22343
- return this.#maintenance.drive();
22393
+ if (this.#subscriptions.drainOwedTurn()) return 0n;
22394
+ const wake = this.#maintenance.drive();
22395
+ return this.#subscriptions.owesRefresh ? 0n : wake;
22344
22396
  }
22345
22397
  /**
22346
22398
  * Carry one exact maintenance demand through a durable host continuation.
@@ -23301,6 +23353,7 @@ var NomosRuntimeComponent = (() => {
23301
23353
  };
23302
23354
  var peerOffice = {
23303
23355
  open(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
23356
+ assertShellContract();
23304
23357
  return new PeerOffice(kernel, credentials, profile, observations, custodyStorage, peerDeskStore);
23305
23358
  },
23306
23359
  Peer: PeerOffice
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  (() => {
3
3
  // ../../platform-shells/browser/worker_page_entry.ts
4
- var workerDigest = true ? "ade4b5cad661abe236e62493f1fae81a32cf1ff3275da2b4f2938a5eb3ae9754" : "";
4
+ var workerDigest = true ? "3f3e4381edf95e9461d7e433b5f55c357eb56cb7d4e280b15077bfadb8eca8cb" : "";
5
5
  var SLOW_OPERATION_MICROS = 1e6;
6
6
  var slowOperationsReported = 0;
7
7
  var bootStages = [];
@@ -145,7 +145,13 @@
145
145
  bootResolve = resolve;
146
146
  bootReject = reject;
147
147
  });
148
- send({ kind: "boot", base });
148
+ let reloaded = false;
149
+ try {
150
+ const navigation = performance.getEntriesByType("navigation")[0];
151
+ reloaded = navigation?.type === "reload" || navigation?.type === "back_forward";
152
+ } catch {
153
+ }
154
+ send({ kind: "boot", base, reloaded });
149
155
  } catch (error) {
150
156
  fail(error instanceof Error ? error : new Error(String(error)));
151
157
  return Promise.reject(error);
@@ -12295,7 +12295,8 @@
12295
12295
  var BrowserCustodyStore = _BrowserCustodyStore;
12296
12296
  var CUSTODY_LOCK_WAIT_MILLIS = 8e3;
12297
12297
  var anotherTab = () => new Error("This application's workspace is open in another tab. Close that tab and retry; your saved data is preserved.");
12298
- async function openBrowserCustody(base) {
12298
+ async function openBrowserCustody(base, options = {}) {
12299
+ const lockWaitMillis = options.lockWaitMillis ?? CUSTODY_LOCK_WAIT_MILLIS;
12299
12300
  if (!globalThis.indexedDB || !globalThis.navigator?.locks) throw new Error("Durable browser custody needs IndexedDB and Web Locks. Use a supported browser on HTTPS and allow site storage.");
12300
12301
  const name = `nomos-custody-v1:${base.replace(/\/+$/, "")}`;
12301
12302
  let release;
@@ -12316,9 +12317,11 @@
12316
12317
  void navigator.locks.request(name, { ifAvailable: true }, async (lock) => {
12317
12318
  if (lock) return holding(lock);
12318
12319
  let signal;
12319
- try {
12320
- signal = AbortSignal.timeout(CUSTODY_LOCK_WAIT_MILLIS);
12321
- } catch {
12320
+ if (lockWaitMillis > 0) {
12321
+ try {
12322
+ signal = AbortSignal.timeout(lockWaitMillis);
12323
+ } catch {
12324
+ }
12322
12325
  }
12323
12326
  if (!signal) {
12324
12327
  refuse(anotherTab());
@@ -13460,6 +13463,33 @@
13460
13463
  init_define_NOMOS_KERNEL_RELEASE();
13461
13464
  init_shims();
13462
13465
 
13466
+ // ../src/runtime/http_origin.ts
13467
+ init_define_NOMOS_KERNEL_RELEASE();
13468
+ init_shims();
13469
+ var AUTHORITY = /^([a-z][a-z0-9+.-]*):\/\/([^/?#]*)/i;
13470
+ var DEFAULT_PORTS = { http: "80", https: "443" };
13471
+ function httpOrigin(url) {
13472
+ const match = AUTHORITY.exec(url.trim());
13473
+ if (!match) return void 0;
13474
+ const scheme = match[1].toLowerCase();
13475
+ if (scheme !== "http" && scheme !== "https") return void 0;
13476
+ const authority = match[2];
13477
+ const hostAndPort = authority.slice(authority.lastIndexOf("@") + 1);
13478
+ const ipv6 = /^(\[[0-9a-f:.]+\])(?::(\d*))?$/i.exec(hostAndPort);
13479
+ const named = /^([^:[\]\s]+)(?::(\d*))?$/.exec(hostAndPort);
13480
+ const parts = ipv6 ?? named;
13481
+ if (!parts) return void 0;
13482
+ const host = parts[1].toLowerCase();
13483
+ if (host.length === 0 || /[\s<>^`{|}%\\]/.test(host)) return void 0;
13484
+ let port = parts[2] ?? "";
13485
+ if (port !== "") {
13486
+ const value = Number(port);
13487
+ if (!Number.isInteger(value) || value > 65535) return void 0;
13488
+ port = String(value);
13489
+ }
13490
+ return port === "" || port === DEFAULT_PORTS[scheme] ? `${scheme}://${host}` : `${scheme}://${host}:${port}`;
13491
+ }
13492
+
13463
13493
  // ../src/runtime/provider_origins.ts
13464
13494
  init_define_NOMOS_KERNEL_RELEASE();
13465
13495
  init_shims();
@@ -13813,14 +13843,7 @@
13813
13843
  ...servedOrigin === void 0 ? {} : { servedOrigin }
13814
13844
  });
13815
13845
  };
13816
- var originOf2 = (url) => {
13817
- try {
13818
- const parsed = new URL(url);
13819
- return parsed.protocol === "https:" || parsed.protocol === "http:" ? parsed.origin : void 0;
13820
- } catch {
13821
- return void 0;
13822
- }
13823
- };
13846
+ var originOf2 = httpOrigin;
13824
13847
  var ReplicaPlacementDirectiveKind = Object.freeze({
13825
13848
  None: "none",
13826
13849
  Cache: "cache",
@@ -19931,7 +19954,10 @@
19931
19954
  ...background ? { background } : {},
19932
19955
  ...awaited || existing?.awaited ? { awaited: true } : {},
19933
19956
  failures: existing?.failures ?? 0,
19934
- retryNotBeforeNanoseconds: 0n
19957
+ // A foreground read may retry at once. Upkeep owed by a write or a sync keeps any back-off
19958
+ // it is already serving: otherwise every write retried a failing upkeep immediately, and a
19959
+ // workspace whose upkeep could not succeed retried on every write (CAP-693).
19960
+ retryNotBeforeNanoseconds: isReadDemand ? 0n : existing?.retryNotBeforeNanoseconds ?? 0n
19935
19961
  });
19936
19962
  if (isReadDemand && (!existing?.read || existing.read.owedByAdvance)) {
19937
19963
  const entries = [...__privateGet(this, _pending).entries()];
@@ -20385,9 +20411,9 @@
20385
20411
  }
20386
20412
  return true;
20387
20413
  };
20388
- var _queries4, _sessions6, _events2, _requestReadMaintenance, _clock9, _subscriptions2, _owed, _nextTurn, _draining, _sequence11, _SubscriptionManager_instances, now_fn4, refreshMatching_fn, drain_fn, groups_fn, refreshGroups_fn, read_fn, refresh_fn, failed_fn;
20414
+ var _queries4, _sessions6, _events2, _requestReadMaintenance, _clock9, _subscriptions2, _owed, _deferRefreshes, _sequence11, _SubscriptionManager_instances, now_fn4, refreshMatching_fn, groups_fn, refreshGroups_fn, read_fn, refresh_fn, failed_fn;
20389
20415
  var SubscriptionManager = class {
20390
- constructor(queries, sessions, events, requestReadMaintenance, clock, nextTurn) {
20416
+ constructor(queries, sessions, events, requestReadMaintenance, clock, deferRefreshes = false) {
20391
20417
  __privateAdd(this, _SubscriptionManager_instances);
20392
20418
  __privateAdd(this, _queries4);
20393
20419
  __privateAdd(this, _sessions6);
@@ -20395,17 +20421,16 @@
20395
20421
  __privateAdd(this, _requestReadMaintenance);
20396
20422
  __privateAdd(this, _clock9);
20397
20423
  __privateAdd(this, _subscriptions2, /* @__PURE__ */ new Map());
20398
- /** Watches owed a re-read, drained one query group per turn when a turn scheduler is given. */
20424
+ /** Watches owed a re-read, drained one query group per office turn (see [drainOwedTurn]). */
20399
20425
  __privateAdd(this, _owed, /* @__PURE__ */ new Set());
20400
- __privateAdd(this, _nextTurn);
20401
- __privateAdd(this, _draining, false);
20426
+ __privateAdd(this, _deferRefreshes);
20402
20427
  __privateAdd(this, _sequence11, 0n);
20403
20428
  __privateSet(this, _queries4, queries);
20404
20429
  __privateSet(this, _sessions6, sessions);
20405
20430
  __privateSet(this, _events2, events);
20406
20431
  __privateSet(this, _requestReadMaintenance, requestReadMaintenance);
20407
20432
  __privateSet(this, _clock9, clock);
20408
- __privateSet(this, _nextTurn, nextTurn);
20433
+ __privateSet(this, _deferRefreshes, deferRefreshes);
20409
20434
  }
20410
20435
  start(request, command) {
20411
20436
  if (!command.subscriptionId) throw new Error("watch requires a subscription identity");
@@ -20503,6 +20528,26 @@
20503
20528
  readIndexAdvanced(workspace) {
20504
20529
  this.refreshWorkspace(workspace);
20505
20530
  }
20531
+ /** Whether any watch is owed a re-read: the office's next drive() is due at once. */
20532
+ get owesRefresh() {
20533
+ return __privateGet(this, _owed).size > 0;
20534
+ }
20535
+ /** One office turn of owed re-reads: the first owed watch's query group. False when none was owed. */
20536
+ drainOwedTurn() {
20537
+ if (__privateGet(this, _owed).size === 0) return false;
20538
+ const first = __privateGet(this, _owed).values().next().value;
20539
+ const lead = __privateGet(this, _subscriptions2).get(first);
20540
+ if (!lead?.request.query) {
20541
+ __privateGet(this, _owed).delete(first);
20542
+ return true;
20543
+ }
20544
+ const declaration = toBinary(QueryRequestSchema, lead.request.query);
20545
+ const session = lead.request.session;
20546
+ const group = __privateMethod(this, _SubscriptionManager_instances, groups_fn).call(this, (subscription) => subscription.request.session === session && __privateGet(this, _owed).has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
20547
+ for (const each of group) for (const watch of each.watches) __privateGet(this, _owed).delete(watch.request.subscriptionId);
20548
+ __privateMethod(this, _SubscriptionManager_instances, refreshGroups_fn).call(this, group);
20549
+ return true;
20550
+ }
20506
20551
  };
20507
20552
  _queries4 = new WeakMap();
20508
20553
  _sessions6 = new WeakMap();
@@ -20511,8 +20556,7 @@
20511
20556
  _clock9 = new WeakMap();
20512
20557
  _subscriptions2 = new WeakMap();
20513
20558
  _owed = new WeakMap();
20514
- _nextTurn = new WeakMap();
20515
- _draining = new WeakMap();
20559
+ _deferRefreshes = new WeakMap();
20516
20560
  _sequence11 = new WeakMap();
20517
20561
  _SubscriptionManager_instances = new WeakSet();
20518
20562
  now_fn4 = function() {
@@ -20523,35 +20567,14 @@
20523
20567
  * or replace current authorization. Each watch still owns its delivery state.
20524
20568
  */
20525
20569
  refreshMatching_fn = function(matches, cause) {
20526
- if (__privateGet(this, _nextTurn) && !cause) {
20570
+ if (__privateGet(this, _deferRefreshes) && !cause) {
20527
20571
  for (const [id, subscription] of __privateGet(this, _subscriptions2)) {
20528
20572
  if (subscription.request.query && matches(subscription)) __privateGet(this, _owed).add(id);
20529
20573
  }
20530
- __privateMethod(this, _SubscriptionManager_instances, drain_fn).call(this);
20531
20574
  return;
20532
20575
  }
20533
20576
  __privateMethod(this, _SubscriptionManager_instances, refreshGroups_fn).call(this, __privateMethod(this, _SubscriptionManager_instances, groups_fn).call(this, matches), cause);
20534
20577
  };
20535
- drain_fn = function() {
20536
- if (__privateGet(this, _draining) || __privateGet(this, _owed).size === 0) return;
20537
- __privateSet(this, _draining, true);
20538
- __privateGet(this, _nextTurn).call(this, () => {
20539
- __privateSet(this, _draining, false);
20540
- if (__privateGet(this, _owed).size === 0) return;
20541
- const first = __privateGet(this, _owed).values().next().value;
20542
- const lead = __privateGet(this, _subscriptions2).get(first);
20543
- if (!lead?.request.query) {
20544
- __privateGet(this, _owed).delete(first);
20545
- } else {
20546
- const declaration = toBinary(QueryRequestSchema, lead.request.query);
20547
- const session = lead.request.session;
20548
- const group = __privateMethod(this, _SubscriptionManager_instances, groups_fn).call(this, (subscription) => subscription.request.session === session && __privateGet(this, _owed).has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
20549
- for (const each of group) for (const watch of each.watches) __privateGet(this, _owed).delete(watch.request.subscriptionId);
20550
- __privateMethod(this, _SubscriptionManager_instances, refreshGroups_fn).call(this, group);
20551
- }
20552
- __privateMethod(this, _SubscriptionManager_instances, drain_fn).call(this);
20553
- });
20554
- };
20555
20578
  groups_fn = function(matches) {
20556
20579
  const groups = [];
20557
20580
  for (const subscription of __privateGet(this, _subscriptions2).values()) {
@@ -20673,6 +20696,40 @@
20673
20696
  });
20674
20697
  }
20675
20698
 
20699
+ // ../src/runtime/shell_contract.ts
20700
+ init_define_NOMOS_KERNEL_RELEASE();
20701
+ init_shims();
20702
+ var SHELL_CONTRACT_V1 = Object.freeze({
20703
+ version: 1,
20704
+ /** Host globals beyond ECMAScript 2022, which every shell supplies. */
20705
+ host: Object.freeze(["TextEncoder", "TextDecoder", "queueMicrotask", "console"]),
20706
+ /** Nomos bridges a native bootstrap installs for the ports it hands to peerOffice.open. */
20707
+ bridges: Object.freeze([
20708
+ "__nomosKernel",
20709
+ "__nomosCredentialVault",
20710
+ "__nomosProfile",
20711
+ "__nomosObservations",
20712
+ "__nomosCustodyStorage",
20713
+ "__nomosPeerDeskStore",
20714
+ "__nomosSyncDiagnostic",
20715
+ "__nomosShellContract"
20716
+ ]),
20717
+ /** Globals the runtime may only probe: used behind their own `typeof` test, never bare. */
20718
+ probed: Object.freeze(["process", "Deno", "Bun", "define"])
20719
+ });
20720
+ var SHELL_CONTRACT_V2 = Object.freeze({ ...SHELL_CONTRACT_V1, version: 2 });
20721
+ var SHELL_CONTRACT_MINIMUM = 1;
20722
+ function declaredShellContract(scope2 = globalThis) {
20723
+ const declared = scope2.__nomosShellContract;
20724
+ return declared === void 0 ? 1 : Number(declared);
20725
+ }
20726
+ function assertShellContract(scope2 = globalThis) {
20727
+ const declared = declaredShellContract(scope2);
20728
+ if (!Number.isInteger(declared) || declared < SHELL_CONTRACT_MINIMUM) {
20729
+ throw new Error(`nomos.runtime.shell_contract_unsupported: this runtime needs shell contract ${SHELL_CONTRACT_MINIMUM} or later; the shell declares ${String(declared)}`);
20730
+ }
20731
+ }
20732
+
20676
20733
  // ../src/runtime/replica_follow_controller.ts
20677
20734
  init_define_NOMOS_KERNEL_RELEASE();
20678
20735
  init_shims();
@@ -29043,10 +29100,9 @@
29043
29100
  __privateGet(this, _trace13),
29044
29101
  (session) => __privateGet(this, _readMaintenance).schedule(session, ReadMaintenanceCause.READ_DEBT),
29045
29102
  observations,
29046
- // An interactive peer keeps its thread responsive while watches catch up.
29047
- __privateGet(this, _interactivePeer) ? (run2) => {
29048
- setTimeout(run2, 0);
29049
- } : void 0
29103
+ // An interactive peer keeps its thread responsive while watches catch up: owed re-reads
29104
+ // wait for its drive() turns.
29105
+ __privateGet(this, _interactivePeer)
29050
29106
  ));
29051
29107
  __privateSet(this, _application3, new ApplicationDesk({
29052
29108
  onAdmitted: (session) => {
@@ -29453,7 +29509,9 @@
29453
29509
  * mirrors queue/backoff state.
29454
29510
  */
29455
29511
  drive() {
29456
- return __privateGet(this, _maintenance2).drive();
29512
+ if (__privateGet(this, _subscriptions5).drainOwedTurn()) return 0n;
29513
+ const wake = __privateGet(this, _maintenance2).drive();
29514
+ return __privateGet(this, _subscriptions5).owesRefresh ? 0n : wake;
29457
29515
  }
29458
29516
  /**
29459
29517
  * Carry one exact maintenance demand through a durable host continuation.
@@ -30428,6 +30486,7 @@
30428
30486
  };
30429
30487
  var peerOffice = {
30430
30488
  open(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
30489
+ assertShellContract();
30431
30490
  return new PeerOffice(kernel, credentials, profile, observations, custodyStorage, peerDeskStore);
30432
30491
  },
30433
30492
  Peer: PeerOffice
@@ -36741,7 +36800,7 @@
36741
36800
  });
36742
36801
  selecting.catch(() => {
36743
36802
  });
36744
- const storage = options.custodyStore ?? await openBrowserCustody(options.base);
36803
+ const storage = options.custodyStore ?? await openBrowserCustody(options.base, options.custodyLockWaitMillis === void 0 ? {} : { lockWaitMillis: options.custodyLockWaitMillis });
36745
36804
  progress("opened browser custody");
36746
36805
  storage.onCheckpoint = options.onCustodyCheckpoint;
36747
36806
  try {
@@ -36955,7 +37014,7 @@
36955
37014
  send({ kind: "effect", id, pending: toBase64(toBinary(CorrespondencePendingSchema, pending)) });
36956
37015
  return fromBinary(PeerEffectReceiptSchema, fromBase64(await received));
36957
37016
  };
36958
- var boot2 = (base) => {
37017
+ var boot2 = (base, reloaded = false) => {
36959
37018
  if (disposing) return Promise.reject(new Error("Nomos peer runtime is disposing"));
36960
37019
  if (peer) return Promise.resolve();
36961
37020
  if (booting) return booting;
@@ -36988,6 +37047,8 @@
36988
37047
  deviceIdentity: externalPeerEffect,
36989
37048
  lawPackage: externalPeerEffect,
36990
37049
  base: base.replace(/\/+$/, ""),
37050
+ // Wait for a predecessor's custody lock only when this page is a reload of it.
37051
+ ...reloaded ? {} : { custodyLockWaitMillis: 0 },
36991
37052
  kernelRepositoryUrl: void 0,
36992
37053
  release: define_NOMOS_KERNEL_RELEASE_default,
36993
37054
  profile: {
@@ -37025,7 +37086,7 @@
37025
37086
  const message = event.data;
37026
37087
  switch (message.kind) {
37027
37088
  case "boot":
37028
- void boot2(message.base).then(() => {
37089
+ void boot2(message.base, message.reloaded === true).then(() => {
37029
37090
  if (!disposing) send({ kind: "booted" });
37030
37091
  }, (error) => {
37031
37092
  if (!disposing) send({ kind: "boot-failed", error: errorText(error) });
@@ -12295,7 +12295,8 @@
12295
12295
  var BrowserCustodyStore = _BrowserCustodyStore;
12296
12296
  var CUSTODY_LOCK_WAIT_MILLIS = 8e3;
12297
12297
  var anotherTab = () => new Error("This application's workspace is open in another tab. Close that tab and retry; your saved data is preserved.");
12298
- async function openBrowserCustody(base) {
12298
+ async function openBrowserCustody(base, options = {}) {
12299
+ const lockWaitMillis = options.lockWaitMillis ?? CUSTODY_LOCK_WAIT_MILLIS;
12299
12300
  if (!globalThis.indexedDB || !globalThis.navigator?.locks) throw new Error("Durable browser custody needs IndexedDB and Web Locks. Use a supported browser on HTTPS and allow site storage.");
12300
12301
  const name = `nomos-custody-v1:${base.replace(/\/+$/, "")}`;
12301
12302
  let release;
@@ -12316,9 +12317,11 @@
12316
12317
  void navigator.locks.request(name, { ifAvailable: true }, async (lock) => {
12317
12318
  if (lock) return holding(lock);
12318
12319
  let signal;
12319
- try {
12320
- signal = AbortSignal.timeout(CUSTODY_LOCK_WAIT_MILLIS);
12321
- } catch {
12320
+ if (lockWaitMillis > 0) {
12321
+ try {
12322
+ signal = AbortSignal.timeout(lockWaitMillis);
12323
+ } catch {
12324
+ }
12322
12325
  }
12323
12326
  if (!signal) {
12324
12327
  refuse(anotherTab());
@@ -13460,6 +13463,33 @@
13460
13463
  init_define_NOMOS_KERNEL_RELEASE();
13461
13464
  init_shims();
13462
13465
 
13466
+ // ../src/runtime/http_origin.ts
13467
+ init_define_NOMOS_KERNEL_RELEASE();
13468
+ init_shims();
13469
+ var AUTHORITY = /^([a-z][a-z0-9+.-]*):\/\/([^/?#]*)/i;
13470
+ var DEFAULT_PORTS = { http: "80", https: "443" };
13471
+ function httpOrigin(url) {
13472
+ const match = AUTHORITY.exec(url.trim());
13473
+ if (!match) return void 0;
13474
+ const scheme = match[1].toLowerCase();
13475
+ if (scheme !== "http" && scheme !== "https") return void 0;
13476
+ const authority = match[2];
13477
+ const hostAndPort = authority.slice(authority.lastIndexOf("@") + 1);
13478
+ const ipv6 = /^(\[[0-9a-f:.]+\])(?::(\d*))?$/i.exec(hostAndPort);
13479
+ const named = /^([^:[\]\s]+)(?::(\d*))?$/.exec(hostAndPort);
13480
+ const parts = ipv6 ?? named;
13481
+ if (!parts) return void 0;
13482
+ const host = parts[1].toLowerCase();
13483
+ if (host.length === 0 || /[\s<>^`{|}%\\]/.test(host)) return void 0;
13484
+ let port = parts[2] ?? "";
13485
+ if (port !== "") {
13486
+ const value = Number(port);
13487
+ if (!Number.isInteger(value) || value > 65535) return void 0;
13488
+ port = String(value);
13489
+ }
13490
+ return port === "" || port === DEFAULT_PORTS[scheme] ? `${scheme}://${host}` : `${scheme}://${host}:${port}`;
13491
+ }
13492
+
13463
13493
  // ../src/runtime/provider_origins.ts
13464
13494
  init_define_NOMOS_KERNEL_RELEASE();
13465
13495
  init_shims();
@@ -13813,14 +13843,7 @@
13813
13843
  ...servedOrigin === void 0 ? {} : { servedOrigin }
13814
13844
  });
13815
13845
  };
13816
- var originOf2 = (url) => {
13817
- try {
13818
- const parsed = new URL(url);
13819
- return parsed.protocol === "https:" || parsed.protocol === "http:" ? parsed.origin : void 0;
13820
- } catch {
13821
- return void 0;
13822
- }
13823
- };
13846
+ var originOf2 = httpOrigin;
13824
13847
  var ReplicaPlacementDirectiveKind = Object.freeze({
13825
13848
  None: "none",
13826
13849
  Cache: "cache",
@@ -19928,7 +19951,10 @@
19928
19951
  ...background ? { background } : {},
19929
19952
  ...awaited || existing?.awaited ? { awaited: true } : {},
19930
19953
  failures: existing?.failures ?? 0,
19931
- retryNotBeforeNanoseconds: 0n
19954
+ // A foreground read may retry at once. Upkeep owed by a write or a sync keeps any back-off
19955
+ // it is already serving: otherwise every write retried a failing upkeep immediately, and a
19956
+ // workspace whose upkeep could not succeed retried on every write (CAP-693).
19957
+ retryNotBeforeNanoseconds: isReadDemand ? 0n : existing?.retryNotBeforeNanoseconds ?? 0n
19932
19958
  });
19933
19959
  if (isReadDemand && (!existing?.read || existing.read.owedByAdvance)) {
19934
19960
  const entries = [...__privateGet(this, _pending).entries()];
@@ -20382,9 +20408,9 @@
20382
20408
  }
20383
20409
  return true;
20384
20410
  };
20385
- var _queries4, _sessions6, _events2, _requestReadMaintenance, _clock9, _subscriptions2, _owed, _nextTurn, _draining, _sequence11, _SubscriptionManager_instances, now_fn4, refreshMatching_fn, drain_fn, groups_fn, refreshGroups_fn, read_fn, refresh_fn, failed_fn;
20411
+ var _queries4, _sessions6, _events2, _requestReadMaintenance, _clock9, _subscriptions2, _owed, _deferRefreshes, _sequence11, _SubscriptionManager_instances, now_fn4, refreshMatching_fn, groups_fn, refreshGroups_fn, read_fn, refresh_fn, failed_fn;
20386
20412
  var SubscriptionManager = class {
20387
- constructor(queries, sessions, events, requestReadMaintenance, clock, nextTurn) {
20413
+ constructor(queries, sessions, events, requestReadMaintenance, clock, deferRefreshes = false) {
20388
20414
  __privateAdd(this, _SubscriptionManager_instances);
20389
20415
  __privateAdd(this, _queries4);
20390
20416
  __privateAdd(this, _sessions6);
@@ -20392,17 +20418,16 @@
20392
20418
  __privateAdd(this, _requestReadMaintenance);
20393
20419
  __privateAdd(this, _clock9);
20394
20420
  __privateAdd(this, _subscriptions2, /* @__PURE__ */ new Map());
20395
- /** Watches owed a re-read, drained one query group per turn when a turn scheduler is given. */
20421
+ /** Watches owed a re-read, drained one query group per office turn (see [drainOwedTurn]). */
20396
20422
  __privateAdd(this, _owed, /* @__PURE__ */ new Set());
20397
- __privateAdd(this, _nextTurn);
20398
- __privateAdd(this, _draining, false);
20423
+ __privateAdd(this, _deferRefreshes);
20399
20424
  __privateAdd(this, _sequence11, 0n);
20400
20425
  __privateSet(this, _queries4, queries);
20401
20426
  __privateSet(this, _sessions6, sessions);
20402
20427
  __privateSet(this, _events2, events);
20403
20428
  __privateSet(this, _requestReadMaintenance, requestReadMaintenance);
20404
20429
  __privateSet(this, _clock9, clock);
20405
- __privateSet(this, _nextTurn, nextTurn);
20430
+ __privateSet(this, _deferRefreshes, deferRefreshes);
20406
20431
  }
20407
20432
  start(request, command) {
20408
20433
  if (!command.subscriptionId) throw new Error("watch requires a subscription identity");
@@ -20500,6 +20525,26 @@
20500
20525
  readIndexAdvanced(workspace) {
20501
20526
  this.refreshWorkspace(workspace);
20502
20527
  }
20528
+ /** Whether any watch is owed a re-read: the office's next drive() is due at once. */
20529
+ get owesRefresh() {
20530
+ return __privateGet(this, _owed).size > 0;
20531
+ }
20532
+ /** One office turn of owed re-reads: the first owed watch's query group. False when none was owed. */
20533
+ drainOwedTurn() {
20534
+ if (__privateGet(this, _owed).size === 0) return false;
20535
+ const first = __privateGet(this, _owed).values().next().value;
20536
+ const lead = __privateGet(this, _subscriptions2).get(first);
20537
+ if (!lead?.request.query) {
20538
+ __privateGet(this, _owed).delete(first);
20539
+ return true;
20540
+ }
20541
+ const declaration = toBinary(QueryRequestSchema, lead.request.query);
20542
+ const session = lead.request.session;
20543
+ const group = __privateMethod(this, _SubscriptionManager_instances, groups_fn).call(this, (subscription) => subscription.request.session === session && __privateGet(this, _owed).has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
20544
+ for (const each of group) for (const watch of each.watches) __privateGet(this, _owed).delete(watch.request.subscriptionId);
20545
+ __privateMethod(this, _SubscriptionManager_instances, refreshGroups_fn).call(this, group);
20546
+ return true;
20547
+ }
20503
20548
  };
20504
20549
  _queries4 = new WeakMap();
20505
20550
  _sessions6 = new WeakMap();
@@ -20508,8 +20553,7 @@
20508
20553
  _clock9 = new WeakMap();
20509
20554
  _subscriptions2 = new WeakMap();
20510
20555
  _owed = new WeakMap();
20511
- _nextTurn = new WeakMap();
20512
- _draining = new WeakMap();
20556
+ _deferRefreshes = new WeakMap();
20513
20557
  _sequence11 = new WeakMap();
20514
20558
  _SubscriptionManager_instances = new WeakSet();
20515
20559
  now_fn4 = function() {
@@ -20520,35 +20564,14 @@
20520
20564
  * or replace current authorization. Each watch still owns its delivery state.
20521
20565
  */
20522
20566
  refreshMatching_fn = function(matches, cause) {
20523
- if (__privateGet(this, _nextTurn) && !cause) {
20567
+ if (__privateGet(this, _deferRefreshes) && !cause) {
20524
20568
  for (const [id, subscription] of __privateGet(this, _subscriptions2)) {
20525
20569
  if (subscription.request.query && matches(subscription)) __privateGet(this, _owed).add(id);
20526
20570
  }
20527
- __privateMethod(this, _SubscriptionManager_instances, drain_fn).call(this);
20528
20571
  return;
20529
20572
  }
20530
20573
  __privateMethod(this, _SubscriptionManager_instances, refreshGroups_fn).call(this, __privateMethod(this, _SubscriptionManager_instances, groups_fn).call(this, matches), cause);
20531
20574
  };
20532
- drain_fn = function() {
20533
- if (__privateGet(this, _draining) || __privateGet(this, _owed).size === 0) return;
20534
- __privateSet(this, _draining, true);
20535
- __privateGet(this, _nextTurn).call(this, () => {
20536
- __privateSet(this, _draining, false);
20537
- if (__privateGet(this, _owed).size === 0) return;
20538
- const first = __privateGet(this, _owed).values().next().value;
20539
- const lead = __privateGet(this, _subscriptions2).get(first);
20540
- if (!lead?.request.query) {
20541
- __privateGet(this, _owed).delete(first);
20542
- } else {
20543
- const declaration = toBinary(QueryRequestSchema, lead.request.query);
20544
- const session = lead.request.session;
20545
- const group = __privateMethod(this, _SubscriptionManager_instances, groups_fn).call(this, (subscription) => subscription.request.session === session && __privateGet(this, _owed).has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
20546
- for (const each of group) for (const watch of each.watches) __privateGet(this, _owed).delete(watch.request.subscriptionId);
20547
- __privateMethod(this, _SubscriptionManager_instances, refreshGroups_fn).call(this, group);
20548
- }
20549
- __privateMethod(this, _SubscriptionManager_instances, drain_fn).call(this);
20550
- });
20551
- };
20552
20575
  groups_fn = function(matches) {
20553
20576
  const groups = [];
20554
20577
  for (const subscription of __privateGet(this, _subscriptions2).values()) {
@@ -20670,6 +20693,40 @@
20670
20693
  });
20671
20694
  }
20672
20695
 
20696
+ // ../src/runtime/shell_contract.ts
20697
+ init_define_NOMOS_KERNEL_RELEASE();
20698
+ init_shims();
20699
+ var SHELL_CONTRACT_V1 = Object.freeze({
20700
+ version: 1,
20701
+ /** Host globals beyond ECMAScript 2022, which every shell supplies. */
20702
+ host: Object.freeze(["TextEncoder", "TextDecoder", "queueMicrotask", "console"]),
20703
+ /** Nomos bridges a native bootstrap installs for the ports it hands to peerOffice.open. */
20704
+ bridges: Object.freeze([
20705
+ "__nomosKernel",
20706
+ "__nomosCredentialVault",
20707
+ "__nomosProfile",
20708
+ "__nomosObservations",
20709
+ "__nomosCustodyStorage",
20710
+ "__nomosPeerDeskStore",
20711
+ "__nomosSyncDiagnostic",
20712
+ "__nomosShellContract"
20713
+ ]),
20714
+ /** Globals the runtime may only probe: used behind their own `typeof` test, never bare. */
20715
+ probed: Object.freeze(["process", "Deno", "Bun", "define"])
20716
+ });
20717
+ var SHELL_CONTRACT_V2 = Object.freeze({ ...SHELL_CONTRACT_V1, version: 2 });
20718
+ var SHELL_CONTRACT_MINIMUM = 1;
20719
+ function declaredShellContract(scope = globalThis) {
20720
+ const declared = scope.__nomosShellContract;
20721
+ return declared === void 0 ? 1 : Number(declared);
20722
+ }
20723
+ function assertShellContract(scope = globalThis) {
20724
+ const declared = declaredShellContract(scope);
20725
+ if (!Number.isInteger(declared) || declared < SHELL_CONTRACT_MINIMUM) {
20726
+ throw new Error(`nomos.runtime.shell_contract_unsupported: this runtime needs shell contract ${SHELL_CONTRACT_MINIMUM} or later; the shell declares ${String(declared)}`);
20727
+ }
20728
+ }
20729
+
20673
20730
  // ../src/runtime/replica_follow_controller.ts
20674
20731
  init_define_NOMOS_KERNEL_RELEASE();
20675
20732
  init_shims();
@@ -29037,10 +29094,9 @@
29037
29094
  __privateGet(this, _trace13),
29038
29095
  (session) => __privateGet(this, _readMaintenance).schedule(session, ReadMaintenanceCause.READ_DEBT),
29039
29096
  observations,
29040
- // An interactive peer keeps its thread responsive while watches catch up.
29041
- __privateGet(this, _interactivePeer) ? (run2) => {
29042
- setTimeout(run2, 0);
29043
- } : void 0
29097
+ // An interactive peer keeps its thread responsive while watches catch up: owed re-reads
29098
+ // wait for its drive() turns.
29099
+ __privateGet(this, _interactivePeer)
29044
29100
  ));
29045
29101
  __privateSet(this, _application3, new ApplicationDesk({
29046
29102
  onAdmitted: (session) => {
@@ -29447,7 +29503,9 @@
29447
29503
  * mirrors queue/backoff state.
29448
29504
  */
29449
29505
  drive() {
29450
- return __privateGet(this, _maintenance2).drive();
29506
+ if (__privateGet(this, _subscriptions5).drainOwedTurn()) return 0n;
29507
+ const wake = __privateGet(this, _maintenance2).drive();
29508
+ return __privateGet(this, _subscriptions5).owesRefresh ? 0n : wake;
29451
29509
  }
29452
29510
  /**
29453
29511
  * Carry one exact maintenance demand through a durable host continuation.
@@ -30422,6 +30480,7 @@
30422
30480
  };
30423
30481
  var peerOffice = {
30424
30482
  open(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
30483
+ assertShellContract();
30425
30484
  return new PeerOffice(kernel, credentials, profile, observations, custodyStorage, peerDeskStore);
30426
30485
  },
30427
30486
  Peer: PeerOffice
@@ -36732,7 +36791,7 @@
36732
36791
  });
36733
36792
  selecting.catch(() => {
36734
36793
  });
36735
- const storage = options.custodyStore ?? await openBrowserCustody(options.base);
36794
+ const storage = options.custodyStore ?? await openBrowserCustody(options.base, options.custodyLockWaitMillis === void 0 ? {} : { lockWaitMillis: options.custodyLockWaitMillis });
36736
36795
  progress("opened browser custody");
36737
36796
  storage.onCheckpoint = options.onCustodyCheckpoint;
36738
36797
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@githolon/runtime",
3
- "version": "0.113.1",
3
+ "version": "0.113.3",
4
4
  "type": "module",
5
5
  "description": "The portable Nomos application runtime, reception contracts, and Node/browser runners.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
package/runner/build.ts CHANGED
@@ -198,6 +198,17 @@ if (existsSync(FLUTTER_ASSETS)) {
198
198
  "// GENERATED by peer-office/package/runner/build.ts. Do not edit.\n"
199
199
  + "// The sha256 of the packaged nomos-runner-web.js this package ships.\n"
200
200
  + `const String kNomosRunnerWebSha256 =\n '${pageSha256}';\n`);
201
+ // The native Peer Office ships as Dart code, not a Flutter asset: a code-push update (Shorebird
202
+ // patch) replaces Dart but never assets, and this runtime is the code we most often need to fix.
203
+ const nativeRuntime = readFileSync(here("../dist/nomos-native-runtime.js"), "utf8");
204
+ if (nativeRuntime.includes("'''")) throw new Error("native runtime bundle cannot be a Dart raw string: it contains '''");
205
+ const nativeRuntimeSha256 = createHash("sha256").update(nativeRuntime).digest("hex");
206
+ writeFileSync(join(FLUTTER_ASSETS, "../lib/src/platform_shell/native_runtime_bundle.g.dart"),
207
+ "// GENERATED by peer-office/package/runner/build.ts from dist/nomos-native-runtime.js. Do not edit.\n"
208
+ + "// ignore_for_file: lines_longer_than_80_chars\n"
209
+ + "// The shared Peer Office the native hosts execute, as Dart code so a code patch can carry it.\n"
210
+ + `const String kNomosNativeRuntimeSha256 =\n '${nativeRuntimeSha256}';\n`
211
+ + `const String kNomosNativeRuntimeJavascript = r'''${nativeRuntime}''';\n`);
201
212
  console.error("✓ synced browser shell and shared Peer Office assets → nomos_flutter/assets");
202
213
  }
203
214
 
@@ -14587,6 +14587,32 @@ var KernelPort = class {
14587
14587
  // ../src/runtime/placement_desk.ts
14588
14588
  init_define_NOMOS_KERNEL_RELEASE();
14589
14589
 
14590
+ // ../src/runtime/http_origin.ts
14591
+ init_define_NOMOS_KERNEL_RELEASE();
14592
+ var AUTHORITY = /^([a-z][a-z0-9+.-]*):\/\/([^/?#]*)/i;
14593
+ var DEFAULT_PORTS = { http: "80", https: "443" };
14594
+ function httpOrigin(url) {
14595
+ const match = AUTHORITY.exec(url.trim());
14596
+ if (!match) return void 0;
14597
+ const scheme = match[1].toLowerCase();
14598
+ if (scheme !== "http" && scheme !== "https") return void 0;
14599
+ const authority = match[2];
14600
+ const hostAndPort = authority.slice(authority.lastIndexOf("@") + 1);
14601
+ const ipv6 = /^(\[[0-9a-f:.]+\])(?::(\d*))?$/i.exec(hostAndPort);
14602
+ const named = /^([^:[\]\s]+)(?::(\d*))?$/.exec(hostAndPort);
14603
+ const parts = ipv6 ?? named;
14604
+ if (!parts) return void 0;
14605
+ const host = parts[1].toLowerCase();
14606
+ if (host.length === 0 || /[\s<>^`{|}%\\]/.test(host)) return void 0;
14607
+ let port = parts[2] ?? "";
14608
+ if (port !== "") {
14609
+ const value = Number(port);
14610
+ if (!Number.isInteger(value) || value > 65535) return void 0;
14611
+ port = String(value);
14612
+ }
14613
+ return port === "" || port === DEFAULT_PORTS[scheme] ? `${scheme}://${host}` : `${scheme}://${host}:${port}`;
14614
+ }
14615
+
14590
14616
  // ../src/runtime/provider_origins.ts
14591
14617
  init_define_NOMOS_KERNEL_RELEASE();
14592
14618
 
@@ -14926,14 +14952,7 @@ var normalizeProfile = (profile) => {
14926
14952
  ...servedOrigin === void 0 ? {} : { servedOrigin }
14927
14953
  });
14928
14954
  };
14929
- var originOf2 = (url) => {
14930
- try {
14931
- const parsed = new URL(url);
14932
- return parsed.protocol === "https:" || parsed.protocol === "http:" ? parsed.origin : void 0;
14933
- } catch {
14934
- return void 0;
14935
- }
14936
- };
14955
+ var originOf2 = httpOrigin;
14937
14956
  var ReplicaPlacementDirectiveKind = Object.freeze({
14938
14957
  None: "none",
14939
14958
  Cache: "cache",
@@ -20783,7 +20802,10 @@ var ReadMaintenanceDesk = class {
20783
20802
  ...background ? { background } : {},
20784
20803
  ...awaited || existing?.awaited ? { awaited: true } : {},
20785
20804
  failures: existing?.failures ?? 0,
20786
- retryNotBeforeNanoseconds: 0n
20805
+ // A foreground read may retry at once. Upkeep owed by a write or a sync keeps any back-off
20806
+ // it is already serving: otherwise every write retried a failing upkeep immediately, and a
20807
+ // workspace whose upkeep could not succeed retried on every write (CAP-693).
20808
+ retryNotBeforeNanoseconds: isReadDemand ? 0n : existing?.retryNotBeforeNanoseconds ?? 0n
20787
20809
  });
20788
20810
  if (isReadDemand && (!existing?.read || existing.read.owedByAdvance)) {
20789
20811
  const entries = [...this.#pending.entries()];
@@ -21392,18 +21414,17 @@ var SubscriptionManager = class {
21392
21414
  #requestReadMaintenance;
21393
21415
  #clock;
21394
21416
  #subscriptions = /* @__PURE__ */ new Map();
21395
- /** Watches owed a re-read, drained one query group per turn when a turn scheduler is given. */
21417
+ /** Watches owed a re-read, drained one query group per office turn (see [drainOwedTurn]). */
21396
21418
  #owed = /* @__PURE__ */ new Set();
21397
- #nextTurn;
21398
- #draining = false;
21419
+ #deferRefreshes;
21399
21420
  #sequence = 0n;
21400
- constructor(queries, sessions, events, requestReadMaintenance, clock, nextTurn) {
21421
+ constructor(queries, sessions, events, requestReadMaintenance, clock, deferRefreshes = false) {
21401
21422
  this.#queries = queries;
21402
21423
  this.#sessions = sessions;
21403
21424
  this.#events = events;
21404
21425
  this.#requestReadMaintenance = requestReadMaintenance;
21405
21426
  this.#clock = clock;
21406
- this.#nextTurn = nextTurn;
21427
+ this.#deferRefreshes = deferRefreshes;
21407
21428
  }
21408
21429
  start(request, command) {
21409
21430
  if (!command.subscriptionId) throw new Error("watch requires a subscription identity");
@@ -21509,34 +21530,33 @@ var SubscriptionManager = class {
21509
21530
  * or replace current authorization. Each watch still owns its delivery state.
21510
21531
  */
21511
21532
  #refreshMatching(matches, cause) {
21512
- if (this.#nextTurn && !cause) {
21533
+ if (this.#deferRefreshes && !cause) {
21513
21534
  for (const [id, subscription] of this.#subscriptions) {
21514
21535
  if (subscription.request.query && matches(subscription)) this.#owed.add(id);
21515
21536
  }
21516
- this.#drain();
21517
21537
  return;
21518
21538
  }
21519
21539
  this.#refreshGroups(this.#groups(matches), cause);
21520
21540
  }
21521
- #drain() {
21522
- if (this.#draining || this.#owed.size === 0) return;
21523
- this.#draining = true;
21524
- this.#nextTurn(() => {
21525
- this.#draining = false;
21526
- if (this.#owed.size === 0) return;
21527
- const first = this.#owed.values().next().value;
21528
- const lead = this.#subscriptions.get(first);
21529
- if (!lead?.request.query) {
21530
- this.#owed.delete(first);
21531
- } else {
21532
- const declaration = toBinary(QueryRequestSchema, lead.request.query);
21533
- const session = lead.request.session;
21534
- const group = this.#groups((subscription) => subscription.request.session === session && this.#owed.has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
21535
- for (const each of group) for (const watch of each.watches) this.#owed.delete(watch.request.subscriptionId);
21536
- this.#refreshGroups(group);
21537
- }
21538
- this.#drain();
21539
- });
21541
+ /** Whether any watch is owed a re-read: the office's next drive() is due at once. */
21542
+ get owesRefresh() {
21543
+ return this.#owed.size > 0;
21544
+ }
21545
+ /** One office turn of owed re-reads: the first owed watch's query group. False when none was owed. */
21546
+ drainOwedTurn() {
21547
+ if (this.#owed.size === 0) return false;
21548
+ const first = this.#owed.values().next().value;
21549
+ const lead = this.#subscriptions.get(first);
21550
+ if (!lead?.request.query) {
21551
+ this.#owed.delete(first);
21552
+ return true;
21553
+ }
21554
+ const declaration = toBinary(QueryRequestSchema, lead.request.query);
21555
+ const session = lead.request.session;
21556
+ const group = this.#groups((subscription) => subscription.request.session === session && this.#owed.has(subscription.request.subscriptionId) && sameBytes(toBinary(QueryRequestSchema, subscription.request.query), declaration));
21557
+ for (const each of group) for (const watch of each.watches) this.#owed.delete(watch.request.subscriptionId);
21558
+ this.#refreshGroups(group);
21559
+ return true;
21540
21560
  }
21541
21561
  #groups(matches) {
21542
21562
  const groups = [];
@@ -21660,6 +21680,39 @@ function createSyntheticRequest(requestId) {
21660
21680
  });
21661
21681
  }
21662
21682
 
21683
+ // ../src/runtime/shell_contract.ts
21684
+ init_define_NOMOS_KERNEL_RELEASE();
21685
+ var SHELL_CONTRACT_V1 = Object.freeze({
21686
+ version: 1,
21687
+ /** Host globals beyond ECMAScript 2022, which every shell supplies. */
21688
+ host: Object.freeze(["TextEncoder", "TextDecoder", "queueMicrotask", "console"]),
21689
+ /** Nomos bridges a native bootstrap installs for the ports it hands to peerOffice.open. */
21690
+ bridges: Object.freeze([
21691
+ "__nomosKernel",
21692
+ "__nomosCredentialVault",
21693
+ "__nomosProfile",
21694
+ "__nomosObservations",
21695
+ "__nomosCustodyStorage",
21696
+ "__nomosPeerDeskStore",
21697
+ "__nomosSyncDiagnostic",
21698
+ "__nomosShellContract"
21699
+ ]),
21700
+ /** Globals the runtime may only probe: used behind their own `typeof` test, never bare. */
21701
+ probed: Object.freeze(["process", "Deno", "Bun", "define"])
21702
+ });
21703
+ var SHELL_CONTRACT_V2 = Object.freeze({ ...SHELL_CONTRACT_V1, version: 2 });
21704
+ var SHELL_CONTRACT_MINIMUM = 1;
21705
+ function declaredShellContract(scope = globalThis) {
21706
+ const declared = scope.__nomosShellContract;
21707
+ return declared === void 0 ? 1 : Number(declared);
21708
+ }
21709
+ function assertShellContract(scope = globalThis) {
21710
+ const declared = declaredShellContract(scope);
21711
+ if (!Number.isInteger(declared) || declared < SHELL_CONTRACT_MINIMUM) {
21712
+ throw new Error(`nomos.runtime.shell_contract_unsupported: this runtime needs shell contract ${SHELL_CONTRACT_MINIMUM} or later; the shell declares ${String(declared)}`);
21713
+ }
21714
+ }
21715
+
21663
21716
  // ../src/runtime/replica_follow_controller.ts
21664
21717
  init_define_NOMOS_KERNEL_RELEASE();
21665
21718
 
@@ -29657,10 +29710,9 @@ var PeerOffice = class {
29657
29710
  this.#trace,
29658
29711
  (session) => this.#readMaintenance.schedule(session, ReadMaintenanceCause.READ_DEBT),
29659
29712
  observations,
29660
- // An interactive peer keeps its thread responsive while watches catch up.
29661
- this.#interactivePeer ? (run2) => {
29662
- setTimeout(run2, 0);
29663
- } : void 0
29713
+ // An interactive peer keeps its thread responsive while watches catch up: owed re-reads
29714
+ // wait for its drive() turns.
29715
+ this.#interactivePeer
29664
29716
  );
29665
29717
  this.#application = new ApplicationDesk({
29666
29718
  onAdmitted: (session) => {
@@ -30067,7 +30119,9 @@ var PeerOffice = class {
30067
30119
  * mirrors queue/backoff state.
30068
30120
  */
30069
30121
  drive() {
30070
- return this.#maintenance.drive();
30122
+ if (this.#subscriptions.drainOwedTurn()) return 0n;
30123
+ const wake = this.#maintenance.drive();
30124
+ return this.#subscriptions.owesRefresh ? 0n : wake;
30071
30125
  }
30072
30126
  /**
30073
30127
  * Carry one exact maintenance demand through a durable host continuation.
@@ -31028,6 +31082,7 @@ var PeerOffice = class {
31028
31082
  };
31029
31083
  var peerOffice = {
31030
31084
  open(kernel, credentials, profile, observations, custodyStorage, peerDeskStore) {
31085
+ assertShellContract();
31031
31086
  return new PeerOffice(kernel, credentials, profile, observations, custodyStorage, peerDeskStore);
31032
31087
  },
31033
31088
  Peer: PeerOffice