Skip to content

aisync 0.2.0: rules as interfaces, loaded in layers, plus an MCP server - #5

Merged
MaxonT merged 4 commits into
mainfrom
port-0.2.0
Nov 9, 2026
Merged

MaxonT merged 4 commits into
mainfrom
port-0.2.0

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 9, 2026

Copy link
Copy Markdown
Owner

feat: aisync 0.2.0, rules as interfaces loaded in layers, plus an MCP server

Rules: rule add --when/--do/--not writes a rule as an interface with a
stable ID; rule_spec = true refuses any other shape; rule lint,
rule rewrite (refuses a rewrite that drops a path, number or command),
rule enforcement (optional sidecar of what keeps each rule;
require_enforcer = true makes it mandatory), --topic, --replaces
with a rules archive. rulecheck proves a cleanup lost no hard fact.

Layers: a target with layer = "core" carries core_topics in full and
folds the rest to one line each; the hook injects a folded topic once per
session when the prompt or a tool call touches its [shelf] keywords.
progress_file keeps agents.md byte-stable so prompt caches keep hitting.

Tidy: aisync tidy proposes (duplicates, uncited rules, core budget) and
never edits; the daily run is off by default (tidy_daily), never starts
under a test, runs one at a time, niced, and scans no transcripts unless
tidy_usage_globs is set.

Any agent: aisync mcp serves rules, rule_add, log, claim, release, news,
status and tidy over stdio; the SDK is the optional aisync[mcp] extra,
the core stays standard-library only. Optional instinct habit list.

Release: CI runs pytest plus tools/privacy_scan.py (tree, wheel and the
commits since the last tag; guarded words kept as SHA-256 prefixes).
watch.restart() refuses to execv a test runner. Demo, board, front screen,
README (EN, ZH) and screenshot updated.

Co-authored-by: Claude [email protected]
Agent: claude-code

Checks before this PR: full suite on a fresh clone (241 passed with pytest and the mcp extra), tools/privacy_scan.py over the tree, wheel, sdist and the new commits: 0 hits.

MaxonT and others added 2 commits November 8, 2026 20:41
… server

Rules: `rule add --when/--do/--not` writes a rule as an interface with a
stable ID; `rule_spec = true` refuses any other shape; `rule lint`,
`rule rewrite` (refuses a rewrite that drops a path, number or command),
`rule enforcement` (optional sidecar of what keeps each rule;
`require_enforcer = true` makes it mandatory), `--topic`, `--replaces`
with a rules archive. `rulecheck` proves a cleanup lost no hard fact.

Layers: a target with `layer = "core"` carries `core_topics` in full and
folds the rest to one line each; the hook injects a folded topic once per
session when the prompt or a tool call touches its `[shelf]` keywords.
`progress_file` keeps agents.md byte-stable so prompt caches keep hitting.

Tidy: `aisync tidy` proposes (duplicates, uncited rules, core budget) and
never edits; the daily run is off by default (`tidy_daily`), never starts
under a test, runs one at a time, niced, and scans no transcripts unless
`tidy_usage_globs` is set.

Any agent: `aisync mcp` serves rules, rule_add, log, claim, release, news,
status and tidy over stdio; the SDK is the optional `aisync[mcp]` extra,
the core stays standard-library only. Optional `instinct` habit list.

Release: CI runs pytest plus tools/privacy_scan.py (tree, wheel and the
commits since the last tag; guarded words kept as SHA-256 prefixes).
watch.restart() refuses to execv a test runner. Demo, board, front screen,
README (EN, ZH) and screenshot updated.

Co-authored-by: Claude <[email protected]>
Agent: claude-code
… tools, 4 weeks); example fits 80 columns

Co-authored-by: Claude <[email protected]>
Agent: claude-code
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T02:47:47.481574Z bc804a4 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: bc804a4fd1

ℹ️ 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".

Comment thread ai_sync/core.py
Comment on lines +461 to +462
new_truth = merge_back(block, extract_block(truth_path.read_text()) or block) if target.slim else block
atomic_write(truth_path, replace_block(truth_path.read_text(), new_truth))

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 Restore shelved topics before resolving in favor of a layered copy

When a layer = "core" target and preferences.md are both edited, resolving the conflict with --take target writes the folded target block directly into the source of truth. Unlike distribute()'s adoption path, this only restores superseded history for slim targets; it never calls layers.merge_back(). Consequently, every shelved topic's actual rules are replaced by its _Shelved placeholder and subsequently disappear from other copies too. Restore the layered target's omitted topics before writing the resolved truth.

Useful? React with 👍 / 👎.

Comment thread ai_sync/ruleids.py
Comment on lines +131 to +134
retired = [l for l in lines[s + 1:e] if l.startswith("- ")]
while s > 0 and lines[s - 1].strip() == "":
s -= 1
del lines[s:e]

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 continuation lines when archiving retired rules

If a rule under ### 已取代 has indented continuation lines, normalization retains only its initial - line and deletes the entire original section. Any commands, paths, or explanations in those continuation lines are therefore lost from both preferences.md and rules-archive.md during the automatic sync cycle. Other rule-handling paths already recognize multiline bullets, including rulecheck.rules() and _insert_topic_rule(). Join each retired bullet's continuation lines before archiving it rather than filtering them out.

Useful? React with 👍 / 👎.

Comment thread ai_sync/enforcement.py
gone = missing(paths)
if gone:
raise ValueError(f"--enforced-by path does not exist: {', '.join(gone)}")
return {"enforced_by": [_tilde(str(Path(p).expanduser())) for p in paths]}

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 Resolve enforcer paths before persisting the sidecar

When a caller supplies a relative enforcer path such as tests/test_api.py, validation succeeds in the caller's repository, but this expression stores the path unchanged. report() later checks that path against its own working directory, so running rule enforcement from another repository falsely reports the existing enforcer as missing and exits unsuccessfully; an identically named file could also incorrectly satisfy the check. Resolve paths against the adding process's working directory before applying the home-directory abbreviation and saving them.

Useful? React with 👍 / 👎.

Comment thread ai_sync/collab.py
Comment on lines +181 to +185
else:
bullet = f"- {_stamp()} ({who}): {text}" + (f" Reason: {' '.join(reason.split())}" if reason.strip() else "")
with core.locked(cfg):
written = _insert_rule(cfg, bullet, text)
added, bullet, rep = bool(written), written or bullet, {"moved": 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 Apply rule-spec validation to hubs without topic headings

On a newly initialized or otherwise ungrouped hub, setting rule_spec = true does not enforce the advertised interface requirement: this legacy branch accepts arbitrary prose without running rulespec.problems(). Even input supplied through --when/--do is wrapped in the legacy date-prefix format instead of the interface format, so the newly added rule fails rule lint. Enforce the configured specification independently of whether topic headings exist, and use the interface bullet format when that mode is enabled.

Useful? React with 👍 / 👎.

MaxonT and others added 2 commits November 8, 2026 20:49
… parses on Python 3.11; privacy scan skips merge commits

CI on 3.11 refused `rule add --agent x "text"` (unrecognized arguments): a positional
list after an action positional only parses intermixed on 3.12+. The scan now skips
merge commits, which GitHub synthesizes for pull_request runs under the account name.

Co-authored-by: Claude <[email protected]>
Agent: claude-code
@MaxonT
MaxonT merged commit 4669119 into main Nov 9, 2026
6 checks passed
@MaxonT
MaxonT deleted the port-0.2.0 branch November 9, 2026 02:51
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