Commit Graph

3323 Commits

Author SHA1 Message Date
Teknium
c711c2efe6 ci(plugin-catalog): maintainer allowlist for third-party tool downloads in the self-updater gate
The self-updater gate rejects any plugin script that both fetches from
GitHub and writes or renames files. rom-studio (#153798) trips it on
kit/kit.ts, which downloads the third-party poryscript 3.6.1 compiler
from its own release, checks a fixed sha256 and unpacks it into
kit/.cache. It never fetches or replaces rom-studio's own files, so the
pin stays the only update path (README rule 3).

Teknium ruled to allow it. A maintainer now lists such a file in
scripts/ci/catalog_self_updater_allowlist.json by repo, pinned sha, path
and the file's sha256: a re-pin, an edit to that file or a second
fetching file is gated again. The list lives under scripts/ci/, which an
entry PR may not touch (catalog_changed_entries.py), so a submitter
cannot add themselves. Rule 3 in both rule blocks names the exception.
2026-11-13 16:49:24 -08:00
Teknium
fea3dd340f fix(pm): gc reclaims a deleted checkout's sole tool pins too
Review (kvnloo): drop_dead_history only looked at facts with a `previous`
list, so a tool only a deleted checkout pinned (no history) kept its entry
forever. gc now judges every tool row: one with no owners (pre-history)
or matching this checkout's own lock stays, otherwise a row lives while
any owning checkout's install state dir exists. A tool left with no live
row loses its fact.

A checkout that finds an entry another checkout recorded now claims it, so
that checkout's deletion cannot reclaim an entry still in use.
2026-11-13 16:09:55 -08:00
Teknium
24272e92ad fix(bundles): a staged payload store keeps no other install's tool pins
prune_staged_store kept every history row facts.json carries, so a cached
build store shipped superseded tool entries. No other checkout shares a
build store: drop all history before computing the keep set.
2026-11-13 16:09:55 -08:00
Teknium
90b9d221b0 docs(pm): say why a missing checkout path alone keeps its tool pins
Also correct tool_store_pins.py: facts.json now keeps other checkouts' pins
as history, so the remaining reason not to share the account store is that
provisioning other pins writes into it under a concurrent run.
2026-11-13 16:09:55 -08:00
Siddharth Balyan
d312b4989e Merge pull request #151880 from NousResearch/sid/migrate-branch-tool
feat(move): just migrate-branch carries a branch across module moves
2026-11-14 05:37:07 +05:30
Teknium
b0f2bf4488 chore(boundary): record the Slack forward renderer's elision import
adapter_forwarded.py is a sibling extracted from adapter.py, which already imports
agent.compression_marker.elide/ELISION_MARKER_MAX_LEN (baselined) for the unfurl budget.
The sibling reuses the same marker so forwards and unfurls elide identically; the
published plugin API has no truncation helper to use instead.
2026-11-13 15:49:08 -08:00
Maciej Lisiewski
5163cc678b Merge pull request #155077 from NousResearch/fix/nit-150296-lockfile-diff
fix(ci): read pnpm explicit-key pairs in lockfile diff; cover peer/dev/optional paths
2026-11-13 22:48:15 +01:00
alt-glitch
fdbb12005b fix(migrate-branch): a renamed name must keep its quoting state on the branch's line
_rename_like() compared the sequence of quote characters on the line and the token line-up. A branch
that moved the quotes from the module name to another argument, use(tui_gateway, "callback"), kept
both, so the resolver renamed the bare name into hermes_agent.tui_gateway, an attribute lookup. Each
renamed token's quote parity must now match its lined-up base token; such a line stays a conflict.
2026-11-13 20:47:06 +00:00
alt-glitch
44cbf070fc fix(move): migrate-branch --continue keeps unstaged edits and --push refuses a slashed default branch
--continue stops when tracked files have unstaged changes, which the import rewrite step would discard.

--push compares the branch with the remote default branch's full name, so release/stable is refused too.
2026-11-13 20:47:06 +00:00
alt-glitch
101d061571 fix(move): migrate-branch resumes mid-move and keeps the branch's own text in resolved hunks
just migrate-branch --continue and --abort reuse the interpreter the first run set up, so they start after commit A moved hermes_cli.
A resolved hunk renames only the token that lines up with the renamed one, on a line whose quotes are unchanged; anything else stops.
2026-11-13 20:47:06 +00:00
alt-glitch
7955edf517 fix(move): migrate-branch runs on real move chunks and rewrites extensionless Python scripts
Commit A of a chunk may also modify hermes_agent/compat/moves.py, which just move-chunk amends into it.
Python scripts without a .py extension that the branch changed go to the import rewriter.
2026-11-13 20:47:06 +00:00
alt-glitch
7cd5840f78 fix(move): migrate-branch never drops main's or the chunk's changes on a conflict
A conflict in a file the branch rewrote was resolved with `git checkout --ours` on the whole
file. That dropped every other hunk the import-rewrite merge brought: main's commits when main
was merged into the chunk between A and B, and hand fixes when commit C carried the trailer.
Now git merges every non-conflicting hunk, and a conflicting hunk is resolved only when one side
changed nothing but module names there (both sides read with moved names spelled the old way); a
line that side renamed keeps the rename, and a line the other side edited takes the same
whole-token rename when that is all the renaming side changed on it. Every other hunk stops with its file and line. The same
rule applies to the final merge of the target.

Commit B is no longer "the last commit with the trailer". Trailers may carry a role
(`Hermes-Move: NN-name move|codemod|fix`); without roles, A is the first trailer commit and B is
only A's direct child, so later trailer commits are hand fixes that arrive with the target.

Also:
- files the branch added only inside a new subdirectory of a package A moved whole are moved to
  the new path (git's directory rename detection leaves them behind), then rewritten;
- the codemod gets only files that still exist (a branch that deletes a moved file no longer
  wedges on --continue);
- docs lines the branch added are rewritten with scripts/move/rewrite_docs.py, and any non-Python
  line the branch added that still names a moved module or path is listed and stops the run
  unless --accept-flags;
- --push pushes HEAD to refs/heads/<branch> on the branch's own remote and refuses the remote's
  default branch; a detached HEAD is refused up front.
2026-11-13 20:47:06 +00:00
alt-glitch
285cc20598 feat(move): just migrate-branch carries a branch across module moves
scripts/move/migrate_branch.py finds the move chunks a branch is missing by
their Hermes-Move trailer and, for each in landing order, merges the commit
before the rename, merges the rename with directory rename detection, runs
scripts/move/rewrite_imports.py on the Python files the branch changed, and
merges the import rewrite keeping the branch version of those files. It then
merges the target. Any other conflict stops the run; --continue resumes and
--abort restores the branch. Merges only; the remote is touched only with
--push.
2026-11-13 20:47:06 +00:00
alt-glitch
edd4b3ed51 fix(move): docs pass keeps gateway.platforms before a placeholder as written
The config.yaml key gateway.platforms.<name>.enabled was rewritten to
hermes_agent.gateway.platforms.<name>.enabled. The config-path deny list
matches gateway.platforms. only when a real segment follows, and a name
token stops at a placeholder or a wildcard, so the bare gateway.platforms
was read as the package. A config path that is also a package, alone or
before a placeholder or wildcard, now stays as written and is counted as
flagged-config-or-module for a person to check.
2026-11-13 20:47:05 +00:00
alt-glitch
3d7774434f fix(move): count a skipped whole-folder glob only when its folder moves
The docs pass counted a `bare-dir` skip for every `cron/*`, `tools/*` or
`plugins/**` it saw, even in a chunk that does not move that folder, so the
skip counts in the build log were inflated. The check now runs only for a
folder the chunk moves. What the pass writes is unchanged.

Add a test that a whole-folder glob on a moved folder that is not ambiguous
(`tui_gateway/*`) is still rewritten, and that an unmoved `cron/*` counts no
skip.
2026-11-13 20:47:05 +00:00
alt-glitch
1a91ce56b7 fix(move): docs pass keeps whole-folder globs on ambiguous names such as cron/* as written
A glob that takes every file of a folder whose name is also a HERMES_HOME dir or an MCP method family (cron/*, tools/*, plugins/**) is skipped like the bare folder; a file pattern such as cron/*.py still follows the move.
2026-11-13 20:47:05 +00:00
alt-glitch
d3cb8b4f67 fix(move): docs pass leaves commit and tag permalinks to moved files unchanged
Only a blob/main/ link follows the move; a commit or tag link points at a tree that keeps the old path.
2026-11-13 20:47:05 +00:00
alt-glitch
ddc718e679 fix(move): docs pass runs from a copy of scripts/move outside the checkout
rewrite_docs.py imports the old-path file generator only when it checks a .py path, so a copy of scripts/move outside the checkout no longer exits or fails to import.
2026-11-13 20:47:05 +00:00
alt-glitch
82e9576c63 fix(move): docs pass skips generated old-path files by path, not by a first-line header 2026-11-13 20:47:05 +00:00
alt-glitch
8309d5967f fix(move): docs pass rewrites a name only where it is code or resolves to a moved module
English that follows from/import in running prose ("from providers like X") and config keys named like a
moved package (plugins.enabled, providers.<id>.api_key) were rewritten to hermes_agent.* names.

- from M import ... / import M / -m M are rewritten only as code: in a code span, a code fence, a >>> line, or
  an import statement that parses as Python and starts its line. A bare top-level word alone is never
  rewritten. import M becomes from hermes_agent import M.
- A dotted name is rewritten when it names a moved module or package, or a moved module plus an attribute it
  defines; a bare package that is also a config section (agent, plugins, providers, ...) needs the attribute.
- DEFAULT_CONFIG keys (shared reader in renames.py, found wherever hermes_cli moved to) and i18n keys
  (locales/en.yaml, first argument of t()) are left alone.
- Files generate_shims.py wrote are skipped.
2026-11-13 20:47:05 +00:00
alt-glitch
e5928a41ac fix(move): read docs with utf-8-sig and keep a BOM on write in rewrite_docs
The windows-footguns check flagged three reads/writes in rewrite_docs without
the policy encoding. Reads now use utf-8-sig; a file that started with a BOM
gets it back via write_bytes so rewritten files keep their bytes.
2026-11-13 20:47:05 +00:00
alt-glitch
f013b0b471 style(move): satisfy the repo ruff config in rewrite_docs 2026-11-13 20:47:05 +00:00
alt-glitch
82b3de05e7 feat(move): rewrite moved paths and module names in docs and comments 2026-11-13 20:47:05 +00:00
alt-glitch
0401485f3c fix(move): commit B for a chunk with nothing to rewrite; copy rows keep their package in the list
`just move-chunk` stopped with "nothing to commit" when no tool changed a file (a moved leaf that nothing
imports), and left commit A as the head. The command now makes commit B without changes, so every chunk has
the same two commits and a second run has nothing left to do.

The package list in pyproject.toml keeps an old package name while a generated file lives under it. A
`copy` row was not counted, so a package kept only by copy rows would have lost its line. No row is in
that position today: both copy rows sit under hermes_cli, which by-path rows keep.
2026-11-13 20:47:05 +00:00
alt-glitch
8a16a8ec90 fix(move): keep import order in multi-name imports; stop instead of deleting ignored files at a move destination
The import rewrite now splits a multi-name import statement in the order of its names, so each module still loads in the same order.
move_roots now deletes only __pycache__ folders at hermes_agent/<ROOT> and refuses when any other file is there.
2026-11-13 20:47:05 +00:00
alt-glitch
a899d5fb50 fix(move): keep the old name in an __import__ whose result the rewrite would change
An __import__ through a variable, a helper, an empty fromlist or five arguments keeps its old module name.

move_roots refuses a Windows ROOT that has a root but no drive (\outside).

The --from-commit help says commit A also holds the MOVES update.
2026-11-13 20:47:05 +00:00
alt-glitch
c2f4063d29 fix(move): refuse a move-chunk ROOT outside the repository before clearing anything
build_chunk.py refuses an absolute ROOT or one with .. instead of deleting that folder before git mv fails.
2026-11-13 20:47:05 +00:00
alt-glitch
62cee6eac6 fix(move): keep the launcher-wrapper exclusion away from a row a later chunk deletes
The row sat directly under the old-updater test row, which the hermes_cli chunk deletes in its hand
fixes, so that pick conflicted on every rebuild. It is now the last row of EXCLUDED.
2026-11-13 20:47:05 +00:00
alt-glitch
7a20cb0edb fix(move): regenerate the skill docs in a chunk, and keep the launcher wrapper's bootstrap import
The docs pass rewrites paths in SKILL.md files, the inputs of website/scripts/generate-skill-docs.py, and
skips the generated pages. Nothing regenerated them, so the docs job failed from the first chunk that
touched a path a skill names. The chunk command and just move-generate now run that generator.

scripts/build/launcher_wrapper.py is the text of minted launchers. It imports hermes_bootstrap first: the
root file, which repairs a torn update and installs the old-name finder before hermes_agent is importable.
The rewrite turned it into hermes_agent.hermes_bootstrap; it is now an excluded site.
2026-11-13 20:47:05 +00:00
alt-glitch
38ecd6d7a1 fix(move): keep a hand-written old-path file in the update startup list
The pyproject rewrite kept an old path in update-startup-files only while a generated file lived there.
The root hermes_bootstrap.py stays hand-written, so its entry was replaced by the new path and updates
stopped syntax-checking the file every launcher imports first.
2026-11-13 20:47:05 +00:00
alt-glitch
c19c9112b6 fix(move): codemod rewrites the startup-file list, keeps names another install reads, adds late() and run-time patch-target sinks 2026-11-13 20:47:05 +00:00
alt-glitch
238faf371d fix(move): by-hand rows for module-name lists anchor the start of the statement 2026-11-13 20:47:05 +00:00
alt-glitch
9efebc8073 refactor(move): share the DEFAULT_CONFIG key reader between the codemod and the docs pass
config_keys moves to renames.py; rewrite_imports.py imports it instead of keeping its own copy.
2026-11-13 20:47:05 +00:00
alt-glitch
64580fce4c fix(move): drop package-list rows of moved packages with no old-path file
A packages.find row ("pkg", "pkg.*") of a moved package stays while
required_names.py gives it a generated old-path file, and goes otherwise:
hermes_agent.* already ships the new place.
2026-11-13 20:47:05 +00:00
alt-glitch
68e6088601 fix(move): codemod rewrites a string only where the code takes a module name
Decision D47. The call-argument sink and the module:attr reading rewrote hook
events, session keys, config keys, i18n keys and message text. A string now
changes only in a sink (sinks.py): import functions and helpers whose
parameter reaches one, validated patch targets, sys.modules keys, logger
names, -m/-c argv pairs, commands given to a process, Python code given to an
interpreter. A name, loop or table that feeds a sink is followed, and
rewritten only when every use feeds a sink. Every other string that names a
moved module or path is flagged with a class of its own.

import a becomes from hermes_agent import a (ruff PLR0402), except where the
from-form changes behaviour: a try that tells a missing module apart, and a
function that removes modules from sys.modules, keep the module form with
noqa. __import__("pkg.mod").Attr gets fromlist. Moved modules under folders
without __init__.py resolve. Code split across literals and f-strings is
edited piece by piece (pieces.py). Path flags need a moved file or folder
after the top folder, so tools/list and hermes-agent/ are not paths.
2026-11-13 20:47:05 +00:00
alt-glitch
b212b83b0e fix(move): exclusion rows follow the base tree and anchor only persisted text
The bot_desktop row anchored text that left the base in ecf7061700, so the
shipped module name was rewritten; it now anchors the base spelling. The
_launcher_script row covered the whole def, including a live import; it now
anchors the minted return statement (anchor_spans widens a return like a def).
print_runtime_command's --module default is persisted text. Two test sites
that exercise old top-level names on purpose get OLD_NAMES rows.
KEPT_NAMES names the reasons whose module names tests may mirror.
2026-11-13 20:47:05 +00:00
alt-glitch
dca9438261 feat(move): add move-chunk, one command for commits A and B of a chunk 2026-11-13 20:47:05 +00:00
alt-glitch
a4c8094d8e fix(move): codemod keeps import bindings, rewrites call-arg strings and pyproject entry points
`import a` became `import hermes_agent.a`, which binds `hermes_agent` for the whole
function: an earlier `hermes_agent.x` read there raised UnboundLocalError (practice
chunk 04, tests/hermes_state/test_fts_layout_drift.py). It now becomes
`import hermes_agent.a as a` and its uses keep their spelling. A function-local
`import a.b` whose new root another read in that function needs is flagged.

A string passed to a call is rewritten when its whole value names a moved module,
`module.attr` or `module:attr` of a name the module defines (`where="batch_runner.AIAgent"`,
`_tools_mod("tui_gateway.checkpoints")`); a bare top-level name needs `(module, attr)`
evidence (`_lazy("hermes_state", "SessionDB")`); a dotted name that only starts with
one is flagged. `"-m", "<mod>"` pairs in call arguments and f-string target heads
(`f"pkg.mod.{name}"`) are rewritten. DEFAULT_CONFIG keys (`agent.reasoning_effort`,
also a module) never change.

pyproject.toml entry points and package-data keys follow their module; package lists
are flagged (the old directory may still hold a shim). The run ends by naming
`just move-generate`, which regenerates the files built from rewritten docstrings.
2026-11-13 20:47:05 +00:00
alt-glitch
d689166f45 fix(move): the codemod never rewrites scripts/move/, whose exclusion anchors hold old names as data 2026-11-13 20:47:05 +00:00
alt-glitch
9948c8f1b1 fix(move): exclusions key on anchor text, BOM and non-UTF-8 files survive, deleted modules skip
Exclusion rows were (path, first line, last line) of the pre-move file. The codemod runs after
commit A, when the file sits at its new path, so no row ever matched a moved file
(hermes_cli/_old_updater.py was rewritten on chunk 11), and in migrate-branch a branch's
inserted lines shifted the site out of its range. Rows are now (path, anchor, reason): the path
also matches the file's new path through this move and the compat MOVES table, and the anchor is
exact source text, widened to the whole def, class or assignment it starts. A row whose anchor is
gone is flagged instead of silently doing nothing. Rows regenerated against origin/main.

A UTF-8 BOM is kept on rewrite; a .py file that is not UTF-8 is skipped with an `undecodable`
flag instead of crashing the whole run. A moved module the working tree no longer has (a branch
deleted it) is left out of the plan instead of raising FileNotFoundError.

String literals were checked against every moved path with a freshly compiled regex each; with
853 paths on chunk 11 that overflowed re's cache and took 80% of the run. One precompiled pattern
now, and the plan goes to each worker once.
2026-11-13 20:47:05 +00:00
alt-glitch
51f0112157 refactor(move): shorten by-hand matcher reasons 2026-11-13 20:47:05 +00:00
alt-glitch
38b461e85a feat(move): leave excluded sites alone, flag identity matchers and exc.name literals as by-hand 2026-11-13 20:47:05 +00:00
alt-glitch
72c161817d feat(move): rewrite programs in strings by parsing them, and flag the ones that do not parse 2026-11-13 20:47:05 +00:00
alt-glitch
860626e922 feat(move): rewrite patch, import and importorskip string targets that resolve in the moved tree 2026-11-13 20:47:05 +00:00
alt-glitch
fb4e37ebaf fix(move): rewrite sys.modules keys on any sys alias and assertLogs logger names 2026-11-13 20:47:05 +00:00
alt-glitch
bced17d3c8 fix(move): rewrite extensionless files that start with a Python shebang 2026-11-13 20:47:05 +00:00
alt-glitch
3fd7b7b4f8 feat(move): rewrite import lines and -m arguments inside code strings
Child-process code passed as python -c text or a string template has no compat finder,
so an old name there fails only at run time; the rehearsal on tui_gateway found 13.
2026-11-13 20:47:05 +00:00
alt-glitch
60d15c0372 feat(move): rewrite old module names from a move commit and flag what it leaves
scripts/move/renames.py reads old -> new dotted module names from a git mv commit.
scripts/move/rewrite_imports.py rewrites imports and their attribute chains with LibCST, plus
the strings the strict compat finder in tests cannot see: -m module arguments of child
processes, sys.modules keys and logger names. Every other site that names a moved module or
path is printed as a flag with its class, and the run fails until it is resolved.
libcst joins the dev dependency group; just move-rewrite runs it.
2026-11-13 20:47:05 +00:00
alt-glitch
c942345770 fix(guards): stop passing truncated AGENTS.md chains and misjudging moved modules
The AGENTS.md chain cap is 30,600 so a chain at the cap still loads whole after the loader's per-file headers.
`from hermes_agent import <moved published module>` is no longer reported as a private import.
Code health pairs a module moved a second time with its last path, not the generated file at its first path.
2026-11-13 20:47:05 +00:00
alt-glitch
bbff53aa2e fix(code-health): spell the base like the head when judging a moved tree
A stacked pull request is judged against the previous chunk, whose files already name earlier-moved modules the new way, while the ratchet renamed only the head back to the old names. So an old violation on such a line, in any file the pull request touches, was reported as new: CI failed chunk 11 with 1 blocking finding and chunk 12 with 5. The base now goes through the same renaming (hit texts and the lines matched to place hits); against main nothing changes, because renaming leaves old names as they are.
2026-11-13 20:47:05 +00:00