Understand first
New to this knowledge point
Complete the prerequisite concepts, read the principles and counterexamples, and then explain why in your own words.
Start with core principles →Understand → Implement → Debug → Design
Use a well-formed foreign order, a state conflict and an uncertain retry to locate the authority boundary.
Knowledge content check2026-10-30 · Check the source of the original question2026-10-30
It is recommended to understand first:
Context and generation budgets →Select the starting point based on the current basis, or you can go deeper one by one. When you encounter an unfamiliar concept, go back to the core principles first; use the knowledge exercises to check your understanding when you are finished.
New to this knowledge point
Complete the prerequisite concepts, read the principles and counterexamples, and then explain why in your own words.
Start with core principles →Prepare to write the principles into code
Understand implementation steps and boundaries, complete small tasks, and check results against acceptance requirements.
View the code example →Need to handle failures and changes in conditions
Follow the continuous questioning to locate the failure premise, and then compare the migration cases to explain how the plan should be adjusted.
Continue to delve deeper into the problem →Need to design or review plans
Combine engineering deductions and senior self-evaluation standards to explain the applicable conditions, costs and alternatives of the plan.
Analyze engineering scenarios →LEARN · PRACTICE · REFLECT
First read along the principles, Q&A and migration cases. When you need to check your understanding, switch to reinforcement exercises or start personal recording.
Can be practiced directly. After logging in, answers, favorites, and notes will be saved to your account.
Log in and saveEach modified commit will be kept as an independent history. Your level of mastery is up to you to evaluate yourself against the standards.
Core concept · A typed proposal is not an authorized business fact
Preparatory concepts:JSON object fields and integer units, Authenticated tenant/actor context, Resource version and durable operation identity
Each gate establishes a different fact; a durable receipt reconciles the same business intent, while authority must be enforced where its effect occurs.
Valid JSON establishes shape only. Trusted object access, current preconditions and a bound operation receipt establish different facts. Select the figure to open it at full size.
Schema validates structure because it sees the request shape. Ownership and permissions are relational facts in trusted state, so they need an object-specific authority check. State versions protect a proposal from a concurrent business change, while receipt identity protects an already completed intent from being executed again.
The counterexample deliberately passes the first predicate and fails the second. Denial must stop execution rather than ask the model to guess alternative IDs. Compare request, context, gate and ledger together. A local COMMIT can bind local facts atomically; it cannot enroll a remote service in the same transaction. See the course and its runnable source for the explicit boundary.
Proposes a tool name, arguments, and call_id. All are candidate inputs.
Checks the allowlist, completeness, shared budget, and arguments. A failed check stops the action.
Reads identity from a trusted session; checks resource ownership and current permissions, then state at the commit boundary.
Correlates success, failure, or unknown receipts by call_id and preserves facts that already occurred.
Adds the receipt to the next input; checks the final answer against facts before reporting business completion.
Valid structure grants no permission. call_id correlates a call in this turn; it cannot replace a business operation key across recovery.
Shape validation establishes field structure, not ownership, current permission, applicable state or a completed business effect. Derive identity from trusted context; check object authorization and business/version preconditions at the authority, then bind the durable operation identity to its payload and receipt. Model-supplied tenant or approved fields cannot grant access.
Take the authored request for order-b, 300 USD minor units, version1 and refund-1 under tenant-a/user-a. Its types and complete v2 fields are valid, but the SQLite authority returns authorization denial and records zero effects. Schema cannot infer resource ownership from a string ID.
Apply gates in causal order: closed typed request; units/currency and business bounds; trusted object-specific authorization; current resource preconditions for a new effect; commit and receipt validation. An authorized retry of a previously committed identical intent replays its receipt before testing a new state transition. A different payload under refund-1 returns idempotency_conflict; it cannot borrow the old receipt.
The executable experiment first commits 300 and then replays refund-1. Actual local state is remaining_minor=700, effect_count=1. A second legitimate refund requires a new operation identity and the current version. A network timeout does not justify generating that new identity: the first effect may already exist.
In the local experiment effect and receipt share one transaction. Moving authorization or payment to another service changes the guarantee: an orchestrator preflight read does not atomically protect remote commit. Enforce policy at the resource authority or use an explicitly scoped/versioned capability and state its revocation semantics. The lab does not exercise a remote provider.
The versioned contract case shows why legal string arrays are not valid citation identities and why a review decision does not require a transaction proposal's entire evidence set. It also adds a missing negative control: an ordinary order cannot become manual_review merely because a battery clause was retrieved. The old missing-proof proposal remains rejected. The old/new literal response replay does not measure new model compliance.
Python 3.9+, standard library. Extract /lab/deep-dive/agent-core-deep-dive-v1.zip and run this snippet beside tool_contract_deep_dive.py; /lab/deep-dive/tool_contract_deep_dive.py is also available. Authored fixtures only; not a live model or external service.
from tool_contract_deep_dive import Executor, Context, request, validate_shape
e = Executor()
ctx = Context('tenant-a', 'user-a')
assert validate_shape(request(order_id='order-b')) is None
assert e.execute(ctx, request(order_id='order-b'))['gate'] == 'authorization'
assert e.execute(ctx, request())['status'] == 'committed'
assert e.execute(ctx, request())['status'] == 'replayed'
print(e.state()['remaining_minor'], e.state()['effect_count'])
e.close()
expected output
700 1Continue reading along with the premises and constraints of the problem. Understand the reference answers first, then try to put away the answers and explain the cause and effect and trade-offs in your own words.
Level 1The model includes tenant_id=tenant-b. Why can that not authorize order-b?
Changes the request from a foreign ID to an attempted identity override.
It is another candidate field from the same untrusted source. Bind tenant and actor from authenticated context and check object access in trusted state. This lab rejects the extra field before lookup; supporting delegated access would need an independently authorized delegation, not a string chosen by the model.
Level 1The actor is authorized and the schema is valid, but remaining balance is below the requested amount. What next?
Removes the access failure and exposes a business precondition failure.
Return a structured business_state failure without committing. Explain the requested/current state only to an authorized reader. A new amount changes intent and may need review; it is not an identical transport retry. Do not spin indefinitely or turn an authorization denial into parameter search.
Level 1Permission is revoked after validation but before the local effect transaction. Which check must still hold?
Introduces a temporal gap after a previously valid decision.
Current authorization at the effect boundary. In a shared authority, order permission/state/effect in one enforceable transaction or equivalent protected operation. A cached preflight result is historical evidence, not permission at commit.
Follow this answer further
Level 2Now permission and payment are separate services. Does checking permission immediately before HTTP dispatch remove the race?
Changes one transactional authority into independent services.
No; revocation can occur after that check. The payment authority must enforce a current permission epoch or scoped capability, or the contract must explicitly permit a bounded authorization lease. Immediate revocation needs current authority/order at remote commit and may couple availability.
Follow this answer further
Level 3Revocation arrives after the payment authority already committed. Should the run simply mark the action as never executed?
Moves revocation across the irreversible commit boundary.
No. Preserve the committed receipt and event ordering. Stop later actions; consider a separately authorized compensation if the business supports it. Compensation is a new action that can fail and cannot rewrite historical completion into non-execution.
First find out the conditions for change, and then determine which premises in the original plan still hold true. The following cases are teaching deductions to facilitate the transfer of principles to new problems.
Changing conditions:A single-owner refund becomes a scoped delegation to a support operator.
Extended question:What must the trusted context carry beyond a model-provided owner ID?
A verifiable delegating subject, delegate, resource/action scope, validity/revocation basis and tenant boundary. The resource authority evaluates those attributes for the object at execution. A broad support role without object scope can over-authorize. Record the delegation/version in the intent and receipt.
The principles that remain unchanged:Model arguments cannot create authority; the effect must satisfy current object-specific policy.
Changing conditions:A write becomes a read of multiple documents with different ACLs.
Extended question:Can one allowed document authorize a merged result that includes a forbidden document?
No. Authorize each protected source and preserve applicability through assembly and caching. Filtering only the final answer is too late if forbidden text reached the model or logs. Read operations also need access and provenance boundaries even when they have no payment side effect.
The principles that remain unchanged:Every protected object used by the operation must be authorized under the trusted scope.
Official mechanisms were checked on 2026-10-11. Examples and schedules are authored; local Python/SQLite outputs are actually executed. No enterprise incident, live model accuracy or production reliability is asserted. New Q&A and migration cases are added for principle explanation, and source verification and case operation verification are recorded separately.
After reading, you can explain the principles, boundaries, and trade-offs against these standards. It is up to you to evaluate your mastery; if further verification is needed, complete the small tasks below.
View verification records for independent examples
First observe whether business effects have been generated while waiting for approval, and then press README to check action binding and recovery.
Read full text and fault analysis → · Download experiment package ↓
python3 approval_cli.py submit
python3 approval_cli.py run
python3 approval_cli.py inspect
# 审查 draft 和 action_json 后,按 README 使用对应 binding_hash 批准并恢复Local approval fixture; --actor is not a login or production authentication. No network by default.
Run the tool module and ToolContractTests from the deep-dive bundle. Record a five-gate diagnosis for foreign_order, changed_retry and new_operation_old_version; then add one second legitimate refund.