Review the prerequisites
Suitable for: Backend developers learning Agent applications.
- Objects, sources, and bitemporal reasoning in memory conflicts
- Two memories will conflict only if they have the same object, the same attributes, the same scope and overlapping validity time. The recording time cannot replace the business effective time, and similarity cannot determine the facts.
How does the mechanism work?
Step-by-step explanation
- Is the latest imported one necessarily the latest and valid?
Move from apparent conflicts to distinctions between time dimensions.
- How to isolate the technology stacks of different projects for the same user?
Contradictory descriptions may concern different entities; separate them before resolving the conflict.
- Can it still be displayed for historical query after cancellation?
A fact's historical validity and current read authorization are independent dimensions.
Foundation · Understand the concepts
Mechanism before code
Objectives of this level: effective/observed time, explicit correction and conflict provenance — Derive eligibility and the exact branch order from concrete inputs.
Visual guide · Two clocks and current access
Resolve conflicts only among the same object, attribute and scope with overlapping validity. Observation time is not business effective time. Select the figure to open it at full size.
Mechanism before code
An after-sales report-language preference has both effective time and observation time. Importing an old note today does not make its value current. Current access revocation still filters historical facts. Explicit corrections, source priority and unresolved equal-authority conflict are separate rules, not a highest-similarity choice.
known_at asks what was known by that observation cutoff; valid_at asks when the fact applied. A correction not yet observed cannot rewrite the former view. Revoked facts do not become readable just because a historical query matches. A late record valid only before10 cannot win at valid_at15. Write a branch trace for the three inputs and create one additional legal/negative input yourself before completing the function.
Starting point and evidence
Download the source-only ZIP, extract it, and work in extended-agent-practice-v1 with lab_runner.py beside cases/. Python3.9+ standard library; no model, cloud, network or business request is made. Scaffold once in a fresh directory; it refuses overwrite. Reuse your module in later tracks. The empty template must exit1 on grade; scaffold exits0, overwrite exits2. Grade exits0 only when every fixed case passes and otherwise exits1.
- https://ai.lwkjob.com/downloads/extended-agent-practice-v1.zip
- https://ai.lwkjob.com/lab/extended-practice/lab_runner.py
- https://ai.lwkjob.com/lab/extended-practice/cases/memory-conflict-time.json
python3 lab_runner.py scaffold --course memory-conflict-time --out memory_conflict_time_student.py
python3 lab_runner.py grade --course memory-conflict-time --module memory_conflict_time_student.py --out memory_conflict_time_before.json
This course has12 public fixed cases. Each calls your resolve_memory(payload), records input/expected/actual/error, strict JSON types, input immutability and no output-container aliases, plus module/runner/cases SHA and Python version. Inputs are complete JSON fixtures. Unknown or missing keys, null outside explicitly allowed fields, wrong types, duplicate IDs/list members where uniqueness is required raise ValueError:input_shape; booleans are not integers. Exceptions match exact class:message. Return fresh JSON values without mutating input.
Trusted identity, approvals, receipts and policy/index metadata are fixtures assembled by the exercise. In a real service the server must obtain them from authenticated/current authority sources; accepting client JSON with these labels does not authenticate it. The function is a decision over that trusted snapshot, not the adapter or race-proof enforcement.
Local function contract
payload exactly principal/query/facts. principal exactly tenant/user/project(nonempty str),enabled(strict bool). query exactly attribute(nonempty str),valid_at/known_at(strict nonnegative int). facts may be empty; each exactly id/tenant/user/project/attribute/value(nonempty str),valid_from/observed_at(strict nonnegative int),valid_to(None or strict int>valid_from),source(confirmed/inferred),supersedes(None or nonempty str),revoked(strict bool); unique IDs globally. Shape validation first. Disabled principal returns denied/None/[] using keys state/value/sources. Select same tenant/user/project/attribute,currently not revoked,valid_from<=valid_at<valid_to(no upper bound when None),observed_at<=known_at. If any eligible confirmed facts exist, discard eligible inferred facts. Build supersedes links only between remaining eligible IDs; a self/cyclic correction chain raises ValueError:correction_cycle. Remove IDs explicitly superseded by remaining eligible facts. No survivors: missing/None/[]; all survivor values equal: value/that value/sorted source IDs; differing values: conflict/None/sorted source IDs. Output is exactly state,value,sources; preserve multiple same-value sources. No observation-recency tie breaker or invented merged value.
def resolve_memory(payload):
raise NotImplementedError("Implement the public local contract")
Three reviewable inputs
explicit-correction
{
"principal": {
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"enabled": true
},
"query": {
"attribute": "report_language",
"valid_at": 15,
"known_at": 30
},
"facts": [
{
"id": "f-old",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "en",
"valid_from": 0,
"valid_to": null,
"observed_at": 1,
"source": "confirmed",
"supersedes": null,
"revoked": false
},
{
"id": "f-new",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "zh",
"valid_from": 10,
"valid_to": null,
"observed_at": 12,
"source": "confirmed",
"supersedes": "f-old",
"revoked": false
}
]
}
Expected / 预期: {"sources": ["f-new"], "state": "value", "value": "zh"}
late-old-import
{
"principal": {
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"enabled": true
},
"query": {
"attribute": "report_language",
"valid_at": 15,
"known_at": 30
},
"facts": [
{
"id": "f-old",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "en",
"valid_from": 0,
"valid_to": 10,
"observed_at": 1,
"source": "confirmed",
"supersedes": null,
"revoked": false
},
{
"id": "f-new",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "zh",
"valid_from": 10,
"valid_to": null,
"observed_at": 12,
"source": "confirmed",
"supersedes": null,
"revoked": false
},
{
"id": "f-late",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "fr",
"valid_from": 0,
"valid_to": 10,
"observed_at": 25,
"source": "confirmed",
"supersedes": null,
"revoked": false
}
]
}
Expected / 预期: {"sources": ["f-new"], "state": "value", "value": "zh"}
equally-confirmed-conflict
{
"principal": {
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"enabled": true
},
"query": {
"attribute": "report_language",
"valid_at": 15,
"known_at": 30
},
"facts": [
{
"id": "f-old",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "en",
"valid_from": 0,
"valid_to": null,
"observed_at": 1,
"source": "confirmed",
"supersedes": null,
"revoked": false
},
{
"id": "f-second",
"tenant": "acme",
"user": "alice",
"project": "after-sales",
"attribute": "report_language",
"value": "zh",
"valid_from": 0,
"valid_to": null,
"observed_at": 20,
"source": "confirmed",
"supersedes": null,
"revoked": false
}
]
}
Expected / 预期: {"sources": ["f-old", "f-second"], "state": "conflict", "value": null}
Responsibility and limits
Junior derives valid/observed-time views and implements conflict outputs. Intermediate would add source/correction lineage and conditional writes with historical/new-task regression. Senior decides when bitemporal complexity is warranted and owns privacy, restore/tombstone, concurrent corrections and audit failure windows. This integer-time fixture does not implement a production bitemporal database. The four tracks are learning activities, not job ranks. Fixed authored examples and known repairs cannot prove independent diagnosis, real-world security or hiring readiness. Keep source, initial failure, personal diff, same-input rerun and a declared changed-condition result. A reviewer-new complete contract and observed personal work are separate; disclose assistance. The five-second worker guard is not a performance SLO or hostile-code sandbox.
code example
Mechanism before code — explicit-correction
Additional review: explain why this case follows the contract and which single-field change would alter the branch. Public case: explicit-correction Expected / 预期: {"sources": ["f-new"], "state": "value", "value": "zh"} https://ai.lwkjob.com/lab/extended-practice/cases/memory-conflict-time.json
Acceptance task for this level
effective/observed time, explicit correction and conflict provenance — Submit three branch traces and two personal payloads; distinguish trusted fixture fields from client/model data.
Reading this browser’s record…
Hide the answer and check your understanding
What makes f-late ineligible at15?
Expand reference derivation
Its effective interval ends at10, even though it was observed at25.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.