Skip to content

Latest commit

 

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

skill_factory_v3

认知节点网络的构建与演化引擎.

它接收自然语言描述的可操作能力, 通过结构化验证、废料回收、跨域碰撞, 持续生产和强化可用的 SkillNode, 最终构成一个随使用自动生长、不因人类个 体局限而停滞的认知积累系统.

CI release python license tests

What this is

Three problems this engine targets:

  1. 碎片化 — 人积累的经验和工具使用习惯散落在脑子里, 用完就忘, 无法复 用, 无法传递. sf3 把这些变成可检索、可调用的结构化节点.
  2. 质量退化 — 堆积的知识越来越多但越来越乱, 早期的强信号被后期的噪声淹没. ARE 机制确保优质语料持续放大, 废料中有价值的部分被回收而不是丢弃.
  3. 边界僵化 — 人类受寿命、精力、领域限制, 认知边界难以突破. sf3 通过跨域 碰撞和涌现, 在已知节点的交叉处生成人类个体无法单独产生的新认知.

具体使用场景、适用人群、如何判断它是否在帮忙 — 见 docs/USAGE.md.

Status: Sprint 1–11 已交付 (373 / 373 tests pass in ~7 s). Sprint 12 是一轮战略重构: 拆 SkillNode 上帝对象, 清理伪 arxiv 引用, 合并 CAF 四 层到单一 WeightedFilter, 补端到端集成测试. 各子步详见 analysis_runs/step12_*_predecisions.md 与同名 close log.

Plan: ~/.windsurf/plans/are-os-v3-implementation-25a40c.md (1559 lines, v3.2 with integrated remediation).

Quick start

# Install (Python 3.11+, uv recommended)
git clone git@github.com:KingOfZhao/skill_factory_v3.git && cd skill_factory_v3
uv venv --python 3.11
source .venv/bin/activate
uv pip install -e ".[dev]"

# Smoke test
sf3 --help                                      # CLI tour
sf3 skill new --topic "attention residuals"     # generate a SkillNode
sf3 doctor --llm                                # probe LLM providers
sf3 doctor --go-no-go                           # 14-metric audit
sf3 doctor --edges --diff                       # ARE edge store + diff vs last snapshot
sf3 doctor --node SK-XXXXXX                     # one-node neighbourhood drill-down

# Optimize a SkillNode (factory ContentOptimizer + signal)
sf3 skill opt SK-XXXXXX --deep --json

# Reflect on the whole corpus (DAG-aware order, Sprint 11.1)
sf3 skill reflect --all --order topo_asc

# Run the test suite
pytest -q                                       # 373 / 373 in ~7 s

Demo: ingest + analyze + optimize + split a real-world Windsurf workflow

# 1. Ingest a 192-line `figma-to-flutter.md` (Windsurf workflow) → SkillNode + analysis report
.venv/bin/python analysis_runs/analyze_figma_to_flutter.py            # ~5 ms

# 2. Run the factory ContentOptimizer + AI rewrite (4 layers) → optimized v2 workflow
.venv/bin/python analysis_runs/optimize_figma_to_flutter_v2.py        # ~1.3 ms
# → validation_score 0.82 → 0.91 (14-metric: 7/14 → 8/14)

# 3. Split into 4 atomic SkillNodes + 4 chained workflow files
.venv/bin/python analysis_runs/split_figma_to_flutter.py              # ~6 ms
# → 4 atoms × avg_score 0.9050, chain detected by collision/engine

# 4. Reversible deploy back to a target git repo (no force-push)
bash analysis_runs/deploy/deploy.sh --strategy {monolithic|atomic} [--apply]

Full walkthrough: analysis_runs/optimization_report.md.

Architecture (5 layers)

L5 Presentation:   sf3 CLI (typer + rich, Apple HIG colors, three-band errors)
L4 Application:    paper_collector | skill_factory | are_engine | orchestrator
L3 Schema:         Pydantic v2 — SkillNode (single source of truth)
L2 Compute:        torch | sentence-transformers | faiss-cpu | sqlmodel | LLM providers
L1 Storage:        LocalFS (default) | NAS (fnos primary, smb fallback) | 1MB ShardManager

Sprint roadmap

Sprint Status Key deliverable
1 ✅ done schema/skill_node.py + CLI skeleton
2 ✅ done paper harvester + auto-fallback LLM stack
3 ✅ done async generator + LifecycleOrchestrator
4 ✅ done CAF 4-layer async pipeline
5 ✅ done RVF extractor (3 types) + retry/degrade
6 ✅ done sharded collision engine + auditor + lifecycle
7 ✅ done ShardManager dynamic rebalance + legacy migrator
8 ✅ done orchestrator + 14 metrics + Go/No-Go cron
9 ✅ done factory-level ContentOptimizer + sf3 skill opt --deep
10 ✅ done meta_skill + lock:* tags + EdgeIndex + sf3 doctor --edges
11 ✅ done DAG-aware reflect ordering + --edges --diff + --node
12 🔄 in progress strategic refactor: arxiv cleanup / SkillNode split / e2e tests / WeightedFilter

Module map

sf3/
├── cli/              L5 — typer app + subcommands (skill / paper / caf / rvf / collide / nas / doctor / status)
├── schema/           L3 — single source of truth (Pydantic v2 SkillNode + NetworkEdge + WasteCorpusEntry)
├── llm/              L2 — 7-provider abstraction (DeepSeek/Ollama/OpenAI/Anthropic/GLM/Qwen/Mock) + auto-fallback
├── papers/           L4 — algorithm modules grouped by pipeline stage; see registry policy below
├── caf/              L4 — Corpus Attention Filter (4 async layers; Sprint 12 will collapse to one WeightedFilter)
├── rvf/              L4 — Residual Valid Fragment recovery (structural / contrastive / metaphor + retry-degrade)
├── attention/        L4 — multiway / cross / mhc-constraint primitives
├── collision/        L4 — sharded engine + auditor + lifecycle expirer + surgical-rewrite
├── factory/          L4 — generate / lifecycle / content_optimizer / llm_synth / edge_doctor / node_inspector
├── lifelong/         L4 — ELL controller (papers/ell)
├── harvester/        L4 — arxiv client + offline fixtures + paper-to-skill
├── orchestrator/     L4 — full-flow DAG + 14 metrics + Go/No-Go
└── storage/          L1 — LocalFS / fnOS / SMB + NASRouter + SQLiteIndex + EdgeIndex + ShardManager

analysis_runs/        — real-world demo + per-sprint close logs + ARE round reports
scripts/              — verify_phase0 / migrate_legacy_nodes / cron_metrics
tests/                — unit tests across Sprint 1–11

Algorithm modules (sf3/papers/)

Each module under sf3/papers/ implements a small algorithm used somewhere in the factory pipeline (CAF / RVF / Collision / Lifelong) and registers itself with a canonical module_id via sf3/papers/_registry.py.

“Real paper” vs “inspired-by” policy (Step 12.1):

  • Real, verified arxiv paper — carries arxiv_id on its registry entry. Currently exactly two:
    • dca — DeepCrossAttention (ICML 2025, 2502.06785)
    • mudd_former — MUDDFormer (ICML 2025, 2502.12082)
  • Inspired-byarxiv_id=None. The module title describes what the code does (e.g. “节点时效评分模块”, “Top-k 稀疏路由器”) and the docstring carries a “参考思路” note pointing at the source inspiration without claiming a 1:1 reproduction.

Run python -c 'from sf3.papers import list_papers; [print(p.module_id, p.title) for p in list_papers()]' to see the live list.

Testing

pytest -q                                # 373 / 373 in ~7 s (Sprint 1–11)
pytest tests/unit/factory -v             # factory only (edge_doctor / node_inspector / content_optimizer)
pytest -k content_optimizer              # 13 ContentOptimizer tests

Unit tests run fully offline (mock LLM provider + offline fixture papers — see _FIXTURE_PAPERS in sf3/harvester/arxiv_client.py, whose IDs are the obvious-test 9999.000X form). Real LLMs / NAS are opt-in via env-vars: DEEPSEEK_API_KEY, OLLAMA_URL, FNOS_HOST, SMB_HOST

Sprint 12 will add an end-to-end integration test that walks generate → validate → optimize → reflect → SQLite and asserts validation_score ≥ 0.85 on the final SkillNode.

Coexistence with legacy ~/Desktop/skill_factory/

This v3 package lives at ~/Desktop/skill_factory/skill_factory_v3/. The legacy node_manager.py / enhanced_node_manager.py / node_cli.py are not modified and remain functional. scripts/migrate_legacy_nodes.py performs a one-shot migration from legacy JSON nodes to v3 SkillNodes (sf3/storage/sqlite_index + ShardManager).

Stats (snapshot, 2026-05-08)

Count
Tests passing 373 / 373 (~7 s)
Algorithm modules in sf3/papers/ 20 (2 real-arxiv + 18 inspired-by)
LLM provider stubs 7
Storage backends 3 (LocalFS / fnOS / SMB) + buffer
CLI subcommands 8
Sprint progress 11 / 11 closed; 12 in progress

Contributing

This project is an outcome of pair-programming between the maintainer and Cascade (an AI coding assistant). Please file issues for plan deviations, missing paper algorithms, or schema-breaking changes. PRs welcome — pytest -q must stay green and any new paper in sf3/papers/ must register itself + ship a smoke_test().

License

Apache-2.0 — see LICENSE.

About

AGI cognitive self-consistency OS. sf3 binary, Pydantic SkillNode, 20 papers, 8 sprints, 219 tests, figma-to-flutter demo.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages