Skip to content

Commit 3e39e45

Browse files
Pigbibicodex
andcommitted
Add plugin lifecycle policy registry
Co-Authored-By: Codex <noreply@openai.com>
1 parent bb6b459 commit 3e39e45

8 files changed

Lines changed: 494 additions & 178 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ python -m pytest -q
3333
```
3434

3535
## Useful docs
36-
36+
- [`docs/plugin_lifecycle_policy.md`](docs/plugin_lifecycle_policy.md)
3737
- [`docs/market-regime-control-plan.md`](docs/market-regime-control-plan.md)
3838
- [`docs/market-regime-control-plan.zh-CN.md`](docs/market-regime-control-plan.zh-CN.md)
3939

README.zh-CN.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ QuantStrategyPlugins 是 QuantStrategyLab 的策略插件包。提供 market-reg
1717
- 密钥和环境专属配置不要写进共享库代码。
1818
- 会影响多个平台或策略包的改动,需要在文档中说明。
1919

20+
## 延伸文档
21+
22+
- [`docs/plugin_lifecycle_policy.zh-CN.md`](docs/plugin_lifecycle_policy.zh-CN.md)
23+
2024
## 仓库结构
2125

2226
- `src/`:库代码和运行时代码。
@@ -34,6 +38,7 @@ python -m pytest -q
3438

3539
## 延伸文档
3640

41+
- [`docs/plugin_lifecycle_policy.zh-CN.md`](docs/plugin_lifecycle_policy.zh-CN.md)
3742
- [`docs/market-regime-control-plan.md`](docs/market-regime-control-plan.md)
3843
- [`docs/market-regime-control-plan.zh-CN.md`](docs/market-regime-control-plan.zh-CN.md)
3944

docs/market-regime-control-plan.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
This document records the current design boundary, arbitration order, strategy
66
consumption policy, and backtest evidence for `market_regime_control`.
77

8+
See also: [`plugin_lifecycle_policy.md`](./plugin_lifecycle_policy.md) for the
9+
shared plugin stage ladder and gate model.
10+
811
## Goals
912

1013
`market_regime_control` is a unified deterministic market-regime facade. It

docs/plugin_lifecycle_policy.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Plugin Lifecycle Policy
2+
3+
[简体中文](./plugin_lifecycle_policy.zh-CN.md)
4+
5+
This document defines the lifecycle ladder and gate model for strategy plugins.
6+
7+
## Design Goal
8+
9+
Plugins should be easy to observe, hard to misuse, and very hard to let affect
10+
capital without explicit approval.
11+
12+
- AI may monitor and summarize plugin evidence.
13+
- AI must not upgrade a plugin into live authority by itself.
14+
- Notification delivery is not the same as position-control authority.
15+
- Compatibility mounts can exist for history, but they should not expand live
16+
permission by accident.
17+
18+
## Recommended Plugin Stages
19+
20+
| Stage | Meaning | Capital impact |
21+
| --- | --- | --- |
22+
| `research_only` | Research artifact, not meant for platform runtime | none |
23+
| `notification_only` | Can notify humans, but cannot control position | none |
24+
| `shadow_observer` | Can be attached to runtime metadata and audit trails | none |
25+
| `automation_candidate` | Has enough evidence to be considered for automation | gated |
26+
| `automation_approved` | Strategy-side automation is allowed when the platform gate also passes | yes |
27+
| `deprecated_compatibility` | Kept for replay or staged migration only | none |
28+
29+
## Three-Gate Rule
30+
31+
For any plugin-driven capital impact, all three gates must pass:
32+
33+
1. **Plugin schema gate**
34+
- The artifact must match a supported schema version and remain in `shadow`
35+
mode for the shared contract.
36+
2. **Plugin evidence gate**
37+
- The plugin must be marked `automation_approved` and
38+
`position_control_allowed = true`.
39+
3. **Strategy/platform gate**
40+
- The consuming strategy must explicitly opt in to the plugin and remain
41+
allowed by the platform catalog.
42+
43+
If any gate fails, the plugin should stay notification-only or compatibility-only.
44+
45+
## Current Policy Shape
46+
47+
- `src/quant_strategy_plugins/plugin_policies.py` is the machine-readable source
48+
for lifecycle, consumption, notification-target, schema-version, and
49+
deprecated-successor policy.
50+
- `market_regime_control` is the unified default runtime plugin.
51+
- `crisis_response_shadow`, `macro_risk_governor`, and `taco_rebound_shadow`
52+
remain compatibility mounts or notification-only sidecars.
53+
- `panic_reversal_shadow` remains research-heavy and should stay notification-only
54+
unless it is separately promoted.
55+
56+
## Recommended Operating Rules
57+
58+
- Keep `notification_allowed` broad for research visibility.
59+
- Keep `position_control_allowed` narrow and explicit.
60+
- Prefer a single shared policy registry instead of spreading allowlists across
61+
runners.
62+
- When a strategy consumes a plugin for live capital impact, keep the platform
63+
notification path separate from the strategy execution path.
64+
65+
## Practical Interpretation
66+
67+
- If the artifact is only for human review, use `notification_only`.
68+
- If the artifact is still a sidecar evidence layer, use `shadow_observer`.
69+
- If the plugin is being prepared for automation, keep it in
70+
`automation_candidate` until the strategy gate also passes.
71+
- If the plugin is no longer the preferred path, mark it
72+
`deprecated_compatibility` and keep it out of new runtime defaults.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# 插件生命周期策略
2+
3+
[English](./plugin_lifecycle_policy.md)
4+
5+
本文定义策略插件的生命周期阶梯和门槛模型。
6+
7+
## 设计目标
8+
9+
插件应该容易观察、难以误用,而且在没有显式批准前非常难影响资金。
10+
11+
- AI 可以监控和总结插件证据。
12+
- AI 不能单独把插件升级成 live 权限。
13+
- 通知投递不等于仓位控制权限。
14+
- 兼容挂载可以保留用于历史回放,但不能意外扩大 live 权限。
15+
16+
## 推荐插件阶段
17+
18+
| 阶段 | 含义 | 资金影响 |
19+
| --- | --- | --- |
20+
| `research_only` | 研究 artifact,不打算进入平台 runtime ||
21+
| `notification_only` | 可以通知人工,但不能控制仓位 ||
22+
| `shadow_observer` | 可以挂到 runtime metadata 和审计轨迹 ||
23+
| `automation_candidate` | 证据足够,进入自动化候选 | 受门槛控制 |
24+
| `automation_approved` | 当平台门槛也通过时,策略侧可自动消费 ||
25+
| `deprecated_compatibility` | 仅用于回放或迁移兼容 ||
26+
27+
## 三道门槛
28+
29+
任何由插件驱动的资金影响,都必须同时通过三道门槛:
30+
31+
1. **插件 schema 门槛**
32+
- artifact 必须匹配支持的 schema version,并在共享契约中保持 `shadow` 模式。
33+
2. **插件证据门槛**
34+
- 插件必须标记为 `automation_approved`,且 `position_control_allowed = true`
35+
3. **策略 / 平台门槛**
36+
- 消费策略必须显式 opt-in,并且仍然被平台 catalog 允许。
37+
38+
任意一项失败,插件就应该停留在 notification-only 或兼容模式。
39+
40+
## 当前策略形态
41+
42+
- `src/quant_strategy_plugins/plugin_policies.py` 是 lifecycle、消费权限、
43+
notification target、schema version 和 deprecated successor 的机器可读来源。
44+
- `market_regime_control` 是统一默认 runtime 插件。
45+
- `crisis_response_shadow``macro_risk_governor``taco_rebound_shadow`
46+
仍然是兼容挂载或 notification-only sidecar。
47+
- `panic_reversal_shadow` 仍然偏研究,应继续保持 notification-only,
48+
除非后续单独晋级。
49+
50+
## 推荐运行规则
51+
52+
- `notification_allowed` 可以保持宽松,方便研究可见。
53+
- `position_control_allowed` 必须保持窄而明确。
54+
- 尽量使用统一的 policy registry,不要把 allowlist 分散到多个 runner。
55+
- 当策略消费插件并产生 live 资金影响时,平台通知路径应与策略执行路径分离。
56+
57+
## 实际解释
58+
59+
- 只给人工复核看的 artifact,用 `notification_only`
60+
- 仍然只是 sidecar 证据层的 artifact,用 `shadow_observer`
61+
- 正在准备自动化的插件,用 `automation_candidate`,直到策略门槛也通过。
62+
- 不再是新默认路径的插件,用 `deprecated_compatibility`,并避免出现在新的 runtime 默认值里。

0 commit comments

Comments
 (0)