feat(strategies): publish type-only strategy authoring API (CL31)
This commit is contained in:
parent
a411f9a665
commit
3a63b2039e
13 changed files with 300 additions and 121 deletions
|
|
@ -27,3 +27,5 @@ Agents use root-reserved disjoint files in the integration worktree. Root alone
|
|||
- **CL35:** Actual FastAPI app/lifespan and optional capability tests: 11 passed. Missing scientific/multipart dependencies do not prevent unrelated routes; unavailable initialization returns503, health observes state. Successful optimizer/model paths tested with stubs; load-to-list output shape corrected and covered. No heavy scientific packages installed.
|
||||
|
||||
- **CL30:** Independent workspace/finding UI suites: 203 passed, 1306 assertions; agent full relevant UI set344 passed, 2143 assertions. Full source typecheck and scoped lint/format passed. Extracted feature-owned read/draft/write hooks; neutral styles and unsaved warning imports replace cross-feature dependencies; custody and uncertainty behavior preserved.
|
||||
|
||||
- **CL31:** Independent public-author/runtime suite:25 passed,363 assertions; standalone compilation uses no repository aliases or orchestrator/native implementation types. Source and packaged strategies produce identical native traces/checkpoints; contract compilation and scoped lint/format passed. Old contract path is a type-only compatibility export.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Canonical development backlog
|
||||
|
||||
**Active: E13 architecture cleanup, CL22–CL35 (10/14 complete).** Owner authorized all October 28 audit recommendations and a commit per validated task. Earlier completion counts below are historical. [Execution record](../architecture-cleanup-execution.md).
|
||||
**Active: E13 architecture cleanup, CL22–CL35 (11/14 complete).** Owner authorized all October 28 audit recommendations and a commit per validated task. Earlier completion counts below are historical. [Execution record](../architecture-cleanup-execution.md).
|
||||
|
||||
**Current scheduled backlog: 99/99 complete.** The owner resumed performance and authorized review of all seven conditions. P08 and O02 are implemented; five optional extensions remain deliberately deferred, and four merged IDs are redirects. This is not a claim that all 108 retained IDs were implemented. [Decisions, measurements and validation](../conditional-review.md).
|
||||
|
||||
|
|
|
|||
|
|
@ -3913,7 +3913,7 @@
|
|||
"complexity": "M",
|
||||
"assignment": null,
|
||||
"write_locks": ["CL30"],
|
||||
"completed_commit": null,
|
||||
"completed_commit": "a411f9a6659014a3a2f1cedd7f3d4ed5f23dbe54",
|
||||
"blocker": null,
|
||||
"release_gates": [],
|
||||
"completion_evidence": "architecture-cleanup-execution.md",
|
||||
|
|
@ -3926,7 +3926,7 @@
|
|||
"epic": "E13",
|
||||
"priority": "P2",
|
||||
"severity": "Medium",
|
||||
"status": "ready",
|
||||
"status": "done",
|
||||
"dependencies": ["CL26"],
|
||||
"decision_dependencies": [],
|
||||
"task_file": "backlog/tasks/CL31.md",
|
||||
|
|
@ -3936,7 +3936,9 @@
|
|||
"completed_commit": null,
|
||||
"blocker": null,
|
||||
"release_gates": [],
|
||||
"completion_evidence": "architecture-cleanup-execution.md"
|
||||
"completion_evidence": "architecture-cleanup-execution.md",
|
||||
"integration_state": "accepted",
|
||||
"validation": "Independent public-author/runtime suite:25 passed,363 assertions; standalone compilation uses no repository aliases or orchestrator/native implementation types. Source and packaged strategies produce identical native traces/checkpoints; contract compilation and scoped lint/format passed. Old contract path is a type-only compatibility export."
|
||||
},
|
||||
{
|
||||
"id": "CL32",
|
||||
|
|
@ -10401,7 +10403,7 @@
|
|||
],
|
||||
"work_policy": "Root integrates/commits reviewed tasks; agents own disjoint explicit files in the root integration worktree. Only root builds shared outputs and runs combined gates. No isolated native agent build claim.",
|
||||
"first_wave": ["CL22", "CL23", "CL24"],
|
||||
"completed": 10,
|
||||
"last_verification": "Independent workspace/finding UI suites: 203 passed, 1306 assertions; agent full relevant UI set344 passed, 2143 assertions. Full source typecheck and scoped lint/format passed. Extracted feature-owned read/draft/write hooks; neutral styles and unsaved warning imports replace cross-feature dependencies; custody and uncertainty behavior preserved."
|
||||
"completed": 11,
|
||||
"last_verification": "Independent public-author/runtime suite:25 passed,363 assertions; standalone compilation uses no repository aliases or orchestrator/native implementation types. Source and packaged strategies produce identical native traces/checkpoints; contract compilation and scoped lint/format passed. Old contract path is a type-only compatibility export."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,3 +18,7 @@ Standalone example compilation; packaging; canonical strategy and state regressi
|
|||
|
||||
No new service/framework, financial simulator, real trading activation, external research execution, push/PR or .env changes. D04/P03/P05/P06/CL21 remain deferred. Root owns shared outputs, task state and commits; agents own disjoint files in the integration worktree.
|
||||
|
||||
|
||||
## Accepted verification
|
||||
|
||||
Independent public-author/runtime suite:25 passed,363 assertions; standalone compilation uses no repository aliases or orchestrator/native implementation types. Source and packaged strategies produce identical native traces/checkpoints; contract compilation and scoped lint/format passed. Old contract path is a type-only compatibility export.
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ This fixture does not need a provider connection or running databases. For initi
|
|||
## Deeper references
|
||||
|
||||
- [Calculation library](../../libs/calculations/README.md): reviewed indicators and analytics, plus clearly separated preserved legacy functions.
|
||||
- [TypeScript strategy contract](../../apps/stock/orchestrator/src/contracts/canonical-strategy.ts): the actual callback context and output types.
|
||||
- [TypeScript strategy contract](../../libs/research/src/strategy-api.ts): the actual callback context and output types.
|
||||
- [Research product reference](../development/architecture/research-product.md): API policies, provenance and paper setup. Its original design examples and later implementation notes need to be read in context.
|
||||
- [Architecture decisions](../development/architecture/decisions): why the boundaries were chosen. These record decisions and migration context, not a substitute for the current runtime map.
|
||||
- [Backlog](../development/backlog/README.md) and [roadmap](../development/ROADMAP.md): work history, completion evidence and conditional future tasks.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ This guide follows **functions and state**, rather than application boxes. The l
|
|||
|
||||
## 1. Begin with the decision contract
|
||||
|
||||
Open [canonical-strategy.ts](../../apps/stock/orchestrator/src/contracts/canonical-strategy.ts). `StrategyProgram` describes the object a strategy factory returns. Its `decide(context)` callback returns two things:
|
||||
Open [strategy-api.ts](../../libs/research/src/strategy-api.ts). `StrategyProgram` describes the object a strategy factory returns. Its `decide(context)` callback returns two things:
|
||||
|
||||
- `nextState`: what the strategy wants to remember for its next decision.
|
||||
- `intent`: what exposure or orders it wants the financial engine to consider.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ A strategy is a TypeScript function that reads observations and account state, t
|
|||
|
||||
| File | What to look for |
|
||||
| --- | --- |
|
||||
| [canonical-strategy.ts](../../apps/stock/orchestrator/src/contracts/canonical-strategy.ts) | `StrategyProgram`, its `decide` callback, and the read-only `StrategyContext`. |
|
||||
| [strategy-api.ts](../../libs/research/src/strategy-api.ts) | `StrategyProgram`, its `decide` callback, and the read-only `StrategyContext`. |
|
||||
| [canonical-sma.ts](../../apps/stock/orchestrator/src/strategies/canonical-sma.ts) | A complete strategy: validated parameters, versioned state, history, crossover, target quantity. |
|
||||
| [canonical-mean-reversion.ts](../../apps/stock/orchestrator/src/strategies/canonical-mean-reversion.ts) | Trend, momentum, volatility regime, entry filters, and exits composed in TypeScript. |
|
||||
| [canonical-builtins.ts](../../apps/stock/orchestrator/src/strategies/canonical-builtins.ts) | The small built-in factory and checks binding each strategy owner to its instrument and observation series. |
|
||||
|
|
@ -33,12 +33,14 @@ Keep history in explicit state, use engine time instead of `Date.now()`, and avo
|
|||
|
||||
## A minimal callback shape
|
||||
|
||||
This is a deliberately simple **in-repository source example**, using imports as if placed beside `canonical-sma.ts`. It requests one share when its series is fresh; it is not an investment strategy or a ready-to-upload candidate package.
|
||||
Import author types from `@stock-bot/research/strategy-api`. This subpath contains only types; it exposes no native sessions, execution controllers, brokers, or storage services. Existing host imports of `contracts/canonical-strategy.ts` remain compatible.
|
||||
|
||||
This simple callback requests one share when its series is fresh. It demonstrates the authoring contract; it is not a validated investment strategy or a ready-to-upload candidate package.
|
||||
|
||||
```ts
|
||||
import { parseFinancialDecimal } from '@stock-bot/types';
|
||||
import type { RetainedProgramSelection } from '@stock-bot/stock-config/candidate-execution';
|
||||
import type { StrategyProgram } from '../contracts/canonical-strategy';
|
||||
import type { StrategyProgram } from '@stock-bot/research/strategy-api';
|
||||
|
||||
export function createStrategy(
|
||||
selection: RetainedProgramSelection
|
||||
|
|
@ -73,6 +75,8 @@ export function createStrategy(
|
|||
}
|
||||
```
|
||||
|
||||
For a self-contained source with no runtime imports, use [fresh-position.ts](../../libs/research/examples/fresh-position.ts). Its `shares` parameter must be a nonnegative safe integer; the example converts that checked integer to a fixed eight-decimal quantity. All imports erase during TypeScript transformation. [The public API tests](../../scripts/test/public-strategy-api.test.ts) compile the example outside the monorepo without path aliases, check the emitted module, and compare source and packaged decisions/state through the same Rust replay. Production candidate packaging still uses the existing isolated CLI; this test does not replace isolation or approval.
|
||||
|
||||
`quantity` is a desired **total holding for this owner**, not “buy this many more.” `parseFinancialDecimal('1')` creates the validated financial string `"1.00000000"`. Numeric arrays remain useful for features; financial postings use the decimal contract.
|
||||
|
||||
An empty target list means no new target update. An explicit zero target requests an exit. Neither guarantees a fill: Rust reconciles the target with holdings and pending orders, applies risk checks, and uses eligible future execution events. Never report a position change merely because the callback requested one.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue