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
6 changes: 3 additions & 3 deletions src/db/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,7 @@ export async function isGlobalAgentFrozen(env: Env): Promise<boolean> {
try {
const row = await env.DB.prepare("SELECT frozen FROM global_agent_controls WHERE id = 'singleton'").first<{ frozen: number }>();
if (!row) {
console.warn(JSON.stringify({ ev: "global_kill_switch_row_missing", message: "global_agent_controls has no singleton row — treating as unfrozen; re-run migrations or re-seed the row" }));
console.warn(JSON.stringify({ event: "global_kill_switch_row_missing", message: "global_agent_controls has no singleton row — treating as unfrozen; re-run migrations or re-seed the row" }));
if (processLocalGlobalAgentFrozen === null) processLocalGlobalAgentFrozen = false;
return processLocalGlobalAgentFrozen === true;
}
Expand All @@ -2488,8 +2488,8 @@ export async function isGlobalAgentFrozen(env: Env): Promise<boolean> {
return frozen;
} catch (error) {
const message = error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200);
console.warn(JSON.stringify({ ev: "global_kill_switch_read_error", message }));
if (processLocalGlobalAgentFrozen === true) { console.warn(JSON.stringify({ ev: "global_kill_switch_read_error_fail_closed", message: "process-local cache shows frozen=1 — halting agent actions despite the read error" })); return true; }
console.warn(JSON.stringify({ event: "global_kill_switch_read_error", message }));
if (processLocalGlobalAgentFrozen === true) { console.warn(JSON.stringify({ event: "global_kill_switch_read_error_fail_closed", message: "process-local cache shows frozen=1 — halting agent actions despite the read error" })); return true; }
return false;
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/queue/processors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3927,7 +3927,7 @@ async function scheduleTrailingIssueLinkedReReview(
} catch (error) {
console.log(
JSON.stringify({
ev: "issue_link_trailing_enqueue_failed",
event: "issue_link_trailing_enqueue_failed",
repoFullName,
pull: prNumber,
message: errorMessage(error).slice(0, 120),
Expand Down Expand Up @@ -3970,7 +3970,7 @@ async function wakeOverCapSiblingPullRequests(
} catch (error) {
console.log(
JSON.stringify({
ev: "contributor_cap_wake_enqueue_failed",
event: "contributor_cap_wake_enqueue_failed",
repoFullName,
pull: prNumber,
message: errorMessage(error).slice(0, 120),
Expand Down Expand Up @@ -6593,7 +6593,7 @@ async function resolvePullRequestFilesForReview(
if (fetched.length > 0) {
console.log(
JSON.stringify({
ev: "review_files_fetched_inline",
event: "review_files_fetched_inline",
repository: args.repoFullName,
pullNumber: args.pullNumber,
files: fetched.length,
Expand Down Expand Up @@ -8151,7 +8151,7 @@ async function maybePublishPrPublicSurface(
}
console.log(
JSON.stringify({
ev: "type_label_decision",
event: "type_label_decision",
repoFullName,
pull: pr.number,
applied: true,
Expand All @@ -8162,7 +8162,7 @@ async function maybePublishPrPublicSurface(
} catch (error) {
console.log(
JSON.stringify({
ev: "type_label_error",
event: "type_label_error",
repoFullName,
pull: pr.number,
message: errorMessage(error).slice(0, 150),
Expand All @@ -8172,7 +8172,7 @@ async function maybePublishPrPublicSurface(
} else {
console.log(
JSON.stringify({
ev: "type_label_decision",
event: "type_label_decision",
repoFullName,
pull: pr.number,
applied: false,
Expand Down Expand Up @@ -10007,7 +10007,7 @@ async function maybePublishPrPublicSurface(
).catch((error) =>
console.log(
JSON.stringify({
ev: "recapture_enqueue_failed",
event: "recapture_enqueue_failed",
repoFullName,
pull: pr.number,
message: errorMessage(error).slice(0, 120),
Expand All @@ -10018,7 +10018,7 @@ async function maybePublishPrPublicSurface(
} catch (error) {
console.log(
JSON.stringify({
ev: "visual_capture_error",
event: "visual_capture_error",
repoFullName,
pull: pr.number,
message: errorMessage(error).slice(0, 200),
Expand Down Expand Up @@ -10046,7 +10046,7 @@ async function maybePublishPrPublicSurface(
incr("gittensory_review_memory_suppressed_total", { repo: repoFullName });
console.log(
JSON.stringify({
ev: "review_memory_applied",
event: "review_memory_applied",
repoFullName,
pull: pr.number,
suppressedCount,
Expand All @@ -10057,7 +10057,7 @@ async function maybePublishPrPublicSurface(
} catch (error) {
console.log(
JSON.stringify({
ev: "review_memory_error",
event: "review_memory_error",
repoFullName,
pull: pr.number,
message: errorMessage(error).slice(0, 200),
Expand Down
2 changes: 1 addition & 1 deletion src/review/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,6 @@ export async function runAnomalyAlerts(env: Env, config: AlertAgentConfig, deps:
try {
await fetch(webhookUrl, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body), signal: AbortSignal.timeout(10_000) });
} catch (error) {
console.log(JSON.stringify({ ev: "anomaly_alert_error", project: config.slug, message: String(error).slice(0, 200) }));
console.log(JSON.stringify({ event: "anomaly_alert_error", project: config.slug, message: String(error).slice(0, 200) }));
}
}
8 changes: 4 additions & 4 deletions src/review/auto-apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export async function runAutoApplyRecommendations(env: StorageEnv, ctx: AutoAppl
const payload = rec.overridePayload;
if (!isStrictlyTightening(payload, liveFloor, liveCap)) continue;
const res = await applyOverrideRecommendation(env, ctx.project, payload, { force: false, soakMs: SHADOW_SOAK_MS, nowMs: ctx.nowMs });
console.log(JSON.stringify({ ev: "auto_apply_shadowed", project: ctx.project, reason: res.reason }));
console.log(JSON.stringify({ event: "auto_apply_shadowed", project: ctx.project, reason: res.reason }));
break; // one pending soak at a time
}
}
Expand All @@ -359,12 +359,12 @@ export async function runAutoApplyRecommendations(env: StorageEnv, ctx: AutoAppl
await writeLiveOverride(env, ctx.project, shadow.override);
await deleteShadowOverride(env, ctx.project);
await recordOverrideAudit(env, ctx.project, "override_promoted", { override: shadow.override, reason: gate.reason });
console.log(JSON.stringify({ ev: "auto_apply_promoted", project: ctx.project, override: describeOverride(shadow.override) }));
console.log(JSON.stringify({ event: "auto_apply_promoted", project: ctx.project, override: describeOverride(shadow.override) }));
} else {
console.log(JSON.stringify({ ev: "auto_apply_hold", project: ctx.project, reason: gate.reason }));
console.log(JSON.stringify({ event: "auto_apply_hold", project: ctx.project, reason: gate.reason }));
}
}
} catch (error) {
console.log(JSON.stringify({ ev: "auto_apply_error", project: ctx.project, message: String(error).slice(0, 160) }));
console.log(JSON.stringify({ event: "auto_apply_error", project: ctx.project, message: String(error).slice(0, 160) }));
}
}
4 changes: 2 additions & 2 deletions src/review/auto-tune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function applyAutoTune(flags: FlagStore, report: GateEvalReport): P
await flags.setFlag(`holdonly:${action.project}`, true);
engaged.push(action);
} catch (error) {
console.log(JSON.stringify({ ev: "auto_tune_error", project: action.project, message: String(error).slice(0, 120) }));
console.log(JSON.stringify({ event: "auto_tune_error", project: action.project, message: String(error).slice(0, 120) }));
}
}
return engaged;
Expand Down Expand Up @@ -198,7 +198,7 @@ export async function applyCloseAutoTune(flags: FlagStore, report: GateEvalRepor
await flags.setFlag(`closehold:${action.project}`, true);
engaged.push(action);
} catch (error) {
console.log(JSON.stringify({ ev: "close_tune_error", project: action.project, message: String(error).slice(0, 120) }));
console.log(JSON.stringify({ event: "close_tune_error", project: action.project, message: String(error).slice(0, 120) }));
}
}
return engaged;
Expand Down
2 changes: 1 addition & 1 deletion src/review/linked-issue-label-propagation-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function resolveIssueLabelsForPropagation(
if (kept.length < allLabels.length && allLabels.length > 0) {
console.log(
JSON.stringify({
ev: "linked_issue_label_propagation_filtered",
event: "linked_issue_label_propagation_filtered",
repoFullName: args.repoFullName,
issueNumber: result.facts.number,
reason: maintainerAuthored ? "strict_label_requires_direct_ownership" : "no_direct_ownership_match",
Expand Down
18 changes: 9 additions & 9 deletions src/review/outcomes-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function isHoldOnly(env: Env, project: string): Promise<boolean> {
} catch (error) {
console.warn(
JSON.stringify({
ev: "flags_read_error",
event: "flags_read_error",
message: errorMessage(error).slice(0, 120),
}),
);
Expand All @@ -96,7 +96,7 @@ export async function isCloseHoldOnly(
} catch (error) {
console.warn(
JSON.stringify({
ev: "flags_read_error",
event: "flags_read_error",
message: errorMessage(error).slice(0, 120),
}),
);
Expand Down Expand Up @@ -136,7 +136,7 @@ async function listEngagedProjectScopes(env: Env): Promise<{ holdonly: string[];
} catch (error) {
console.warn(
JSON.stringify({
ev: "flags_read_error",
event: "flags_read_error",
message: errorMessage(error).slice(0, 120),
}),
);
Expand Down Expand Up @@ -242,8 +242,8 @@ async function appendReviewAudit(
} catch (error) {
console.warn(
JSON.stringify({
ev: "review_audit_record_error",
event: input.eventType,
event: "review_audit_record_error",
auditEventType: input.eventType,
project: input.project,
message: errorMessage(error).slice(0, 160),
}),
Expand Down Expand Up @@ -331,7 +331,7 @@ export async function recordPrOutcome(
}).catch((error) =>
console.warn(
JSON.stringify({
ev: "pr_outcome_audit_error",
event: "pr_outcome_audit_error",
message: errorMessage(error).slice(0, 160),
}),
),
Expand Down Expand Up @@ -554,18 +554,18 @@ export async function runSelfTuneBreaker(env: Env): Promise<void> {
const closeClearCandidates = new Set([...report.rows.map((row) => row.project), ...engagedScopes.closehold]);
for (const project of mergeClearCandidates) {
if (await maybeAutoClearHoldOnly(flags, report, project, nowMs)) {
console.log(JSON.stringify({ ev: "breaker_auto_cleared", project }));
console.log(JSON.stringify({ event: "breaker_auto_cleared", project }));
}
}
for (const project of closeClearCandidates) {
if (await maybeAutoClearCloseHoldOnly(flags, report, project, nowMs)) {
console.log(JSON.stringify({ ev: "close_breaker_auto_cleared", project }));
console.log(JSON.stringify({ event: "close_breaker_auto_cleared", project }));
}
}
} catch (error) {
console.warn(
JSON.stringify({
ev: "breaker_tick_error",
event: "breaker_tick_error",
message: errorMessage(error).slice(0, 200),
}),
);
Expand Down
2 changes: 1 addition & 1 deletion src/review/parity-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export async function recordNativeGateDecision(
.run();
} catch (error) {
// Telemetry must never break finalization.
console.warn(JSON.stringify({ ev: "parity_audit_record_error", project, pr: input.pullNumber, message: errorMessage(error).slice(0, 200) }));
console.warn(JSON.stringify({ event: "parity_audit_record_error", project, pr: input.pullNumber, message: errorMessage(error).slice(0, 200) }));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/review/prompt-injection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ export function neutralizePromptInjection(text: string): { text: string; injecte
* verdict. Returns the safe title for the prompt. (#271 review-path injection) */
export function safeReviewTitle(target: { title?: string; repo?: string; number?: number }): string {
const { text, injected } = neutralizePromptInjection(target.title ?? "");
if (injected) console.log(JSON.stringify({ ev: "prompt_injection_neutralized", repo: target.repo, pr: target.number, field: "title" }));
if (injected) console.log(JSON.stringify({ event: "prompt_injection_neutralized", repo: target.repo, pr: target.number, field: "title" }));
return text;
}
8 changes: 4 additions & 4 deletions src/review/rag-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async function fetchRepoTree(env: Env, repoFullName: string, ref: string, token:
}
return entries;
} catch (error) {
console.error(JSON.stringify({ level: "error", event: "rag_index_tree_error", ev: "rag_index_tree_error", repo: repoFullName, message: String(error).slice(0, 200) }));
console.error(JSON.stringify({ level: "error", event: "rag_index_tree_error", repo: repoFullName, message: String(error).slice(0, 200) }));
return null;
}
}
Expand Down Expand Up @@ -220,7 +220,7 @@ export async function listStoredChunkPaths(infra: ReturnType<typeof createReview
.all<{ path: string }>();
return (rows.results ?? []).map((row) => row.path).filter((path) => typeof path === "string" && path.length > 0);
} catch (error) {
console.error(JSON.stringify({ level: "error", event: "rag_list_paths_error", ev: "rag_list_paths_error", project, repo, message: String(error).slice(0, 200) }));
console.error(JSON.stringify({ level: "error", event: "rag_list_paths_error", project, repo, message: String(error).slice(0, 200) }));
return [];
}
}
Expand Down Expand Up @@ -312,7 +312,7 @@ export async function indexRepo(
}
}
console.log(
JSON.stringify({ ev: "rag_index_repo", project, repo: repoFullName, files: filesIndexed, indexed: upserted, capped }),
JSON.stringify({ event: "rag_index_repo", project, repo: repoFullName, files: filesIndexed, indexed: upserted, capped }),
);
return { indexed: upserted, files: filesIndexed, capped };
} catch (error) {
Expand Down Expand Up @@ -379,7 +379,7 @@ export async function reindexChangedPaths(
}
}
console.log(
JSON.stringify({ ev: "rag_reindex_paths", project, repo: repoFullName, paths: unique.length, files: filesIndexed, indexed: upserted, capped }),
JSON.stringify({ event: "rag_reindex_paths", project, repo: repoFullName, paths: unique.length, files: filesIndexed, indexed: upserted, capped }),
);
return { indexed: upserted, files: filesIndexed, capped };
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/review/rag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ export async function retrieveContextWithMetrics(
// context was injected) instead of flying blind — feeds tuning of minScore/topK + the /stats readout.
console.log(
JSON.stringify({
ev: "rag_retrieve",
event: "rag_retrieve",
project: opts.project,
repo: opts.repo,
candidates: metrics.candidates,
Expand Down
4 changes: 2 additions & 2 deletions src/review/selftune-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ export async function runSelfTune(env: Env): Promise<void> {
nowMs,
});
} catch (error) {
console.warn(JSON.stringify({ ev: "selftune_repo_error", repo: repoFullName, message: errorMessage(error).slice(0, 200) }));
console.warn(JSON.stringify({ event: "selftune_repo_error", repo: repoFullName, message: errorMessage(error).slice(0, 200) }));
}
}
} catch (error) {
console.warn(JSON.stringify({ ev: "selftune_error", message: errorMessage(error).slice(0, 200) }));
console.warn(JSON.stringify({ event: "selftune_error", message: errorMessage(error).slice(0, 200) }));
}
}
2 changes: 1 addition & 1 deletion src/review/submitter-reputation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export async function recordSubmissionOutcome(env: Env, project: string, submitt
.bind(project, submitter)
.run();
} catch (error) {
console.log(JSON.stringify({ ev: "reputation_record_error", message: String(error).slice(0, 150) }));
console.log(JSON.stringify({ event: "reputation_record_error", message: String(error).slice(0, 150) }));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/review/visual/preview-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function getLatestDeploymentStatus(params: {
// 404 → the ref genuinely has no deployments. Any other failure (403 missing scope, rate limit, 5xx) is
// NOT "no preview"; report `error` so the caller keeps polling rather than showing a false terminal state.
if (error instanceof PreviewGitHubError && error.status === 404) return { url: null, failed: false };
console.log(JSON.stringify({ ev: "deployment_lookup_error", repo: `${params.repo.owner}/${params.repo.repo}`, selector, message: String(error).slice(0, 200) }));
console.log(JSON.stringify({ event: "deployment_lookup_error", repo: `${params.repo.owner}/${params.repo.repo}`, selector, message: String(error).slice(0, 200) }));
return { url: null, failed: false, error: true };
}
const ids = deployments.map((d) => d.id).filter((id): id is number => id != null);
Expand All @@ -117,7 +117,7 @@ export async function getLatestDeploymentStatus(params: {
apiVersion: params.apiVersion,
rateLimitAdmissionKey: params.rateLimitAdmissionKey,
}).catch((error) => {
console.log(JSON.stringify({ ev: "deployment_status_error", deployment: id, message: String(error).slice(0, 200) }));
console.log(JSON.stringify({ event: "deployment_status_error", deployment: id, message: String(error).slice(0, 200) }));
return [] as Array<{ state?: string; environment_url?: string }>;
}),
),
Expand Down Expand Up @@ -195,7 +195,7 @@ export async function findPreviewUrlFromChecks(params: {
if (url) return url;
}
} catch (error) {
console.log(JSON.stringify({ ev: "preview_from_checks_error", repo: `${params.repo.owner}/${params.repo.repo}`, message: String(error).slice(0, 200) }));
console.log(JSON.stringify({ event: "preview_from_checks_error", repo: `${params.repo.owner}/${params.repo.repo}`, message: String(error).slice(0, 200) }));
}
return null;
}
Expand Down Expand Up @@ -228,7 +228,7 @@ export async function findPreviewUrlFromPrComments(params: {
if (url) return url;
}
} catch (error) {
console.log(JSON.stringify({ ev: "preview_from_comments_error", repo: `${params.repo.owner}/${params.repo.repo}`, message: String(error).slice(0, 200) }));
console.log(JSON.stringify({ event: "preview_from_comments_error", repo: `${params.repo.owner}/${params.repo.repo}`, message: String(error).slice(0, 200) }));
}
return null;
}
Expand Down
Loading