Make Longevity OS portable, grounded, and ClawHub-deployable#4
Draft
llj0824 wants to merge 12 commits into
Draft
Make Longevity OS portable, grounded, and ClawHub-deployable#4llj0824 wants to merge 12 commits into
llj0824 wants to merge 12 commits into
Conversation
* fix: unify runtime path resolution * feat: add deterministic demo reset workflow * docs: add architecture and demo workflow guide * docs: replace architecture note with html deep dive
* feat(write): add durable meal and metric write scripts * docs(write): point meal and metric agents to real scripts * feat(write): support shared timestamps for metric batches * docs(write): document durable meal and metric scripts
* feat(runtime): add grounded exercise biomarker and supplement surfaces * docs(runtime): point agents to grounded runtime surfaces
* feat(read): add grounded weekly report and trial status scripts * docs(read): point grounded read flows to real scripts
* feat(openclaw): render and verify local skill install * docs(openclaw): document rendered skill installation
* docs(readme): add openclaw rehearsal restart note * docs(openclaw): capture telegram rehearsal proof
Add comprehensive Architecture section with 6 Mermaid diagrams: system overview, data flow, ERD, agent dispatch sequence, trial state machine, and architectural boundaries. Includes subsystem breakdowns, dashboard API reference, and schema design. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
docs: add architecture diagrams to README
…14) * chore(skill): tighten longevity routing guidance * chore(skill): restore slash triggers and add handoff guidance
* fix: make longevity portable for clawhub * fix: align installed skill runtime setup flow * fix: make openclaw installs deterministic
llj0824
marked this pull request as draft
March 24, 2026 03:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Visual explainer
Start here for the fast architectural read: PR 4 Deep Dive | Longevity OS Portability
This HTML artifact walks through the runtime shape after the PR, the gap it closes, the concrete code surfaces involved, and the verification stack behind the portability claim.
What this PR does
This PR makes Longevity OS runnable anywhere — not just on your local machine. It also replaces every agent's raw-SQL-via-imaginary-CLI pattern with real, tested Python scripts that read and write the SQLite database.
Before these changes, every path in the codebase was hardcoded to
/Users/A.Y/Desktop/Projects/2026/longevity-os/.... The agents told the AI to run commands against that path, which obviously doesn't work for anyone else — or for ClawHub deployment.After these changes, the system resolves paths at runtime, every write goes through a dedicated script, and the whole bundle passes a portability validator.
High-level summary
1. Portable path resolution (
paths.py)A new top-level
paths.pymodule replaces every hardcoded/Users/A.Y/...path in the codebase.get_project_root()— returns the mutable data directory. Defaults to a sibling folderlongevity-os-data/next to the repo, or reads fromLONGEVITY_OS_PROJECT_DIRenv var.get_db_path()— returns the SQLite path. Overridable viaLONGEVITY_OS_DB_PATH.data/db.py,modeling/engine.py,modeling/causal.py,modeling/patterns.py,dashboard/server.py, every script) now import frompaths.pyinstead of using string literals.This means the same checkout works on your machine, Leo's machine, a ClawHub sandbox, or CI — no edits needed.
2. Grounded runtime scripts (11 new scripts)
Previously, agent prompts told the AI to run raw SQL via
sqlite3shell or adb.pyCLI that didn't exist as described. Now each agent action maps to a real, tested script:scripts/log_meal.pydiet_entries+diet_ingredients, returns totalsscripts/log_metrics.pybody_metricsrows from JSONscripts/log_exercise.pyexercise_entries+exercise_detailsfrom JSONscripts/log_biomarkers.pybiomarkersrows from JSONscripts/manage_supplements.pyscripts/query_sqlite.pyscripts/weekly_report.pyscripts/trial_status.pyscripts/demo_reset.pyscripts/install_openclaw_skill.pyscripts/check_clawhub_bundle.pyEvery script:
scripts/setup.py)paths.py3. Agent prompts updated
All 10 agent markdown files (
agents/*.md) and the orchestrator (SKILL.md) were updated:/Users/A.Y/...paths replaced with{baseDir}/scripts/...log_meal.py, daoyin.md tolog_exercise.py)SUBSTR(timestamp, 1, 10)instead ofDATE(timestamp)for SQLite compatibility with ISO 8601 strings4. SKILL.md routing and metadata
longevity-ostolongevity(ClawHub convention)metadata.openclawblock with homepage and binary requirements{baseDir}placeholder that OpenClaw resolves at install time5. SQLite DATE() fix across modeling layer
DATE(timestamp)doesn't work reliably on ISO 8601 strings with timezone offsets in SQLite. All queries inmodeling/engine.py,modeling/causal.py, andmodeling/patterns.pynow useSUBSTR(timestamp, 1, 10)instead — a pattern that works correctly regardless of how the timestamp was stored.6. Architecture docs in README
Added a comprehensive Architecture section to README.md with 6 Mermaid diagrams: system overview, data flow, ERD, agent dispatch sequence, trial state machine, and architectural boundaries. Plus subsystem breakdowns, dashboard API reference, and schema documentation.
7. Test coverage
4 new test files covering the critical paths:
test_write_paths.py— meal logging, metric batch writes (isolated temp DB)test_read_paths.py— weekly report generation, trial status reads (seeded temp DB)test_runtime_surfaces.py— exercise logging, biomarker writes, supplement lifecycletest_openclaw_install.py— skill install, bundle validation, stale file detection, end-to-end runtimeAll tests run against isolated temporary directories — no shared state, no hardcoded paths.
Data flow (before vs after)
Before:
After:
Files changed: 46 files, +4,200 / -147
paths.py(new)log_meal.py,log_metrics.py,log_exercise.py,log_biomarkers.py,manage_supplements.py(all new)query_sqlite.py,weekly_report.py,trial_status.py(all new)demo_reset.py,install_openclaw_skill.py,check_clawhub_bundle.py(all new)setup.py,backup.py,export.py,migrate.py,import_apple_health.py,import_labs.py,generate_demo_data.py(path fixes)data/db.py,modeling/engine.py,modeling/causal.py,modeling/patterns.py(path + DATE fix)dashboard/server.py(path fix)agents/+SKILL.md(grounded tool refs)tests/README.mdarchitecture section,docs/artifacts,screenshots/.gitignore,requirements.txtHow to verify
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com