@runeditrun/rer 0.2.48 → 0.2.49

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.
@@ -61,7 +61,7 @@ export async function resolvePersona(url, key, as, signal) {
61
61
  const { appFetch } = await shared('app-fetch.mjs');
62
62
  const response = await appFetch(url + '/__dev/personas', { headers: { [DEV_KEY_HEADER]: key }, signal: AbortSignal.any([signal, AbortSignal.timeout(10000)].filter(Boolean)) });
63
63
  if (!response.ok) { await response.body?.cancel(); throw refuse(`The application did not serve dev identity (HTTP ${response.status}). Check its local-only entry.`); }
64
- const personas = await response.json(), persona = personas.find(entry => entry.as === as);
64
+ const personas = await response.json(), email = as.toLowerCase(), persona = personas.find(entry => entry.as === as || (as.includes('@') && entry.email?.toLowerCase() === email));
65
65
  if (persona) return persona;
66
66
  // The people rer can sign in as: each persona with its email, then every
67
67
  // invited or active person in this checkout's local database by email.
@@ -175,5 +175,5 @@ async function devReady(url,key,options,signal){
175
175
  const as=options.as??'owner',persona=await resolvePersona(url,key,as,signal);
176
176
  // The owner persona names the owner the session will actually have (the
177
177
  // remaining owner once the setup owner has left), or none when none is left.
178
- return {identity:true,signedInAs:persona.email??null,ownerLeft:as==='owner'&&!persona.email,openUrl:openUrl(url,key,{path:'/__dev/key',as})};
178
+ return {identity:true,signedInAs:persona.email??null,ownerLeft:as==='owner'&&!persona.email,openUrl:openUrl(url,key,{path:'/__dev/key',as:persona.as})};
179
179
  }
package/cli/release.mjs CHANGED
@@ -67,7 +67,7 @@ export async function dispatchRelease(args) {
67
67
  console.log(JSON.stringify(receipt, null, 2));
68
68
  return receipt.status === 'BLOCKED' ? 1 : 0;
69
69
  } catch (error) {
70
- console.error(error?.code === 'placeholder_mark' ? error.message : 'Release failed during argument, source or artifact validation. No release completed.');
70
+ console.error(error?.message || 'Release failed during argument, source or artifact validation. No release completed.');
71
71
  return 2;
72
72
  }
73
73
  }
@@ -120,6 +120,19 @@ function areaGroup(headings, area) {
120
120
  return 'published'
121
121
  }
122
122
 
123
+ // A clause's prose, on one line: what follows its definition on that line, then
124
+ // the lines below it up to the next heading or definition. A bullet's body also
125
+ // ends at the first unindented line; a bold paragraph's or heading's runs on.
126
+ function bodyText(lines, line, form, rest) {
127
+ const body = [rest]
128
+ for (let next = line; next < lines.length; next++) {
129
+ const text = lines[next]
130
+ if (heading.test(text) || definitions.some(pattern => pattern.test(text)) || (form === 0 && text.trim() && !/^[\t ]/.test(text))) break
131
+ body.push(text)
132
+ }
133
+ return body.join(' ').replace(/\s+/gu, ' ').trim()
134
+ }
135
+
123
136
  // Clause definitions everywhere except the Status section and retired-ID
124
137
  // sections. The area is the nearest heading above that is not a clause.
125
138
  // A clause's own "*Status:* partial." line, kept beside its text, is recorded
@@ -132,7 +145,7 @@ function readDefinitions(lines, headings, skipped, problems) {
132
145
  const marker = /^\s*(```|~~~)/.exec(text)?.[1]
133
146
  if (marker) { fence = fence === marker ? undefined : fence ?? marker; return }
134
147
  if (fence || skipped.some(([start, end]) => line >= start && line <= end)) { current = undefined; return }
135
- const match = definitions.map(pattern => pattern.exec(text)).find(Boolean)
148
+ const form = definitions.findIndex(pattern => pattern.test(text)), match = form < 0 ? null : definitions[form].exec(text)
136
149
  if (!match) {
137
150
  if (heading.test(text)) current = undefined
138
151
  const stated = /^\*{1,2}Status:\*{1,2}\s*(done|partial|missing)\b/.exec(text)
@@ -143,7 +156,7 @@ function readDefinitions(lines, headings, skipped, problems) {
143
156
  const [, clause, title] = match
144
157
  if (defined.has(clause)) { problems.push({ line, message: `${clause} is defined twice (first at line ${defined.get(clause).line}).` }); return }
145
158
  if (!area) { problems.push({ line, message: `${clause} is defined above every section heading, so it has no area.` }); return }
146
- current = { id: clause, title: cleanTitle(title), area: area.text, line }
159
+ current = { id: clause, title: cleanTitle(title), area: area.text, line, text: bodyText(lines, line, form, text.slice(match[0].length)) }
147
160
  defined.set(clause, current)
148
161
  const group = areaGroup(headings, area), known = areas.get(area.text)
149
162
  if (known && known.group !== group) problems.push({ line: area.line, message: `Area "${area.text}" is a ${group} area here but a ${known.group} area at line ${known.line}; give one of them its own name.` })
@@ -256,7 +269,7 @@ export function parseContract(text, { file = 'CONTRACT.md' } = {}) {
256
269
  if (state === 'done' && !evidence.length) problems.push({ line: rowLine, message: `${clause} is done, so its Evidence names the repository path that proves it, in backticks.` })
257
270
  if (state === 'partial' && !evidence.length) problems.push({ line: rowLine, message: `${clause} is partial, so its Evidence names the repository path that backs it, in backticks.` })
258
271
  if ((state === 'partial' || state === 'missing') && !gap) problems.push({ line: rowLine, message: `${clause} is ${state}, so its Gap says what is missing.` })
259
- if (definition && kinds.includes(kind) && statuses.includes(state)) clauses.push({ id: clause, title, kind, status: state, evidence, gap, area: definition.area, line: definition.line, row: rowLine })
272
+ if (definition && kinds.includes(kind) && statuses.includes(state)) clauses.push({ id: clause, title, kind, status: state, evidence, gap, area: definition.area, text: definition.text, line: definition.line, row: rowLine })
260
273
  }
261
274
  }
262
275
  line = end
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.49
4
+
5
+ - **Large imports no longer fail with D1's request limit.** The import kit sized each D1 batch from the data statements alone and left out the authority, progress, scope and return checks that `atomic()` adds to the same request. A large import could therefore build one request just over D1's limit and stop with 409 `IMPORT_D1_REQUEST_LIMIT`: Nook's 3,547-entry Slack import stopped at checkpoint 51, where the estimate said 524 statements and the request held 573 against 572 remaining. Each batch is now sized with `atomicCount()`, the same count `atomic()` sends. The apply, reverse and fenced-reversal planners share it, because undo had the same gap. Nook's import now applies all 3,547 entries in 78 saved batches (#230).
6
+ - **A native demo serves every built chunk as immutable.** The demo worker now sends `cache-control: public, max-age=31536000, immutable` for every hashed chunk the seed's build produced, taken from its Vite manifest or else its recorded `assetsDir`, as well as for the existing `/assets/` default. Before, seeds that build elsewhere, such as Lamp with `/app-assets/`, had their chunks revalidated on every use, so the start page's prefetch barely helped (#227).
7
+ - **`rer release` names the real validation error.** A validation failure now prints its own message, such as "CONTRACT.md must contain published clauses", in place of the generic "Release failed during argument, source or artifact validation", and still exits 2. The release catalogue reads clauses through `parseContract`, the same parser `rer check` and the run site use, so published clauses written as headings or bold paragraphs release just like the bullet form. `rer dev --as <email>` also matches a built-in persona by its address, so a person invited at a persona's address signs in as that invited person with the invited role (#231).
8
+ - Base's TanStack Start migration notes add one harness line for test queues: keep the producers, drop the consumers, and name a single opt-in for tests that need real consumers (#225).
9
+
3
10
  ## 0.2.48
4
11
 
5
12
  - **The job queue no longer aborts or strands a waiting command under load.** Before, when another queued job's owner did not answer its 3 s identity probe, the waiting build, verify or deploy stopped with "Command failed; inspect the project operating documentation." A probe timeout now counts as "the owner may still be alive", so the waiting job samples again instead of giving up. The same holds for the queue lock and for nested-command membership, which had left a job queued behind its own parent until the queue's maximum wait. A recorded failed install is retried only when `pnpm-lock.yaml` or `package.json` changed since it failed. An error that is not one of rer's own now prints its message and a hint instead of the generic line (#219).
@@ -15,7 +15,9 @@ host. See [adoption and deployment](../../export/DEMO.md#hosting-the-demo).
15
15
  - `native/warm.mjs`: the start page's prefetch list, built from `dist/client`
16
16
  (the Vite manifest if the build wrote one, else the build's `assetsDir`, else
17
17
  `assets`) and TanStack Start's route manifest, the console's views first,
18
- capped by compressed size.
18
+ capped by compressed size. The same built chunks (`bundle.immutable`) are
19
+ what `native/worker.mjs` serves with an immutable `cache-control`, besides
20
+ hashed files under `/assets/`.
19
21
  - `capacity.mjs`: concurrent visitor admission and operator diagnostics. This
20
22
  is used by the native host as well as retained during legacy upgrades.
21
23
  - `upgrade.mjs`: verifies ownership, removes the old Container application and
@@ -4,7 +4,7 @@ import { createHash } from 'node:crypto';
4
4
  import { collectBuildModules } from '../../deploy-kit/build-modules.mjs';
5
5
  import { collectFiles, moduleType } from '../../deploy-kit/artifact.mjs';
6
6
  import { nativeBindings, ISOLATE_FILES, objectExports } from './config.mjs';
7
- import { warmList } from './warm.mjs';
7
+ import { warmList, builtChunks } from './warm.mjs';
8
8
 
9
9
  // The Worker Loader module kind for each upload type deploy-kit gives a build
10
10
  // module, so a demo carries what a normal deploy uploads. Binary kinds travel
@@ -34,6 +34,7 @@ export async function prepareNative(folder) {
34
34
  const bundle = { compatibilityDate: config.compatibility_date, compatibilityFlags: [...new Set([...(config.compatibility_flags ?? []), 'nodejs_compat'])], modules,
35
35
  bindings, migrations: manifest.migrations, vars: config.vars ?? {}, crons: config.triggers?.crons ?? [],
36
36
  assetPaths: assets.filter(file => !file.path.split('/').some(part => part.startsWith('.'))).map(file => '/' + file.path),
37
+ immutable: [...builtChunks(assets, manifest.assetsDir)].sort(),
37
38
  warm: (await warmList(assets, root, manifest.operatorPath, manifest.assetsDir)).paths };
38
39
  bundle.digest = createHash('sha256').update(JSON.stringify(bundle)).digest('hex');
39
40
  await cp(join(app, 'dist/client'), join(folder, 'assets'), { recursive: true });
@@ -20,7 +20,7 @@ const within = (path, root) => path === root || path.startsWith(root.endsWith('/
20
20
  // names (build.manifest), else everything under the configured build.assetsDir
21
21
  // (Vite's default is 'assets'). Never source maps or unhashed files.
22
22
  const MANIFESTS = ['.vite/manifest.json', 'manifest.json'];
23
- function builtChunks(files, assetsDir) {
23
+ export function builtChunks(files, assetsDir) {
24
24
  const manifest = files.find(file => MANIFESTS.includes(file.path));
25
25
  const paths = (manifest
26
26
  ? Object.values(JSON.parse(Buffer.from(manifest.base64, 'base64'))).flatMap(entry => [entry.file, ...(entry.css ?? [])]).map(path => '/' + path)
@@ -7,6 +7,8 @@ export { NativeDemo } from './visitor.mjs';
7
7
  export { DemoCapacity } from '../capacity.mjs';
8
8
 
9
9
  const assets = new Set(bundle.assetPaths);
10
+ // The seed's built chunks (its Vite manifest, else its assetsDir) are hashed wherever the build put them.
11
+ const chunks = new Set(bundle.immutable);
10
12
  export default {
11
13
  async fetch(request, env, ctx) {
12
14
  const url = new URL(request.url);
@@ -14,7 +16,7 @@ export default {
14
16
  if (['GET', 'HEAD'].includes(request.method) && assets.has(url.pathname)) {
15
17
  const response = await env.ASSETS.fetch(request);
16
18
  const headers = new Headers(response.headers);
17
- if (HASHED_ASSET.test(url.pathname)) headers.set('cache-control', 'public, max-age=31536000, immutable');
19
+ if (chunks.has(url.pathname) || HASHED_ASSET.test(url.pathname)) headers.set('cache-control', 'public, max-age=31536000, immutable');
18
20
  headers.set('x-rer-demo-assets', 'edge');
19
21
  return new Response(response.body, { status: response.status, headers });
20
22
  }
@@ -130,15 +130,18 @@ async function enter(request, gate, { config, store, hash, current, everyone, ow
130
130
  reply.set('location', '/');
131
131
  return new Response(null, { status: 303, headers: reply });
132
132
  }
133
- const persona = (await everyone()).find(p => p.as === as);
134
- if (!persona) {
135
- const value = await auth.oneClick.enter(request, { as, returnTo: url.searchParams.get('returnTo') ?? '/app' });
133
+ const oneClick = async email => {
134
+ const value = await auth.oneClick.enter(request, { as: email, returnTo: url.searchParams.get('returnTo') ?? '/app' });
136
135
  reply.append('set-cookie', value.cookie);
137
136
  reply.set('location', value.returnTo);
138
137
  return new Response(null, { status: 303, headers: reply });
139
- }
138
+ };
139
+ const persona = (await everyone()).find(p => p.as === as);
140
+ if (!persona) return oneClick(as);
140
141
  if (!persona.email) return text(409, 'No active owner remains in this app. Sign in another way, or run rer reset --yes and rer setup for a new owner.');
141
142
  let operator = await store.byEmail(persona.email);
143
+ // Someone invited at a persona's address is that person, with the role they were invited to; accepting the invite signs them in.
144
+ if (operator?.status === 'invited') return oneClick(operator.email);
142
145
  // Personas are real operators, created only here, in local dev.
143
146
  if (!operator && persona.role) {
144
147
  if (persona.role === 'owner') {
@@ -1,36 +1,16 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { mkdirSync, writeFileSync } from 'node:fs';
3
3
  import { resolve, dirname } from 'node:path';
4
- import { clauseIdSource } from '../../foundation/runtime/seed-contract.mjs';
4
+ import { parseContract } from '../../foundation/runtime/seed-contract.mjs';
5
5
 
6
6
  export const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
7
7
  export const json = value => JSON.stringify(value, null, 2) + '\n';
8
8
 
9
+ // The listing's clauses are the contract's published ones, read by the parser
10
+ // `rer check` and the run site use: a malformed contract throws its ContractError.
9
11
  function clauses(text) {
10
- const result = [];
11
- let current = null;
12
- const finish = () => {
13
- if (!current) return;
14
- const body = current.body.join(' ').replace(/\s+/gu, ' ').trim();
15
- if (body) result.push({ id: current.id, title: current.title, text: body });
16
- current = null;
17
- };
18
- const clauseLine = new RegExp(`^- \\*\\*(${clauseIdSource})\\s+[—–-]\\s+(.+?)\\.?\\*\\*[ \\t]*(.*)$`);
19
- for (const line of text.split(/\r\n|\n|\r/)) {
20
- const match = clauseLine.exec(line);
21
- if (match) {
22
- finish();
23
- current = { id: match[1], title: match[2], body: [match[3]] };
24
- continue;
25
- }
26
- if (!current) continue;
27
- if (!line.trim() || /^[\t ]/.test(line)) {
28
- current.body.push(line);
29
- continue;
30
- }
31
- finish();
32
- }
33
- finish();
12
+ const result = parseContract(text).clauses.filter(clause => clause.kind === 'published' && clause.text)
13
+ .sort((a, b) => a.line - b.line).map(({ id, title, text }) => ({ id, title, text }));
34
14
  if (!result.length) throw Error('CONTRACT.md must contain published clauses');
35
15
  return result;
36
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.48",
3
+ "version": "0.2.49",
4
4
  "description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
5
5
  "license": "MIT",
6
6
  "type": "module",