Skip to content

sminos: a session sent to the background goes on as the same member - #228

Merged
SSFSKIM merged 5 commits into
mainfrom
sminos-lineage
Oct 18, 2026
Merged

SSFSKIM merged 5 commits into
mainfrom
sminos-lineage

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 17, 2026

Copy link
Copy Markdown
Owner

/background (and ←, the agents view's gesture) does not move a session: the engine starts a --bg job with --resume <transcript> --fork-session (a new session id, a new process, a new bridge socket), lets the interactive process exit, and appends {"type":"continued-in","continuedInSessionId":<new>} to the old transcript (engine 2.1.300, G_t/MAe). sminos keyed everything on the session id, so the member was retired ended and an unrelated one joined under the job's generated title. Seen today in MAWS: maws-fe became "GUI AI agent workspace charter". Separately, a derived name (<dir>-<one random byte>, drawn again by every process unless the tengu_session_stable_address gate is on) renamed a member on a plain resume (maws-4d → maws-3f, same session).

What changes (sminos.py, sminos_bridge.py)

  • The job continues the member. The old session is retired with reason: "continued", to: <new>. The link is recorded when the job joins while the old process still exits, else when the old one's membership would end; a reconcile pass over stopped seats catches a job that joined before the record existed. The job takes over the alias, chat cursor and seat, and inherits the in-charge line and status through the projection's lineage. A tag, alias#oldshort or full id naming the old session resolves to the job; list --json carries former.
  • The hand-off is ordered so one cut short is retried whole: cursor, then seat (a held seat lock leaves the old session joined), then retire, then rename. If the old session is resumed and re-joins, the link is cut.
  • A name the harness made up (derived, auto, collision) never replaces an alias the log already holds; a given name (/rename, --name) still renames. Applies to the view, joins, the record hook's alias, and a session's sender identity.
  • sminos watch follows the session into the job when it ends by a hand-off; a full id passed to watch/steer/interrupt/... resolves along the chain.
  • transcript_path caches hits per invocation (cleared by forget_caches), so the new seat pass shares state()'s glob.

Design: "Hand-off" and "Names the harness makes up" in §2 of the smns design, plus a Decision Log entry; SKILL.md's overview and --json fields. The desk's own projection still reads the job as a separate session; folding it there is MAWS's follow-up.

Verification: tests in run-sminos-tests.sh (1153 assertions in the family core; each fix-wave test shown to fail with its fix reverted). Independent review: high rung (4 findings, fixed in 50d3e02), then medium rung (1 finding, fixed in 2826ce0). ci-gate GREEN on 2826ce0: https://github.com/SSFSKIM/doperpowers/actions/runs/39080394732. Version 7.171.0.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T00:04:55.964245Z 2826ce0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2826ce0dca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

else:
state_word = "stopped" if transcript_path(sid) else "gone"
status = (r or {}).get("status")
status = max((x["status"] for x in chain if x["status"]), key=lambda e: e["ts"], default=None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve writer sequence when inheriting status

When the same writer sets a status on the predecessor and later sets or clears it on the continued session after a backward clock correction, this timestamp-only max selects the stale predecessor status. Status ordering within one writer is defined by seq, and this code has already reduced each session separately before losing that cross-session ordering; merge the lineage's status events by writer/sequence (as the in-charge merge below does) before comparing timestamps across writers.

Useful? React with 👍 / 👎.

return latest_membership(evs) == "joined"

try:
carried = cursor_load(project, old)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Carry pending deliveries across the hand-off

When an addressed event is recorded for the old session shortly before the hand-off—especially on another machine and synced afterward—this transfers only its chat cursor. The successor's former lineage is not considered by _owed, and deliver_next checks only member.session, so the event addressed to the old ID is never pushed to the continuing job. Carry the old delivery state and treat events addressed to former session IDs as owed to the successor.

Useful? React with 👍 / 👎.

Comment on lines +1346 to +1348
held = own_alias(_own_events(project, sid), sid)
if str(peer.get("kind") or "") == "bg" and not held[0]:
old, old_peer = predecessor(project, sid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recover the predecessor alias when the job joins late

If reconciliation reads the old transcript after its process exits but before the successor appears in the peer registry, hand_off retires the old session while the successor is not yet joined and therefore cannot rename it. When the successor later reaches this code, own_alias is empty and predecessor can no longer find the stopped seat-less predecessor, so the join records the job's generated title instead of the inherited alias. The projection may display the inherited alias, but _member_alias and default_from read the successor's own events and attribute its messages to the generated title until a daemon rename happens (which never occurs for a local project without a daemon).

Useful? React with 👍 / 👎.

"""The session that goes on for `session`: itself while it runs or was
never handed off, else the end of its chain of hand-offs (continued_in)."""
seen = {session}
while not S.session_running(session) and (nxt := S.continued_in(session)) and nxt not in seen:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Redirect controls before the predecessor process exits

During the normal hand-off window the old interactive process remains alive while the background job is already the member, so this condition returns the old session for a full-ID query. Because sminos_control.py uses watch_session for steer, interrupt, model, compact, answer, and decide, those commands target the ending predecessor rather than the active successor, even though the same old ID resolved through member addressing reaches the successor. Keep the old endpoint behavior only for a watcher that intends to auto-follow, and resolve control commands through the recorded continuation immediately.

Useful? React with 👍 / 👎.

…retried whole, a resume unlinks, one writer's lines read in order

- reconciliation looks, for each seat whose session no longer runs, for the
  record naming a job it continues in: the job may join before the harness
  writes it. transcript_path keeps its hits per invocation, so the pass
  costs no extra glob beside state().
- hand_off copies the cursor and moves the seat before it retires the old
  session; a seat lock another command holds leaves it joined, for the next
  pass to do again; the rename runs whoever won the retirement.
- an own joined after a continued retirement ends the link: a resumed
  session is its own member, and the job keeps its own events.
- a chain's in-charge events are merged in each writer's seq order.
…d-off is the target the verbs and the bridge see
@SSFSKIM
SSFSKIM merged commit 61ba5cc into main Oct 18, 2026
9 checks passed
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