Skip to content

Commit 68a6dfc

Browse files
authored
Restore public Bay job and step details (#1180)
* Restore verified public Bay work details * Classify Bay apply steps before publication * Handle oversized Bay action timelines * Filter public lifecycle rows before cap * Index public lifecycle repository reads * Bound cold Bay status reads * Bound multi-repository Bay lifecycle reads * Clarify Bay view-only GitHub references * Keep expanded Bay tide sample within budget * Cap Bay worker-health fetch fanout * Correct Bay worker-health fanout docs
1 parent c06a897 commit 68a6dfc

15 files changed

Lines changed: 1629 additions & 214 deletions

‎AGENTS.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ not split reports into issue/PR subtrees.
9494
dashboard data-contract changes, state in the PR or handoff whether
9595
OpenClaw Bay is affected. If it is, update Bay and its proof; otherwise
9696
record why no Bay change is needed. OpenClaw Bay is a public, indexable,
97-
observer-only surface: it may display status but must never trigger or offer
98-
queue, workflow, GitHub, DLQ, recovery, deploy, or rollback actions.
97+
observer-only surface: it may display status and provide view-only navigation
98+
to verified-public GitHub repository, item, workflow-run, and job pages. Those
99+
canonical GET links are references, not action controls. Bay must never call
100+
GitHub from the browser or trigger or offer queue, workflow, GitHub, DLQ,
101+
recovery, deploy, rollback, or other mutation controls.
99102
- A ClawSweeper result that requires proof or identifies an accepted/actionable
100103
finding remains PR-owner work, not a handoff. Before a manually requested
101104
review or re-review, put current proof and the finding disposition or evidence

‎dashboard/bay-page.ts‎

Lines changed: 27 additions & 21 deletions
Large diffs are not rendered by default.

‎dashboard/dashboard-pages.ts‎

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,10 +2080,66 @@ function dashboardPublicBayReferences(value) {
20802080
const key = repository + "#" + itemNumber;
20812081
if (seen.has(key)) continue;
20822082
seen.add(key);
2083-
references.push({ repository, item_number: itemNumber, stage: entry.stage, source: entry.source });
2083+
const action = dashboardPublicBayAction(entry.action);
2084+
references.push({
2085+
repository,
2086+
item_number: itemNumber,
2087+
stage: entry.stage,
2088+
source: entry.source,
2089+
...(action ? { action } : {})
2090+
});
20842091
}
20852092
return references;
20862093
}
2094+
const PUBLIC_ACTION_STEP_LABELS = {
2095+
setup: "Set up job",
2096+
checkout: "Check out repository",
2097+
dependencies: "Prepare dependencies",
2098+
lease: "Acquire work lease",
2099+
review: "Run review",
2100+
proof: "Verify proof",
2101+
test: "Run checks",
2102+
publish: "Publish result",
2103+
apply: "Apply result",
2104+
finalize: "Finalize",
2105+
cleanup: "Clean up",
2106+
workflow: "Workflow step"
2107+
};
2108+
function dashboardPublicBayAction(value) {
2109+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
2110+
const repository = typeof value.repository === "string" ? value.repository.trim().toLowerCase() : "";
2111+
const runId = value.run_id;
2112+
const jobId = value.job_id;
2113+
const statuses = new Set(["queued", "in_progress", "completed"]);
2114+
const conclusions = new Set(["success", "failure", "cancelled", "skipped", "neutral", "timed_out", "action_required", "startup_failure", "stale"]);
2115+
const startedAt = value.started_at === null ? null : dashboardObservabilityTimestamp(value.started_at);
2116+
if (
2117+
repository.length > 200 ||
2118+
!/^[a-z0-9_.-]+\\/[a-z0-9_.-]+$/.test(repository) ||
2119+
typeof runId !== "number" || !Number.isSafeInteger(runId) || runId <= 0 || runId > 1000000000000000 ||
2120+
(jobId !== undefined && (typeof jobId !== "number" || !Number.isSafeInteger(jobId) || jobId <= 0 || jobId > 1000000000000000)) ||
2121+
!statuses.has(value.status) ||
2122+
(value.started_at !== null && !startedAt) ||
2123+
typeof value.steps_complete !== "boolean" ||
2124+
!Array.isArray(value.steps) || value.steps.length > 100
2125+
) return null;
2126+
const steps = [];
2127+
const seen = new Set();
2128+
for (const step of value.steps) {
2129+
if (!step || typeof step !== "object" || Array.isArray(step)) return null;
2130+
if (
2131+
typeof step.sequence !== "number" || !Number.isSafeInteger(step.sequence) || step.sequence <= 0 || step.sequence > 1000 || seen.has(step.sequence) ||
2132+
!Object.hasOwn(PUBLIC_ACTION_STEP_LABELS, step.kind) ||
2133+
!statuses.has(step.status) ||
2134+
(step.conclusion !== null && !conclusions.has(step.conclusion))
2135+
) return null;
2136+
seen.add(step.sequence);
2137+
steps.push({ sequence: step.sequence, kind: step.kind, status: step.status, conclusion: step.conclusion });
2138+
}
2139+
if ((!value.steps_complete && steps.length) || (value.steps_complete && steps.length !== value.steps.length)) return null;
2140+
steps.sort((left, right) => left.sequence - right.sequence);
2141+
return { repository, run_id: runId, ...(jobId === undefined ? {} : { job_id: jobId }), status: value.status, started_at: startedAt, steps_complete: value.steps_complete, steps };
2142+
}
20872143
function dashboardStatusSnapshot(value) {
20882144
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
20892145
const projected = dashboardStatusValue(value, "root", 0);
@@ -3667,6 +3723,14 @@ function renderPublicReferenceDialog(row, key) {
36673723
const repositoryUrl = "https://github.com/" + row.repository;
36683724
const itemUrl = repositoryUrl + "/issues/" + row.item_number;
36693725
const source = row.source === "queue" ? "Bounded queue sample" : "Bounded live sample";
3726+
const action = dashboardPublicBayAction(row.action);
3727+
const completedSteps = action ? action.steps.filter(step => step.status === "completed").length : 0;
3728+
const actionRepositoryUrl = action ? "https://github.com/" + action.repository : null;
3729+
const runUrl = action ? actionRepositoryUrl + "/actions/runs/" + action.run_id : null;
3730+
const jobUrl = action?.job_id ? runUrl + "/job/" + action.job_id : null;
3731+
const stepRows = action?.steps.map(step =>
3732+
'<li class="step-row ' + esc(step.status) + '"><i class="step-mark"></i><strong>' + esc(PUBLIC_ACTION_STEP_LABELS[step.kind]) + '</strong><span>' + esc((step.conclusion || step.status).replaceAll("_", " ")) + '</span></li>'
3733+
).join("") || "";
36703734
document.getElementById("worker-dialog-heading").innerHTML =
36713735
'<div><span class="pill">' + esc(row.source) + '</span> <span class="pill">' + esc(row.stage) + '</span></div>' +
36723736
'<h3 id="worker-dialog-title">' + esc(key) + '</h3>' +
@@ -3677,13 +3741,17 @@ function renderPublicReferenceDialog(row, key) {
36773741
'<div class="drawer-stat"><span>Source</span><strong>' + esc(source) + '</strong></div>' +
36783742
'<div class="drawer-stat"><span>Repository</span><strong>' + esc(row.repository) + '</strong></div>' +
36793743
'<div class="drawer-stat"><span>Reference</span><strong>#' + esc(row.item_number) + '</strong></div>' +
3744+
(action ? '<div class="drawer-stat"><span>Action status</span><strong>' + esc(action.status.replaceAll("_", " ")) + '</strong></div>' : '') +
3745+
(action ? '<div class="drawer-stat"><span>Progress</span><strong>' + esc(completedSteps) + ' / ' + esc(action.steps.length) + ' steps</strong></div>' : '') +
36803746
'</div>' +
36813747
'<div class="drawer-links">' +
36823748
linkClass(itemUrl, "Open issue or pull request", "pill run-link") +
36833749
linkClass(repositoryUrl, "Open repository", "pill run-link") +
3750+
linkClass(jobUrl, "Open job", "pill run-link") +
3751+
linkClass(runUrl, "Open workflow run", "pill run-link") +
36843752
'</div>' +
3685-
'<h2>Public status</h2>' +
3686-
'<ol class="step-list"><li class="step-row"><i class="step-mark"></i><strong>Reference verified</strong><span>Public repository and item coordinates only</span></li><li class="step-row in_progress"><i class="step-mark"></i><strong>Current aggregate stage</strong><span>' + esc(row.stage) + '</span></li></ol>';
3753+
'<h2>' + (action ? 'Step timeline' : 'Public status') + '</h2>' +
3754+
(stepRows ? '<ol class="step-list">' + stepRows + '</ol>' : '<ol class="step-list"><li class="step-row completed"><i class="step-mark"></i><strong>Reference verified</strong><span>Verified public GitHub coordinates</span></li><li class="step-row in_progress"><i class="step-mark"></i><strong>Current Bay stage</strong><span>' + esc(row.stage) + '</span></li></ol>');
36873755
if (!dialog.open) dialog.showModal();
36883756
history.replaceState(null, "", "#public-reference-" + encodeURIComponent(key));
36893757
}

‎dashboard/exact-review-lifecycle.ts‎

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export const EXACT_REVIEW_LIFECYCLE_PROJECTION_TABLE = "exact_review_lifecycle_projection_v1";
22
export const EXACT_REVIEW_ACKNOWLEDGEMENT_ATTEMPT_LEASE_MS = 5 * 60 * 1000;
3-
export const EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT = 512;
3+
// Keep the public reader bounded, but leave enough headroom for the durable
4+
// history between normal retention passes. The former 512-row ceiling turned
5+
// a healthy, append-only store into a permanently unknown public snapshot.
6+
export const EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT = 10_000;
47
export const EXACT_REVIEW_LIFECYCLE_BAY_SAMPLE_LIMIT = 24;
58
export const EXACT_REVIEW_LIFECYCLE_AUDIT_READ_LIMIT = 10_000;
69
export const EXACT_REVIEW_LIFECYCLE_AUDIT_PAGE_MAX = 100;
@@ -270,6 +273,17 @@ export class ExactReviewLifecycleProjectionStore {
270273
ON ${EXACT_REVIEW_LIFECYCLE_PROJECTION_TABLE}
271274
(updated_at DESC, canonical_target_key, fence_key, revision)`,
272275
);
276+
this.storage.sql.exec(
277+
`CREATE INDEX IF NOT EXISTS exact_review_lifecycle_projection_bay_repository_v2
278+
ON ${EXACT_REVIEW_LIFECYCLE_PROJECTION_TABLE}
279+
(
280+
LOWER(SUBSTR(canonical_target_key, 1, INSTR(canonical_target_key, '#') - 1)),
281+
updated_at DESC,
282+
canonical_target_key,
283+
fence_key,
284+
revision DESC
285+
)`,
286+
);
273287
this.schemaReady = true;
274288
}
275289

@@ -787,11 +801,14 @@ export class ExactReviewLifecycleProjectionStore {
787801
}
788802

789803
/**
790-
* This reader is intentionally side-effect free. In particular, it does not
791-
* ensure schema, normalize legacy rows, or write an index: the public Bay
792-
* route must never turn an observation into queue maintenance.
804+
* This reader is intentionally side-effect free. Its caller provisions the
805+
* table and indexes through the Durable Object constructor barrier; this
806+
* method does not ensure schema, normalize legacy rows, or write an index.
793807
*/
794-
readBaySnapshot(now = Date.now()): DurableLifecycleBaySnapshot {
808+
readBaySnapshot(
809+
now = Date.now(),
810+
allowedRepositories?: ReadonlySet<string>,
811+
): DurableLifecycleBaySnapshot {
795812
const unknown = (reason: DurableLifecycleBayUnknownReason): DurableLifecycleBaySnapshot => ({
796813
version: 1,
797814
source: "exact-review-lifecycle-projection-v1",
@@ -803,17 +820,55 @@ export class ExactReviewLifecycleProjectionStore {
803820
sample: null,
804821
});
805822

823+
const repositories = allowedRepositories
824+
? [
825+
...new Set([...allowedRepositories].map((repository) => repository.trim().toLowerCase())),
826+
].sort()
827+
: null;
828+
if (
829+
repositories &&
830+
(repositories.length > 32 ||
831+
repositories.some((repository) => !/^[a-z0-9_.-]+\/[a-z0-9_.-]+$/.test(repository)))
832+
) {
833+
return unknown("malformed");
834+
}
835+
806836
let rows: Array<Record<string, unknown>>;
807837
try {
808-
rows = Array.from(
809-
this.storage.sql.exec(
810-
`SELECT projection_json FROM ${EXACT_REVIEW_LIFECYCLE_PROJECTION_TABLE}
811-
ORDER BY updated_at DESC, canonical_target_key ASC, fence_key ASC, revision DESC
812-
LIMIT ?`,
813-
EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT + 1,
814-
),
815-
);
816-
// The fixed 512+1 public source bound is deliberately fail-closed. Do
838+
if (repositories?.length === 0) {
839+
rows = [];
840+
} else if (repositories) {
841+
rows = [];
842+
for (const repository of repositories) {
843+
const remaining = EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT + 1 - rows.length;
844+
const repositoryRows = Array.from(
845+
this.storage.sql.exec(
846+
`SELECT projection_json FROM ${EXACT_REVIEW_LIFECYCLE_PROJECTION_TABLE}
847+
INDEXED BY exact_review_lifecycle_projection_bay_repository_v2
848+
WHERE LOWER(SUBSTR(canonical_target_key, 1, INSTR(canonical_target_key, '#') - 1)) = ?
849+
ORDER BY updated_at DESC, canonical_target_key ASC, fence_key ASC, revision DESC
850+
LIMIT ?`,
851+
repository,
852+
remaining,
853+
),
854+
);
855+
rows.push(...repositoryRows);
856+
if (rows.length > EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT) {
857+
return unknown("over_cap");
858+
}
859+
}
860+
} else {
861+
rows = Array.from(
862+
this.storage.sql.exec(
863+
`SELECT projection_json FROM ${EXACT_REVIEW_LIFECYCLE_PROJECTION_TABLE}
864+
INDEXED BY exact_review_lifecycle_projection_bay
865+
ORDER BY updated_at DESC, canonical_target_key ASC, fence_key ASC, revision DESC
866+
LIMIT ?`,
867+
EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT + 1,
868+
),
869+
);
870+
}
871+
// The fixed bounded public source read is deliberately fail-closed. Do
817872
// not paginate, prune, or otherwise maintain storage while observing it.
818873
if (rows.length > EXACT_REVIEW_LIFECYCLE_BAY_READ_LIMIT) return unknown("over_cap");
819874
} catch {
@@ -831,7 +886,6 @@ export class ExactReviewLifecycleProjectionStore {
831886
} catch {
832887
return unknown("mixed");
833888
}
834-
835889
const maxRevisionByTarget = new Map<string, number>();
836890
for (const projection of projections) {
837891
maxRevisionByTarget.set(

‎dashboard/exact-review-queue.ts‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ export class ExactReviewQueue {
714714
private storage;
715715
private env;
716716
private ready: Promise<void> | null = null;
717+
private lifecycleProjectionReady: Promise<void>;
717718
private migratedAt = 0;
718719
private legacyMirrorDisabled = false;
719720
private legacyMirrorWarningReported = false;
@@ -759,22 +760,43 @@ export class ExactReviewQueue {
759760
);
760761
this.githubEtagResponseStore = new GithubEtagResponseStore(this.storage);
761762
this.githubWebhookReadModelStore = new GithubWebhookReadModelStore(this.storage);
762-
// Direct in-process users retain the established eager setup behavior.
763-
// A real Durable Object has blockConcurrencyWhile; defer that setup until a
764-
// non-Bay request so constructing it for the public pure reader cannot
765-
// initialize or migrate storage before the route is known.
766-
if (typeof state.blockConcurrencyWhile !== "function") {
763+
// The public lifecycle reader remains side-effect free, but its table and
764+
// repository-leading index must exist before the first read. Provision
765+
// only that bounded read schema in the constructor barrier; full queue
766+
// initialization and migration stay deferred until an ordinary request.
767+
if (typeof state.blockConcurrencyWhile === "function") {
768+
this.lifecycleProjectionReady = Promise.resolve(
769+
state.blockConcurrencyWhile(async () => {
770+
this.lifecycleProjectionStore.ensureSchemaSync();
771+
}),
772+
);
773+
} else {
767774
this.ready = this.initializeStorage();
775+
this.lifecycleProjectionReady = this.ready;
768776
}
769777
}
770778

771779
async fetch(request: Request) {
772780
const url = new URL(request.url);
773781
// This is deliberately the only route that may observe lifecycle rows
774-
// before storage initialization. It must stay a pure reader: no schema
775-
// creation, cleanup, queue reclamation, alarm scheduling, or GitHub work.
782+
// before full queue initialization. Its constructor-managed schema barrier
783+
// is already complete; the handler itself performs no schema creation,
784+
// cleanup, queue reclamation, alarm scheduling, or GitHub work.
776785
if (request.method === "GET" && url.pathname === "/lifecycle-bay") {
777-
return json({ durable_lifecycle_bay: this.lifecycleProjectionStore.readBaySnapshot() });
786+
await this.lifecycleProjectionReady.catch(() => undefined);
787+
const publicRepositories = url.searchParams
788+
.getAll("public_repo")
789+
.map((value) => value.trim().toLowerCase());
790+
const validPublicRepositories =
791+
publicRepositories.length <= 32 &&
792+
publicRepositories.every((value) => /^[a-z0-9_.-]+\/[a-z0-9_.-]+$/.test(value));
793+
return json({
794+
durable_lifecycle_bay: !url.searchParams.has("public_repo")
795+
? this.lifecycleProjectionStore.readBaySnapshot()
796+
: validPublicRepositories
797+
? this.lifecycleProjectionStore.readBaySnapshot(Date.now(), new Set(publicRepositories))
798+
: this.lifecycleProjectionStore.readBaySnapshot(Date.now(), new Set()),
799+
});
778800
}
779801
if (request.method === "POST" && url.pathname === "/lifecycle-audit/inventory") {
780802
return this.readLifecycleAuditInventory(await request.json().catch(() => null));

0 commit comments

Comments
 (0)