Skip to content

LATX, refactor: staged KZT library passthrough - #4

Closed
LaurenIsACoder wants to merge 18 commits into
masterfrom
lauren/kzt-step1-clean-l1-20260701
Closed

LATX, refactor: staged KZT library passthrough#4
LaurenIsACoder wants to merge 18 commits into
masterfrom
lauren/kzt-step1-clean-l1-20260701

Conversation

@LaurenIsACoder

@LaurenIsACoder LaurenIsACoder commented Jul 1, 2026

Copy link
Copy Markdown
Owner

KZT staged refactor: Step2 Runtime Dynamic Parser

This PR is the cumulative PR for the staged KZT refactor. This update completes Step2, Runtime Dynamic Parser, while keeping the existing KZT legacy flow as the source of runtime behavior. The new path is observable, testable, and fail-open.

Step2 scope

  • Added a runtime Dynamic Table parser with explicit status reporting for success, read errors, truncation, parser errors, and unknown tags.
  • Added parser edge reporting so boundary and failure states can be tested and archived as evidence.
  • Attached GuestDynamicView snapshots to the existing registry/object lifecycle instead of introducing a process-level global object.
  • Integrated the observation adapter so dynamic snapshots are committed only after valid registry observe results.
  • Kept parser/read/commit failures fail-open: they are recorded as diagnostics and do not change the legacy KZT observation result.
  • Added a dynamic diagnostics helper for comparing old/new dynamic views.
  • Added comparison summary/log APIs so evidence can be traced by GuestObject, generation, tag, and field.
  • Kept unknown dynamic tags diagnostic-only and non-blocking.
  • Kept Step2 as an observability closure, not a runtime enforcement gate.
  • Left PR3-derived symbol, relocation, version, and owner-resolution consumption for Step3 and later phases.

Step2 commit chain

Commit Purpose
7a5268946b39 Step2 parser base: add KZT guest dynamic parser foundation
125277a6031f WI-185: report parser edge and abnormal states
4f22a8d5ff65 WI-186: add per-object GuestDynamicView snapshots under registry/object lifecycle
75ad9a33c4fb WI-187: commit dynamic views from the adapter after valid observe results, preserving fail-open behavior
191c58c8f211 WI-188: add dynamic diagnostics helper for old/new dynamic view comparison
b6af8a329009 WI-209: add comparison summary/log APIs and close the dual-parser evidence loop

Latest local commit prepared for this PR update:

b6af8a329009a2430647ca97a61a024071ec19e6

Verification

  • Lightweight KZT Meson tests: 8/8 passed.
  • build64-dbg KZT Meson tests: 8/8 passed.
  • Step2 T-44 WorkItems have Evidence, ExecutionRun, AI QA, and Owner Review closure in AgentsFlow.
  • T-44 archive fields have been written. Final archival is currently blocked only by AgentsFlow expert permission required to verify resolved review comments.

CI note

Remote CI may still fail because of GHCR runner image access, runner environment, or AOSC build environment issues. Those failures are separate from the local LAT build and KZT unit-test evidence above and should not be treated as Step2 code failures without checking the failing logs.

Safety note

This PR must only be updated through the LaurenIsACoder/lat fork. It must not be pushed to the upstream LAT repository. Any push or PR update still requires explicit human approval before execution.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Add the Step2 T1 KZT runtime Dynamic Table parser and view
representation. The parser reads Elf64_Dyn entries through the
kzt_guest_link_map_reader_ops_t reader seam, records the happy-path fields
needed by later KZT stages, and preserves runtime address semantics for
pointer-valued DT_* entries while keeping DT_NEEDED values as string table
offsets.

This change also wires the parser into the LATX context build and adds a
tests/unit/kzt white-box unit test. The test covers a complete
DT_NULL-terminated Dynamic Table, multiple DT_NEEDED offsets, load-bias
preservation, and the T1 address-semantics contract.

This is only the Step2 T1 parser/view happy path. It does not connect the
parser to the KZT registry, observation adapter, diagnostics, patch planner,
relocation patcher, lazy binding, dlopen/dlsym/dlclose, or hook replacement
paths. Error-state coverage for read failures and missing DT_NULL remains
for later Step2 tasks.

Validation:
- cc -I. -Itarget/i386/latx/include tests/unit/kzt/test_guest_dynamic_parser.c target/i386/latx/context/kzt_guest_dynamic.c -o "$out"
- "$out" --filter complete_runtime_dynamic_view
- "$out" --filter dynamic_address_semantics
- ../configure --target-list=x86_64-linux-user --disable-blobs --disable-debug-info --disable-docs --disable-linux-io-uring --disable-werror --enable-kzt --enable-latx --extra-ldflags=-ldl --optimize-O1
- meson compile -C build-t1-review-build-20260706-143954 kzt-guest-dynamic-parser
- meson test -C build-t1-review-build-20260706-143954 kzt-guest-dynamic-parser --print-errorlogs
- git diff --check

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
@LaurenIsACoder
LaurenIsACoder marked this pull request as draft July 6, 2026 12:30
@LaurenIsACoder LaurenIsACoder changed the title LATX, refactor: add KZT guest object registry observation LATX, refactor: staged KZT library passthrough Jul 6, 2026
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
@LaurenIsACoder

Copy link
Copy Markdown
Owner Author

该 PR 是本次 KZT 重构的 Step1/Step2 阶段性草稿,内容已被后续累计分支完全包含。为遵循“所有阶段完成、验证和人工审核结束后只创建一个最终累计 PR”的约定,现关闭此阶段性 PR;分支与提交仍保留供追溯。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant