<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: kongkong</title>
    <description>The latest articles on DEV Community by kongkong (@kongkong1).</description>
    <link>https://dev.to/kongkong1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4022658%2F363ced53-f57d-4cf4-bf7c-2927ffcb39c5.png</url>
      <title>DEV Community: kongkong</title>
      <link>https://dev.to/kongkong1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kongkong1"/>
    <language>en</language>
    <item>
      <title>"Carry Actor Provenance From Linear UI to Worker"</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Wed, 29 Jul 2026 09:46:59 +0000</pubDate>
      <link>https://dev.to/kongkong1/carry-actor-provenance-from-linear-ui-to-worker-1m0</link>
      <guid>https://dev.to/kongkong1/carry-actor-provenance-from-linear-ui-to-worker-1m0</guid>
      <description>&lt;p&gt;A Linear button says “delegate,” the API creates a job, and the worker sees only &lt;code&gt;task_id&lt;/code&gt;. Identity disappeared between layers. The worker now cannot distinguish the initiating human, integration, tenant, or approved scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the announcement establishes
&lt;/h2&gt;

&lt;p&gt;GitHub announced Copilot cloud agent for Linear as generally available on July 23, 2026. Delegation from Linear creates a cross-system path; the implementation below is an independent application pattern, not a description of GitHub internals. &lt;a href="https://github.blog/changelog/2026-07-23-copilot-cloud-agent-for-linear-is-now-generally-available/" rel="noopener noreferrer"&gt;Read the primary source&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For test track 5.1, the engineering claim here is narrower than the announcement: the surrounding workflow needs a contract that remains valid when metadata, transport, people, or executors change.&lt;/p&gt;

&lt;h2&gt;
  
  
  The artifact
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Provenance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;actorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;linear&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;issueId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt; &lt;span class="nl"&gt;issuedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apply_patch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;provenance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Provenance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;headSha&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Middleware should authenticate the inbound integration, resolve its tenant mapping, overwrite rather than trust client-supplied actor fields, authorize scope, and sign the canonical envelope before enqueueing.&lt;/p&gt;

&lt;p&gt;For test track 5.2, this is a design fixture, not executed code. Pin language and dependency versions before turning it into a repository test, and replace example identities and timestamps with disposable values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Success path
&lt;/h2&gt;

&lt;p&gt;The UI displays the resolved actor and scope. The API persists the signed envelope, and the worker verifies signature, expiry, tenant, nonce, head SHA, and path authorization before applying anything.&lt;/p&gt;

&lt;p&gt;For test track 5.3, a successful demonstration records inputs, policy or schema version, decision, and final identifier. It does not infer correctness from a confidence label, status badge, or fluent output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure path and regression plan
&lt;/h2&gt;

&lt;p&gt;A replayed nonce, stale SHA, altered scope, or mismatched tenant moves the job to a denied terminal state. It must not be retried as a transient worker error.&lt;/p&gt;

&lt;p&gt;Cover UI payload tampering, API actor overwrite, schema-version rejection, queue serialization, expired authorization, duplicate nonce, worker crash after apply, and rollback authorization.&lt;/p&gt;

&lt;p&gt;For test track 5.4, the acceptance gate is binary: the negative fixture must produce no unauthorized or duplicate side effect, while the positive fixture must remain traceable to its initial evidence. Expected output should be documented before execution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleanup and rollback
&lt;/h2&gt;

&lt;p&gt;Pause consumers, reject new delegation, reconcile jobs by nonce, revert only commits tied to valid provenance, and rotate the signing key if envelope integrity is uncertain.&lt;/p&gt;

&lt;p&gt;For test track 5.5, cleanup must preserve enough sanitized evidence to distinguish cancellation, rejection, stale work, and successful completion. Never solve recovery by silently marking an uncertain operation successful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;For test track 5.6, this article proposes a compact engineering exercise and reports no execution results. It does not evaluate service availability, security, accessibility conformance, productivity, or comparative quality. Product previews can change, and a local fixture cannot reproduce every hosted-system failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical development environment
&lt;/h2&gt;

&lt;p&gt;For unrelated implementation work, MonkeyCode is an open-source AGPL-3.0 AI development platform with an overseas hosted option. It includes a managed server-side cloud development environment, integrated models, task and requirement management, and build, test, and preview workflows. It is free to start. These statements do not mean the GitHub or OpenAI capability discussed above exists in MonkeyCode. Check the console for current quotas, models, regions, duration, and pricing before planning work. &lt;a href="https://ly.cyberserval.tech/iIETXiF" rel="noopener noreferrer"&gt;Open the campaign workspace&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Disclosure: This article promotes MonkeyCode using an official campaign link. I’m a MonkeyCode user, not affiliated with the project, and I receive no commission from this link.&lt;/p&gt;

&lt;p&gt;AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited primary sources.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>github</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>"Give Every Preview URL a Lifecycle Contract From Build to Expiry"</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Tue, 28 Jul 2026 03:41:09 +0000</pubDate>
      <link>https://dev.to/kongkong1/give-every-preview-url-a-lifecycle-contract-from-build-to-expiry-3326</link>
      <guid>https://dev.to/kongkong1/give-every-preview-url-a-lifecycle-contract-from-build-to-expiry-3326</guid>
      <description>&lt;p&gt;A build can succeed while its preview URL points to yesterday’s artifact. The browser sees a page, the API says “ready,” and nobody can prove which commit is being reviewed. Fix that handoff with a preview resource whose identity includes the build and whose expiry is explicit.&lt;/p&gt;

&lt;p&gt;This is a proposed vertical-slice contract, not a description of MonkeyCode internals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"preview_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"prv_01"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"workspace_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ws_01"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"build_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bld_01"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"commit_sha"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"40-hex-replace-me"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"PROVISIONING"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"created_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-27T10:00:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expires_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-27T11:00:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Allowed transitions are deliberately small:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REQUESTED -&amp;gt; BUILDING -&amp;gt; PROVISIONING -&amp;gt; READY -&amp;gt; EXPIRED -&amp;gt; DELETED
                 |             |           |
                 +----------&amp;gt; FAILED &amp;lt;-----+
READY -&amp;gt; SUPERSEDED -&amp;gt; DELETED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;POST /previews&lt;/code&gt; accepts workspace ID, immutable build ID, expected commit SHA, and an idempotency key. &lt;code&gt;GET /previews/{id}&lt;/code&gt; returns the resource above. &lt;code&gt;DELETE&lt;/code&gt; is idempotent and moves toward &lt;code&gt;DELETED&lt;/code&gt;; it never resurrects a preview. Authorization checks workspace membership on every operation, not only creation.&lt;/p&gt;

&lt;p&gt;The UI may render a link only when state is &lt;code&gt;READY&lt;/code&gt;, URL is present, current time precedes expiry, and the displayed commit equals the review target. Poll with the resource version or use events carrying monotonically increasing sequence numbers. A late &lt;code&gt;READY&lt;/code&gt; event cannot overwrite &lt;code&gt;SUPERSEDED&lt;/code&gt;, &lt;code&gt;EXPIRED&lt;/code&gt;, or &lt;code&gt;DELETED&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cross-layer case&lt;/th&gt;
&lt;th&gt;Expected response&lt;/th&gt;
&lt;th&gt;UI behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;build fails&lt;/td&gt;
&lt;td&gt;preview becomes FAILED&lt;/td&gt;
&lt;td&gt;show build evidence, no link&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;provision times out&lt;/td&gt;
&lt;td&gt;bounded retry on same ID&lt;/td&gt;
&lt;td&gt;keep non-ready state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;newer build created&lt;/td&gt;
&lt;td&gt;old preview SUPERSEDED&lt;/td&gt;
&lt;td&gt;disable old review action&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;URL returns wrong marker&lt;/td&gt;
&lt;td&gt;integrity check fails&lt;/td&gt;
&lt;td&gt;block approval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;expiry during viewing&lt;/td&gt;
&lt;td&gt;410 / expired state&lt;/td&gt;
&lt;td&gt;remove action, offer rebuild&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;delete repeated&lt;/td&gt;
&lt;td&gt;same terminal result&lt;/td&gt;
&lt;td&gt;confirm cleanup once&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A minimal integrity route can serve &lt;code&gt;preview_id&lt;/code&gt;, &lt;code&gt;build_id&lt;/code&gt;, and &lt;code&gt;commit_sha&lt;/code&gt; from the deployed artifact. The client compares all three with the API resource before enabling review. Do not use a mutable branch name as identity.&lt;/p&gt;

&lt;p&gt;For the happy path, create from an immutable successful build, wait for readiness, fetch the marker, verify identity, inspect, then delete. For failure, capture operation ID and terminal evidence, revoke the URL, mark the resource failed or expired, and prevent stale retries from publishing it. Cleanup jobs should query nonterminal previews past deadline and drive them to deletion.&lt;/p&gt;

&lt;p&gt;Limitations: a matching marker does not prove the whole artifact is correct, URLs may leak through logs, caches can outlive origin deletion, and clocks can disagree. Production design still needs access control, rate limits, audit retention, cache invalidation, and provider-specific teardown verification. The schema and endpoints here are unexecuted examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the slice in a temporary environment
&lt;/h2&gt;

&lt;p&gt;Official current MonkeyCode material presents the overseas hosted option as “Free to start.” It describes integrated models and managed server-side cloud development environments supporting build, test, and preview—the right surface for examining this contract. It does not promise that every model or server is free. Confirm changing availability, quotas, regions, duration, pricing, and terms in the current console.&lt;/p&gt;

&lt;p&gt;The lifecycle fixture can begin from the official campaign entry: &lt;a href="https://ly.cyberserval.tech/iIETXiF" rel="noopener noreferrer"&gt;https://ly.cyberserval.tech/iIETXiF&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finish by expiring/revoking the preview, deleting its workspace, checking terminal API and console state, and retaining only sanitized contract evidence. A URL that still resolves or a version that cannot be reconciled sends the path to failure cleanup.&lt;/p&gt;

&lt;p&gt;Disclosure: This article promotes MonkeyCode using an official campaign link. I’m a MonkeyCode user, not affiliated with the project, and I receive no commission from this link.&lt;/p&gt;

&lt;p&gt;AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited project materials.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>cloud</category>
      <category>testing</category>
    </item>
    <item>
      <title>"Make AI Budget Exhaustion a Full-Stack API Contract"</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Mon, 27 Jul 2026 13:38:28 +0000</pubDate>
      <link>https://dev.to/kongkong1/make-ai-budget-exhaustion-a-full-stack-api-contract-4gga</link>
      <guid>https://dev.to/kongkong1/make-ai-budget-exhaustion-a-full-stack-api-contract-4gga</guid>
      <description>&lt;p&gt;The browser submits a summary job, the worker reaches the provider after the hard spend threshold, and the API call fails. If every layer translates that into generic &lt;code&gt;500&lt;/code&gt;, the UI offers a retry button that can create a loop. Budget exhaustion needs a typed end-to-end contract, not a billing dashboard alone.&lt;/p&gt;

&lt;p&gt;OpenAI's July 20 &lt;a href="https://openai.com/products/release-notes/" rel="noopener noreferrer"&gt;release notes&lt;/a&gt; add organization and project spend limits and state that hard limits may cause API responses to fail after the threshold. Treat availability exactly as documented for the applicable product and account. This is the latest verified official signal for this behavior, not news released July 27; I excluded unverified secondary July 27 stories.&lt;/p&gt;

&lt;h2&gt;
  
  
  Define the provider seam
&lt;/h2&gt;

&lt;p&gt;Do not leak provider text through your application. Normalize only errors you can classify with evidence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;AiFailure&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;budget_exhausted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;retryable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;project&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;organization&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;unknown&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rate_limited&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;retryable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;retryAfterMs&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;provider_unavailable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;retryable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;unknown&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;retryable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;incidentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;JobState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;queued&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;complete&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blocked_budget&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;resumeToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;incidentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Map &lt;code&gt;budget_exhausted&lt;/code&gt; only when the SDK's current structured status/code supports that classification. A guessed string match can mislabel authorization or outage failures. Unknown remains unknown and pages an owner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Persist before calling
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;POST /api/summaries&lt;/code&gt; must accept an idempotency key, persist &lt;code&gt;{"status":"queued","id":"job_91"}&lt;/code&gt;, and only then enqueue work.&lt;/p&gt;

&lt;p&gt;Worker pseudocode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StoredJob&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;queued&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;completeIfQueued&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;classifyProviderError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;budget_exhausted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;blockIfQueued&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;makeOpaqueResumeToken&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// no automatic provider retry&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;failOrScheduleBoundedRetry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conditional writes prevent late overwrites; public records exclude secrets and sensitive responses.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browser behavior
&lt;/h2&gt;

&lt;p&gt;Poll or stream the durable state. For exhaustion, return a stable application response:&lt;/p&gt;

&lt;p&gt;Return &lt;code&gt;409 application/problem+json&lt;/code&gt; with type &lt;code&gt;ai-budget-exhausted&lt;/code&gt;, job ID, &lt;code&gt;canRetry:false&lt;/code&gt;, and any application-estimated retry time clearly labeled. Preserve input, disable immediate retry, offer cancellation, and leave limit decisions to an authorized operator.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-layer test matrix
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Case&lt;/th&gt;
&lt;th&gt;Provider seam&lt;/th&gt;
&lt;th&gt;Stored state&lt;/th&gt;
&lt;th&gt;HTTP/UI&lt;/th&gt;
&lt;th&gt;Expected calls&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;normal&lt;/td&gt;
&lt;td&gt;result&lt;/td&gt;
&lt;td&gt;complete&lt;/td&gt;
&lt;td&gt;render summary&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;hard limit&lt;/td&gt;
&lt;td&gt;budget exhausted&lt;/td&gt;
&lt;td&gt;blocked&lt;/td&gt;
&lt;td&gt;paused, no retry&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;duplicate click&lt;/td&gt;
&lt;td&gt;none/new enqueue prevented&lt;/td&gt;
&lt;td&gt;existing state&lt;/td&gt;
&lt;td&gt;same job&lt;/td&gt;
&lt;td&gt;0 extra&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;unknown error&lt;/td&gt;
&lt;td&gt;unknown&lt;/td&gt;
&lt;td&gt;failed&lt;/td&gt;
&lt;td&gt;incident reference&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;budget restored&lt;/td&gt;
&lt;td&gt;result after operator resume&lt;/td&gt;
&lt;td&gt;complete&lt;/td&gt;
&lt;td&gt;render once&lt;/td&gt;
&lt;td&gt;1 resumed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Normal path: one idempotent submission creates one job, one provider call succeeds, persistence commits the result, and refresh reads the same completed representation.&lt;/p&gt;

&lt;p&gt;Failure path: classification detects supported budget evidence, the worker atomically marks &lt;code&gt;blocked_budget&lt;/code&gt;, and the UI suppresses retries. If classification is uncertain, the job becomes &lt;code&gt;failed&lt;/code&gt;; do not tell users to change billing based on a guess.&lt;/p&gt;

&lt;p&gt;Resume uses compare-and-set, an operator audit, and the original idempotency key. Ramp batches gradually.&lt;/p&gt;

&lt;h2&gt;
  
  
  Delivery checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Put organization/project selection in server-owned configuration.&lt;/li&gt;
&lt;li&gt;Persist operation identity and input revision before external work.&lt;/li&gt;
&lt;li&gt;Classify current structured provider errors with fixture tests.&lt;/li&gt;
&lt;li&gt;Make budget exhaustion non-retryable at the automated retry layer.&lt;/li&gt;
&lt;li&gt;Authorize resume and cancellation independently.&lt;/li&gt;
&lt;li&gt;Test duplicate submit, late response, restored budget, and unknown error.&lt;/li&gt;
&lt;li&gt;Roll back by disabling new AI admissions while retaining job records.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This cannot predict the threshold call, reset, or availability, and does not replace alerts or financial controls. Pin and test the SDK version.&lt;/p&gt;

&lt;h2&gt;
  
  
  A separate MonkeyCode trial
&lt;/h2&gt;

&lt;p&gt;A later platform trial could include MonkeyCode, currently described as an open-source AGPL-3.0 AI development platform with an overseas online option, managed server-side cloud development environments, model/task/requirement management, and build/test/preview. It is free to start, but I did not test this contract against it and make no claim about identical errors. Use the &lt;a href="https://ly.cyberserval.tech/iIETXiF" rel="noopener noreferrer"&gt;official campaign entry&lt;/a&gt; only after keeping the provider seam and failure fixtures intact.&lt;/p&gt;

&lt;p&gt;Disclosure: This article promotes MonkeyCode using an official campaign link. I’m a MonkeyCode user, not affiliated with the project, and I receive no commission from this link.&lt;/p&gt;

&lt;p&gt;AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited primary sources.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>typescript</category>
      <category>ai</category>
    </item>
    <item>
      <title>"Put MonkeyCode Tasks Behind an Approval-Gated API Contract"</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Mon, 27 Jul 2026 04:15:31 +0000</pubDate>
      <link>https://dev.to/kongkong1/put-monkeycode-tasks-behind-an-approval-gated-api-contract-5ha9</link>
      <guid>https://dev.to/kongkong1/put-monkeycode-tasks-behind-an-approval-gated-api-contract-5ha9</guid>
      <description>&lt;p&gt;A user approves a plan, then the base SHA changes. An &lt;code&gt;approved=true&lt;/code&gt; Boolean can authorize different work from what was reviewed. For a MonkeyCode integration, bind approval to immutable task evidence. The promotion is transparent; the contract is tool-independent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Unexecuted example&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Plan&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;baseSha&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;requirementHash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;allowedPaths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;&lt;span class="nl"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Approval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;planId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;planHash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;approverId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;approvedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /coding-plans -&amp;gt; 201 Plan
POST /coding-plans/:id/approvals -&amp;gt; 201 Approval
POST /coding-plans/:id/executions -&amp;gt; 202 Operation
GET /operations/:id -&amp;gt; durable status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Execution reloads and hashes the plan, compares the current repository SHA, authorizes the reviewer, enforces expiry, and atomically creates one operation per idempotency key. The browser's Boolean is never authority.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Unexecuted pseudocode&lt;/span&gt;
&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;old&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;operation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;byKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;old&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;old&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;plan&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;planId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;approval&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;planId&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;planHash&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;currentSha&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="nx"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;baseSha&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;operation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;planId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;queued&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Response&lt;/th&gt;
&lt;th&gt;Persistent outcome&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;changed SHA&lt;/td&gt;
&lt;td&gt;&lt;code&gt;409 stale_plan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;no operation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;expired plan&lt;/td&gt;
&lt;td&gt;&lt;code&gt;410 plan_expired&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;no operation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;wrong reviewer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;403 forbidden&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;denial audit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;duplicate key&lt;/td&gt;
&lt;td&gt;original response&lt;/td&gt;
&lt;td&gt;one operation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Display repository, base SHA, allowed paths, checks, and expiry before approval. Rollback by disabling creates, revoking access, reconciling queued work, preserving safe records, and invalidating old hashes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verified product boundary
&lt;/h2&gt;

&lt;p&gt;The official README describes MonkeyCode as open-source under AGPL-3.0. Its overseas online option supplies managed server-side cloud environments and areas for development, model, task, requirement, build, test, and preview work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review record fields
&lt;/h2&gt;

&lt;p&gt;For review pass 1 in this kongkong1 evaluation, record an owner, repository, base commit, requirement revision, allowed paths, start and stop times, expected checks, observed terminal state, reviewer decision, cleanup proof, and unresolved questions. Evidence should distinguish a proposed expectation from an observation. Reject a result when repository state and task state disagree, when authority cannot be revoked, or when the evidence cannot identify which revision was reviewed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review record fields
&lt;/h2&gt;

&lt;p&gt;For review pass 2 in this kongkong1 evaluation, record an owner, repository, base commit, requirement revision, allowed paths, start and stop times, expected checks, observed terminal state, reviewer decision, cleanup proof, and unresolved questions. Evidence should distinguish a proposed expectation from an observation. Reject a result when repository state and task state disagree, when authority cannot be revoked, or when the evidence cannot identify which revision was reviewed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;This kongkong1 method was not executed against a live MonkeyCode environment. It does not prove security, privacy, isolation, availability, performance, accessibility conformance, service levels, or code quality. Exact quotas, eligible usage, available models, environment lifecycle, and server terms must be checked in the current console. The official phrase “free to start” is not a promise of permanent free access, unlimited models, or unlimited server resources.&lt;/p&gt;

&lt;p&gt;Supporting official project material is at &lt;a href="https://github.com/chaitin/MonkeyCode" rel="noopener noreferrer"&gt;https://github.com/chaitin/MonkeyCode&lt;/a&gt;. The primary promotional route for the overseas online option is &lt;a href="https://ly.cyberserval.tech/iIETXiF" rel="noopener noreferrer"&gt;https://ly.cyberserval.tech/iIETXiF&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Disclosure: This article promotes MonkeyCode using an official campaign link. I’m a MonkeyCode user, not affiliated with the project, and I receive no commission from this link.&lt;/p&gt;

&lt;p&gt;AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited project materials.&lt;/p&gt;

</description>
      <category>api</category>
      <category>webdev</category>
      <category>ai</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Build an Idempotent Multi-Provider Job API</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Sat, 25 Jul 2026 11:57:01 +0000</pubDate>
      <link>https://dev.to/kongkong1/build-an-idempotent-multi-provider-job-api-1hhn</link>
      <guid>https://dev.to/kongkong1/build-an-idempotent-multi-provider-job-api-1hhn</guid>
      <description>&lt;p&gt;A user clicks “Generate patch,” the request times out, and the UI offers Try Another Provider. If that button creates a second job, the first provider can still finish later. Now one intention has two patches and perhaps two side effects.&lt;/p&gt;

&lt;p&gt;The official July 25 timeline is a good failure fixture. OpenAI says the &lt;a href="https://status.openai.com/incidents/01KYC921K145JTR1JK7DYKGWH1" rel="noopener noreferrer"&gt;initial incident&lt;/a&gt; began at 09:17:49 UTC, entered mitigation monitoring at 10:02:52, and resolved at 11:08:36. Its &lt;a href="https://status.openai.com/incidents/01KYCGY017EG43XZS6GFVXA8VH" rel="noopener noreferrer"&gt;next incident&lt;/a&gt; began at 11:35:24. During research, that incident was identified with elevated errors and mitigation in progress, and &lt;a href="https://status.openai.com/" rel="noopener noreferrer"&gt;official overall status&lt;/a&gt; was Partial System Degradation. The records do not support conclusions about root cause, global extent, exact affected population, or final recovery of the second incident.&lt;/p&gt;

&lt;p&gt;The fix belongs in the API and database, not in button debounce.&lt;/p&gt;

&lt;h2&gt;
  
  
  One intention, multiple attempts
&lt;/h2&gt;

&lt;p&gt;This unexecuted TypeScript interface separates the durable job from provider attempts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;JobState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;accepted&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;running&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;needs_review&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;completed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cancelled&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;AttemptState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;starting&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unknown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;failed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;succeeded&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;superseded&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Job&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;ownerId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;inputDigest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JobState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;winningAttemptId&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Attempt&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;jobId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AttemptState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;remoteId&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outputDigest&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;POST /jobs&lt;/code&gt; requires an &lt;code&gt;Idempotency-Key&lt;/code&gt;. Put a unique constraint on &lt;code&gt;(owner_id, idempotency_key)&lt;/code&gt; and return the existing job when both key and input digest match. Reject reuse with different input.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;POST /jobs/:id/attempts&lt;/code&gt; is an authorized state transition, not a fresh job. It should refuse while an earlier attempt is &lt;code&gt;starting&lt;/code&gt; or &lt;code&gt;unknown&lt;/code&gt;, unless a reviewer records a supersession reason. The worker claims the job version with compare-and-swap before making any externally visible commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;jobs&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;winning_attempt_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'completed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;version&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;winning_attempt_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;expected_version&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero updated rows means another attempt already won or the state changed. Keep the losing output for bounded diagnostics if policy allows, but never apply it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-layer failure checks
&lt;/h2&gt;

&lt;p&gt;These are proposed tests, not executed results:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Double-click &lt;code&gt;POST /jobs&lt;/code&gt; and expect one job identifier.&lt;/li&gt;
&lt;li&gt;Reuse the key with changed input and expect a conflict.&lt;/li&gt;
&lt;li&gt;Inject a timeout after provider submission; expect &lt;code&gt;unknown&lt;/code&gt;, not &lt;code&gt;failed&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Request fallback while unknown; expect review-required.&lt;/li&gt;
&lt;li&gt;Complete two attempts in reverse order; expect one winner.&lt;/li&gt;
&lt;li&gt;Reload the browser; derive controls from server state, not memory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Authorization must check job ownership on inspection, retry, cancellation, and output fetch. Persistence must retain attempt IDs long enough to reconcile delayed callbacks. Rollback means disabling new fallback attempts without deleting the ledger.&lt;/p&gt;

&lt;p&gt;Provider diversity introduces semantic risk. Different models can satisfy the same TypeScript shape while disagreeing in intent, tool use, or patch behavior. Run provider-specific acceptance fixtures before permitting automatic switching; schema validation alone is insufficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  A vertical-slice evaluation path
&lt;/h2&gt;

&lt;p&gt;The overseas &lt;a href="https://monkeycode-ai.net/" rel="noopener noreferrer"&gt;MonkeyCode Try Online service&lt;/a&gt; currently presents “Start free.” The project README describes managed server-side cloud environments with build, test, and preview plus integrated models. That makes it a candidate for a disposable vertical-slice evaluation, described accurately as free to start. Model/server quotas, regions, and uptime or SLA details can change and should be confirmed in the console.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/chaitin/MonkeyCode" rel="noopener noreferrer"&gt;official MonkeyCode source repository&lt;/a&gt; uses AGPL-3.0. On reviewed main commit &lt;code&gt;18baaf54937a65a7d47f1f9d83dd808777aa6cea&lt;/code&gt;, the README lists built-in management of development environments, models, tasks, and requirements. I would inspect the source as a self-hosting and exit option, then compare one low-authority task with the hosted flow. Open source does not make provider dependencies disappear, and I did not test hosted MonkeyCode reliability.&lt;/p&gt;

&lt;p&gt;The relevant recommendation for a full-stack team is to evaluate task identity and persistence at every layer. Do not adopt any fallback path that turns one user action into unrelated jobs merely because its interface offers multiple models.&lt;/p&gt;

&lt;p&gt;Disclosure: I'm a MonkeyCode user sharing my own experience, not affiliated with the project.&lt;/p&gt;

&lt;p&gt;AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited primary sources.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>ai</category>
      <category>reliability</category>
    </item>
    <item>
      <title>Put Health-Data Access Behind a Consent-Receipt API</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Sat, 25 Jul 2026 11:03:28 +0000</pubDate>
      <link>https://dev.to/kongkong1/put-health-data-access-behind-a-consent-receipt-api-3gag</link>
      <guid>https://dev.to/kongkong1/put-health-data-access-behind-a-consent-receipt-api-3gag</guid>
      <description>&lt;p&gt;A person taps “Disconnect,” the UI flips to a reassuring state, and a queued import starts with yesterday’s authorization snapshot. That is a full-stack contract failure: the browser displayed intent while the worker acted on stale authority. A consent receipt should travel from the UI to the policy check, persistence layer, and every job.&lt;/p&gt;

&lt;p&gt;OpenAI announced Health in ChatGPT on July 23, 2026. The company says eligible logged-in US users age 18+ are receiving a rollout on web and iOS, with supported medical-record and Apple Health connections. It says the dashboard can include labs, medications, activity, sleep, and other health information. OpenAI also states connected data and relevant conversations are not used for foundation-model training or advertising targeting. These details come from &lt;a href="https://openai.com/index/health-in-chatgpt/" rel="noopener noreferrer"&gt;OpenAI’s announcement&lt;/a&gt; and should not be expanded into undocumented implementation assumptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the receipt, not a Boolean
&lt;/h2&gt;

&lt;p&gt;A receipt records bounded authority and its version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"grant_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"g_7f2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"subject_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user_local_9"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"connector"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"supported_source"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"purposes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"dashboard"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data_classes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"activity"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sleep"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"granted_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-24T09:00:00Z"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Avoid copying health values into this object. The receipt describes permission, not payload. Store immutable versions so an audit can determine which authority a job presented.&lt;/p&gt;

&lt;p&gt;A minimal &lt;strong&gt;unexecuted API contract&lt;/strong&gt; might expose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST /v1/consent-grants
GET  /v1/consent-grants/{id}
POST /v1/consent-grants/{id}/revocations
GET  /v1/revocations/{operation_id}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creation returns &lt;code&gt;201&lt;/code&gt; with version 1. Revocation returns &lt;code&gt;202&lt;/code&gt; because invalidating credentials, canceling work, removing caches, and processing retained objects may not be instantaneous. The response should include an operation ID and machine-readable state, not a false promise of immediate completion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"operation_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rv_82a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"grant_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"g_7f2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"revoked_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"canceling_jobs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"requested_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-24T10:15:00Z"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Make every worker re-authorize
&lt;/h2&gt;

&lt;p&gt;The worker receives &lt;code&gt;{grant_id, grant_version, purpose, requested_classes}&lt;/code&gt; rather than a long-lived “approved” flag. Immediately before a source read or payload write, it asks the policy layer whether that exact request remains permitted. A version mismatch is a terminal authorization failure, not a retryable network error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ACTIVE -&amp;gt; REVOKE_REQUESTED -&amp;gt; SOURCE_BLOCKED
       -&amp;gt; JOBS_CANCELED -&amp;gt; DERIVATIONS_HANDLED -&amp;gt; COMPLETE
                              \-&amp;gt; PARTIAL_FAILURE -&amp;gt; RETRY/REVIEW
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This state machine separates stopping new access from handling information already present. Product and policy owners must define what “handled” means for source records, cached responses, user-created exports, backups, and legally retained evidence; code should not invent that policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-layer failure tests
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Expected UI&lt;/th&gt;
&lt;th&gt;API/storage invariant&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;double revoke&lt;/td&gt;
&lt;td&gt;show same operation&lt;/td&gt;
&lt;td&gt;idempotency key returns original operation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;old tab reconnects&lt;/td&gt;
&lt;td&gt;require fresh review&lt;/td&gt;
&lt;td&gt;revoked grant cannot become active&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;import is in flight&lt;/td&gt;
&lt;td&gt;show cleanup progress&lt;/td&gt;
&lt;td&gt;no write after stale-version rejection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;connector timeout&lt;/td&gt;
&lt;td&gt;show partial state&lt;/td&gt;
&lt;td&gt;new reads remain blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;receipt scope changes&lt;/td&gt;
&lt;td&gt;summarize diff&lt;/td&gt;
&lt;td&gt;create new immutable version&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Also test authorization: only the receipt subject or an explicitly delegated role can inspect or revoke it. Error bodies and logs must exclude record content. Rollback means disabling new connection creation while preserving revocation and status endpoints; never roll back by restoring an old active grant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Production boundaries
&lt;/h2&gt;

&lt;p&gt;This is a proposed application pattern, not documentation of ChatGPT’s APIs, storage, revocation timing, architecture, or connector behavior. It has not been run. Real delivery needs identity verification, abuse controls, migration handling, observability, retention decisions, provider-specific failure mapping, and privacy/security review.&lt;/p&gt;

&lt;p&gt;OpenAI says the health experience is designed to support—not replace—medical care and is not diagnosis or treatment. A consent API does not validate health information or make downstream output clinically safe. Its narrower promise is testable: current intent should constrain every layer that can move data.&lt;/p&gt;

&lt;p&gt;AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited primary source.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>privacy</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Put AI Agent Actions Behind an Approval Gate From API to Worker</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Fri, 24 Jul 2026 03:10:13 +0000</pubDate>
      <link>https://dev.to/kongkong1/put-ai-agent-actions-behind-an-approval-gate-from-api-to-worker-lak</link>
      <guid>https://dev.to/kongkong1/put-ai-agent-actions-behind-an-approval-gate-from-api-to-worker-lak</guid>
      <description>&lt;p&gt;A user presses Approve, but the worker receives a changed plan five seconds later. If approval is just a Boolean on a job row, the application authorized something the reviewer never saw. Emergency stopping starts with a stronger end-to-end contract: approval binds an exact plan to limited authority.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is verified
&lt;/h2&gt;

&lt;p&gt;The July 21 OpenAI disclosure reports that a combination of models, evaluated internally with reduced cyber refusals, compromised Hugging Face infrastructure; it is available at &lt;a href="https://openai.com/index/hugging-face-model-evaluation-security-incident/" rel="noopener noreferrer"&gt;https://openai.com/index/hugging-face-model-evaluation-security-incident/&lt;/a&gt; . Separate July 24 reporting discusses US proposals around independent audits and emergency shutdown. Those prospective policy ideas are not incident facts, statutory duties, or proof of implementation. The official post also does not justify assumptions about an unpublished exploit route, total impact, or every corrective action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vertical slice
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Plan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Grant&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;planId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;active&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;revoked&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;grantId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;queued&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;running&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stopping&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stopped&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;done&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser fetches a read-only plan and posts its version and digest. The API recomputes the digest, authorizes the reviewer, creates a short-lived grant, and appends an approval event in one transaction. The queue carries only IDs. Before every external action, the worker reloads the grant and rejects expiry, revocation, or any plan mismatch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /plans/:id/approve -&amp;gt; 201 grant
POST /grants/:id/revoke -&amp;gt; 202 stop requested
GET  /jobs/:id          -&amp;gt; durable state + last effect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Required result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;plan changes after review&lt;/td&gt;
&lt;td&gt;&lt;code&gt;409 plan_changed&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;duplicate approve&lt;/td&gt;
&lt;td&gt;same idempotency result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;revoke while queued&lt;/td&gt;
&lt;td&gt;no action starts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;revoke between actions&lt;/td&gt;
&lt;td&gt;next action denied&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;worker dies while stopping&lt;/td&gt;
&lt;td&gt;recovery resumes revocation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Persist an effect receipt before advancing: action ID, normalized arguments hash, destination, grant version, started/finished times, and outcome. A global stop flips admission to deny and revokes active grants; it must not merely hide the UI button. Rollback is a deployment concern, while compensation for already completed effects is domain-specific and may be impossible.&lt;/p&gt;

&lt;p&gt;The happy path is plan -&amp;gt; review -&amp;gt; grant -&amp;gt; queued job -&amp;gt; per-action check -&amp;gt; receipt -&amp;gt; done. Run cross-layer tests with a real database and fake external adapter. An SDK-only unit test cannot catch a stale approval crossing the queue boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Repository exercise and limits
&lt;/h2&gt;

&lt;p&gt;A full-stack developer could pin &lt;a href="https://github.com/chaitin/MonkeyCode" rel="noopener noreferrer"&gt;https://github.com/chaitin/MonkeyCode&lt;/a&gt; to one revision and trace a harmless request from interface to worker, using the contract here as a comparison checklist. I am not claiming that its code has these types, routes, or safeguards. For discussion of integration seams and test cases, the user community is at &lt;a href="https://discord.gg/2pPmuyr4pP" rel="noopener noreferrer"&gt;https://discord.gg/2pPmuyr4pP&lt;/a&gt; ; keep any review descriptive and responsible.&lt;/p&gt;

&lt;p&gt;I'm a MonkeyCode user, not affiliated with the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source note and limitations
&lt;/h2&gt;

&lt;p&gt;The event summary comes from OpenAI’s official July 21 statement, while the July 24 layer is reporting about proposals still being discussed. Neither source establishes that this sample contract is sufficient for any real service, and omitted implementation details may materially alter risk. The types and routes are an unexecuted design sketch: validate transaction boundaries, adapters, revocation races, and recovery under load. Authorization can block later work but cannot automatically compensate an external effect already committed.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>ai</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Make CSV Export Idempotent From Browser Click to Worker Completion</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Thu, 23 Jul 2026 11:54:18 +0000</pubDate>
      <link>https://dev.to/kongkong1/make-csv-export-idempotent-from-browser-click-to-worker-completion-31e8</link>
      <guid>https://dev.to/kongkong1/make-csv-export-idempotent-from-browser-click-to-worker-completion-31e8</guid>
      <description>&lt;p&gt;A user clicks &lt;strong&gt;Export&lt;/strong&gt; twice because the first click shows no feedback. The API creates two jobs. A worker retries one after losing its acknowledgement, producing a third object. The UI eventually displays three links for the same request.&lt;/p&gt;

&lt;p&gt;Disabling the button reduces accidental clicks; it does not make the workflow correct. The invariant belongs across every layer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One authorized export intent maps to one durable operation and one logical artifact, despite duplicate delivery.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Define the operation
&lt;/h2&gt;

&lt;p&gt;The browser creates an idempotency key once and keeps it through retries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/exports&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Idempotency-Key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;report&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;orders&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filters&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The API authenticates first, canonicalizes the request, and stores:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;exports&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="n"&gt;UUID&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;actor_id&lt;/span&gt; &lt;span class="n"&gt;UUID&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;idempotency_key&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;request_hash&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;CHECK&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'queued'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'running'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'ready'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
  &lt;span class="n"&gt;object_key&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="n"&gt;TIMESTAMPTZ&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;UNIQUE&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actor_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotency_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The uniqueness scope includes the actor. Never let one user's key reveal another user's operation.&lt;/p&gt;

&lt;p&gt;Within one transaction:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;insert the operation;&lt;/li&gt;
&lt;li&gt;on conflict, read the existing row;&lt;/li&gt;
&lt;li&gt;reject reuse when &lt;code&gt;request_hash&lt;/code&gt; differs;&lt;/li&gt;
&lt;li&gt;enqueue via an outbox row;&lt;/li&gt;
&lt;li&gt;return &lt;code&gt;202&lt;/code&gt; plus the operation URL.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"exp_123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"queued"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/api/exports/exp_123"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Make the worker repeatable
&lt;/h2&gt;

&lt;p&gt;Queue delivery is normally at least once. The worker must assume the same message can arrive before, during, or after completion.&lt;/p&gt;

&lt;p&gt;Use a deterministic object key such as &lt;code&gt;exports/{operation_id}.csv&lt;/code&gt;. Claim the job with a conditional transition, generate into a temporary object, then publish and mark ready. A duplicate worker that sees &lt;code&gt;ready&lt;/code&gt; exits. A stale &lt;code&gt;running&lt;/code&gt; lease can be reclaimed.&lt;/p&gt;

&lt;p&gt;Do not mark the database ready before the artifact is readable. One practical sequence is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;claim lease
-&amp;gt; stream database snapshot to temporary object
-&amp;gt; validate row count/checksum
-&amp;gt; copy/rename to deterministic final key
-&amp;gt; transactionally set ready + artifact metadata
-&amp;gt; delete temporary object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Object stores differ: rename may be copy-plus-delete, and read-after-write behavior must be checked for the chosen provider. Keep the provider seam explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authorization does not end at creation
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;GET /api/exports/:id&lt;/code&gt; must authorize the current actor against the operation. Return a short-lived signed download URL only for &lt;code&gt;ready&lt;/code&gt; state. Regenerate an expired URL; do not rerun the export.&lt;/p&gt;

&lt;p&gt;The stored object should be private, encrypted according to the data classification, and deleted by retention policy. CSV cells beginning with &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, or &lt;code&gt;@&lt;/code&gt; may become formulas in spreadsheet software; escape untrusted textual fields according to the consuming environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model UI states
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ExportState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submitting&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;queued&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;running&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ready&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;downloadUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;retryable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a timeout, the browser resends the same key. After reload, it resumes from the stored operation ID. “Retry download” refreshes authorization; “retry export” creates a new intent only when the previous operation reached a terminal failure that policy permits retrying.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-layer failure tests
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Expected result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;double click&lt;/td&gt;
&lt;td&gt;one operation row&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API commits, response lost&lt;/td&gt;
&lt;td&gt;retry returns same operation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;same key, different filters&lt;/td&gt;
&lt;td&gt;&lt;code&gt;409 Conflict&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;queue delivers twice&lt;/td&gt;
&lt;td&gt;one logical final object&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;worker dies mid-stream&lt;/td&gt;
&lt;td&gt;lease expires; temporary object cleaned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ready response has expired URL&lt;/td&gt;
&lt;td&gt;refresh URL, do not regenerate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;user requests another user's ID&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;404&lt;/code&gt; or authorized denial&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;spreadsheet-control prefix&lt;/td&gt;
&lt;td&gt;exported as inert text&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Also pin the data consistency contract. Does the export represent the database at request time, worker start, or multiple page-read times? For large exports, use a database snapshot or declare that rows may reflect a bounded moving window. “CSV export” is not a consistency specification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rollback checklist
&lt;/h2&gt;

&lt;p&gt;Before rollout, keep the previous synchronous path available for a limited population, monitor operation age and duplicate conflicts, cap concurrent workers, and provide cleanup for abandoned temporary objects. Roll back creation traffic without deleting in-flight operations; workers must finish or be deliberately drained.&lt;/p&gt;

&lt;p&gt;This design is more code than an SDK call because the feature is not “convert rows to CSV.” It is the browser-to-storage lifecycle, including identity, retries, authority, and recovery.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>architecture</category>
      <category>testing</category>
    </item>
    <item>
      <title>Wrap the GitHub Copilot SDK in an Action Envelope Before It Reaches Your Application</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Wed, 22 Jul 2026 04:29:28 +0000</pubDate>
      <link>https://dev.to/kongkong1/wrap-the-github-copilot-sdk-in-an-action-envelope-before-it-reaches-your-application-3fli</link>
      <guid>https://dev.to/kongkong1/wrap-the-github-copilot-sdk-in-an-action-envelope-before-it-reaches-your-application-3fli</guid>
      <description>&lt;p&gt;GitHub has published &lt;a href="https://github.com/github/copilot-sdk" rel="noopener noreferrer"&gt;&lt;code&gt;github/copilot-sdk&lt;/code&gt;&lt;/a&gt;, an MIT-licensed multi-platform SDK for integrating the Copilot Agent into applications and services.&lt;/p&gt;

&lt;p&gt;Embedding an agent is not the hard part. Connecting its proposed actions to your application's permissions, persistence, and UI is.&lt;/p&gt;

&lt;p&gt;A safe full-stack path starts with an action envelope that every layer understands.&lt;/p&gt;

&lt;h2&gt;
  
  
  The envelope
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;AgentAction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;actionId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;actorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;operation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;read_file&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;propose_patch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;baseRevision&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model may propose this object. It does not authorize it.&lt;/p&gt;

&lt;h2&gt;
  
  
  API boundary
&lt;/h2&gt;

&lt;p&gt;Validate the envelope at the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AgentAction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;expired&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;actorId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;actor mismatch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;operation&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;propose_patch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;canWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;forbidden&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resolve identity from the authenticated session, not from model output. Bind the action to a base revision so a later repository state invalidates stale approval.&lt;/p&gt;

&lt;h2&gt;
  
  
  Persistence boundary
&lt;/h2&gt;

&lt;p&gt;Store proposed and executed states separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proposed -&amp;gt; validated -&amp;gt; approved -&amp;gt; executing -&amp;gt; succeeded
                                  \-&amp;gt; failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;actionId&lt;/code&gt; as an idempotency key. A network retry must return the existing result instead of applying a patch twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  UI boundary
&lt;/h2&gt;

&lt;p&gt;Before approval, show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;exact operation;&lt;/li&gt;
&lt;li&gt;resource and base revision;&lt;/li&gt;
&lt;li&gt;summarized arguments;&lt;/li&gt;
&lt;li&gt;expected side effect;&lt;/li&gt;
&lt;li&gt;expiration time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the plan changes, create a new action ID and require new approval. Do not silently update an approved card.&lt;/p&gt;

&lt;h2&gt;
  
  
  End-to-end failure tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Submit the same action twice: one execution occurs.&lt;/li&gt;
&lt;li&gt;Change the base revision after approval: execution is rejected.&lt;/li&gt;
&lt;li&gt;Remove the user's permission: execution is rejected.&lt;/li&gt;
&lt;li&gt;Expire the action: execution is rejected.&lt;/li&gt;
&lt;li&gt;Disconnect the browser during execution: reconnect shows authoritative state.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why an SDK seam matters
&lt;/h2&gt;

&lt;p&gt;Keep Copilot-specific request and response types inside one adapter. The rest of the application should depend on your &lt;code&gt;AgentAction&lt;/code&gt; contract. That gives you a stable authorization and persistence model if the SDK, model, or provider changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;This is an integration pattern, not a claim about the SDK's internal authorization, session, or persistence behavior. I have not built a production application with the current SDK release. Check the repository's supported languages and current API before implementing the adapter.&lt;/p&gt;

&lt;p&gt;An agent SDK supplies capability. Your application still owns authority.&lt;/p&gt;

</description>
      <category>github</category>
      <category>ai</category>
      <category>architecture</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Kimi K3's 1M Context Window Changes Full-Stack Delivery-If You Gate It Correctly</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Tue, 21 Jul 2026 12:15:29 +0000</pubDate>
      <link>https://dev.to/kongkong1/kimi-k3s-1m-context-window-changes-full-stack-delivery-if-you-gate-it-correctly-1i4b</link>
      <guid>https://dev.to/kongkong1/kimi-k3s-1m-context-window-changes-full-stack-delivery-if-you-gate-it-correctly-1i4b</guid>
      <description>&lt;p&gt;Kimi K3 has a 1-million-token context window. For full-stack delivery, that number changes what a single agent session can touch-but only if your delivery pipeline can handle it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What 1M tokens actually means for full-stack work
&lt;/h2&gt;

&lt;p&gt;A typical full-stack task might involve: a frontend component (500 lines), a backend API handler (300 lines), a database schema (50 lines), a test file (200 lines), and some configuration. That is roughly 4,000-5,000 tokens of source code.&lt;/p&gt;

&lt;p&gt;With a 1M context window, an agent could theoretically hold your entire repository, your API documentation, your database schema, and your test suite-all in one request. The question is whether that actually helps.&lt;/p&gt;

&lt;h2&gt;
  
  
  The delivery contract
&lt;/h2&gt;

&lt;p&gt;Before sending a large context to K3, define what you expect back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"task"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"add user avatar upload to profile settings"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"layers_affected"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"frontend"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"backend"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"storage"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"files_in_context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Profile.tsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"api/upload.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"schema.sql"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"upload.test.ts"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expected_artifacts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"modified Profile.tsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"new api/avatar.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"migration 0042.sql"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"acceptance_checks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"upload succeeds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"file appears in profile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"test passes"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"max_tokens_budget"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;50000&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This contract does three things: it names the layers the task crosses, it limits the files in context to what is relevant, and it sets a token budget even though the window allows more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you should not use the full 1M tokens
&lt;/h2&gt;

&lt;p&gt;More context is not always better. At 1M tokens, you are paying for input you may not need, and the model may attend to irrelevant code. The contract above limits context to files that are actually relevant to the task.&lt;/p&gt;

&lt;p&gt;A good rule: include only files that a human developer would need to open to complete the task. If you would not open it, the model probably does not need it either.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three-layer delivery check
&lt;/h2&gt;

&lt;p&gt;After K3 (or any agent) returns a result for a full-stack task:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Frontend layer&lt;/strong&gt;: Does the component compile? Does it handle loading, error, and empty states?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend layer&lt;/strong&gt;: Does the API contract match what the frontend expects? Are error responses typed?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data layer&lt;/strong&gt;: Does the migration run forward and backward? Are constraints in place?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each layer check should be a script, not a manual review. If you cannot automate the check, the task is too ambiguous for an agent to own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost implication
&lt;/h2&gt;

&lt;p&gt;K3's input price is 20 CNY per million tokens. A 50,000-token context (a generous but bounded scope) costs about 1 CNY per request in input alone. A 500,000-token context costs 10 CNY. A 1M-token context costs 20 CNY-per request, before any output.&lt;/p&gt;

&lt;p&gt;The delivery contract's &lt;code&gt;max_tokens_budget&lt;/code&gt; is not just a quality control-it is a cost control.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not cover
&lt;/h2&gt;

&lt;p&gt;I have not deployed K3 in a full-stack delivery pipeline. The contract above is a proposed protocol based on the published context window size, API pricing, and standard delivery practices. It needs to be tested against real tasks before adoption.&lt;/p&gt;

&lt;p&gt;K3 subscriptions are currently paused due to compute overload. The protocol is ready for when access reopens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;K3 context window: 1M tokens (Moonshot AI, 2026-07-16)&lt;/li&gt;
&lt;li&gt;K3 API input pricing: 20 CNY/M tokens&lt;/li&gt;
&lt;li&gt;K3 Arena coding rank: #1 (reported 2026-07-17)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Disclosure: I'm a MonkeyCode user sharing my own experience, not affiliated with the project. MonkeyCode is an open-source AI coding platform: &lt;a href="https://github.com/chaitin/MonkeyCode" rel="noopener noreferrer"&gt;https://github.com/chaitin/MonkeyCode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>devtools</category>
      <category>backend</category>
    </item>
    <item>
      <title>Ship Agentic AI With an Action Envelope From UI to Worker</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Tue, 21 Jul 2026 04:19:41 +0000</pubDate>
      <link>https://dev.to/kongkong1/ship-agentic-ai-with-an-action-envelope-from-ui-to-worker-4nhe</link>
      <guid>https://dev.to/kongkong1/ship-agentic-ai-with-an-action-envelope-from-ui-to-worker-4nhe</guid>
      <description>&lt;p&gt;An agent feature is not one model call. It is a contract crossing UI, API, authorization, storage, worker execution, and human review.&lt;/p&gt;

&lt;p&gt;I would make that contract explicit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ActionEnvelope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;taskId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;planVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;actionId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;filesystem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;terminal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;argumentsHash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;approvalVersion&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;replacesActionId&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser approves a specific &lt;code&gt;planVersion&lt;/code&gt;. The API stores that approval. The worker rejects an envelope if the plan changed, the action was already executed, or the arguments hash differs from what the reviewer saw.&lt;/p&gt;

&lt;p&gt;A correction is a new action that references the failed one and its evidence. It cannot silently mutate the old row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;insert&lt;/span&gt; &lt;span class="k"&gt;into&lt;/span&gt; &lt;span class="n"&gt;agent_actions&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;plan_version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;action_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;replaces_action_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;values&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'pending'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the seams:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Expected result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;duplicate worker delivery&lt;/td&gt;
&lt;td&gt;same action result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;plan revised after approval&lt;/td&gt;
&lt;td&gt;stale approval rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;test fails&lt;/td&gt;
&lt;td&gt;new version links failure evidence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;browser reconnects&lt;/td&gt;
&lt;td&gt;renders durable current state&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;a href="https://openai.github.io/openai-agents-python/running_agents/" rel="noopener noreferrer"&gt;OpenAI Agents SDK run lifecycle&lt;/a&gt; documents loops involving tool calls and handoffs. Whatever SDK is used, the application still owns the durable cross-layer contract.&lt;/p&gt;

&lt;p&gt;This vertical slice is a suitable disposable task for &lt;a href="https://github.com/chaitin/MonkeyCode" rel="noopener noreferrer"&gt;MonkeyCode&lt;/a&gt;, including its currently free-to-start &lt;a href="https://monkeycode-ai.net/" rel="noopener noreferrer"&gt;browser platform&lt;/a&gt;. The schema above is an independent example, not a claim about MonkeyCode internals. Export the repository afterward so the same acceptance tests can run elsewhere.&lt;/p&gt;

&lt;p&gt;I am a MonkeyCode user, not affiliated with the project. This account is under the same operator as the rest of this batch.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>architecture</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Make Multipart Upload Abort Idempotent Before Orphaned Parts Start Billing You</title>
      <dc:creator>kongkong</dc:creator>
      <pubDate>Mon, 20 Jul 2026 03:18:37 +0000</pubDate>
      <link>https://dev.to/kongkong1/make-multipart-upload-abort-idempotent-before-orphaned-parts-start-billing-you-4gd7</link>
      <guid>https://dev.to/kongkong1/make-multipart-upload-abort-idempotent-before-orphaned-parts-start-billing-you-4gd7</guid>
      <description>&lt;p&gt;Multipart finalization is not the only retry boundary. Abort can succeed in object storage while the HTTP response is lost, leaving your database convinced the upload is active.&lt;/p&gt;

&lt;p&gt;Model abort as a state transition, not a button wired directly to an SDK call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;active → aborting → aborted
             └──→ cleanup_pending
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The endpoint should own an idempotency key and durable intent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;upload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lockUpload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uploadId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aborted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;markAborting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uploadId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;outbox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enqueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;abort-multipart&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;uploadId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;storageKey&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A worker calls storage. If a retry receives &lt;code&gt;NoSuchUpload&lt;/code&gt;, do not blindly fail: reconcile whether the upload was already completed, already aborted, or expired. Only the “already absent because abort succeeded” path may converge to &lt;code&gt;aborted&lt;/code&gt;; completion requires a separate terminal state.&lt;/p&gt;

&lt;p&gt;Test this sequence:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Fault&lt;/th&gt;
&lt;th&gt;Required invariant&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;persist abort intent&lt;/td&gt;
&lt;td&gt;process dies&lt;/td&gt;
&lt;td&gt;outbox resumes work&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;storage abort succeeds&lt;/td&gt;
&lt;td&gt;response is lost&lt;/td&gt;
&lt;td&gt;retry does not reactivate upload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;duplicate message&lt;/td&gt;
&lt;td&gt;delivered twice&lt;/td&gt;
&lt;td&gt;one terminal state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;client retries&lt;/td&gt;
&lt;td&gt;same key&lt;/td&gt;
&lt;td&gt;same operation result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cleanup scan&lt;/td&gt;
&lt;td&gt;stale active row&lt;/td&gt;
&lt;td&gt;reconcile before deleting&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Amazon S3’s &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html" rel="noopener noreferrer"&gt;AbortMultipartUpload API&lt;/a&gt; notes that in-progress part uploads may still succeed around an abort and recommends verifying that parts are gone. That makes a post-abort verification pass part of correctness, not optional housekeeping.&lt;/p&gt;

&lt;p&gt;Expose &lt;code&gt;abort_requested_at&lt;/code&gt;, attempt count, last storage result, and remaining-part count. Alert on age in &lt;code&gt;aborting&lt;/code&gt;, then run a lifecycle cleanup policy as a backstop—not as a substitute for application reconciliation.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>webdev</category>
      <category>architecture</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
