Skip to content
Agent Field Notes
Practice topicsFilter practice questions by topic.All practice →
knowledge unit 63FundamentalsImplementationAbout 12 minutes

Understand → Implement → Debug → Design

A typed proposal is not an authorized business fact

Use a well-formed foreign order, a state conflict and an uncertain retry to locate the authority boundary.

JSON SchemaParameter verificationtool gatewaybusiness rules

Knowledge content check2026-10-30 · Check the source of the original question2026-10-30

Which step do you want to learn from this knowledge point?

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.

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 →

Implement next

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 →

Debug failures

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 →

Compare designs

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 →
Knowledge unit directory

LEARN · PRACTICE · REFLECT

Knowledge learning and personal records

My notes and review ↗

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.

Answers and personal notes

Each 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

Understand the core principles first

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.

Visual guide · Each tool gate proves one additional fact

Each tool gate proves one additional fact

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.

Tool calls: trust boundaries from proposal to receipt
  1. 1
    Model

    Proposes a tool name, arguments, and call_id. All are candidate inputs.

  2. 2
    Runtime

    Checks the allowlist, completeness, shared budget, and arguments. A failed check stops the action.

  3. 3
    Business service

    Reads identity from a trusted session; checks resource ownership and current permissions, then state at the commit boundary.

  4. 4
    Tool adapter

    Correlates success, failure, or unknown receipts by call_id and preserves facts that already occurred.

  5. 5
    Acceptance

    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.

Check understanding with a question

What remains unproved after tool arguments pass JSON Schema?

Compare with the reference answer

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.

Implementation and trade-offs

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.

Complete failure and repair

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.

code example

Reproducible local boundary check

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 1

Engineering deduction

scene
Authored tenant-a request targets an existing tenant-b order; then a valid local refund is delivered twice.
design decisions
Validate types independently, authorize against local resource ownership, and commit effect plus receipt under one operation key.
Verify target
Foreign request passes shape but is denied with zero effects. Valid/retry return committed/replayed and leave one 300-unit effect.
applicable boundary
A local SQLite authority and trusted caller context are tested; no authentication provider, remote payment or distributed revocation is exercised.

Continuous questions and answers

Continue 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.

Draw inferences from one example: If the conditions change, how to deduce it?

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.

Delegated object access

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?

Derivation and reference solutions

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.

Authorized evidence reading across resources

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?

Derivation and reference solutions

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.

Easy to make mistakes

  • Equating schema validity or model confidence with resource authority.
  • Returning another tenant's balance while explaining a denial.
  • Changing operation identity after a timeout before reconciling the first operation.
  • Claiming a local unique row makes a remote HTTP effect exactly once.

References

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.

Check how far you understand

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.

Basic standards met
Identifies authorization and business/state checks beyond schema, with a specific valid foreign-ID counterexample.
Intermediate and advanced signals
Explains gate ordering, unit normalization, receipt replay and changed-payload conflicts using actual local ledger values.
Senior criteria
Defines the resource-side enforcement and unknown-outcome protocol when permissions or effects cross services; states remaining assumptions.

View verification records for independent examples

Continue to do advanced research experiments

Push the read-only tool boundary to the approval boundary

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 批准并恢复

Keep evidence and check item by item

  • Status waiting_approval, no reports service has written yet.
  • Review actions, targets, scopes, inputs, and content summaries before approving the corresponding binding_hash.
  • Run tests to reject, cancel and modify content respectively to explain why old approvals cannot be reused.

Local approval fixture; --actor is not a login or production authentication. No network by default.

Hands-on verificationComplete on demand · Suggestions35 minutes

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.

Expand acceptance requirements and checkpoints
  • Foreign request passes shape, fails authorization and writes no effect.
  • Identical retry replays one receipt; changed amount under refund-1 is denied.
  • A second operation with version2 and amount400 leaves remaining300/effect_count2.
  • The report separates the local transaction proof from remote-provider guarantees.

Key inspections

  • Separates shape, business semantics, authorization, resource state and committed receipt.
  • Uses authenticated tenant/actor and object-specific checks, not model identity fields.
  • Keeps the same operation identity for uncertain retries and detects changed payload.
  • Names the residual race when authorization and effect reside in separate services.