Skip to content

Add codespace keepalive to prevent idle shutdown - #1

Merged
intricko merged 5 commits into
mainfrom
feature/codespace-keepalive
Aug 3, 2026
Merged

intricko merged 5 commits into
mainfrom
feature/codespace-keepalive

Conversation

@intricko

@intricko intricko commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

Implements a two-layer Codespaces keepalive so headless services (gateway, ollama) aren't reaped by the idle timeout, and folds in the CI-watch skill/playbook improvement.

Changes

  • keepalive.sh: (A) periodic terminal heartbeat to mimic client activity + (B) pinger to VS Code server internal /delay-shutdown endpoint (zero-auth, verified HTTP 200). The heartbeat targets the interactive hermes process's tty, discovered at runtime via pgrep (no hardcoded PID) so it stays portable across rebuilds/CI.
  • start-hermes.sh: start keepalive idempotently (pgrep-guarded) on every codespace start/rebuild.
  • wiki/keepalive-proposal.md: design proposal, layers, success criteria, risks.
  • wiki/codespace-lifecycle.md: reference on Codespaces idle detection (folds in removed orphan skill's content).
  • wiki/INDEX.md + mnemon/seed.json: updated (keepalive entry, importance=5).
  • skills/github-codespace/SKILL.md: new "Non-blocking watch from an agent turn" subsection — run gh run watch as a background terminal with notify_on_complete instead of sleep-polling.
  • wiki/codespace-playbook.md: cross-reference the above as a third option in "Step 3: Monitor (Poll or Stream)" so skill (procedural) and wiki (reference) stay in sync.

Notes

  • Removed orphan codespace-lifecycle skill (had broken references/); content folded into wiki article.
  • Billing implication: keeping the codespace active longer bills longer (intended trade-off).
  • No CI workflow changes; relies on existing devcontainer-ci.yml (lint-check + conditional full-build).

Verification

  • Shell syntax check, seed.json validation, and keepalive.sh --test all pass locally.
  • Heartbeat tty discovery verified live (resolves to the interactive hermes pty, skipping gateway/dashboard).
  • CI lint-check (docs/runtime) + full-build (infrastructure: start-hermes.sh) run on this PR — both green on latest push.

Two-layer keepalive so headless services (gateway, ollama) aren't reaped
by the Codespaces idle timeout:

- keepalive.sh: (A) periodic terminal heartbeat on the session tty to
  mimic client activity (GitHub platform idle signal); (B) pinger to the
  VS Code server internal /delay-shutdown endpoint to reset the 5-min
  server-side shutdown timer. Zero-auth endpoint, verified HTTP 200.
- start-hermes.sh: start keepalive idempotently (pgrep-guarded) on every
  codespace start/rebuild, using existing SCRIPT_DIR var.
- wiki/keepalive-proposal.md: design, layers, success criteria, risks.
- wiki/codespace-lifecycle.md: reference on Codespaces idle detection.
  (Folds in the removed orphan skill's content.)
- wiki/INDEX.md + mnemon/seed.json updated (keepalive, importance=5).

Shell syntax, seed.json validation, and keepalive --test pass locally.
Add a new section to the github-codespace skill documenting the
background + notify_on_complete pattern for watching long CI builds
without blocking the agent turn or burning a sleep-polling loop.

Cross-reference this in the codespace-playbook wiki (Step 3: Monitor)
as a third option alongside polling and streaming approaches, so both
the skill (procedural) and wiki (reference) stay in sync.

Skill change: .devcontainer/skills/github-codespace/SKILL.md
  - "Non-blocking watch from an agent turn" subsection under CI Monitoring

Wiki change: .devcontainer/wiki/codespace-playbook.md
  - "Agent session approach" bullet in Step 3: Monitor (Poll or Stream)
  - links to the skill for full rationale and code

No functional code changes; documentation/skill only.
Replace the hardcoded hermes PID (17522) with runtime pgrep discovery that
resolves the interactive hermes process attached to a tty, skipping the
headless gateway/dashboard/supervised processes. Keeps keepalive portable
across rebuilds and CI (where that PID won't exist).
- Resolve SCRIPT_DIR/SELF from the script's own location so --test passes
  when invoked from the repo root or CI, not just from .devcontainer/.
- Fix handed-off \n Note echo that printed a literal backslash-n.
@intricko
intricko merged commit a84fe05 into main Aug 3, 2026
3 checks passed
@intricko
intricko deleted the feature/codespace-keepalive branch August 3, 2026 01:01
intricko added a commit that referenced this pull request Aug 3, 2026
* Add codespace keepalive to prevent idle shutdown (#1)

* Add codespace keepalive to prevent idle shutdown

Two-layer keepalive so headless services (gateway, ollama) aren't reaped
by the Codespaces idle timeout:

- keepalive.sh: (A) periodic terminal heartbeat on the session tty to
  mimic client activity (GitHub platform idle signal); (B) pinger to the
  VS Code server internal /delay-shutdown endpoint to reset the 5-min
  server-side shutdown timer. Zero-auth endpoint, verified HTTP 200.
- start-hermes.sh: start keepalive idempotently (pgrep-guarded) on every
  codespace start/rebuild, using existing SCRIPT_DIR var.
- wiki/keepalive-proposal.md: design, layers, success criteria, risks.
- wiki/codespace-lifecycle.md: reference on Codespaces idle detection.
  (Folds in the removed orphan skill's content.)
- wiki/INDEX.md + mnemon/seed.json updated (keepalive, importance=5).

Shell syntax, seed.json validation, and keepalive --test pass locally.

* chore: add trailing newlines to keepalive and wiki files (markdownlint MD047)

* feat: add non-blocking CI watch pattern to skill and playbook

Add a new section to the github-codespace skill documenting the
background + notify_on_complete pattern for watching long CI builds
without blocking the agent turn or burning a sleep-polling loop.

Cross-reference this in the codespace-playbook wiki (Step 3: Monitor)
as a third option alongside polling and streaming approaches, so both
the skill (procedural) and wiki (reference) stay in sync.

Skill change: .devcontainer/skills/github-codespace/SKILL.md
  - "Non-blocking watch from an agent turn" subsection under CI Monitoring

Wiki change: .devcontainer/wiki/codespace-playbook.md
  - "Agent session approach" bullet in Step 3: Monitor (Poll or Stream)
  - links to the skill for full rationale and code

No functional code changes; documentation/skill only.

* fix: discover keepalive heartbeat tty at runtime, drop hardcoded PID

Replace the hardcoded hermes PID (17522) with runtime pgrep discovery that
resolves the interactive hermes process attached to a tty, skipping the
headless gateway/dashboard/supervised processes. Keeps keepalive portable
across rebuilds and CI (where that PID won't exist).

* fix: make keepalive --test robust to cwd; clean output

- Resolve SCRIPT_DIR/SELF from the script's own location so --test passes
  when invoked from the repo root or CI, not just from .devcontainer/.
- Fix handed-off \n Note echo that printed a literal backslash-n.

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: gitricko <gitricko@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
intricko added a commit that referenced this pull request Aug 18, 2026
…o#24)

* Add codespace keepalive to prevent idle shutdown (#1)

* Add codespace keepalive to prevent idle shutdown

Two-layer keepalive so headless services (gateway, ollama) aren't reaped
by the Codespaces idle timeout:

- keepalive.sh: (A) periodic terminal heartbeat on the session tty to
  mimic client activity (GitHub platform idle signal); (B) pinger to the
  VS Code server internal /delay-shutdown endpoint to reset the 5-min
  server-side shutdown timer. Zero-auth endpoint, verified HTTP 200.
- start-hermes.sh: start keepalive idempotently (pgrep-guarded) on every
  codespace start/rebuild, using existing SCRIPT_DIR var.
- wiki/keepalive-proposal.md: design, layers, success criteria, risks.
- wiki/codespace-lifecycle.md: reference on Codespaces idle detection.
  (Folds in the removed orphan skill's content.)
- wiki/INDEX.md + mnemon/seed.json updated (keepalive, importance=5).

Shell syntax, seed.json validation, and keepalive --test pass locally.

* chore: add trailing newlines to keepalive and wiki files (markdownlint MD047)

* feat: add non-blocking CI watch pattern to skill and playbook

Add a new section to the github-codespace skill documenting the
background + notify_on_complete pattern for watching long CI builds
without blocking the agent turn or burning a sleep-polling loop.

Cross-reference this in the codespace-playbook wiki (Step 3: Monitor)
as a third option alongside polling and streaming approaches, so both
the skill (procedural) and wiki (reference) stay in sync.

Skill change: .devcontainer/skills/github-codespace/SKILL.md
  - "Non-blocking watch from an agent turn" subsection under CI Monitoring

Wiki change: .devcontainer/wiki/codespace-playbook.md
  - "Agent session approach" bullet in Step 3: Monitor (Poll or Stream)
  - links to the skill for full rationale and code

No functional code changes; documentation/skill only.

* fix: discover keepalive heartbeat tty at runtime, drop hardcoded PID

Replace the hardcoded hermes PID (17522) with runtime pgrep discovery that
resolves the interactive hermes process attached to a tty, skipping the
headless gateway/dashboard/supervised processes. Keeps keepalive portable
across rebuilds and CI (where that PID won't exist).

* fix: make keepalive --test robust to cwd; clean output

- Resolve SCRIPT_DIR/SELF from the script's own location so --test passes
  when invoked from the repo root or CI, not just from .devcontainer/.
- Fix handed-off \n Note echo that printed a literal backslash-n.

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* feat: persistent memory via symlinks (Option A) + self-check validation (#2)

* feat: persistent memory via symlinks (Option A) + self-check validation

- post-create-cmd.sh: authoritative creation of ~/.hermes/memories -> .devcontainer/memories (whole-folder symlink, skills pattern), runs before Hermes instantiates the runtime dir
- start-hermes.sh: slim repair guard for pre-existing containers (postCreateCommand doesn't re-run)
- self-check.sh: Persistence section validates both symlinks (memories + skills), 3-case logic, 9c content check removed as redundant with git checkout
- devcontainer-ci.yml: memories/skills in runtime path group (30s lint-check, not 15min full-build); lint-check gains 'Validate symlink persistence' step
- .devcontainer/memories/: MEMORY.md, USER.md, .gitignore (*.lock, *.log) — git-tracked persistence store
- wiki: persistent-memory-proposal.md (reference) + INDEX entry
- skill: codespace-persistent-symlinks (procedural) + seed.json entries for Option A, self-check, CI wiring, wiki, skill

* fix: remove trailing spaces in persistent-memory-proposal.md (MD009)

* fix: symlink persistence check must be static (bare runner has no devcontainer symlinks)

* chore: sync MEMORY.md with runtime rules (CI path-filter convention, gh pr create ref-lag workaround)

---------

Co-authored-by: gitricko <gitricko@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant