feat(autonomy): add budget guard, compensation registry, agent-jobs D…#14
Open
cryptoxdog wants to merge 1 commit into
Open
feat(autonomy): add budget guard, compensation registry, agent-jobs D…#14cryptoxdog wants to merge 1 commit into
cryptoxdog wants to merge 1 commit into
Conversation
…DL, and per-module autonomy workflow - .github/workflows/autonomy-ops.yml — NEW workflow (does not touch existing ci.yml) - src/core/budget-guard.ts — AgentBudgetGuard aligned with existing TokenBudget policy - src/core/compensation.ts — CompensationRegistry saga/rollback for external mutations - src/core/schema-additions.sql — agent_jobs, budget_violations, compensation_log DDL (additive; does not modify existing Drizzle schema.ts) - adr/0005-autonomy-runtime-controls.md — Architecture decision record for this upgrade
| `Admission rejected for job=${this.jobId} client=${this.clientId}: forecast $${this.forecastUsd.toFixed(4)} > cap $${this.capUsd.toFixed(4)}`, | ||
| ); | ||
| } | ||
| logger.info({ jobId: this.jobId, clientId: this.clientId, capUsd: this.capUsd }, 'budget_guard:opened'); |
| this.actualUsd += actualUsd; | ||
| this.reservedUsd = Math.max(0, this.reservedUsd - actualUsd); | ||
| this.forecastUsd = this.actualUsd + this.reservedUsd + nextEstimateUsd; | ||
| logger.debug({ jobId: this.jobId, actualUsd: this.actualUsd, forecastUsd: this.forecastUsd }, 'budget_guard:reconciled'); |
| */ | ||
| register(stepId: string, action: () => Promise<void>): void { | ||
| this.entries.push({ stepId, clientId: this.clientId, action, registeredAt: new Date() }); | ||
| logger.debug({ jobId: this.jobId, stepId, clientId: this.clientId }, 'compensation:registered'); |
| try { | ||
| await entry.action(); | ||
| results.push({ stepId: entry.stepId }); | ||
| logger.info({ jobId: this.jobId, stepId: entry.stepId }, 'compensation:ok'); |
| } catch (err) { | ||
| const message = err instanceof Error ? err.message : String(err); | ||
| results.push({ stepId: entry.stepId, error: message }); | ||
| logger.error({ jobId: this.jobId, stepId: entry.stepId, message }, 'compensation:failed'); |
| else if (pressure < 0.95) this.mode = 'narrow_scope'; | ||
| else if (pressure < 1.00) this.mode = 'require_approval'; | ||
| else this.mode = 'stop'; | ||
| logger.warn({ jobId: this.jobId, mode: this.mode, pressure: pressure.toFixed(3) }, 'budget_guard:mode_changed'); |
| * Moves: Open (admission) → Reserve → Reconcile → Enforce | ||
| */ | ||
|
|
||
| import { getConfig } from './config.js'; |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


…DL, and per-module autonomy workflow
Summary
Type of Change
Governance Checklist
setup_workspace_symlinks.sh, symlinks resolve (§2)ls -la .cursor/rules .cursor/skills .cursor/commandsall resolve@v1, never@mainor bare SHABreaking Change
If checked, describe the impact and migration path:
Rollback Plan
Related Issues
Closes #