[truealpha-factors] Implement safe Qlib expression contract - #194
Merged
Conversation
Owner
Author
|
@copilot review |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a Qlib-independent, content-addressed typed expression contract and a “safe compiler boundary” that emits canonical Qlib syntax only from approved typed AST nodes, then validates parity against pinned Qlib behavior using the frozen S8 synthetic corpus.
Changes:
- Add
truealpha_contracts.qlib_expressionmodels for typed AST nodes, operator registry, compiled expressions, and execution bindings/evidence (all strict/frozen and content-addressed). - Add the S8 tiny runtime compiler/adapter in
libs/factorsplus a Qlib-parity test suite (including an independent evaluator oracle). - Advance S8 batch governance metadata to reflect E0 acceptance and move the batch forward to E1 work.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/contracts/src/truealpha_contracts/qlib_expression.py | Defines the Qlib-independent typed AST + operator registry + identity/binding contracts with strict validation and hashing. |
| libs/contracts/tests/test_qlib_expression.py | Validates contract canonicalization, injection resistance, limits, and identity stability against a frozen corpus. |
| libs/factors/src/factors/batches/qlib_expression_contract_tiny/compiler.py | Implements the compiler boundary (typed AST → canonical Qlib field) and execution evidence binding. |
| libs/factors/src/factors/batches/qlib_expression_contract_tiny/init.py | Exposes the S8 compiler/evidence surface for provisional callers without changing the Gate 0 export. |
| libs/factors/tests/batches/qlib_expression_contract_tiny/test_compiler.py | Tests compiler rejection paths, lookback validation, and execution-vs-semantic identity separation. |
| libs/factors/tests/batches/qlib_expression_contract_tiny/test_qlib_runtime.py | Validates oracle parity vs Qlib runtime and ensures Qlib sees only compiler output. |
| governance/batches/S8-qlib-factor-expression.v1.json | Updates batch status/revision and records E0 acceptance state plus acceptance commands. |
| governance/vision-issue-graph.json | Updates the Vision graph batch entry to match the new manifest hash/status/target rung. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wangzitian0
force-pushed
the
batch/s8-qlib-expression-e0
branch
from
July 14, 2026 13:35
9ad1972 to
d9f90d9
Compare
This was referenced Jul 14, 2026
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Implement E0 for #189 over the frozen S8 corpus. This PR accepts experimental code only; it leaves #189 open and approves no product factor, real data, provider, replay, persistence, or release path.
The slice adds:
The Gate 0-frozen
truealpha_contracts/__init__.pyremains unchanged. Provisional callers import the dedicated module directly; public re-export waits for a stable handoff and Gate 0 candidate rebind.Verification
uv sync --project libs/factors/qlib-runtime --all-groups --frozenuv run pytest libs/contracts/tests/test_qlib_expression.py -q(14 passed)uv run --project libs/factors/qlib-runtime pytest libs/factors/tests/batches/qlib_expression_contract_tiny -q(15 passed)uv run mypypassed (95 source files)make issue-graph-checkpassedmake checkpassed (714 passed, 5 skipped); exact rebased head is covered by PR CIIssue: #189