Skip to content

sync: upstream/main (405 commits) - #4

Closed
randlee wants to merge 2 commits into
mainfrom
sync/upstream-20260813-1106
Closed

sync: upstream/main (405 commits)#4
randlee wants to merge 2 commits into
mainfrom
sync/upstream-20260813-1106

Conversation

@randlee

@randlee randlee commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Automated sync of upstream/main.

  • 405 commit(s) behind
  • Branch: sync/upstream-20260813-1106
  • Timestamp: 20260813-1106

randlee and others added 2 commits August 10, 2026 22:57
* feat: inject_internal_message — public profile-aware injection API

GatewayRunner.inject_internal_message(profile, platform, chat_id, text, notice_text)
enables plugins (e.g. hermes-atm) to inject host-originated messages through
the existing adapter→gateway dispatch path with internal=True.

- Resolves adapter from _profile_adapters[profile] or self.adapters
- Constructs SessionSource + MessageEvent(internal=True)
- Supports optional notice_text for visible 📬 observability
- Fire-and-forget: queues event via adapter.handle_message()

AL17 deployable contract per c50c4232.

* fix: fail closed on unknown profile, add user_id to SessionSource (AL17 review)

- Explicit profile must be found in _profile_adapters; no silent fallback
- SessionSource includes user_id=chat_id for correct session identity
- Notice text delivered before event construction

* fix: Optional[str]->None return, profile default='', reorder params (AL17 review)

- Return type changed from Optional[str] to None
- profile parameter moved to end with default ''
- All return None changed to bare return
- SessionSource includes user_id=chat_id
- Docstring updated for new signature

* feat: add steer vs queue mode to inject_internal_message

Adds mode parameter to inject_internal_message:
- mode="queue" (default): fire-and-forget via adapter.handle_message()
- mode="steer": inject directly into running agent's turn via
  agent.steer(), falling back to queue when no agent is running

Also fixes bug from review commit 0869cc6 where event was
referenced before construction in the queue path.

Tests: 19 passing (11 queue mode + 5 steer mode + 2 hook + 1 negative)
- steer into running agent skips handle_message
- steer falls back to queue when no agent running
- steer falls back to queue when steer() returns False
- queue mode never calls steer() even when agent running
- notice_text preserved in steer mode
- strict profile resolution (fail closed on unknown profile)
- no ATM platform creation

* fix: correct profile resolver using _active_profile_name() (AL17 review)

- Resolve via self._active_profile_name() for primary profile
- Registered secondary profiles via _profile_adapters lookup
- fail closed on unknown profile (no silent fallback)
- Signature: profile='' default at end, -> None return, no mode param
- Remove _profile_adapters-is-empty-as-error heuristic

* fix: restore mode=steer per user directive, fix return None -> return

- mode='queue' (default), mode='steer' for non-interrupting injection
- steer uses _session_key_for_source + _running_agents
- falls through to queue if steer unavailable
- bare return everywhere

* fix: apply AL17 contract — keyword-only inject_internal_message with steer mode

- Add * separator and required profile: str (keyword-only)
- Add mode: Literal['queue','steer'] = 'queue' with steer logic
- Replace empty-string profile default with explicit active-profile check
- Fix return None → bare return everywhere
- Update tests for keyword-only API (mock _active_profile_name)
- 19/19 tests pass

* fix: expose gateway_runner in gateway:startup hook context

- Adds 'gateway_runner': self to the hook emit dict
- Enables hermes-atm to call runner.inject_internal_message()
  from a gateway:startup hook without private imports

* fix: structured errors, isolation tests, gateway_runner hook name (AL17 gaps 3-5)

- InjectInternalMessageError with code/chat_id/detail
- Profile/adapter failures raise instead of silently returning
- Isolation tests: queue and steer cannot cross sessions
- Hook context uses gateway_runner (not runner)
- test_missing_adapter uses real adapter map pattern

* fix: actually raise InjectInternalMessageError in inject_internal_message (gaps 3-4)

* feat: add host-contract isolation tests + mode validation (AL17 gate)

Three host-contract tests for PR NousResearch#82915:
1. same-profile/two-chat steer isolation — steer per-chat within profile
2. two-profiles/same-chat isolation — steer per-profile within same chat_id
3. invalid runtime mode fails closed — InjectInternalMessageError

Also adds mode validation at top of inject_internal_message: unknown
mode values now raise InjectInternalMessageError(code='invalid_mode')
rather than silently falling through to queue mode.

---------

Co-authored-by: Rand Lee <randlee@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

૮ >ﻌ< ა ci review

running on 509a62c — Merge remote-tracking branch 'upstream/main' into sync/upstr

waiting for jobs to start…

@randlee randlee left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

contessa re-review: fixes verified, tests pass ✓

  • Sync branch rebased onto origin/main (fork-specific "public gateway injection seam" commit f4fd527 preserved).
  • Resolved the single content conflict in gateway/run.py imports (kept upstream timedelta, timezone + fork Literal).
  • gateway/run.py compiles (ast.parse OK); tests/gateway/test_inject_internal_message.py: 25/25 passing.
  • Diff is a clean upstream sync (405 commits) with the injection-seam feature intact.

Note: automated approve is not possible — GitHub blocks approving your own PR (fork is owned by randlee, same gh identity). Manual review/merge required.

@randlee

randlee commented Aug 15, 2026

Copy link
Copy Markdown
Owner Author

Superseded: the fork now syncs via REBASE (main = upstream/main + 1 fork patch) instead of merge-based sync. This merge PR was a stale balloon. Closing.

@randlee randlee closed this Aug 15, 2026
@randlee
randlee deleted the sync/upstream-20260813-1106 branch August 15, 2026 11:11
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