{"id":48667152,"url":"https://github.com/animagram-jp/context-engine","last_synced_at":"2026-04-10T11:07:31.864Z","repository":{"id":335510911,"uuid":"1118327554","full_name":"animagram-jp/context-engine","owner":"animagram-jp","description":"Declarative state data management system for process","archived":false,"fork":false,"pushed_at":"2026-04-04T23:44:14.000Z","size":512,"stargazers_count":0,"open_issues_count":8,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-05T00:40:27.235Z","etag":null,"topics":["animagram","crate","declarative","domain-specific-language","rust","state-management","wasm","webassembly","yaml"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/state-engine","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/animagram-jp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-17T15:35:24.000Z","updated_at":"2026-04-04T22:46:56.000Z","dependencies_parsed_at":"2026-01-31T09:05:33.287Z","dependency_job_id":null,"html_url":"https://github.com/animagram-jp/context-engine","commit_stats":null,"previous_names":["animagram-jp/state-engine","animagram-jp/context-engine"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/animagram-jp/context-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fcontext-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fcontext-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fcontext-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fcontext-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/animagram-jp","download_url":"https://codeload.github.com/animagram-jp/context-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fcontext-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31639530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animagram","crate","declarative","domain-specific-language","rust","state-management","wasm","webassembly","yaml"],"created_at":"2026-04-10T11:07:31.260Z","updated_at":"2026-04-10T11:07:31.858Z","avatar_url":"https://github.com/animagram-jp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# context-engine\n\nData labels used by a web system's runtime within a single processing cycle should have their session-context-dependent variations resolved outside of code (e.g., `system_context[\"session.user\"]` rather than `users[session[user_id]]`). context-engine processes the data retrieval methods that application developers define as a DSL in YAML files, for each label. This allows server/client differences in `system_context[\"session.user.preference\"]` and multi-tenant differences in `context[\"session.user.tenant\"]` to be resolved appropriately through the methods defined in YAML. This library is a foundational technology for the reconstructed web system architecture (see [Background](#background)).\n\n- [See original text(ja)](#original-text-ja)\n\n---\n\n## Version\n\n| Version | Status    | Date      | Description |\n|---------|-----------|-----------|-------------|\n| 0.1     | Released  | 2026-2-12 | -           |\n| 0.1.5   | Current   | 2026-3-21 | improve #43 |\n| 0.1.6   | Scheduled | 2026-4-19 | improve #38 |\n\n---\n\n## Provided Functions\n\n| Mod | Description | fn |\n|-------|------|---------|\n| `Context` | operates context | `new/get/set/delete/exists` |\n\n---\n\n## Why context-engine?\n\n**Before:**\n```Rust\n// Manual cache management\nlet session_key = format!(\"user:{}\", id);\nlet user = redis.get(\u0026session_key).or_else(|| {\n    let user = db.query(\"SELECT id, email, name FROM users WHERE id=?\", id)?;\n    redis.set(\u0026session_key, \u0026user, 3600);\n    Some(user)\n})?;\n```\n\n**After:**\n```Rust\nlet user = state.get(\"session.user.name\")?;\n```\n\n---\n\n## Quick Start\n\n1. Add to dependencies.\n\n```toml\n# Cargo.toml\n[dependencies]\ncontext-engine = \"0.1\"\n```\n\n2. Write a yaml file.\n\n```yaml\n# mine.yml\nsession:\n  user:\n    id:\n      _load:\n        client: Memory\n        key: \"request.authorization.user.id\"\n    name:\n      _load:\n        client: Db\n        key: \"users.${session.user.id}.name\"\n```\n\n| Case              | Example |\n|-------------------|---------|\n| multi-tenant app  | [tenant.yml](./examples/tenant.yml) |\n\n3. Implement `StoreClient` and `StoreRegistry` for your stores.\n\n| Trait           | Description                              | Example |\n|-----------------|------------------------------------------|---------|\n| `StoreClient`   | `get()` `set()` `delete()`               | [DbClient](./examples/implements.rs) |\n| `StoreRegistry` | maps YAML client names to `StoreClient`s | [MyRegistry](./examples/implements.rs) |\n\n4. Precompile your yaml to a rs file.\n\n```bash\ncargo run --example precompile --features precompile -- examples/mine.yml src/dsl_compiled.rs\n# -- \u003cinput.yml: required\u003e \u003coutput.rs: optional\u003e\n```\n\n5. Initialize Context with your registry.\n\n```rust\nuse context_engine::{Context, Index};\nuse std::sync::Arc;\n\n// Include the precompiled static data\ninclude!(\"generated.rs\");\n\nlet index = Arc::new(Index::new(\n    Box::from(PATHS),\n    Box::from(CHILDREN),\n    Box::from(LEAVES),\n    Box::from(INTERNING),\n    Box::from(INTERNING_IDX),\n));\n\nlet registry = MyRegistry::new();\nlet mut context = Context::new(index, \u0026registry);\n\n// --- setup completed ---\n\nlet user_name = context.get(\"session.user.name\")?;\n```\n\n---\n\n## Architecture\n\n```\n┌─────────────┐       ┌────────────────────────────────┐\n│ DSL YAMLs   │------\u003e│ Manifest (app global instance) │\n└─────────────┘compile└───────────┬────────────────────┘\n                                  │\n                                  ▼\n┌─────────────┐       ┌────────────────────────────────┐\n│ Application │\u003c------│ Context(request scope instance)│\n└─────────────┘provide└────────────────────────────────┘\n                                  ▲\n                                  │\n┌─────────────┐       ┌───────────┴────────────────────┐\n│ ClientImpls │------\u003e│ StoreRegistry (required port)  │\n└─────────────┘regist └────────────────────────────────┘\n```\n\nSee for details [Architecture.md](./docs/Architecture.md)\n\n## Tree\n\n```\n./\n  README.md\n  Cargo.toml\n\n  docs/\n    Architecture.md\n    Dsl_guide.md\n\n  src/\n    lib.rs\n    ports.rs\n    ports/\n      provided.rs\n      required.rs\n    debug_log.rs\n    tree.rs\n    dsl.rs\n    index.rs\n    context.rs\n\n  examples/\n    tenant.yml\n    implements.rs\n```\n\n## Test\n\nPassed unit and integration tests\n\n```bash\n# unit test\ncargo test --features=logging -- --nocapture\n```\n\n---\n\n## License\n\nSPDX-License-Identifier: Apache-2.0\nCopyright (c) 2026 Andyou \u003candyou@animagram.jp\u003e\n\n---\n\n## Background\n\n**reimagined web architecture**\n\nBy substituting a portion of human activities with data processing on network-capable computers, we gain benefits such as assurance of verifiability and reduction of physical constraints. The mechanism that realizes this — receiving input as electrical signals through hardware, processing it, and outputting to designated hardware — is called a web system. To realize a web system, it is first necessary to define the conceptual framework it requires in both human language and the language of computer.\n\n```yaml\n# computers structure of web system\ncomputer:       \"Network-capable nodes in the system.\"\n  server:       \"Computers that serves human users.\"\n    fixture:    \"Servers that provides continuous network.\"\n    terminal:   \"Servers that provides human interfaces.\"\n  orchestrator: \"Computers responsible for maintenance of servers. (optional)\"\n```\n\n---\n\n## Original Text (ja)\n\n### 概要\n\nwebシステムのランタイムが1回の処理の中で使用するデータのラベルは、セッションコンテクストによる変動を、コード外で処理するべきです(例: users[session[user-id]]では無く、system_context[\"session.user\"]で呼び出せるべき)。context-engineは、アプリ開発者がYAMLファイルにDSLとして定義したデータの取得方法を、ラベルごとに処理します。これにより、例えばsystem_context[\"session.user.preference\"]のサーバー/クライアント差異が、context[session.user.tenant]のマルチテナント差異が、YAML内のデータ取得方法によって、適切に解決されます。このライブラリは、[背景](#背景)記載の、再構成されたwebシステムアーキテクチャの基盤技術に位置付けられています。\n\n### 背景\n\n**webシステムの構成再定義**\n\n人々の営みの一部を、ネットワーク機能を持ったコンピューターのデータ処理で代替することで、検証可能性の保証や物理的制約の緩和といった恩恵を受けます。これを実現する、ハードウェアを通して電気信号として入力を受け取り、処理後、所定のハードウェア群に出力する仕組みのことをwebシステムと呼びます。webシステムの実現には、まず、システムに必要な概念体系を、人間言語とコンピューターのビット列それぞれで定義する必要があります。\n\n```yaml\n# computers structure of web system\ncomputer:       \"(ネットワーク通信機能を要する)コンピューター\"\n  server:       \"人間(ユーザー・開発者)に処理能力を提供する\"\n    fixture:    \"継続的な待機により、ネットワーク機能を提供する\"\n    terminal:   \"人間とのインターフェースを提供する。端末。\"\n  orchestrator: \"サーバー群の維持を管理する(optional)\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanimagram-jp%2Fcontext-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanimagram-jp%2Fcontext-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanimagram-jp%2Fcontext-engine/lists"}