Research-Stack/4-Infrastructure/infra/ene-session-sync/systemd/ene-session-sync.service
Brandon Schneider 2cc9fc8dc7 Rust ene-session-sync: complete rewrite with Python adaptation layer
- source.rs: Add ClawSource adapter that reads .claw/sessions/*.jsonl (skips
  LFS stubs), parses both full-JSON and JSONL-stream formats, normalises into
  ChatSession/ChatMessage identical to the OpenCode path.

- models.rs: Add title/agent/model fields to ChatSession; remove unused
  chrono import.

- normalize.rs: Populate title/agent/model from OpenCodeSession.

- sink.rs: Full rewrite:
  - DDL adds title/agent/model columns + ALTER TABLE IF NOT EXISTS migration
    path for existing clusters.
  - upsert_session and upsert_messages parameter counts match placeholders
    ($19 and $13 respectively).
  - FTS index uses COALESCE to handle NULL text_content.
  - sslmode= token stripped before parse so NoTls connect doesn't reject
    it; README documents the SSL upgrade path (tokio-postgres-rustls).
  - with-serde_json-1 feature added to tokio-postgres dep for JSONB params.

- main.rs:
  - Replace DefaultHasher sha256_text with FNV-1a 64-bit (correct hex digest).
  - Add ClawSync, List, Get subcommands.
  - Remove unused Context import.

- bridge.rs: Rewrite to use bridge_wrapper.py subprocess rather than inline
  -c script; resolves wrapper path relative to infra_dir or CARGO_MANIFEST_DIR;
  unwraps {"ok":true,"data":{}} envelope; health_check() tests python3 only.

- embed.rs: Remove unused OllamaEmbedRequest import.

- systemd/: Add ene-session-sync.service + .timer (5-min cadence, 2-min
  OnBootSec, Persistent=true for catch-up after suspend).

- README.md: Architecture diagram, CLI reference, schema, build/install,
  systemd install, Python bridge setup.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-19 09:16:19 +00:00

37 lines
1.2 KiB
Desktop File

[Unit]
Description=ENE Session Sync — OpenCode→RDS chat log ingestion daemon
Documentation=file:///home/researcher/stack/4-Infrastructure/infra/ene-session-sync/README.md
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
# Run as the developer user so ~/.local/share/opencode/opencode.db is reachable.
User=researcher
Group=researcher
# Binary is installed to ~/.cargo/bin after `cargo install --path .` or
# symlinked from target/release/.
ExecStart=/home/researcher/.cargo/bin/ene-session-sync \
--db /home/researcher/.local/share/opencode/opencode.db \
sync
# Embedding is opt-in; set OLLAMA_HOST + OLLAMA_EMBED_MODEL env vars and
# add --embed to ExecStart if Ollama is available.
EnvironmentFile=-/etc/ene-session-sync/env
EnvironmentFile=-/home/researcher/.config/ene-session-sync/env
# Credentials (RDS_HOST, RDS_PORT, RDS_USER, RDS_PASSWORD or RDS_IAM_TOKEN)
# live in the EnvironmentFile above. Never hard-code them here.
StandardOutput=journal
StandardError=journal
SyslogIdentifier=ene-session-sync
# Restart on failure with backoff — the DB may be temporarily locked.
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target