amr-engine · Vi Nhật Sơn

Does the order of two shocks leave a permanent mark?

A runnable six-layer model of the dollar index, and a measurement of something the original model cannot express: the hole that stays behind after a closed loop returns to where it started.

Start with the panels

Three self-contained pages. Nothing to install, no server, no build step — they run entirely in your browser.

manifold_panel

The six sheets in 3D. All 78 variables as sliders grouped by sheet, a knife you can open and close, and a toggle between two memory models. Fire two shocks in either order and watch for a scar.

open →

geometry_panel

The same 78 variables, placed by geometric role rather than by which equation they are a coefficient of. Position, tangent, curvature, amplitude.

open →

regimes_panel

Drive the six layers directly and watch the three-block decomposition respond. Eleven scenarios built in, five of them historical case studies.

open →

The panel interface is in Vietnamese. Variable names, Greek symbols and numbers are not language-specific, and each sheet group is labelled Σ₀ … Σ₅.

The result worth arguing about

Three quantities that are all exactly zero in the original model — not small, zero, and zero for a structural reason.

τ ≡ 0hysteresis · τ = 0.294fatigue · τ = 0.122
commutator ‖[L₄, L₅]‖0.000e+000.000e+001.720e-02
holonomy H(γ)+0.000e+00−7.318e-02−4.056e-02
residue after unwinding+0.000000+0.027931+0.011078

The original model's layer E9 is a function of the current state and carries no history, so two paths reaching the same state must produce the same output. It is not missing a term — it sits in a function class that cannot express "the hole that stays behind."

That turns into an empirical question, and it does not need a long sample:

Does the order of two shocks change the permanent level, when the final state is identical?
Yes → fatigue. No → hysteresis.

Note the hysteresis commutator is zero by the definition of the operator: it takes a running maximum over history, and two orderings traverse the same state set. Holonomy and residue are non-zero in both. A closed loop returns to the starting state; the scar remains.

Three packages, three different things

The relationship between them is the interesting part.

packagewhat it isimports amr?
amrthe book's model — six layers at standard form, with boundary checks—
amr2a different model: the book's errors corrected, fitted to real FRED data, with out-of-sample backtestsno, by design
amr3the same model re-read in geometric coordinates: sheets, scars, path dependenceyes, runs it inside

amr2 stands apart because it is a rival model and has to be comparable. amr3 nests amr because it is the same model in different coordinates, and the way you prove a re-reading is faithful is to run the original inside it:

τ ≡ 0  →  no overrides  →  ln DXY identical to amr, difference 0.000e+00

amr3 adds exactly one parameter and no new edges — the edge set is taken unchanged from the gamma field of amr/registry.py.

Run it yourself

Python 3.9+. No dependencies at all — standard library only.

git clone https://github.com/vinhatson/amr-engine.git
cd amr-engine
python -m amr check            # structural constraints, with the slack on each

python -m amr list             # the scenarios, and what the book says about each
python -m amr run narrative    # a full qualitative reading
python -m amr audit            # every scenario against the book's own numbers
python -m amr2                 # book model vs corrected model, same exam
python -m amr3                 # the atlas, three measurements, the τ sweep

python tests/test_engine.py    # amr
python tests/test_amr2.py      # amr2
python tests/test_amr3.py      # amr3

All three suites pass on Python 3.12 across Windows, macOS and Linux. They check structure, not just output: test_atlas_covers_every_amr_variable_exactly_once asserts 78 of 78, nothing added and nothing dropped.

Honest limits

Read this before quoting any number. amr is qualitative: it produces an arrow scale and a three-block decomposition, not a calibrated point forecast.
  • The rendered narrative is Vietnamese only. The method is narrative_vi(); there is no narrative_en() yet. Everything structured — numbers, arrow scale, block attribution, evidence_mix — is language neutral, and the registry carries a name_en field. An English renderer is the most useful contribution anyone could make.
  • On Σ₅ the tautness rule is exact; on Σ₁ it is an approximation, because σ_sys is a linear composite rather than a logistic. The code says so rather than passing over it.
  • τ defaults to 0, which is the null. Quote no τ > 0 result without stating τ and the memory model.
  • One data defect is carried, not hidden. CPI for 2025-10 does not exist — the BLS did not publish during the shutdown that began 2025-10-01 — so that month is interpolated and row.cpi_imputed is True there.
  • The geometric framing is a reading, not a dimension count. A two-sheet model that scars is already a puncture; a ten-sheet model that does not is still a slide. The invariant that matters is whether the layer operators commute.

Documentation

Full guide

Every command and every claim, explained.

read →

SPEC.md

The mathematics in full.

read →

User manual

The amr3 manual, as a page.

read →

The paper

The Architecture of Market Regimes.

PDF →

Thứ tự hai cú sốc có để lại vết hằn thường trực không?

Một mô hình sáu tầng chạy được của chỉ số đô la, và một phép đo cho thứ mà mô hình gốc không diễn đạt nổi: cái lỗ còn lại sau khi một vòng kín đã quay về đúng nơi nó bắt đầu.

Bắt đầu từ các panel

Ba trang tự chứa. Không phải cài gì, không cần server, không cần build — chúng chạy hoàn toàn trong trình duyệt của bạn.

manifold_panel

Sáu tấm trong không gian 3D. Cả 78 biến dưới dạng slider nhóm theo tấm, một con dao bạn mở đóng được, và một công tắc chuyển giữa hai mô hình trí nhớ. Bắn hai cú sốc theo hai thứ tự rồi xem có vết sẹo nào không.

mở →

geometry_panel

Cùng 78 biến đó, xếp theo vai hình học thay vì theo việc chúng là hệ số của phương trình nào: vị trí, tiếp tuyến, độ cong, biên độ.

mở →

regimes_panel

Điều khiển trực tiếp sáu tầng và xem phân rã ba khối phản ứng. Mười một kịch bản có sẵn, năm trong số đó là nghiên cứu tình huống lịch sử.

mở →

Kết quả đáng tranh luận

Ba đại lượng mà cả ba bằng đúng 0 trong mô hình gốc — không phải nhỏ, mà là 0, và 0 vì một lý do cấu trúc.

τ ≡ 0trễ · τ = 0,294mỏi · τ = 0,122
giao hoán tử ‖[L₄, L₅]‖0,000e+000,000e+001,720e-02
holonomy H(γ)+0,000e+00−7,318e-02−4,056e-02
dư âm sau khi gỡ sốc+0,000000+0,027931+0,011078

Tầng E9 của mô hình gốc là một hàm của trạng thái hiện tại và không mang theo lịch sử nào, nên hai đường đi tới cùng một trạng thái bắt buộc cho cùng một đầu ra. Nó không thiếu một số hạng — nó nằm trong một lớp hàm không thể diễn đạt nổi "cái lỗ còn lại".

Điều đó biến thành một câu hỏi thực nghiệm, và câu này không cần đợt dữ liệu dài:

Thứ tự hai cú sốc có đổi mức thường trực không, khi trạng thái cuối giữ nguyên?
Có → mỏi. Không → trễ.

Lưu ý giao hoán tử của dạng trễ bằng 0 theo đúng định nghĩa của toán tử: nó lấy cực đại theo lịch sử, và hai thứ tự đi qua cùng tập trạng thái. Holonomy và dư âm thì khác 0 ở cả hai. Vòng kín quay về đúng trạng thái đầu; vết sẹo thì ở lại.

Ba package, ba thứ khác nhau

Quan hệ giữa chúng mới là phần thú vị.

packagelà gìcó nhập amr?
amrmô hình của sách — sáu tầng ở dạng chuẩn, có kiểm tra biên—
amr2một mô hình KHÁC: sửa các lỗi của sách, khớp với dữ liệu FRED thật, có backtest ngoài mẫukhông, có chủ đích
amr3CÙNG mô hình, đọc lại trong hệ toạ độ hình học: tấm, vết sẹo, phụ thuộc đường đicó, chạy nó ở bên trong

amr2 đứng riêng vì nó là mô hình đối thủ, phải so sánh được. amr3 lồng amr vào trong vì nó là cùng mô hình trong hệ toạ độ khác, và cách chứng minh một lối đọc là trung thực chính là chạy bản gốc ở trong nó:

τ ≡ 0  →  overrides rỗng  →  ln DXY trùng khít amr, chênh lệch 0.000e+00

amr3 thêm đúng một tham số và không thêm cạnh nào — tập cạnh lấy nguyên từ trường gamma trong amr/registry.py.

Tự chạy thử

Python 3.9+. Không phụ thuộc gì cả — chỉ thư viện chuẩn.

git clone https://github.com/vinhatson/amr-engine.git
cd amr-engine
python -m amr check            # ràng buộc cấu trúc, kèm độ dư từng cái

python -m amr list             # các kịch bản, kèm điều sách nói về từng cái
python -m amr run narrative    # một bản đọc định tính đầy đủ
python -m amr audit            # mọi kịch bản, đối chiếu số liệu sách
python -m amr2                 # mô hình sách đối đầu mô hình đã sửa
python -m amr3                 # bản đồ, ba phép đo, quét τ

python tests/test_engine.py    # amr
python tests/test_amr2.py      # amr2
python tests/test_amr3.py      # amr3

Cả ba bộ test pass trên Python 3.12, trên Windows, macOS và Linux. Chúng kiểm cấu trúc, không chỉ kiểm output: test_atlas_covers_every_amr_variable_exactly_once khẳng định 78/78, không thêm không bớt.

Giới hạn, nói thẳng

Đọc phần này trước khi trích bất kỳ con số nào. amr là định tính: nó cho ra thang mũi tên và phân rã ba khối, không phải một dự báo điểm đã hiệu chỉnh.
  • Trên Σ₅ quy tắc độ căng là đúng hệt; trên Σ₁ nó là xấp xỉ, vì σ_sys là hợp tuyến tính chứ không phải logistic. Code nói ra điều đó thay vì bỏ qua.
  • τ mặc định bằng 0, và đó là giả thuyết không. Đừng trích một kết quả τ > 0 mà không nêu τ và mô hình trí nhớ.
  • Một khuyết tật dữ liệu được mang theo, không giấu. CPI tháng 2025-10 không tồn tại — BLS không công bố vì đợt đóng cửa chính phủ bắt đầu 01/10/2025 — nên tháng đó là nội suy và row.cpi_imputed bật True.
  • Khung hình học là một lối đọc, không phải một số chiều. Mô hình hai tầng mà có vết sẹo thì đã là đâm xuyên; mô hình mười tầng mà không có vết sẹo thì vẫn chỉ là trượt. Bất biến đáng kể là các toán tử tầng có giao hoán hay không.

Tài liệu

Hướng dẫn đầy đủ

Từng lệnh và từng khẳng định, được giải thích.

đọc →

SPEC.md

Toàn bộ phần toán.

đọc →

Sổ tay sử dụng

Sổ tay amr3, dạng trang web.

đọc →

Bài báo

The Architecture of Market Regimes.

PDF →