Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cloudflare-gastown/src/dos/town/beads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import type {
BeadStatus,
BeadPriority,
BeadType,
FailureReason,
} from '../../types';
import type { BeadEventType } from '../../db/tables/bead-events.table';

Expand Down Expand Up @@ -255,7 +256,8 @@ export function updateBeadStatus(
sql: SqlStorage,
beadId: string,
status: string,
agentId: string | null
agentId: string | null,
failureReason?: FailureReason
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: The new failureReason parameter is not exposed through the DO boundary

cloudflare-gastown/src/dos/Town.do.ts:728 still exposes updateBeadStatus(beadId, status, agentId) and forwards only those three arguments into beadOps.updateBeadStatus(...). Any caller that goes through the RPC/HTTP/TRPC path still has no way to persist a FailureReason, so this metadata is only reachable from code already running inside the DO.

): Bead {
const bead = getBead(sql, beadId);
if (!bead) throw new Error(`Bead ${beadId} not found`);
Expand Down Expand Up @@ -285,6 +287,7 @@ export function updateBeadStatus(
eventType: 'status_changed',
oldValue: oldStatus,
newValue: status,
metadata: status === 'failed' && failureReason ? { failure_reason: failureReason } : {},
});

// If the bead reached a terminal status and is tracked by a convoy,
Expand Down Expand Up @@ -1005,7 +1008,14 @@ export function addBeadToConvoy(sql: SqlStorage, beadId: string, convoyId: strin
const metadataPatch: Record<string, unknown> = { convoy_id: convoyId };
if (featureBranch) metadataPatch.feature_branch = featureBranch;

<<<<<<< convoy/bead-failure-reasons-1172/22d1b15b/gt/ember/184533ed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Unresolved merge conflict markers left in committed code

This <<<<<<< / ======= / >>>>>>> block makes beads.ts invalid TypeScript, so the Town DO will fail to build until one side of the conflict is removed.

const existingMetadata = z
.record(z.string(), z.unknown())
.catch({})
.parse(typeof bead.metadata === 'string' ? JSON.parse(bead.metadata) : (bead.metadata ?? {}));
=======
const existingMetadata = cloneBeadMetadata(bead.metadata);
>>>>>>> gastown-staging
const merged = { ...existingMetadata, ...metadataPatch };

query(
Expand Down Expand Up @@ -1076,7 +1086,14 @@ export function removeBeadFromConvoy(sql: SqlStorage, beadId: string): string |
// Strip convoy_id + feature_branch from metadata
const bead = getBead(sql, beadId);
if (bead) {
<<<<<<< convoy/bead-failure-reasons-1172/22d1b15b/gt/ember/184533ed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Second unresolved merge conflict block

This conflict marker sequence has the same problem as the earlier block: the file cannot compile while these markers are present.

const existingMetadata = z
.record(z.string(), z.unknown())
.catch({})
.parse(typeof bead.metadata === 'string' ? JSON.parse(bead.metadata) : (bead.metadata ?? {}));
=======
const existingMetadata = cloneBeadMetadata(bead.metadata);
>>>>>>> gastown-staging
delete existingMetadata.convoy_id;
delete existingMetadata.feature_branch;
const timestamp = now();
Expand Down
13 changes: 13 additions & 0 deletions cloudflare-gastown/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ export type PatrolResult = {
orphaned_beads: string[];
};

// -- Failure Reasons --

export type FailureReason = {
/** Machine-readable failure code */
code: string;
/** Human-readable summary */
message: string;
/** Optional detail: stack trace, error output, container logs */
details?: string;
/** What triggered the failure: 'scheduler' | 'patrol' | 'refinery' | 'triage' | 'admin' | 'container' */
source: string;
};

// -- Merge Strategy --

export const MergeStrategy = z.enum(['direct', 'pr']);
Expand Down
Loading