mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Count a build on the web console's session meter while it runs, and score Implement + Review's built-in review once instead of twice
AI Assisted
This commit is contained in:
1 parent
739e56c5cf
commit
c8e65f12a6
59 files changed
+1578
-210
No files matched your search
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
@@ -60,7 +60,9 @@ The first payload for a phase you are about to build:
|
||||
```
|
||||
|
||||
`headline.cleared` / `total` are tasks done out of tasks in the phase: the
|
||||
progress bar is the first thing someone watching a build looks at.
|
||||
progress bar is the first thing someone watching a build looks at. The session
|
||||
meter counts the build's tasks from `cleared` as it rises, so keep it current,
|
||||
and start every phase (a second one in the same run too) at `"cleared": 0`.
|
||||
|
||||
`phasefile` is the whole `phase-X.md`, verbatim from disk, as its own tab —
|
||||
the person can read the prerequisites and task specs while you build. Re-post
|
||||
@@ -233,8 +235,9 @@ sign-off card, and approving past it was the answer. `implement-review` ends
|
||||
the same way; that phase was reviewed already. Only a finished `quick-task`
|
||||
still offers the review on its finish — see below.
|
||||
|
||||
`run` scores the approved phase on the session meter (console.md → Posting an
|
||||
update → Session meter), in the same post that records the approval:
|
||||
`run` gives the approved phase its final score on the session meter (console.md →
|
||||
Posting an update → Session meter), in the same post that records the approval;
|
||||
it takes over what the build already counted from `cleared`, never adds to it:
|
||||
`implement-phase` for Implement, `implement-review-phase` for Implement +
|
||||
Review, id `phase-N`, and `tasks`: how many of the phase's tasks were
|
||||
completed (`[x]`, not blocked `[!]`). The phase scores by its size, so a
|
||||
@@ -392,7 +395,10 @@ a question still owed, above the ending itself:
|
||||
|
||||
The same build, then Stage 2 publishes the findings exactly as above (the
|
||||
`review` doc and the `fixes` item). Stage 3 fixes, with no "Check the fixes"
|
||||
item: Stage 4 is the only gate. Stage 4 is the sign-off above **without the
|
||||
item: Stage 4 is the only gate. The post that starts Stage 2's review carries
|
||||
`"run": { "event": "review", "id": "review" }`, as above: in this workflow it
|
||||
scores the review stage's 1 point on the meter as it begins, and the phase's
|
||||
final `run` leaves that point out. Stage 4 is the sign-off above **without the
|
||||
review verdict** — the phase was already reviewed — with the review results
|
||||
and unresolved findings in the report doc, header "Reviewed and ready for
|
||||
sign-off" in the item's `body`. The finish never carries `review`, and its
|
||||
|
||||
@@ -901,7 +901,9 @@ Per-unit work is yours to report, with `run` in any post:
|
||||
not count), a whole number from 1 to 999. A built phase scores by its size,
|
||||
one point per 3 tasks rounded up, and Implement + Review one more for the
|
||||
review. Always send it: without it a phase scores a flat 2 (or 3), however
|
||||
big it was. On any other event it is exit `3`.
|
||||
big it was. On any other event it is exit `3`. The console already counts a
|
||||
build's tasks from `headline.cleared` as they are ticked off; the phase's
|
||||
`run` takes that count over with the final score, so it never counts twice.
|
||||
- One `run` per post. Which events a workflow reports is in its own notes
|
||||
(Workflow notes → Pathfinder; `building.md` for Implement and for the
|
||||
review run on the page after a build).
|
||||
|
||||
@@ -90,7 +90,7 @@ import {
|
||||
writeJsonAtomic,
|
||||
writeWorkspaceCursor,
|
||||
} from "./lib.mjs";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount } from "./public/meter.js";
|
||||
import { RUN_EVENTS, TASK_EVENTS, MAX_TASKS, isTaskCount, progressEntry } from "./public/meter.js";
|
||||
import { changeLine } from "./public/workspace.js";
|
||||
|
||||
// Mirrors the server's absolute lifetime cap: a handle older than this cannot
|
||||
@@ -593,6 +593,13 @@ function cmdPost() {
|
||||
const next = written.state;
|
||||
|
||||
for (const line of ledgerLines) appendLedger(dir, line);
|
||||
// A build scores its tasks as it clears them (meter.js, PROGRESS_WORKFLOWS),
|
||||
// after any `run` in the same post, so a phase finished here ends its count.
|
||||
if (patch.headline && typeof patch.headline === "object") {
|
||||
const ledger = readLedger(dir);
|
||||
const progress = progressEntry(ledger, lastLaunchId(ledger), next.workflow, patch.headline.cleared);
|
||||
if (progress) appendLedger(dir, progress);
|
||||
}
|
||||
appendEvent(dir, { type: "post", items: (patch.items || []).length });
|
||||
|
||||
const open = next.items.filter((i) => isOpen(i) && i.required !== false).length;
|
||||
|
||||
@@ -53,16 +53,55 @@ export const TASK_EVENTS = Object.freeze(new Set(Object.keys(TASK_BONUS)));
|
||||
// The most tasks one run may report: past this it is a typo, not a phase.
|
||||
export const MAX_TASKS = 999;
|
||||
|
||||
// A build scores while it runs, not only once it is approved: console.mjs
|
||||
// writes a `progress` ledger entry whenever a build's `headline.cleared`
|
||||
// rises, and the build's row scores those tasks at TASKS_PER_POINT with no
|
||||
// bonus. The phase's `run` then takes the row over with its final score, so
|
||||
// the total only ever climbs. Workflows whose headline counts tasks:
|
||||
export const PROGRESS_WORKFLOWS = Object.freeze(new Set(["implement", "implement-review"]));
|
||||
|
||||
// Implement + Review reviews every phase as a stage of the build. A `review`
|
||||
// run inside it is that stage, so it scores the phase's TASK_BONUS when it
|
||||
// starts, and the phase's own run leaves the bonus out after it.
|
||||
const BUILT_IN_REVIEW = Object.freeze({ "implement-review": "implement-review-phase" });
|
||||
|
||||
/**
|
||||
* The ledger entry a build's progress post stands for, or null when it adds
|
||||
* nothing: not a task-counting workflow, no whole `cleared`, or no more tasks
|
||||
* than this build already has. `seg` is how many phases this skill run has
|
||||
* finished, so a second phase in the same run starts its own count, but only
|
||||
* once its headline is back at 0: until then a `cleared` is the finished
|
||||
* phase's, posted again, and opening a build on it would count it twice.
|
||||
*/
|
||||
export function progressEntry(entries, launch, workflow, cleared) {
|
||||
if (!PROGRESS_WORKFLOWS.has(workflow)) return null;
|
||||
if (cleared !== 0 && !isTaskCount(cleared)) return null;
|
||||
const list = Array.isArray(entries) ? entries : [];
|
||||
const seg = list.filter((e) => e && e.kind === "run" && TASK_EVENTS.has(e.event) && launchOf(e.id) === launch).length;
|
||||
const build = `${launch}:b${seg}`;
|
||||
const mine = list.filter((e) => e && e.kind === "progress" && e.build === build);
|
||||
const entry = (tasks) => ({ kind: "progress", id: `${build}:${tasks}`, build, workflow, tasks });
|
||||
if (cleared === 0) return seg > 0 && !mine.length ? entry(0) : null;
|
||||
if (seg > 0 && !mine.length) return null;
|
||||
const most = mine.reduce((n, e) => Math.max(n, e.tasks), 0);
|
||||
return cleared > most ? entry(cleared) : null;
|
||||
}
|
||||
|
||||
/** A valid `run.tasks`: a whole number from 1 to MAX_TASKS. */
|
||||
export function isTaskCount(tasks) {
|
||||
return Number.isInteger(tasks) && tasks >= 1 && tasks <= MAX_TASKS;
|
||||
}
|
||||
|
||||
/** What one `run` scores, from its event and (for a built phase) its tasks. */
|
||||
export function runPoints(event, tasks) {
|
||||
/**
|
||||
* What one `run` scores, from its event and (for a built phase) its tasks.
|
||||
* `bonus: false` leaves the review bonus out, for a phase whose review
|
||||
* already scored.
|
||||
*/
|
||||
export function runPoints(event, tasks, { bonus = true } = {}) {
|
||||
if (TASK_EVENTS.has(event) && isTaskCount(tasks)) {
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + TASK_BONUS[event];
|
||||
return Math.ceil(tasks / TASKS_PER_POINT) + (bonus ? TASK_BONUS[event] : 0);
|
||||
}
|
||||
if (TASK_EVENTS.has(event) && !bonus) return weightOf(event) - TASK_BONUS[event];
|
||||
return weightOf(event);
|
||||
}
|
||||
|
||||
@@ -133,6 +172,8 @@ export function breakdownFrom(entries) {
|
||||
const seen = new Set();
|
||||
const rows = [];
|
||||
const answers = new Map(); // launch id -> { row, count, workflow }
|
||||
const builds = new Map(); // launch id -> the row of the build in progress
|
||||
const reviewed = new Set(); // launch ids whose built-in review has scored
|
||||
for (const entry of Array.isArray(entries) ? entries : []) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
if (entry.id !== undefined) {
|
||||
@@ -150,17 +191,54 @@ export function breakdownFrom(entries) {
|
||||
tally.count += 1;
|
||||
continue;
|
||||
}
|
||||
if (entry.kind === "progress") {
|
||||
if (!isTaskCount(entry.tasks)) continue;
|
||||
const launch = launchOf(entry.id);
|
||||
let row = builds.get(launch);
|
||||
if (!row || row.build !== entry.build) {
|
||||
row = { label: "", points: 0, build: entry.build, tasks: 0 };
|
||||
builds.set(launch, row);
|
||||
rows.push(row);
|
||||
}
|
||||
if (entry.tasks > row.tasks) {
|
||||
row.tasks = entry.tasks;
|
||||
row.points = Math.ceil(entry.tasks / TASKS_PER_POINT);
|
||||
const where = WORKFLOW_NAMES[entry.workflow] || "Build";
|
||||
row.label = `${where}: ${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"} built so far`;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let points = 0;
|
||||
let label = "";
|
||||
if (entry.kind === "launch" && LAUNCH_COUNTED.has(entry.workflow)) {
|
||||
points = weightOf(entry.workflow);
|
||||
label = LAUNCH_LABELS[entry.workflow] || entry.workflow;
|
||||
} else if (entry.kind === "run") {
|
||||
points = runPoints(entry.event, entry.tasks);
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit ? `: ${unit}` : "") + size;
|
||||
const launch = launchOf(entry.id);
|
||||
const builtIn = BUILT_IN_REVIEW[entry.workflow];
|
||||
if (entry.event === "review" && builtIn) {
|
||||
// The review stage of Implement + Review: it scores the bonus its
|
||||
// phase would otherwise carry, once per skill run.
|
||||
if (reviewed.has(launch)) continue;
|
||||
reviewed.add(launch);
|
||||
points = TASK_BONUS[builtIn];
|
||||
label = `${WORKFLOW_NAMES[entry.workflow]}: code review run`;
|
||||
} else {
|
||||
const bonus = !(TASK_EVENTS.has(entry.event) && reviewed.has(launch));
|
||||
points = runPoints(entry.event, entry.tasks, { bonus });
|
||||
const unit = unitOf(entry.id);
|
||||
const counted = TASK_EVENTS.has(entry.event) && isTaskCount(entry.tasks);
|
||||
const size = counted ? ` (${entry.tasks} ${entry.tasks === 1 ? "task" : "tasks"})` : "";
|
||||
label = (RUN_LABELS[entry.event] || entry.event) + (unit && unit !== entry.event ? `: ${unit}` : "") + size;
|
||||
}
|
||||
// A finished phase takes over its build's progress row, in place.
|
||||
if (TASK_EVENTS.has(entry.event) && builds.has(launch)) {
|
||||
const row = builds.get(launch);
|
||||
builds.delete(launch);
|
||||
row.label = label;
|
||||
row.points = Math.max(points, row.points);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (points > 0) rows.push({ label, points });
|
||||
}
|
||||
@@ -169,7 +247,7 @@ export function breakdownFrom(entries) {
|
||||
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
|
||||
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
|
||||
}
|
||||
return rows.filter((row) => row.points > 0);
|
||||
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
|
||||
}
|
||||
|
||||
/** The session's points, folded from ledger entries in order. */
|
||||
|
||||
Reference in new issue
Block a user