moonfish

moon add vectie/moonfish@0.1.0
Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
14 days ago
Downloads
2
README

#MoonFish

Domain pack · governed research and shadow-only alpha. Read the product contract for the recommendation shape, licensed-data boundary, validation gates and explicit non-trading scope.

MoonFish is a MoonSuite-native research product. The repository now contains two related layers:

  • Systematic A-share research and paper-portfolio product: the active product direction, exposed through the MoonBit moonpack/, suitepack/, ashare/, and cmd/ packages. The former Python localhost pilot has been removed.
  • Price-action/PA Agent migration foundation: a deterministic MoonBit pack that preserves the earlier PA migration work as a tested suite-native reference for contracts, evidence, replay, release, rollback, and operations readiness.

Both layers follow the same rule: Moonfish owns domain contracts and evidence; MoonGate owns provider/proxy status; MoonClaw owns bounded execution; MoonBook owns durable accepted records; Moondesk projects product tools and records.

#Product Scope And Boundary

Moonfish currently owns:

  • A-share systematic research contracts, deterministic factor scoring, dossiers, independent bull/bear review artifacts, recommendation-plan math, paper positions, durable paper accounts, account outcomes, Bookkeeper finalization payloads, and MoonFlow boundary handoff records.
  • Price-action analysis contracts and evidence retained from the PA migration: market snapshots, deterministic indicator/level/routing/validation helpers, two-stage analysis routine projections, replay/export anchors, and cutover reports.

Moonfish does not own live broker execution, order transmission, market-data licensing rights, final publication authority, the desktop shell, the agent runtime, or durable book infrastructure. Commercial data must arrive through a validated customer-owned licensed bundle. Development fixtures never grant commercial release, broker, order, cash movement, or investment-advice authority.

The price-action foundation still owns:

  • market snapshots and closed-bar data readiness
  • deterministic indicator, level, strategy-routing, validation, and safety helpers
  • two-stage analysis routine packets and outputs
  • MoonBook write plans, replay/export anchors, and review queues
  • cutover, rollback, parity, and decommission evidence from the PA Agent migration
  • Moondesk app-tool manifests and run-history projections for Moonfish records

#Current Product Surfaces

  • moonpack/: installable MoonPack distribution for Moonfish Systematic A-Share Research (version 0.20.0) with 58 schemas, 34 tools, 2 workflows, 15 provider ports, 10 policies, migrations, evaluations, and uninstall contract.
  • suitepack/: MoonBit declaration of the installable pack manifest. It validates authority classes and proves the pack exposes no broker/order or physical-effect capability. The pack declares the generic finance.moonfish Moondesk area and carries an installed compatibility contract until the shared manifest codec preserves that field directly.
  • ashare/: MoonBit A-share packages for deterministic factor scoring and ranking, systematic run composition, policy/math, eligibility and watchlist policy, exact trading-policy binding and readiness gates, MoonBook record persistence, pack-tool execution, app-service contracts, wiki projection, MF3 adapters/exporters, and tests.
  • cmd/moonfish_tool: native stdin/stdout implementation of the installed systematic.run pack tool.
  • cmd/moonfish_service: native loopback service for the Finance operator surface. It submits installed workflows to MoonClaw and stores accepted requests and completed results through the MoonBook record adapter.
  • cmd/moonfish_tushare: retained unregistered adapter code. Tushare is not an active or packaged provider for the current workflow.
  • cmd/moonfish_sina: native permissioned Sina client with full-universe discovery, daily history, and aggregate multi-symbol quote modes.
  • cmd/moonfish_market_store: native embedded-SQLite data-plane command. It imports full Sina snapshots, plans incremental work, shares provider quota across processes, skips committed sessions, and commits complete post-close aggregate sessions atomically.
  • cmd/moonfish_cninfo_backfill: native immutable-cohort CNInfo importer. It resumes disclosure pages and reported-facts datasets from embedded-SQLite evidence cursors, preserves raw official-public-web evidence, and emits no policy pass or investment recommendation.
  • cmd/moonfish_post_filter_rl: native post-basic-filter historical learner. It verifies the immutable cohort, complete source-policy criterion catalog, and versioned tuning form before evaluating bounded parameter actions. Its current price-only output is research priority, not an investment score.
  • moonpack/apps/daily/: pack-owned operator UI. Moondesk discovers and same-origin proxies this surface without importing finance rules.
  • pack/, product/, release/, rollback/, operations/, and related packages: the price-action suite-pack foundation from the PA migration.
  • cmd/main: local MoonBit smoke CLI. summary prints the price-action product readiness chain; layout prints fresh-suite product-home paths.

#Implementation Guidance

Keep analysis behavior explainable and replayable. Deterministic packages should produce evidence that the routine and UI can inspect later; orchestration packages should compose those records instead of recomputing domain facts.

The package list below is intentionally long because it documents product surface area. When adding a feature, update the owning package description and avoid creating a parallel path that bypasses policy, record integrity, replay, export, or review gates.

Price-action foundation implementation:

  • product/: assembled Moonfish product status and launch manifest over workspace, settings, import, parity, comparison, acceptance, readiness, handoff, decommission, and daily cutover rehearsal evidence.
  • release/: standalone release certificates proving Moonfish is the primary workflow and PA Agent is retained only as a read-only archive reference.
  • rollback/: rollback-window reports proving read-only PA Agent fallback, Moonfish primary workflow, replay/export, escalation, and archive evidence.
  • operations/: day-2 readiness reports proving suite health, primary workflow, rollback monitoring, replay/export, resilience, and operator observability after cutover.
  • domain/: market snapshots, stage contracts, validation reports, durable analysis records.
  • data/: market-source requests, adapter plans, closed-bar refresh readiness, local fixture snapshots, and external snapshot ingestion.
  • tools/: deterministic indicator, structure-level, strategy-routing, and validation helpers.
  • policy/: standalone advisory decision policy for no-market-order, reversal-risk, confidence, and risk-note hard bans.
  • routine/: the two-stage routine phase plan and dry-run record assembly.
  • prompt/: deterministic prompt packet assembly for Stage 1 and Stage 2.
  • skills/: suite-owned prompt skills, strategy-note catalog, and PA prompt source-to-MoonBook migration plan.
  • memory/: suite-native experience memory entries and deterministic Stage 2 selection for prompt evidence.
  • model/: MoonGate discovery snapshots, model gateways, catalog, usage/quota, integration contracts, context budget reports, provider error normalization, and model-call contracts.
  • resilience/: provider failure reports that join normalized provider errors, retry disposition, failed routine evidence, and partial-record preservation.
  • config/: migration plans for legacy provider/general/validation settings into MoonGate suite status, market requests, and retry policy.
  • planning/: pre-execution analysis plans joining operator intent, MoonGate status, market adapters, refresh readiness, and MoonClaw routine phases.
  • job/: deterministic durable-state projection for MoonClaw-owned jobs in ready, awaiting-data, completed, failed, and cancelled states. It does not run an agent or schedule work.
  • orchestration/: deterministic projection and validation of seeded two-stage MoonClaw results, including context-budget and decision-policy gates, retry dispositions, cancellation evidence, and partial-record visibility. It never invokes a model/provider or owns an agent loop.
  • cancellation/: reusable cancellation reports that prove operator-cancelled routines emit cancel events, preserve partial record paths, and stop at the requested stage boundary.
  • retry/: validation retry decisions with bounded policy, feedback targets, and immutable-field guards.
  • execution/: offline execution projections that join deterministic evidence, structure levels, prompts, context budgets, fixture model outputs, decision policy, events, and records.
  • workflow/: product-level analysis bundles that compose data, execution, chart, book write plans, and commit reports.
  • integrity/: MoonBook record integrity reports over self-contained analysis records, write-plan declarations, commit readiness, replay anchors, and export anchors.
  • appsmoke/: Moondesk app-tool smoke reports over removable completed, external-ingest, redacted-debug, and MoonBook-backed operator workflows.
  • workspace/: product-level run workspaces that compose plan, workflow, job, retry, policy, app, replay, export, safety, and history projections.
  • migration/: idempotent MoonBook import plans and inspectable imported record projections for legacy PA Agent records, pending analyses, experience entries, and trade logs.
  • evaluation/: cutover readiness reports over workspace, import, prompt-skill migration, safety, replay, export, operator, and manifest evidence.
  • comparison/: phase 8 cutover comparison reports over golden parity evidence, live snapshot rehearsals, and read-only rollback evidence.
  • acceptance/: fixture-driven product acceptance gates for completed runs, external data review, retry pause, cancellation reports, provider failure handling, record integrity, app-tool contract, app-tool smoke, import traceability, prompt-skill migration, parity readiness, operator handoff, decommission archive readiness, and safety redaction.
  • parity/: traced golden-fixture parity reports with PA Agent fixture paths, Moonfish evidence paths, assertions, and known-difference classifications.
  • cutover/: operator cutover checklists, rollback plans, imported-data manifest references, and decommission notes.
  • handoff/: operator activation reports with launch path, readiness gates, and Moondesk runbook steps.
  • decommission/: PA Agent read-only decommission reports with archive manifests, rollback evidence, imported-record preservation, and final notes.
  • review/: MoonBook review queues derived from fetch, validation, and confidence evidence.
  • followup/: analysis-attached context, cited session plans, responses, and turn records for post-run chat.
  • replay/: deterministic replay plans over persisted MoonBook evidence and commit reports.
  • export/: audit and public-summary export manifests over run artifacts.
  • safety/: explicit safety reports for broker, decision policy, context budget, book commit completeness, replay, export, and ownership boundaries.
  • app/: Moondesk app-tool manifests and run views with controls, bindings, panels, actions, and status counts.
  • history/: Moondesk run history indexes over analysis bundles.
  • book/: MoonBook write plans and idempotent commit reports for durable raw evidence and generated records.
  • chart/: Moondesk-facing chart frame projections with candles, support/resistance summaries, and decision annotations.
  • pack/: the discoverable suite-pack manifest for MoonBook, MoonClaw, and Moondesk integration.
  • schemas/: JSON-schema artifacts for records, routine envelopes, and tool contracts.

#Docs

#Testing Guidance

Run MoonBit validation before changing contracts:

/Users/kq/.moon/bin/moon check --warn-list +73 /Users/kq/.moon/bin/moon test /Users/kq/.moon/bin/moon info /Users/kq/.moon/bin/moon fmt

Current validation snapshot, as of 2026-07-24:

  • moon check --warn-list +73, moon test, moon info, and moon fmt are the release gates; no product Python test path remains.
  • suitepack checks the checked-in distribution and all JSON schemas through MoonBit.
  • A fresh MoonBook install records and verifies the app, service, command, workflow, fixture, policy, schemas, and app-area contract.
  • The installed native service submits the daily fixture workflow to the generic MoonClaw pack runner. MoonClaw persists a succeeded durable job and MoonBook persists separate request and result records.
  • Every native systematic run must present the exact moonfish-a-share-trading-policy@2.0.0 content hash. Its objective searches for a 10x extreme bull scenario within one quarter, defined as 40–65 trading sessions. This is not the expected return or a guarantee. Fixture or community data, missing named review, and owner risk limits keep the result explicitly non-investment-ready.
  • Moondesk discovers the installed pack as finance.moonfish, proxies the pack-owned UI, and can submit the workflow through the same-origin app route.
  • scripts/fresh-suite-product-home-smoke.sh remains the price-action layout smoke.

For workflow changes, add or update fixture tests that prove completed runs, external-data review, retry pause, cancellation, provider failure handling, record integrity, app-tool contracts, import traceability, parity readiness, operator handoff, safety redaction, A-share scoring, recommendation-plan authority, paper-account mutation, validation shadow state, Bookkeeper finalization, and MoonFlow boundary records. Use replay/export tests whenever a record can be persisted or shared.

#Worth Noticing

  • Moonfish should never place live broker execution behind analysis wording. Advisory and no-market-order policies are hard boundaries.
  • Legacy PA Agent material is archive and parity evidence, not the new source of truth.
  • Public summaries must be derived from persisted MoonBook-safe records, not transient prompt text.
  • App-tool UI should display evidence paths, review state, and replay/export anchors instead of hiding the audit trail.

#Future Plan

  • Keep the MoonPack manifest and checked-in moonpack/pack.json synchronized.
  • Add a licensed-provider implementation behind the existing provider port. The native Tushare free-tier command provides unadjusted daily-bar pre-screening, and the permissioned Sina command provides a rate-limited delayed session snapshot. The executable systematic workflow still exposes only the verified fixture and fails closed rather than treating either feed as complete point-in-time evidence.
  • Extend the native MoonClaw workflow one governed phase at a time: licensed acquisition, dossier generation, independent review, named-human release, and paper-account operations.
  • Move pack-app service activation into the generic suite runtime lifecycle so operators never need to start a pack binary manually.
  • Keep the PA/price-action foundation as a concise, passing reference; do not add stale PA compatibility paths.

#
MoonfishMoonSuiteProductHome

pub(all) struct MoonfishMoonSuiteProductHome {
product_id : String
state_path : String
service_path : String
cache_path : String
tmp_path : String
accepted_output_path : String
} derive(Eq, ToJson,
Debug
,
FromJson
)

#
moonsuite_product_accepted_output_path

fn moonsuite_product_accepted_output_path(book_id? : String) -> String

#
moonsuite_product_accepted_output_path_for_workspace_root

fn moonsuite_product_accepted_output_path_for_workspace_root(root : String, book_id? : String) -> String

#
moonsuite_product_cache_path

fn moonsuite_product_cache_path() -> String

#
moonsuite_product_cache_path_for_workspace_root

fn moonsuite_product_cache_path_for_workspace_root(root : String) -> String

#
moonsuite_product_home

fn moonsuite_product_home(book_id? : String) -> MoonfishMoonSuiteProductHome

#
moonsuite_product_home_for_workspace_root

fn moonsuite_product_home_for_workspace_root(root : String, book_id? : String) -> MoonfishMoonSuiteProductHome

#
moonsuite_product_id

fn moonsuite_product_id() -> String

#
moonsuite_product_service_path

fn moonsuite_product_service_path() -> String

#
moonsuite_product_service_path_for_workspace_root

fn moonsuite_product_service_path_for_workspace_root(root : String) -> String

#
moonsuite_product_state_path

fn moonsuite_product_state_path() -> String

#
moonsuite_product_state_path_for_workspace_root

fn moonsuite_product_state_path_for_workspace_root(root : String) -> String

#
moonsuite_product_tmp_path

fn moonsuite_product_tmp_path() -> String

#
moonsuite_product_tmp_path_for_workspace_root

fn moonsuite_product_tmp_path_for_workspace_root(root : String) -> String

#
prepare_operations_readiness_report

#
prepare_product_launch_manifest

#
prepare_product_rehearsal_report

#
prepare_product_status

#
prepare_release_certificate

#
prepare_rollback_window_report

#
product_name

fn product_name() -> String