shimo4228 commited on
Commit
167e55b
·
verified ·
1 Parent(s): 62f19f8

Upload graph.jsonld with huggingface_hub

Browse files
Files changed (1) hide show
  1. graph.jsonld +136 -7
graph.jsonld CHANGED
@@ -74,7 +74,7 @@
74
  {"@value": "観想的エージェント", "@language": "ja"},
75
  "CA"
76
  ],
77
- "description": "An autonomous CLI agent (Python package) with structural security (security-by-absence) and a three-layer memory architecture (episode log -> knowledge -> identity). Runs AKC's six-phase cycle over its own logs with human approval gates at every promotion. Local 9B stack (qwen3.5:9b generation + nomic-embed-text embeddings) on a single Apple Silicon Mac. The four contemplative axioms from Laukkonen et al. (2025) are available as an optional constitutional preset.",
78
  "identifier": "10.5281/zenodo.19212118",
79
  "author": {"@id": "https://orcid.org/0009-0002-6168-4162"},
80
  "url": "https://github.com/shimo4228/contemplative-agent",
@@ -234,9 +234,10 @@
234
  "@type": ["ADR", "TechArticle"],
235
  "name": "ADR-0006: Docker Network Isolation",
236
  "identifier": "ADR-0006",
237
- "status": "accepted",
238
  "datePublished": "2026-03-14",
239
- "description": "Optional containerized deployment with non-root execution and an isolated network namespace for the external surface. Local Ollama-on-host remains the default; Docker is an opt-in hardening layer."
 
240
  },
241
  {
242
  "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md",
@@ -484,6 +485,126 @@
484
  ],
485
  "belongsToPhase": "https://shimo4228.github.io/shimo4228/vocab#ca/phase/extract"
486
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  {
488
  "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0022-memory-evolution-and-hybrid-retrieval.md",
489
  "@type": ["ADR", "TechArticle"],
@@ -806,12 +927,12 @@
806
  {
807
  "@id": "https://shimo4228.github.io/shimo4228/vocab#ca/concept/local-9b-stack",
808
  "@type": ["Concept", "DefinedTerm"],
809
- "name": "local 9B stack on Apple Silicon",
810
  "alternateName": [
811
- {"@value": "local 9B stack on Apple Silicon", "@language": "en"},
812
- {"@value": "Apple Silicon 上の local 9B スタック", "@language": "ja"}
813
  ],
814
- "description": "Runtime architecture: Apple Silicon Mac (M1+, ~16 GB RAM, ~10 GB free disk), qwen3.5:9b for generation (Q4_K_M, ~6.6 GB), nomic-embed-text for embeddings (768-dim, ~274 MB), local Ollama via HTTP. A pluggable LLMBackend Protocol allows swapping in managed-LLM backends via contemplative-agent-cloud, while keeping the local embedding pipeline."
815
  },
816
  {
817
  "@id": "https://shimo4228.github.io/shimo4228/vocab#ca/concept/moltbook-adapter",
@@ -1009,6 +1130,14 @@
1009
  "url": "https://github.com/shimo4228/contemplative-agent-cloud",
1010
  "extends": "https://doi.org/10.5281/zenodo.19212118"
1011
  },
 
 
 
 
 
 
 
 
1012
  {
1013
  "@id": "https://github.com/shimo4228/contemplative-agent-data",
1014
  "@type": ["EcosystemRepo", "SoftwareSourceCode"],
 
74
  {"@value": "観想的エージェント", "@language": "ja"},
75
  "CA"
76
  ],
77
+ "description": "An autonomous CLI agent (Python package) with structural security (security-by-absence) and a three-layer memory architecture (episode log -> knowledge -> identity). Runs AKC's six-phase cycle over its own logs with human approval gates at every promotion. Local LLM stack (gemma4:e4b generation + nomic-embed-text embeddings) on a single Apple Silicon Mac. The four contemplative axioms from Laukkonen et al. (2025) are available as an optional constitutional preset.",
78
  "identifier": "10.5281/zenodo.19212118",
79
  "author": {"@id": "https://orcid.org/0009-0002-6168-4162"},
80
  "url": "https://github.com/shimo4228/contemplative-agent",
 
234
  "@type": ["ADR", "TechArticle"],
235
  "name": "ADR-0006: Docker Network Isolation",
236
  "identifier": "ADR-0006",
237
+ "status": "superseded-by ADR-0070",
238
  "datePublished": "2026-03-14",
239
+ "description": "Optional containerized deployment with non-root execution and an isolated network namespace for the external surface. Local Ollama-on-host remains the default; Docker is an opt-in hardening layer. Superseded by ADR-0070: Docker removed from main (recoverable by git revert).",
240
+ "supersededBy": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0070-retire-mlx-to-sibling-repo-and-remove-docker.md"
241
  },
242
  {
243
  "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md",
 
485
  ],
486
  "belongsToPhase": "https://shimo4228.github.io/shimo4228/vocab#ca/phase/extract"
487
  },
488
+ {
489
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0061-action-time-untrusted-cap-at-platform-limits.md",
490
+ "@type": ["ADR", "TechArticle"],
491
+ "name": "ADR-0061: Action-Time Untrusted Input Caps at Platform Field Limits; Internal Note Reads the Full Body",
492
+ "identifier": "ADR-0061",
493
+ "status": "accepted",
494
+ "datePublished": "2026-06-23",
495
+ "description": "Resolves weekly-2026-06-21 F1.1 (the agent read a mechanical mid-word truncation as a deliberate authorial 'pause'). A 2026-06-23 re-diagnosis (10-agent ultracode trace + adversarial verify) found F1.1's named path dead: history_summaries/_build_context_section were removed by ADR-0059, and content_summary's sole reader is unreachable after ADR-0060's activity-only _is_rich_episode filter. The insight survived on a live path with two real defects: (1) the internal note (generate_internal_note) ran on the 500-char submolt-feed server preview (FEED_CONTENT_PREVIEW_LEN), because feed_manager generated the note before _fetch_full_if_truncated 'on the preview by design'; since 500 < the note's max_input=1000, wrap_untrusted_content (ADR-0042) stamped a FALSE 'complete (500 chars)' marker over a server-clipped mid-word body; (2) when the wrapper itself truncated (post_text[:max_input] at 8000), the marker was honest but the residual still ended mid-word and the contemplative register re-read that edge as a pause. The small action-time caps existed only as a num_ctx safety valve (generate() skips a call when system+prompt+num_predict > NUM_CTX=32768, protecting the value layer); real posts are p90 ≈ 4700 chars. Decision: raise the action-time untrusted-input caps to the platform field limits (MAX_POST_LENGTH=40000 / MAX_COMMENT_LENGTH=10000), mirroring ADR-0060's distill EXCERPT_CAPS pattern — generate_comment → MAX_POST_LENGTH, generate_reply → MAX_POST_LENGTH/MAX_COMMENT_LENGTH, generate_internal_note → MAX_POST_LENGTH+MAX_COMMENT_LENGTH; real content cannot exceed the limit so the truncation branch never fires on real content (marker always honestly 'complete', no mid-word edge), and the cap is now only the num_ctx safety valve. Measured 2026-06-23: full system prompt ≈14.5K tok by _estimate_tokens (six skills dominate ≈11.8K) + comment/reply num_predict ≈6.7K leaves ≈11.6K tok input headroom under NUM_CTX=32768, so generate()'s guard skips an ASCII post above ≈34.8K chars or a CJK post above ≈11.6K chars — both far above the observed production max (≈7.4K chars); an outsized post is skipped (logged, value layer protected), not truncated mid-word. Gate/classification caps (score_relevance=1000, select_submolt=1000, summarize_post_topic=2000) stay small (cheap per-post gates, no prose). And: fetch the full body BEFORE the internal note in feed_manager (gated on score >= min(upvote_only_threshold, threshold)) so the note reads the whole post; the separate full-fetch before create_comment is removed (the single earlier fetch serves both). No change to wrap_untrusted_content or _io.truncate/truncate_boundary — the fix is entirely caller cap values and fetch ordering. Rejected: the content_full_len field on the dead content_summary path (fixes nothing); boundary-slicing the wrapper residual (fires only on out-of-spec input once caps equal platform limits; adds double-marker / char-count hazards); raising only the cap while keeping the note on the preview (a higher cap does not un-clip a server preview); moving note generation after the comment decision (the note is shared with the upvote-only episode). Open: the exact origin of the specific exemplars is not confirmable from code (reading internal-note logs is forbidden); a source-author-text or model-own-generation origin cannot be ruled out — watch for recurrence. The reply note reads notification post_content, which has no documented preview clamp; if notifications also deliver previews the full-fetch principle would extend there (unverified).",
496
+ "extends": [
497
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0042-explicit-truncation-contract-for-untrusted-wrapper.md",
498
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0060-per-episode-grounded-distill.md"
499
+ ],
500
+ "alignsWith": [
501
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md",
502
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0045-pre-action-internal-note.md",
503
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0059-remove-dead-reply-history.md"
504
+ ]
505
+ },
506
+ {
507
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0062-create-time-verification-handshake.md",
508
+ "@type": ["ADR", "TechArticle"],
509
+ "name": "ADR-0062: Create-Time Content-Verification Handshake via LLM Reasoning; Gate Recording on Visibility",
510
+ "identifier": "ADR-0062",
511
+ "status": "accepted",
512
+ "datePublished": "2026-06-26",
513
+ "description": "Moltbook now requires is_verified=false agents to solve an obfuscated math CAPTCHA returned in every create-response (post/comment/submolt) and POST /api/v1/verify {verification_code, answer} before verification_status flips pending->verified; unsolved content stays pending. Pre-existing verification code had silently stopped firing across 2026-05-22..06-25 — every post (posts_count=349) and comment sat pending while POST returned HTTP 201 and counters incremented, and the code never read its own verification_status so the gap went undetected. Three-layer drift: (1) wiring — the only solve-and-submit call sat in the feed-read loop keyed on post.verification_challenge, a field the live API never populates (0 fires); the create-response verification object was never inspected. (2) field names — code read challenge.text/.id and submitted {challenge_id, answer}; the API delivers challenge_text/verification_code and expects {verification_code, answer}. (3) solver — deterministic deobfuscate handled only uniform char-doubling (ttwweennttyy) and returned 'Failed to parse' on the live alternating-case + scattered-symbol format. Decision: (a) wire solve->POST /verify into all create paths (post_pipeline._publish_post, feed_manager comment path, reply_handler) via the injected shared callback Agent._handle_verification; post_comment folds a root-level verification into the returned comment dict so the gate fires regardless of nesting. (b) Gate recording on visibility — mark_posted / own_post_ids / episodes / memory.record_post / memory.record_commented / NoveltyGate.record / actions_taken run only after verification succeeds; scheduler rate counters stay right after the POST (quota consumed regardless); trusted-bypass responses (no verification object) fall through and record as before. (c) Solve via LLM reasoning, not deterministic parsing or constrained extraction — pass raw challenge_text with a reason-step-by-step prompt (num_predict=3000 cap not target, drop_truncated=True to fail closed), extract the final numeric token to 2dp; the trust boundary is the numeric output, so an instruction injected via the untrusted challenge fails closed to None. (d) Remove the dead feed-based verification path. (e) Add structural-only API instrumentation at the client._request chokepoint -> logs/api-audit.jsonl (method, normalized endpoint, status, envelope key-names, whitelisted content-status, soft-fail flag, sanitized server-error, rate-remaining; schema-drift WARNING only on 2xx; no free-text body, so the log is safe to read directly unlike episode logs). (f) Thread replies with parent_id. Confirmed end-to-end in production: a controlled real post solved 26+17=43 and flipped to verified, and the first live autonomous hour verified 9/11 replies (the 2 failures — one Incorrect-answer 400, one Challenge-expired 410 from solve latency — were handled gracefully, content left unrecorded for retry). Rejected: extending the deterministic parser (the two obfuscation styles need contradictory normalization and real challenges carry unseen junk), format=json structured extraction (suppresses the reasoning model's think block -> 3/6 wrong), answer-only prompting (suppresses chain-of-thought -> 20+5 read as 27), verification inside client.py (needs LLM, reverses core<-adapters), full-body API logging (untrusted free-text in a directly-read log), and routing verification through the human approval gate (would leave content invisible). Forward-only repair: pre-fix pending content is unrecoverable (challenge windows expired, no re-challenge endpoint). Cost: ~30-90s solve latency per creation on a warm model.",
514
+ "alignsWith": [
515
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md",
516
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0015-one-external-adapter-per-agent.md",
517
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0039-novelty-score-lagrangian-self-post-gate.md",
518
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0043-per-post-seeding-for-self-post-generation.md"
519
+ ]
520
+ },
521
+ {
522
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0063-novelty-gate-verified-only-comparison.md",
523
+ "@type": ["ADR", "TechArticle"],
524
+ "name": "ADR-0063: Scope the NoveltyGate Comparison to Verified (Visible) Posts",
525
+ "identifier": "ADR-0063",
526
+ "status": "accepted",
527
+ "datePublished": "2026-06-26",
528
+ "description": "After ADR-0062 fixed verification, the agent still produced zero visible posts: the NoveltyGate (ADR-0039) dedupes a draft against memory.get_recent_posts(limit=50), and all 349 stored posts are verification_status=pending (created pre-0062, challenge windows expired, permanently invisible) — so every draft was rejected for being too similar to a post nobody ever saw (observed: reject:low_novelty, novelty=0.25, nearest=0.79 vs a pending post). A secondary defect: the rate-deficit Lagrangian (mu·(target-actual_rate)) never loosened because get_post_rate_7d() counted the 349 pending posts as recent activity. Comments/replies were unaffected (they skip the gate). Decision: (1) scope the NoveltyGate comparison set to VERIFIED posts only — add verified:bool=False to PostRecord (frozen), record_post(verified=True) since the pipeline now records only after the handshake (ADR-0062), and get_recent_posts(verified_only=True) called from post_pipeline; the filtered list feeds both the cosine comparison and body-hash dedup. (2) Rely on backward-compatible deserialization — pre-fix 'post' episodes lack the verified key, so PostRecord(**data) falls through to default False and the 349 pending posts are excluded with no episode-log edit (honors the append-only / no-delete-episodes invariant). (3) Do NOT scope the rate-deficit term: with the verified comparison set empty, novelty=1.0 already admits, unblocking posting; scoping the rate too would make deficit≈target_rate during rebuild, letting mu·deficit override novelty and admit near-duplicate VISIBLE posts every 30 min (the May-2026 echo chamber). Leaving the rate counting all posts keeps deficit≈0 (pending posts age out of the 7-day window over ~7 days), so once verified posts accumulate the novelty comparison correctly blocks near-duplicates; code review confirmed no regime re-silences the agent (empty verified set → novelty=1.0 regardless of deficit). Rejected alternatives: scope the rate too (echo chamber during rebuild), purge/rewrite the 349 pending records (violates append-only episode log; would not survive reload), lower theta globally (blunt, weakens dedup on visible posts), do-nothing/wait-for-ageout (slow, unreliable — a 0.79-similar draft still blocks while the comparison set holds invisible posts). Trade-off: two denominators now differ (comparison=verified-only, rate=all-posts), deliberately. Pre-existing follow-up: _load_episodes_into_memory does not enforce MAX_POST_HISTORY on load while record_post does.",
529
+ "extends": [
530
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0062-create-time-verification-handshake.md"
531
+ ],
532
+ "alignsWith": [
533
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0039-novelty-score-lagrangian-self-post-gate.md"
534
+ ]
535
+ },
536
+ {
537
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0064-mlx-generation-backend.md",
538
+ "@type": ["ADR", "TechArticle"],
539
+ "name": "ADR-0064: Route Generation Through a Local mlx_lm.server on Apple Silicon",
540
+ "identifier": "ADR-0064",
541
+ "status": "superseded-by ADR-0070",
542
+ "datePublished": "2026-06-27",
543
+ "description": "On the maintainer's M1/16GB host, qwen3.5:9b on Ollama (Metal/GGUF Q4_K_M, ~8.6GB resident) swaps and decodes slowly. A controlled same-host, same-weights benchmark (thinking off, temp 0, 256-tok cap, 3-run median; docs/evidence/adr-0064/) showed Apple's MLX runtime via mlx_lm.server runs ~1.8x faster (6.8-7.0 -> 12.1-12.7 tok/s) at ~3.4GB less memory (8.6GB -> 5.2GB); re-measuring Ollama under low swap still gave ~7 tok/s, so the gap is intrinsic to the runtime, not a swap artifact, and the smaller footprint is what relieves the 16GB swap pressure. Three constraints shape adoption: mlx_lm.server is generation-only (no embeddings endpoint, no token-constrained structured output / no Ollama format= equivalent); it has no Metal passthrough in Docker so it runs on the host, not the ADR-0006 isolated compose stack; and format= is used by exactly one call site (distill._distill_one, {patterns:[...]}) which already has a JSON->bullet fallback. Decision: add an opt-in MLX generation backend that routes GENERATION ONLY through a local mlx_lm.server, keeping embeddings on Ollama. (1) core/mlx_backend.py MlxLmBackend(LLMBackend) POSTs to {MLX_BASE_URL}/v1/chat/completions, maps the OpenAI body to a BackendResult, sets thinking off per request via chat_template_kwargs={enable_thinking:false}, and renders a format schema into a prompt instruction (the distill bullet fallback absorbs drift). (2) The LLMBackend Protocol is extended: generate() takes keyword temperature and returns Optional[BackendResult] (text+finish_reason+eval_count) instead of Optional[str], so the injected path honors per-call temperature (0.0 deterministic verification, 1.3 outward) and the CALLER (_generate_via_backend), not the backend, applies the drop_truncated fail-closed gate (audit M2) from finish_reason with the same circuit-success-on-deliberate-drop accounting as the Ollama path. (3) cli.py composition root injects MlxLmBackend when LLM_BACKEND=mlx; unset keeps the default Ollama path, so the switch reverts by clearing one env var. (4) Embeddings stay on Ollama (OLLAMA_BASE_URL, nomic-embed-text); the MLX host reuses the shared validate_trusted_url() SSRF allowlist (localhost:8080 passes, port is not part of the host check). Target topology = two host-local services: mlx_lm.server (generation, :8080, ~5.2GB) + Ollama (embeddings, :11434, ~0.3GB). mlx-lm is run via uvx/uv tool, not a project dependency (the agent only makes HTTP calls; pyproject stays requests+numpy). Hardening done in passing: validate_trusted_url now also rejects non-HTTP schemes and is shared by both transports; the Ollama path gained allow_redirects=False. Verified: the verification challenge solver (temp 0, drop_truncated, gates publishing) solves correctly end-to-end through MLX; 21 new tests; python+security review PASS (no CRITICAL/HIGH). Rejected: repoint OLLAMA_BASE_URL (breaks shared-URL embeddings), keep format-distill on Ollama as auto-fallback (deferred — distill-on-Ollama is the 8.6GB path that swaps hardest; env gate allows revert if pattern yield regresses), run mlx in a container (no Metal passthrough), make MLX the default (host/platform-specific; opt-in keeps zero-config Ollama everywhere). Adoption of distill-on-MLX is gated on a dry-run pattern-yield comparison vs the Ollama baseline; quality drift from non-identical quantization (Q4_K_M vs MLX 4bit) is out of scope (OptiQ-4bit is a follow-up).",
544
+ "alignsWith": [
545
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0001-core-adapter-separation.md",
546
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0006-docker-network-isolation.md",
547
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md"
548
+ ],
549
+ "supersededBy": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0070-retire-mlx-to-sibling-repo-and-remove-docker.md"
550
+ },
551
+ {
552
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0066-backend-aware-context-budget-guard.md",
553
+ "@type": ["ADR", "TechArticle"],
554
+ "name": "ADR-0066: Backend-Aware Context-Budget Guard via an LLMBackend.context_window Contract",
555
+ "identifier": "ADR-0066",
556
+ "status": "accepted",
557
+ "datePublished": "2026-06-27",
558
+ "description": "Follow-up parameter-parity audit after the MLX sampler-omission fix (ebc227e/30f7e39/b3d0599). Audited every generation parameter for drift between the Ollama path (_post_ollama) and MlxLmBackend.generate; only num_ctx required a code change. The hole: the C2 token-budget pre-flight (skip when est system+prompt+num_predict exceeds the context window, protecting the system prompt's value layer from silent front-truncation) sat AFTER the backend dispatch in _generate_impl, so injected backends (MLX, cloud) bypassed it entirely. For MLX this is live, not theoretical: mlx_lm.server has no context/kv-size flag (ml-explore/mlx-lm issue #615) and does not front-truncate an over-window prompt — it grows the KV cache until the 16GB host swaps/OOMs (Qwen3.5-9B native window is 262144 but the practical ceiling is memory-bounded at ~32k). Phase 0 research (/search-first -> scout) over LiteLLM (drop_params, get_supported_openai_params, model_prices_and_context_window registry) and LlamaIndex (LLMMetadata.context_window) returned Build: do not adopt LiteLLM (all backends already speak OpenAI-shaped HTTP so its format translation is redundant; its context registry has no local-model entries; ~28MB/12-core-dep footprint vs a few lines), borrow the window-on-the-object pattern. Decision: (1) add read-only context_window:int to the LLMBackend Protocol, parallel to ADR-0065's model property; MlxLmBackend declares 32768 (memory-bounded on the host, not the model native window). (2) make the budget guard backend-aware and move it before the dispatch: ctx_window = getattr(_backend, context_window, None) if _backend is not None else NUM_CTX; an over-window estimate skips (outcome=budget_exceeded) for any backend before the HTTP call; a backend omitting the property falls back to None and is unguarded, so a not-yet-updated external backend keeps delegating (graceful degrade). (3) keep top_p/top_k as shared SAMPLING_TOP_P/K module constants, NOT Protocol params — they are Qwen3.5-specific model-local tuning shared by the two local backends and never handed to cloud (OpenAI has no top_k); the prior-session GenerationParams-through-Protocol idea is rejected because it would impose Qwen sampler values on cloud and change the cloud backend signature. Other audited params unchanged: temperature per-call (OK), num_predict maps to max_tokens (OK), format is an intentional native-vs-prompt-injection difference (ADR-0064), think is off on both via different mechanisms (OK). Because the guard is now load-bearing for MLX, _estimate_tokens was hardened to a true upper bound (security review): non-ASCII/CJK counted at 2 tok/char instead of 1 (a 33-50% under-count that a CJK-heavy untrusted prompt could exploit to slip past the guard into front-truncation/OOM), and MlxLmBackend rejects a non-positive context_window at construction (a zero window would skip every call). All in-repo LLMBackend doubles (FakeBackend, in-test stubs) were updated; the sibling contemplative-agent-cloud backend must add context_window (one-line follow-up) to gain the guard. Fully reversible (env-gated). Task 2 from the same handoff (verify_solve ~13% truncation, common to both backends and fail-closed) is unrelated to parity and remains deferred.",
559
+ "alignsWith": [
560
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0064-mlx-generation-backend.md",
561
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0065-mlx-ondemand-launchd-and-telemetry-model-contract.md",
562
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md"
563
+ ]
564
+ },
565
+ {
566
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0065-mlx-ondemand-launchd-and-telemetry-model-contract.md",
567
+ "@type": ["ADR", "TechArticle"],
568
+ "name": "ADR-0065: Wire mlx_lm.server as an On-Demand launchd Job and Enforce a Served-Model-ID Contract on LLM Telemetry",
569
+ "identifier": "ADR-0065",
570
+ "status": "partially-superseded-by ADR-0067 and ADR-0070",
571
+ "datePublished": "2026-06-27",
572
+ "description": "ADR-0064 deferred wiring mlx_lm.server into the production launchd jobs (agent.plist at 0/6/12/18h, distill.plist at 03:30). Two gaps were closed together. Gap 1: the LLM telemetry model field derived from a class-name sentinel (e.g. 'MlxLmBackend') rather than the real served model id, so operators could not trust which model served a call. Gap 2: process lifecycle — whether to run mlx_lm.server as a resident KeepAlive service or on demand. Decision: (1) generalize the telemetry model field into a served-model-id contract via a read-only model property on the LLMBackend Protocol (model = _backend.model if injected else _get_model(); MlxLmBackend already exposes model:str; commit 0f2b169). (2) run mlx_lm.server on demand via scripts/run-with-mlx.sh invoked from agent.plist/distill.plist ProgramArguments — polls /health (cold M1 load ~12s, 60s cap), runs the agent with LLM_BACKEND=mlx, kills the server via trap EXIT so its lifetime matches the job, with NO silent Ollama fallback — rather than a resident KeepAlive mlx-server.plist that would hold ~5.2GB idle all day and worsen idle memory vs the Ollama-default-unload baseline (commit 9f230d8). Partially superseded by ADR-0067: the launchd-wiring half was reverted to a direct contemplative-agent (Ollama) invocation on 2026-06-28 (commit b888840) after the 16GB production A/B showed mlx_lm.server is unfit for unattended continuous use; the served-model-id telemetry contract remains in effect and is the instrument that produced ADR-0067's evidence.",
573
+ "partiallySupersededBy": [
574
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0067-keep-ollama-for-unattended-production.md",
575
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0070-retire-mlx-to-sibling-repo-and-remove-docker.md"
576
+ ],
577
+ "alignsWith": [
578
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0064-mlx-generation-backend.md"
579
+ ]
580
+ },
581
+ {
582
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0067-keep-ollama-for-unattended-production.md",
583
+ "@type": ["ADR", "TechArticle"],
584
+ "name": "ADR-0067: Keep Ollama as the Production Generation Backend — mlx_lm.server Unfit for Unattended Continuous Use on 16 GB Apple Silicon",
585
+ "identifier": "ADR-0067",
586
+ "status": "accepted — partially-supersedes ADR-0065",
587
+ "datePublished": "2026-06-28",
588
+ "description": "Full-day production A/B on 2026-06-27 (M1/16GB), recomputed from ~/.config/moltbook/logs/llm-calls-2026-06-27.jsonl via ADR-0065's served-model-id telemetry contract. MLX (mlx-community/Qwen3.5-9B-4bit via mlx_lm.server): 21,224 generation calls, only 107 ok (0.50%), 21,060 circuit_open (99.2%), 53 error, 4 truncated; the 09:00-UTC hour alone spun 19,520 attempts with 2 ok. Ollama (qwen3.5:9b) across the surrounding 18-day baseline (06-09..06-26) ran ~200-270 calls/day at ~100% ok and essentially never tripped the circuit breaker. The model loaded and ran (21k logged real-model-id calls) — the failure is runtime degradation, not a load failure. Root cause: mlx_lm.server has no graceful OOM degradation (a Metal OOM aborts the process / wedges generation rather than returning an error — mlx-lm #854/#883 class), which trips the agent's circuit breaker; the breaker opens and the reactive retry path spins. Two mechanisms compound it on 16GB: a non-linear prefill cliff (mlx-server.log: the same ~7.5k-token prompt prefilled in 72s right after load, then 58min eleven minutes later, ~75x, on the same process — MLX Metal allocations are wired/non-swappable so under memory compression there is no graceful page-out unlike Ollama's mmap'd GGUF; a Metal OOM abort at 18:13 UTC was also seen) and prompt-cache churn (the ~7.6k all-injected system prefix is evicted under --prompt-cache-size 2 as reply/comment/score/internal_note prompts rotate, so most generations pay a full cold prefill). Decision: (1) production generation stays Ollama (launchd reverted, commit b888840); (2) retain ADR-0065's served-model-id telemetry contract (backend-neutral, produced this evidence); (3) keep the MLX backend code and all opt-in paths (LLM_BACKEND=mlx, /agent-run mlx, scripts/serve-mlx.sh) for interactive/manual/short-lived use; (4) scope the unfitness claim to 16GB Apple Silicon + Qwen3.5-9B-4bit + unattended continuous — deliberately NOT generalized to 'mlx_lm.server is unfit for production' (the evidence is config-specific; an over-broad claim is brittle and reifies a contingent result into a rule, against the Emptiness axiom). Two survey caveats are resolved as not-applicable here: the 'qwen3_5 is a VLM that fails to load' caveat (contradicted by 21k logged real-model-id calls) and truncation-as-MLX-EOS-runaway (the local verify_solve A/B found it n=5 noise / a solver-design property, not MLX-specific) — so this ADR rests on the circuit-breaker cascade, not truncation. Rejected: mitigate-and-keep MLX in production (symptomatic; the root is upstream-unfixed — #615 no kv-size flag, #854/#883 OOM aborts, all OPEN; 8-bit has no 16GB headroom, bf16 ~18GB does not fit), state the claim broadly, delete the MLX code (opt-in is reversible and useful), switch to a smaller MLX model (quality cost, still no graceful OOM), cloud backend (separate opt-in, relaxes security-by-absence for research only). Reversal thresholds — revisit unattended MLX only when ALL hold: (a) bounded KV / --max-kv-size lands (#615/#884 merged); (b) #854/#883 resolved so a Metal OOM returns HTTP 5xx and the process survives without a kernel panic; (c) a 24h / tens-of-thousands-of-calls run on the target host holds error and truncation rates at Ollama parity (~0).",
589
+ "alignsWith": [
590
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0064-mlx-generation-backend.md",
591
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0066-backend-aware-context-budget-guard.md",
592
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0007-security-boundary-model.md"
593
+ ]
594
+ },
595
+ {
596
+ "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0070-retire-mlx-to-sibling-repo-and-remove-docker.md",
597
+ "@type": ["ADR", "TechArticle"],
598
+ "name": "ADR-0070: Retire the MLX Backend to a Sibling Repo and Remove Docker from Main",
599
+ "identifier": "ADR-0070",
600
+ "status": "accepted",
601
+ "datePublished": "2026-06-28",
602
+ "description": "ADR-0067 found mlx_lm.server unfit for unattended production on 16GB Apple Silicon but kept the MLX backend opt-in in main (Decision #3). This ADR retires both MLX and Docker from main. MLX is structurally symmetric with the contemplative-agent-cloud add-on (both implement the LLMBackend Protocol), so it is relocated to a sibling contemplative-agent-mlx repo (follow-up): the in-tree LLM_BACKEND=mlx branch, core/mlx_backend.py, MLX scripts (serve-mlx.sh / run-with-mlx.sh), and tests are deleted, while the LLMBackend Protocol, configure(backend=...), the served-model-id telemetry contract (ADR-0065), and the context-budget guard (ADR-0066) are retained as the backend-neutral cloud injection seam. Docker is an infra wrapper, not a Protocol-injected backend, so its Dockerfile / docker-compose / docker-entrypoint / .dockerignore / setup.sh are removed outright, recoverable by git revert. Evidence (docs/evidence/adr-0064, adr-0067) and the apple-silicon-local-llm-serving skill are retained. Strengthens security-by-absence: the only in-tree generation path is Ollama; every alternative backend is opt-in and out-of-tree. core 25->24 modules.",
603
+ "supersedes": [
604
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0064-mlx-generation-backend.md",
605
+ "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0006-docker-network-isolation.md"
606
+ ]
607
+ },
608
  {
609
  "@id": "https://github.com/shimo4228/contemplative-agent/blob/main/docs/adr/0022-memory-evolution-and-hybrid-retrieval.md",
610
  "@type": ["ADR", "TechArticle"],
 
927
  {
928
  "@id": "https://shimo4228.github.io/shimo4228/vocab#ca/concept/local-9b-stack",
929
  "@type": ["Concept", "DefinedTerm"],
930
+ "name": "local LLM stack on Apple Silicon",
931
  "alternateName": [
932
+ {"@value": "local LLM stack on Apple Silicon", "@language": "en"},
933
+ {"@value": "Apple Silicon 上の local LLM スタック", "@language": "ja"}
934
  ],
935
+ "description": "Runtime architecture: Apple Silicon Mac (M1+, ~16 GB RAM, ~12 GB free disk), gemma4:e4b for generation (Q4_K_M, ~9.6 GB), nomic-embed-text for embeddings (768-dim, ~274 MB), local Ollama via HTTP. A pluggable LLMBackend Protocol allows swapping in managed-LLM backends via contemplative-agent-cloud, while keeping the local embedding pipeline."
936
  },
937
  {
938
  "@id": "https://shimo4228.github.io/shimo4228/vocab#ca/concept/moltbook-adapter",
 
1130
  "url": "https://github.com/shimo4228/contemplative-agent-cloud",
1131
  "extends": "https://doi.org/10.5281/zenodo.19212118"
1132
  },
1133
+ {
1134
+ "@id": "https://github.com/shimo4228/contemplative-agent-mlx",
1135
+ "@type": ["EcosystemRepo", "SoftwareSourceCode"],
1136
+ "name": "contemplative-agent-mlx",
1137
+ "description": "Optional local MLX generation backend (Apple Silicon, mlx_lm.server) that routes generation to a local MLX runtime while keeping embeddings on Ollama. On-device only, no cloud egress, so it does not relax the no-cloud property — the same LLMBackend Protocol-injection shape as contemplative-agent-cloud. Relocated out of Contemplative Agent core by ADR-0070; unfit for unattended continuous use on a 16 GB host per ADR-0067, so it is for interactive use while production runs on Ollama.",
1138
+ "url": "https://github.com/shimo4228/contemplative-agent-mlx",
1139
+ "extends": "https://doi.org/10.5281/zenodo.19212118"
1140
+ },
1141
  {
1142
  "@id": "https://github.com/shimo4228/contemplative-agent-data",
1143
  "@type": ["EcosystemRepo", "SoftwareSourceCode"],