@bongos/core 1.19.1056 → 1.19.1058

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.
@@ -0,0 +1,87 @@
1
+ // modules/lifecycle/page-tweak-reads.js — the two ledger reads Tweak Mode's
2
+ // status, changelog, drift and tally are derived from (task 1004316 / BV2.TW05,
3
+ // ADR 0341 D7, D8, D10). Read-only; no state transition lives here.
4
+ //
5
+ // On the `lifecycle` port because tasks and claims are this module's tables and
6
+ // copy-desk may only cross the wall through a port (ADR 0083, ADR 0093 §2). The
7
+ // derivation itself is copy-desk's (modules/copy-desk/page-status.js); these
8
+ // return the rows it reads, column for column, with no projection in between,
9
+ // so a field added here reaches the derivation without a second mapper to
10
+ // forget.
11
+
12
+ 'use strict';
13
+
14
+ const api = require('../../src/module-api');
15
+
16
+ // Every page-tweak task, oldest first, with what the round state (D7) and the
17
+ // changelog (D8) need beside the task itself:
18
+ //
19
+ // grade_passed the task's grade (task_grades holds one row per task, the
20
+ // latest). A completed round with a passed grade is waiting
21
+ // for the artist; with a failed one it is still applying.
22
+ // holder_* the ACTIVE claim, if any. holder_worktree is true for a CLI
23
+ // claim (a worktree: the applier) and false for a web claim
24
+ // (bind_session=false, no worktree: the artist writing).
25
+ // artist_* the round's artist, the payee rule of D10: the builder of
26
+ // the latest WEB claim on the task, which is the one the
27
+ // submit released. Never a field in the description, which
28
+ // the task's editors could change.
29
+ //
30
+ // THE QUERY PLAN, since this read backs all three page routes:
31
+ // * `t.source = 'page-tweak'` is served by idx_tasks_source_ref, which leads
32
+ // on (source) (migrations/core_240_artist_gate_indexes.sql), so the scan is
33
+ // bounded to the page-tweak rows, not the whole task table.
34
+ // * the active claim is a plain join: uniq_active_claim_per_task allows at
35
+ // most one row per task, and its partial index serves it.
36
+ // * the latest web claim is ONE pass over claims (the `web` CTE, DISTINCT ON
37
+ // per task), joined once, rather than a correlated subquery per task:
38
+ // claims has no full index on task_id, so a per-row LATERAL would scan it
39
+ // once per round.
40
+ async function listPageTweakTasks() {
41
+ const { rows } = await api.pool.query(
42
+ `WITH pt AS (
43
+ SELECT t.id FROM tasks t WHERE t.source = 'page-tweak'
44
+ ), web AS (
45
+ SELECT DISTINCT ON (c.task_id) c.task_id, c.builder_id
46
+ FROM claims c JOIN pt ON pt.id = c.task_id
47
+ WHERE c.worktree_name IS NULL AND c.creator_session_id IS NULL
48
+ ORDER BY c.task_id, c.claimed_at DESC, c.id DESC
49
+ )
50
+ SELECT t.id, t.status, t.title, t.description, t.source_ref, t.touches,
51
+ t.shipped_at, t.created_at, t.updated_at,
52
+ g.passed AS grade_passed,
53
+ ac.builder_id AS holder_id, hb.github_login AS holder_login,
54
+ (ac.worktree_name IS NOT NULL) AS holder_worktree,
55
+ wc.builder_id AS artist_id, ab.github_login AS artist_login
56
+ FROM tasks t
57
+ LEFT JOIN task_grades g ON g.task_id = t.id
58
+ LEFT JOIN claims ac ON ac.task_id = t.id AND ac.released_at IS NULL
59
+ LEFT JOIN builders hb ON hb.id = ac.builder_id
60
+ LEFT JOIN web wc ON wc.task_id = t.id
61
+ LEFT JOIN builders ab ON ab.id = wc.builder_id
62
+ WHERE t.source = 'page-tweak'
63
+ ORDER BY t.id ASC`
64
+ );
65
+ return rows;
66
+ }
67
+
68
+ // The ships that changed a page since its last round (D8): shipped tasks after
69
+ // `since` whose touches meet the page's files. The array-overlap operator is the
70
+ // same one the parallel-safety check uses, served by idx_tasks_touches_gin.
71
+ async function shippedTasksTouchingSince({ files, since, limit = 50 } = {}) {
72
+ const list = Array.isArray(files) ? files.map(String).filter(Boolean) : [];
73
+ if (!list.length || !since) return [];
74
+ const { rows } = await api.pool.query(
75
+ `SELECT t.id, t.title, t.shipped_at
76
+ FROM tasks t
77
+ WHERE t.status = 'shipped'
78
+ AND t.shipped_at > $2::timestamptz
79
+ AND t.touches && $1::text[]
80
+ ORDER BY t.shipped_at ASC, t.id ASC
81
+ LIMIT $3`,
82
+ [list, since, Math.max(1, Math.min(200, Number(limit) || 50))]
83
+ );
84
+ return rows;
85
+ }
86
+
87
+ module.exports = { listPageTweakTasks, shippedTasksTouchingSince };
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.1056",
3
+ "version": "1.19.1058",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.1056",
9
+ "version": "1.19.1058",
10
10
  "license": "AGPL-3.0-or-later",
11
11
  "dependencies": {
12
12
  "express": "^4.21.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.1056",
3
+ "version": "1.19.1058",
4
4
  "description": "Cloud Bongos — the AI-first build platform core (GDS + platform surfaces + module system), installed as a versioned dependency (ADR 0108).",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "main": "src/platform-server.js",
@@ -7637,5 +7637,17 @@
7637
7637
  "id": "1004332",
7638
7638
  "text": "Tweak Mode now has one written plan that every later step builds on. It says how a page is taken, where the artist's words rest while they write, how a page shows as tweaked or changed since, how the Word download and upload w"
7639
7639
  }
7640
+ ],
7641
+ "1.19.1057": [
7642
+ {
7643
+ "id": "1004315",
7644
+ "text": "Every page of the project now has a written reading: all the words it actually shows, in order, grouped under its headings. Each line says where the words live. Some come from a known place in the code, some are shared by ever"
7645
+ }
7646
+ ],
7647
+ "1.19.1058": [
7648
+ {
7649
+ "id": "1004316",
7650
+ "text": "Every page now has a status that is worked out from the project's own record, with nothing new to keep in sync. For each page you can see whether it is untweaked or text tweaked and how many times, a history of each round (who"
7651
+ }
7640
7652
  ]
7641
7653
  }