Skip to content

feat: Codex startup parity (#633)#658

Merged
laynepenney merged 1 commit intosprint-17from
apollo/codex-startup-parity
Apr 11, 2026
Merged

feat: Codex startup parity (#633)#658
laynepenney merged 1 commit intosprint-17from
apollo/codex-startup-parity

Conversation

@laynepenney
Copy link
Copy Markdown
Collaborator

Summary

  • Extract context-surfacing logic from Claude's SessionStart hook into a reusable generate_startup_context() function
  • Add synapt recall startup CLI command with --compact and --json output modes
  • Update codex-loop.sh to auto-inject startup context before each prompt via --no-startup opt-out flag
  • Refactor cmd_hook to use the shared function (DRY, same behavior)

Premium boundary: OSS only. Public recall infrastructure enabling cross-tool startup parity.

What Codex gets now

When codex-loop.sh runs (or any tool calls synapt recall startup):

  • Latest journal entries (last 3 rich entries)
  • Branch-aware context (focus, decisions, next steps)
  • Open PR status for current branch
  • Knowledge nodes
  • Pending reminders
  • Pending contradictions
  • Channel unread summary + recent messages
  • Pending directives

Test plan

  • 11 new tests in test_startup.py covering generate_startup_context(), cmd_startup output modes, and CLI registration
  • All 46 existing CLI tests pass (no regression from refactor)
  • Smoke tested synapt recall startup, --compact, and --json modes end-to-end

Closes #633

🤖 Generated with Claude Code

Extract context-surfacing logic from Claude's SessionStart hook into a
reusable generate_startup_context() function. Add `synapt recall startup`
CLI command with --compact and --json modes so Codex (and any other tool)
gets the same journal/reminder/channel context Claude gets automatically.
Update codex-loop.sh to auto-inject startup context before each prompt.

**Premium boundary**: OSS only. This is public recall infrastructure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement.

To sign, please comment on this PR with the following exact text:

I have read the CLA Document and I hereby sign the CLA

You can also re-trigger the CLA check by commenting recheck.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Collaborator Author

@laynepenney laynepenney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean DRY refactor with a useful Codex parity addition.

Extraction: generate_startup_context() correctly pulls the 9-step startup logic out of cmd_hook without changing behavior. The refactor in cmd_hook reduces to a single loop, which is exactly right. Same output, single source of truth.

codex-loop.sh: Startup injection is safe — || true prevents failure if synapt isn't installed, empty-string check prevents injecting a blank prefix. The --no-startup escape hatch is the right design for automated/test callers.

Minor note: generate_startup_context() calls channel_join('dev', role='human') (step 7), which creates a presence row for the calling process. In Codex's headless loop, this will register a new presence entry each run. Same behavior as the old cmd_hook path, so not a regression — but worth tracking if agent presence gets noisy. Non-blocking.

Boundary: OSS recall infrastructure. No premium content, no identity/org writes.

11 new tests, 46 existing CLI tests still passing. At 0 reviews — needs 2 before merge.

Copy link
Copy Markdown
Collaborator Author

@laynepenney laynepenney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Second review.

The extraction is clean: generate_startup_context() returns list[str] so callers choose formatting (print, join, JSON-wrap). cmd_hook reduces to a two-line loop. Side effects (archiving, background indexing, enrichment) stay in cmd_hook where they belong.

The compact mode properly flattens multi-line blocks via splitlines + rejoin, preventing prompt bloat in Codex's headless exec path. The codex-loop.sh integration is safe: || true + empty-string guard + --no-startup escape hatch.

11 tests with full coverage of all three output modes plus empty-context edge cases. Ready to merge.

Copy link
Copy Markdown
Collaborator Author

@laynepenney laynepenney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opus review: LGTM. Clean DRY refactor extracting generate_startup_context() from cmd_hook(). The shared function returns context lines; callers decide how to emit them (print in cmd_hook, JSON/compact in cmd_startup, prompt prefix in codex-loop.sh).

Key design decisions:

  • Side effects (background indexing, enrichment, archiving) remain in cmd_hook only, not in the shared function. Correct: Codex has its own lifecycle.
  • --no-startup flag on codex-loop.sh for opt-out.
  • Startup context injected before the user prompt in codex-loop ([Recall context] ... ${PROMPT}).

Tests: 4 test classes covering generate_startup_context (empty, journal, reminders, channel), cmd_startup (plain, compact, JSON, empty), and CLI registration. Good coverage with appropriate mocking boundaries.

At 2 reviews (Layne + Opus). Meets policy.

@laynepenney laynepenney merged commit 61e598e into sprint-17 Apr 11, 2026
9 of 10 checks passed
@laynepenney laynepenney deleted the apollo/codex-startup-parity branch April 11, 2026 00:27
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant