Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3bf3205
feat(linear): stream task progress into the agent session (#1066)
isadeks Nov 20, 2026
9f58ea2
fix(cli): honest Linear vault fallback status and a re-asking identit…
isadeks Nov 5, 2026
26786d2
style(cli): end files with a single newline (end-of-file hook)
isadeks Nov 16, 2026
25a6e9d
feat(linear): default the Identity vault on wherever AgentCore is dep…
isadeks Nov 5, 2026
15287c1
docs(linear): say when enableLinearIdentityVault=true still matters
isadeks Nov 5, 2026
e38fbce
refactor(cdk): resolveLinearIdentityVault is used only in its own fil…
isadeks Nov 16, 2026
a2206aa
fix(cdk): default the Linear vault on only when Linear is deployed
isadeks Nov 16, 2026
c46d2a1
fix(linear): detect dead Linear grants even when no Linear events arr…
isadeks Nov 5, 2026
9586e84
refactor(linear): GRANT_HEALTH_PROBE_INTERVAL_HOURS is used only in i…
isadeks Nov 16, 2026
b2d083a
fix(linear): approval notices and approve/deny replies on Linear issu…
isadeks Nov 5, 2026
589fcce
fix(linear): pass the new complexity ceiling and coverage contract
isadeks Nov 16, 2026
2faaaf0
fix(linear): carry the vault, grant-probe and approval-reply changes …
isadeks Nov 25, 2026
8bcf2f5
feat(linear): approval requests in the agent session, and redact what…
isadeks Nov 25, 2026
c81d431
feat(approvals): 30-minute approval window by default, settable per repo
isadeks Nov 25, 2026
31a071e
fix(linear): Linear's delegation comment is not the task's instruction
isadeks Nov 25, 2026
2ebff9c
feat(linear): Approve for this task in the agent session
isadeks Nov 25, 2026
257c00f
fix(linear): read tool-input fields with one fixed pattern, not a reg…
isadeks Nov 26, 2026
d2eee27
fix(linear): a session prompt that starts with "deny" is work, not a …
isadeks Nov 26, 2026
1ac627c
fix(cli): repo onboard keeps the Blueprint approval window
isadeks Nov 26, 2026
27a8d05
fix(cdk): a Blueprint redeploy without approvalTimeoutSeconds removes…
isadeks Nov 26, 2026
121d083
refactor(linear): drop duplicated PR-label parsing, dead guards and r…
isadeks Nov 26, 2026
76db21e
fix(linear): a session approval is read back from Linear before it is…
isadeks Nov 26, 2026
27fceaf
fix(admission): announce each queue heartbeat mark once, however runs…
isadeks Nov 26, 2026
e059eb7
Merge branch 'main' into feat/1066-linear-session-progress
isadeks Nov 26, 2026
4f5d7c4
fix(linear): an approval button decides only the request it was shown…
isadeks Nov 26, 2026
10183e4
fix(linear): a finished session task moves its issue only to a state …
isadeks Nov 26, 2026
3664651
fix(linear): a session answer decides only the request open when it w…
isadeks Nov 26, 2026
183eecd
fix(linear): a session answer counts only if Linear recorded it after…
isadeks Nov 26, 2026
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
14 changes: 8 additions & 6 deletions agent/policies/soft_deny.cedar
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ permit (principal, action, resource);
// `security.cedarPolicies.disable: [rule_id]`. They may NOT disable any
// rule in hard_deny.cedar (blueprint loader rejects those at task start).

// Gate any git --force / -f push. 300s default approval window, medium severity.
// Gate any git --force / -f push. Medium severity. Each built-in rule allows the
// platform maximum (3600s), so the task's window decides (default 1800s, per repo
// via security.approvalTimeoutSeconds, per task via approval_timeout_s).
// Covers both long-form (--force) and short-form (-f) variants, including
// the bare `git push -f` invocation with no branch argument, and the flag
// after the remote and branch (`git push origin feature --force`). After
Expand All @@ -37,7 +39,7 @@ permit (principal, action, resource);
// other option that begins with `-f`.
@tier("soft")
@rule_id("force_push_any")
@approval_timeout_s("300")
@approval_timeout_s("3600")
@severity("medium")
@category("destructive")
forbid (principal, action == Agent::Action::"execute_bash", resource)
Expand All @@ -61,7 +63,7 @@ when { context.command like "*git push --force*"
// merging picks min(300, 600)=300s and max(medium, high)=high.
@tier("soft")
@rule_id("force_push_main")
@approval_timeout_s("600")
@approval_timeout_s("3600")
@severity("high")
@category("destructive")
forbid (principal, action == Agent::Action::"execute_bash", resource)
Expand All @@ -74,7 +76,7 @@ when { context.command like "*git push --force origin main*"
// agent bypasses PR workflow by pushing directly.
@tier("soft")
@rule_id("push_to_protected_branch")
@approval_timeout_s("300")
@approval_timeout_s("3600")
@severity("medium")
@category("destructive")
forbid (principal, action == Agent::Action::"execute_bash", resource)
Expand All @@ -86,7 +88,7 @@ when { context.command like "*git push origin main*"
// Writes to `.env` files typically contain secrets. 600s window, high severity.
@tier("soft")
@rule_id("write_env_files")
@approval_timeout_s("600")
@approval_timeout_s("3600")
@severity("high")
@category("filesystem")
forbid (principal, action == Agent::Action::"write_file", resource)
Expand All @@ -96,7 +98,7 @@ when { context.file_path like "*.env" };
// service-account JSON, etc. 300s window, high severity.
@tier("soft")
@rule_id("write_credentials")
@approval_timeout_s("300")
@approval_timeout_s("3600")
@severity("high")
@category("auth")
forbid (principal, action == Agent::Action::"write_file", resource)
Expand Down
2 changes: 2 additions & 0 deletions agent/src/output_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class ScanResult:
),
# Slack tokens (xoxb-, xoxp-, ...)
("SLACK_TOKEN", re.compile(r"\bxox[baprs]-[A-Za-z0-9-]{10,}\b")),
# Linear personal API keys (lin_api_) and OAuth access tokens (lin_oauth_).
("LINEAR_TOKEN", re.compile(r"\blin_(?:api|oauth)_[A-Za-z0-9]{16,}")),
# Generic Bearer / token patterns (min 20-char token to avoid false positives
# on natural English like "bearer of good news")
("BEARER_TOKEN", re.compile(r"Bearer\s+[a-zA-Z0-9\-._~+/]{20,}=*", re.IGNORECASE)),
Expand Down
2 changes: 1 addition & 1 deletion agent/tests/test_blueprint_cedar_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_guide_hard_rule_matches_the_prod_directory(guide_policies, tool, path,
assert "block_prod_writes" in decision.reason


@pytest.mark.parametrize(("task_timeout", "expected"), [(None, 300), (600, 600), (3600, 900)])
@pytest.mark.parametrize(("task_timeout", "expected"), [(None, 900), (600, 600), (3600, 900)])
def test_guide_soft_rule_uses_shorter_approval_window(guide_policies, task_timeout, expected):
engine = engine_for(guide_policies, timeout_s=task_timeout)
decision = engine.evaluate_tool_use("Bash", {"command": "terraform apply"})
Expand Down
9 changes: 5 additions & 4 deletions agent/tests/test_policy_three_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,20 @@ def test_soft_deny_force_push_returns_require_approval(self):
d = engine.evaluate_tool_use("Bash", {"command": "git push --force origin feature"})
assert d.outcome == Outcome.REQUIRE_APPROVAL
assert "force_push_any" in d.matching_rule_ids
assert d.timeout_s == 300
# The rule allows 3600s; the task default (1800s) decides.
assert d.timeout_s == 1800
assert d.severity == "medium"

def test_soft_deny_multi_match_merges_annotations(self):
# force_push_any (300s, medium) + force_push_main (600s, high) both
# match "git push --force origin main". Merge picks min(300, 600)=300s
# force_push_any (3600s, medium) + force_push_main (3600s, high) both
# match "git push --force origin main". Merge picks min(3600, 3600, 1800)=1800s
# and max(medium, high)=high. §6.3.
engine = PolicyEngine(task_type="new_task", repo="owner/repo")
d = engine.evaluate_tool_use("Bash", {"command": "git push --force origin main"})
assert d.outcome == Outcome.REQUIRE_APPROVAL
assert "force_push_any" in d.matching_rule_ids
assert "force_push_main" in d.matching_rule_ids
assert d.timeout_s == 300 # min across rules + task default
assert d.timeout_s == 1800 # min across rules (3600) + task default (1800)
assert d.severity == "high" # max across rules

def test_default_allow_on_no_match(self):
Expand Down
3 changes: 3 additions & 0 deletions cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
"tsconfig": "tsconfig.jest.json"
}
]
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
}
}
}
60 changes: 57 additions & 3 deletions cdk/src/constructs/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const DOMAIN_PATTERN = /^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9
*/
const APPROVAL_GATE_CAP_MIN = sharedConstants.approval_gate_cap.min;
const APPROVAL_GATE_CAP_MAX = sharedConstants.approval_gate_cap.max;
const APPROVAL_TIMEOUT_S_MIN = sharedConstants.approval_timeout_s.min;
const APPROVAL_TIMEOUT_S_MAX = sharedConstants.approval_timeout_s.max;

/**
* Bounds on a per-repo cost budget (#748). Same JSON the task-submit path
Expand Down Expand Up @@ -209,6 +211,18 @@ export interface BlueprintProps {
* back to the platform default of 50 defined in the handler layer.
*/
readonly approvalGateCap?: number;

/**
* How long, in seconds, a person has to answer an approval request on this
* repo's tasks before it is denied. Captured at task-submit time onto the
* TaskRecord; a task submitted with its own ``approval_timeout_s`` keeps
* that. A rule's own ``@approval_timeout_s`` still caps it for that rule.
*
* Must be an integer in the platform's ``approval_timeout_s`` range
* (``contracts/constants.json``: 30 to 3600). When omitted, the platform
* default applies.
*/
readonly approvalTimeoutSeconds?: number;
};

/**
Expand Down Expand Up @@ -277,6 +291,9 @@ export class Blueprint extends Construct {
*/
public readonly approvalGateCap?: number;

/** Default approval window in seconds from security.approvalTimeoutSeconds, if set. */
public readonly approvalTimeoutSeconds?: number;

/**
* Per-repo cost budget in USD from the agent.maxBudgetUsd prop (#748),
* exposed for inspection. Undefined when the blueprint did not configure
Expand Down Expand Up @@ -306,7 +323,7 @@ export class Blueprint extends Construct {

this.egressAllowlist = [...(props.networking?.egressAllowlist ?? [])];
this.cedarPolicies = [...(props.security?.cedarPolicies ?? [])];
this.approvalGateCap = props.security?.approvalGateCap;
({ approvalGateCap: this.approvalGateCap, approvalTimeoutSeconds: this.approvalTimeoutSeconds } = approvalSettings(props));
const { maxBudgetUsd, memoryTokenBudget } = props.agent ?? {};
this.maxBudgetUsd = maxBudgetUsd;
this.memoryTokenBudget = memoryTokenBudget;
Expand All @@ -331,6 +348,7 @@ export class Blueprint extends Construct {
this.node.addValidation(new RepoFormatValidation(props.repo));
this.node.addValidation(new DomainFormatValidation(this.egressAllowlist));
this.node.addValidation(new ApprovalGateCapValidation(this.approvalGateCap));
this.node.addValidation(new ApprovalTimeoutValidation(this.approvalTimeoutSeconds));
this.node.addValidation(new MaxBudgetUsdValidation(this.maxBudgetUsd));
this.node.addValidation(new MemoryTokenBudgetValidation(this.memoryTokenBudget));
this.node.addValidation(new RegistryRefValidation('assets.mcpServers', this.mcpServerRefs, 'mcp_server'));
Expand Down Expand Up @@ -396,6 +414,9 @@ export class Blueprint extends Construct {
if (this.approvalGateCap !== undefined) {
item.approval_gate_cap = { N: String(this.approvalGateCap) };
}
if (this.approvalTimeoutSeconds !== undefined) {
item.approval_timeout_s = { N: String(this.approvalTimeoutSeconds) };
}
if (this.mcpServerRefs.length > 0) {
item.mcp_servers = { L: this.mcpServerRefs.map(r => ({ S: r })) };
}
Expand Down Expand Up @@ -482,6 +503,7 @@ export class Blueprint extends Construct {
if (this.egressAllowlist.length > 0) fields.push(', #egress_allowlist = :egress_allowlist');
if (this.cedarPolicies.length > 0) fields.push(', #cedar_policies = :cedar_policies');
if (this.approvalGateCap !== undefined) fields.push(', #approval_gate_cap = :approval_gate_cap');
if (this.approvalTimeoutSeconds !== undefined) fields.push(', #approval_timeout_s = :approval_timeout_s');
// Registry asset refs (#246) — must mirror onCreate's item, else a redeploy
// of an already-onboarded repo silently drops asset-ref changes.
if (this.mcpServerRefs.length > 0) fields.push(', #mcp_servers = :mcp_servers');
Expand All @@ -506,6 +528,7 @@ export class Blueprint extends Construct {
if (this.egressAllowlist.length > 0) names['#egress_allowlist'] = 'egress_allowlist';
if (this.cedarPolicies.length > 0) names['#cedar_policies'] = 'cedar_policies';
if (this.approvalGateCap !== undefined) names['#approval_gate_cap'] = 'approval_gate_cap';
if (this.approvalTimeoutSeconds !== undefined) names['#approval_timeout_s'] = 'approval_timeout_s';
if (this.mcpServerRefs.length > 0) names['#mcp_servers'] = 'mcp_servers';
if (this.cedarPolicyModuleRefs.length > 0) names['#cedar_policy_modules'] = 'cedar_policy_modules';
if (this.skillRefs.length > 0) names['#skills'] = 'skills';
Expand All @@ -528,6 +551,7 @@ export class Blueprint extends Construct {
if (this.egressAllowlist.length > 0) values[':egress_allowlist'] = { L: this.egressAllowlist.map(d => ({ S: d })) };
if (this.cedarPolicies.length > 0) values[':cedar_policies'] = { L: this.cedarPolicies.map(p => ({ S: p })) };
if (this.approvalGateCap !== undefined) values[':approval_gate_cap'] = { N: String(this.approvalGateCap) };
if (this.approvalTimeoutSeconds !== undefined) values[':approval_timeout_s'] = { N: String(this.approvalTimeoutSeconds) };
if (this.mcpServerRefs.length > 0) values[':mcp_servers'] = { L: this.mcpServerRefs.map(r => ({ S: r })) };
if (this.cedarPolicyModuleRefs.length > 0) values[':cedar_policy_modules'] = { L: this.cedarPolicyModuleRefs.map(r => ({ S: r })) };
if (this.skillRefs.length > 0) values[':skills'] = { L: this.skillRefs.map(r => ({ S: r })) };
Expand All @@ -546,14 +570,19 @@ export class Blueprint extends Construct {
return empty;
}

/** Asset fields now empty, and an approval window no longer set: only the Blueprint writes it. */
private removedFields(): string[] {
return [...this.emptyAssetFields(), ...(this.approvalTimeoutSeconds === undefined ? ['approval_timeout_s'] : [])];
}

private buildRemoveClause(): string {
const fields = this.emptyAssetFields();
const fields = this.removedFields();
return fields.length > 0 ? ` REMOVE ${fields.map(f => `#${f}`).join(', ')}` : '';
}

private buildRemoveNames(): Record<string, string> {
const names: Record<string, string> = {};
const fields = this.emptyAssetFields();
const fields = this.removedFields();
for (const f of fields) names[`#${f}`] = f;
return names;
}
Expand Down Expand Up @@ -617,6 +646,31 @@ class ApprovalGateCapValidation implements IValidation {
}
}

/** The blueprint's approval settings (read here to keep the constructor under the complexity ceiling). */
function approvalSettings(props: BlueprintProps): { approvalGateCap?: number; approvalTimeoutSeconds?: number } {
const security = props.security ?? {};
return { approvalGateCap: security.approvalGateCap, approvalTimeoutSeconds: security.approvalTimeoutSeconds };
}

/** Validates ``security.approvalTimeoutSeconds`` against the platform's ``approval_timeout_s`` range. */
class ApprovalTimeoutValidation implements IValidation {
constructor(private readonly seconds: number | undefined) {}

public validate(): string[] {
if (this.seconds === undefined) return [];
if (!Number.isInteger(this.seconds)) {
return [`Invalid security.approvalTimeoutSeconds: ${this.seconds}. Must be an integer.`];
}
if (this.seconds < APPROVAL_TIMEOUT_S_MIN || this.seconds > APPROVAL_TIMEOUT_S_MAX) {
return [
`Invalid security.approvalTimeoutSeconds: ${this.seconds}. `
+ `Must be between ${APPROVAL_TIMEOUT_S_MIN} and ${APPROVAL_TIMEOUT_S_MAX}.`,
];
}
return [];
}
}

/**
* #748 — validates the per-repo cost budget is a finite number inside
* ``[MAX_BUDGET_USD_MIN, MAX_BUDGET_USD_MAX]``. Bounds come from
Expand Down
19 changes: 18 additions & 1 deletion cdk/src/constructs/concurrency-reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Duration } from 'aws-cdk-lib';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import * as events from 'aws-cdk-lib/aws-events';
import * as targets from 'aws-cdk-lib/aws-events-targets';
import { Runtime, Architecture } from 'aws-cdk-lib/aws-lambda';
import { Runtime, Architecture, type IFunction } from 'aws-cdk-lib/aws-lambda';
import * as lambda from 'aws-cdk-lib/aws-lambda-nodejs';
import { NagSuppressions } from 'cdk-nag';
import { Construct } from 'constructs';
Expand Down Expand Up @@ -92,6 +92,7 @@ export class ConcurrencyReconciler extends Construct {
props.userConcurrencyTable.grantReadWriteData(this.fn);

const schedule = props.schedule ?? Duration.minutes(DEFAULT_SCHEDULE_MINUTES);
this.fn.addEnvironment('RECONCILER_TICK_MINUTES', String(schedule.toMinutes()));
const rule = new events.Rule(this, 'ReconcilerSchedule', {
schedule: events.Schedule.rate(schedule),
});
Expand All @@ -108,4 +109,20 @@ export class ConcurrencyReconciler extends Construct {
},
], true);
}

/**
* Have this reconciler invoke the Linear webhook processor's grant health probe
* (#1004) on one tick every 12 h.
*
* Revocation detection (#812) only runs when a Linear event needs a token, so an
* idle workspace or a dead webhook never re-detects a dead grant, and an unused
* refresh token simply expires. The probe refreshes expiring tokens and sends a
* rejected grant down the existing latch-and-announce path. It rides this
* schedule by async invoke because the root stack has no resource budget for a
* rule of its own: this adds only an IAM statement and two env vars.
*/
public triggerLinearGrantProbe(processor: IFunction): void {
this.fn.addEnvironment('LINEAR_GRANT_PROBE_FUNCTION_ARN', processor.functionArn);
processor.grantInvoke(this.fn);
}
}
11 changes: 11 additions & 0 deletions cdk/src/constructs/fanout-consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export interface FanOutConsumerProps {
*/
readonly taskTable?: dynamodb.ITable;

/**
* Approval state for channel approval notices (#1001): the dispatcher renders
* from the saved row, records per-request delivery receipts and the Linear
* reply-thread mapping.
*/
readonly taskApprovalsTable?: dynamodb.ITable;

/**
* RepoTable — GitHub dispatcher reads per-repo
* `github_token_secret_arn` overrides. Optional: if omitted, falls
Expand Down Expand Up @@ -224,6 +231,10 @@ export class FanOutConsumer extends Construct {
props.taskTable.grantReadWriteData(this.fn);
this.fn.addEnvironment('TASK_TABLE_NAME', props.taskTable.tableName);
}
if (props.taskApprovalsTable) {
props.taskApprovalsTable.grant(this.fn, 'dynamodb:GetItem', 'dynamodb:UpdateItem');
this.fn.addEnvironment('TASK_APPROVALS_TABLE_NAME', props.taskApprovalsTable.tableName);
}
if (props.repoTable) {
props.repoTable.grantReadData(this.fn);
this.fn.addEnvironment('REPO_TABLE_NAME', props.repoTable.tableName);
Expand Down
12 changes: 12 additions & 0 deletions cdk/src/constructs/linear-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export interface LinearIntegrationProps {
/** The DynamoDB task events table. */
readonly taskEventsTable: dynamodb.ITable;

/**
* Enables task-owner approve/deny decisions from replies to Linear approval
* notices (#1001). The processor reads the reply thread mapping and records
* the decision through the same handler path as the API.
*/
readonly taskApprovalsTable?: dynamodb.ITable;

/** Monthly user/team budget configuration and spend table. */
readonly budgetTable?: dynamodb.ITable;

Expand Down Expand Up @@ -301,6 +308,9 @@ export class LinearIntegration extends Construct {
TASK_EVENTS_TABLE_NAME: props.taskEventsTable.tableName,
TASK_RETENTION_DAYS: String(props.taskRetentionDays ?? DEFAULT_TASK_RETENTION_DAYS),
};
if (props.taskApprovalsTable) {
createTaskEnv.TASK_APPROVALS_TABLE_NAME = props.taskApprovalsTable.tableName;
}
if (props.repoTable) {
createTaskEnv.REPO_TABLE_NAME = props.repoTable.tableName;
}
Expand Down Expand Up @@ -455,6 +465,8 @@ export class LinearIntegration extends Construct {
}
props.taskTable.grantReadWriteData(webhookProcessorFn);
props.taskEventsTable.grantReadWriteData(webhookProcessorFn);
// Approval replies: thread mapping, rate-limit counter and the decision.
props.taskApprovalsTable?.grantReadWriteData(webhookProcessorFn);
if (props.repoTable) {
props.repoTable.grantReadData(webhookProcessorFn);
}
Expand Down
Loading
Loading