Skip to content

refactor(core): reorganize the ReMe runtime and shared helpers - #769

Merged
jinliyl merged 5 commits into
mainfrom
refactor/reme-core-layout
Nov 20, 2026
Merged

jinliyl merged 5 commits into
mainfrom
refactor/reme-core-layout

Conversation

@jinliyl

@jinliyl jinliyl commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Move application assembly, execution contexts, the backend registry, and entry-point helpers into reme/core. Group plugin loading under reme/plugin.
  • Use Application as the CLI and SDK runtime entry point. Use the canonical modules directly in the runtime, plugins, tests, and developer guides.
  • Share service discovery between find_reme and job calls. Skip one-shot jobs and resolve built-in and plugin config names before looking up the process working directory for relative file paths.
  • Probe explicit startup ports when the service config cannot be replayed. Job calls fall back to the caller’s config and retain the configured port when HTTP is selected by default.
  • Pass StreamChunk through stream execution and encode SSE at the HTTP boundary.
  • Store Todo and Idea records under the configured notebook_dir, which defaults to notebook/.
  • Group file and document helpers by responsibility, move single-owner helpers closer to their callers, and update package version discovery and release smoke checks.
  • Restore reme/steps/evolve behavior to the base revision and update its imports for the relocated modules.

Based on main at a1aeb75b. Related work on proactive summary recovery and Markdown link validation is tracked in #764.

New layout

This PR establishes the initial project layout. The code, configuration, examples, and guides use the new interfaces and paths directly. Each workspace uses one configured notebook store.

Local validation

  • The core unit suite passed 4,200 tests with 65 skipped. The Home, Auto Fin, Daily Paper, and DingTalk suites passed 1,123 tests.
  • Pre-commit checks passed across the repository and on the final CLI changes.
  • GitHub Pages passed 23 tests, and the production build verified 47 artifacts.
  • Clean source-built wheels passed import and plugin discovery checks for Home, Auto Fin, and Daily Paper.
  • Local HTTP smoke tests covered cross-directory configuration discovery, filtering of one-shot jobs, caller config fallback when the server uses an environment variable unavailable to the client, and SSE termination.

Real-provider integration tests and release workflows were skipped.

Comment thread reme/reme.py
with socket.socket(family, socket.SOCK_STREAM) as s:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
s.bind((host, port))

@ployts ployts left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address the notebook cutover and the remaining module aliases before merging. I reproduced the notebook issue by creating a Todo on the current main branch and opening the same workspace at this PR's head. The proactive refresh comment is a follow-up about test coverage. Locally, 297 focused core tests and 106 plugin tests passed.

def path(self, relative):
"""Apply the same containment and request scope as the file jobs."""
path, error = resolve_path(self.workspace, relative)
workspace_relative = f"{self.notebook_dir}/{relative}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Keep existing Todo and Idea records reachable after the cutover. I created a Todo on the current main branch and ran list scope=all against the same workspace on this commit. The count went from 1 to 0 while the original todos.json stayed at the workspace root. Existing archive shards and pending recovery journals are skipped for the same reason. Please move the active files, archives, and recovery journals together before switching the reader to the new directory, so existing workspaces end up with one canonical store.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for reproducing this and checking the archive and recovery journal paths. We’re treating this as the initial release layout for Todo and Idea. A workspace uses one configured notebook directory, notebook/ by default, and the code and guides will describe that layout directly. Migration from workspace-root files created on earlier development checkouts is outside the scope of this refactor.

Comment thread reme/components/__init__.py Resolved
Comment thread tests/unit/test_proactive_refresh.py Resolved
Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service.

@ployts ployts left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The legacy module aliases are gone and the repository callers use the canonical imports. The proactive publication change was reverted to the base behavior, which addresses my coverage comment. I confirmed that Todo and Idea were introduced after the latest published release, 0.4.2.3, and accept notebook/ as the initial release layout. The new CLI discovery changes introduce a reproducible regression that can route a job to the wrong service. Please fix that before merging. Locally, 377 focused tests passed and one skipped.

Comment thread reme/reme.py
service = overrides.get("service")
if not isinstance(service, dict) or not service:
continue
config = overrides

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Preserve the client endpoint when replaying the server config fails. If the server YAML needs an environment variable present only in the service process, this fallback yields service: {port: 8127} from an explicit service.port=8127 startup override. call_server() accepts that as the full running config and bypasses the caller's config=client.yaml. It then selects HTTP by default, but the backend comparison used to seed its client arguments drops the known port. I reproduced find_reme scanning port 8127 while the Job client selected 2333. With an explicit client config pointing to 8127, the previous commit also selected 8127 and this commit selected 2333. A partial replay can supply a probe address, while client selection needs enough configuration to honor the intended endpoint or fall back to the caller's config.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for reproducing the endpoint mismatch. Fixed in a1fb9eca. When the running service config cannot be replayed, find_reme can still probe the explicit startup port. Job calls fall back to the caller’s config, and the default HTTP client keeps the configured port. I verified this with a regression test and a local HTTP service that requires an environment variable unavailable to the CLI.

Comment thread reme/reme.py Outdated
try:
config_name = overrides.get("config")
config_dir = (
Path(proc.cwd()) if isinstance(config_name, str) and not Path(config_name).is_absolute() else None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P3] Resolve named configs independently of access to the server's working directory. This queries proc.cwd() for every non-absolute string, including built-in names such as config=proactive. I simulated a visible command line with proc.cwd() raising psutil.AccessDenied: the previous commit resolved the built-in config and this commit dropped the service. Look up built-in and entry-point names before requiring the process working directory for a relative file path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for catching the working-directory access case. Fixed in a1fb9eca. The loader resolves built-in and entry-point config names before asking for the process working directory to resolve a relative file path. The regression test covers AccessDenied for a built-in name and an entry-point name ending in .yaml.

Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.

@ployts ployts left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified both fixes on a1fb9ec. When a server-only environment variable prevents config replay, discovery still finds the explicit startup port and the Job call uses the caller's YAML. I verified the endpoint with a live loopback HTTP service. Built-in and entry-point config names also resolve with process CWD access denied. The focused suite passed 380 tests with one skipped. I reproduced the same HTTP probe shutdown warning on the base and this commit, with successful probes in both cases.

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