Skip to content

refactor(daemon): de-duplicate cross-section rules in the runtime brief (MUL-5442) - #6302

Merged
Bohan-J merged 4 commits into
mainfrom
refactor/brief-cross-section-dedup
Aug 3, 2026
Merged

refactor(daemon): de-duplicate cross-section rules in the runtime brief (MUL-5442)#6302
Bohan-J merged 4 commits into
mainfrom
refactor/brief-cross-section-dedup

Conversation

@Bohan-J

@Bohan-J Bohan-J commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

The runtime brief states several rules in more than one place. Each duplicate is a second site to edit when the rule changes, and the copies had already started to drift — in one case the two copies had become materially different. This PR gives each duplicated rule a single canonical home and leaves a pointer at the other call sites.

De-duplication and one gating fix: no rule is dropped, no behavioural constraint is weakened, and every change is static — the brief stays byte-identical across runs of a resumed session, so prompt-cache prefix stability (#6008 / MUL-5377) is untouched.

Measured on a plain issue task, no agent instructions or workspace data:

ordinary agent squad leader
before (main) 19,231 20,718
after 18,009 19,759
delta −1,222 (−6.4%) −959 (−4.6%)

Per section (ordinary agent): Workflow 5,682 → 4,867, Background Task Safety 3,508 → 3,378, Available Commands/Core 2,790 → 2,673, Squad maintenance 203 → 0, Attachments 521 → 451. ## Instruction Precedence grows 370 → 410 and ## Mentions 269 → 342, because both absorbed rules that were previously stated inside the workflow steps.

Commits

  1. Fold four restatements of the end-of-turn rule into one. Background Task Safety opened with four bullets that were four views of the same rule — the general ban, "a tool told me it would notify me", "I can't observe the result", and the "standing by" sign-off.
  2. Demote workflow-step restatements to pointers. Delivery → ## Output; mention discipline → ## Mentions; the metadata read/write bar → ## Issue Metadata.
  3. One home for the comment-read surface and the file-safety rules. The workflow step and the Available Commands entry both explained the comment-read flags; the step now keeps only the two reads it mandates. Same for the --content-file guardrail and the MUL-4252 workdir rule, both owned by ## Comment Formatting.
  4. Merge the Agent Identity action list, gate squad maintenance, trim the attachment restatement. See below.

On commit 4

The two Agent Identity lists had diverged. ## Instruction Precedence and workflow step 4 were added in the same commit (#3802) and each carried its own enumeration of the actions Agent Identity can forbid. Instruction Precedence named status changes; step 4 named issue create/update and delegation. Neither list contained the other, so adding an action type meant editing two places that nobody would remember were linked. They are now one list, in the section that owns the rule. Step 4 keeps only what that section cannot express: a delegation-only role stops once its delegation is delivered.

Squad maintenance was ungated. multica squad member set-role shipped in every brief, including every agent that leads no squad and therefore has no squad whose roles it could change. It is now gated on IsSquadLeader — agent configuration, not per-run state, so the brief stays byte-stable across runs of one session; the workflow already branches on the same predicate.

The attachment rule was a verbatim restatement. ## Attachments repeated Output's no-clickable-local-path rule. It now keeps the framing Output cannot express — a downloaded attachment feels shared because it arrived from the conversation, but it landed in a private workdir — and points at Output for the rule itself. The delivery test additionally asserts the pointed-at rule is present, so the pointer cannot dangle.

Semantic invariants preserved

Every behaviour these sections encode is still asserted by tests:

  • Background Task SafetyDo NOT end your turn while background tasks, Never background-and-yield, wait for a future notification/reminder, running in the background so you can keep working, run the work synchronously instead, foreground tool call that blocks, standing by, the persistent-service handoff contract, the gh pr checks --watch ban, the merge-gate-is-not-acceptance-criteria rule, and the one CI exception.
  • Comment catch-up (MUL-5372) — both mandated reads, this is mandatory, not optional, Skipping this step is the most common cause, the --recent N saturation trap and the pagination cursor labels. These stay: daemon/prompt.go still steers agents onto --recent on the coalesced-comments path, so the trap is live, not historical.
  • Delivery (MUL-4899)Final results MUST be delivered via multica issue comment add, does NOT see your terminal output, Post exactly ONE comment per run, private working copy, and the clickable-local-path ban.
  • Agent Identity — precedence, skip-on-conflict, the merged action enumeration, all three status transitions, and the delegation-only stop rule.
  • Mentionsend with no mention at all, Silence ends conversations, Never @mention the agent you are replying to as a thank-you or sign-off.

Test changes are placement-only. Where a test pinned wording that moved, it now pins the new location; where a test pinned a sentence that merely duplicated another section, it pins the surviving canonical rule plus the pointer. No assertion was deleted without a replacement covering the same behaviour.

Deliberately not done

Retiring the --recent N saturation semantics to --help was considered and rejected: server/internal/daemon/prompt.go:278 still tells agents to run --recent 30 on the coalesced-comments path, so deleting the warning would leave a flag the platform recommends and no longer traps. The better fix is to stop recommending it there — a behaviour change in a different file, worth its own PR.

This PR is de-duplication. The larger remaining win is prose compression inside Workflow and Background Task Safety, which together are still ~46% of the brief.

Verification

  • go test ./internal/daemon/... — pass (daemon, execenv, repocache).
  • go build ./... and go vet ./internal/daemon/... — clean.
  • Before/after byte counts produced by rendering buildMetaSkillContent with identical fixture contexts on both main and this branch, for an ordinary agent and a squad leader.
  • Remaining go test ./... failures in cmd/multica, internal/handler, internal/integrations/* reproduce identically on main in this environment (they need Postgres/config not available locally) and are unrelated.

MUL-5442

Bohan-J and others added 3 commits August 3, 2026 15:31
… one (MUL-5442)

Background Task Safety opened with four bullets that were four views of the
same rule -- do not end the turn with run-owned work outstanding: the general
ban, the "tool says it will notify you" case, the unobservable-result case,
and the "standing by" sign-off. Separating them cost bytes without adding a
distinct behaviour.

Fold them into the leading bullet. Every phrase the behaviour tests pin is
carried over verbatim, including "Do NOT end your turn while background
tasks", "Never background-and-yield", "wait for a future
notification/reminder", "running in the background so you can keep working",
"run the work synchronously instead" and "standing by".

MUL-5442

Co-authored-by: multica-agent <github@multica.ai>
…ion and metadata policy to pointers (MUL-5442)

The six workflow steps and the Reply mode block restated policy that already
has a dedicated section. Each restatement is a second place to edit when the
policy changes, which is how they drifted apart in the first place.

Give each rule one canonical home and leave a pointer at the call site:

- delivery ("only a comment reaches the user") -> ## Output; steps 5 and the
  Reply block point at it.
- mention discipline -> ## Mentions. The reply-time phrasing the loop-hardening
  test pins moves into that section rather than being duplicated in the Reply
  block, so the anti-loop signal is unchanged.
- metadata read/write bar -> ## Issue Metadata; steps 2 and 6 point at it
  instead of paraphrasing the bar.

Tests: the metadata scope test pinned the old pointer wording, and the mention
test's comment claimed the sign-off rule lived in the workflow steps. Both are
updated to the new placement; every behavioural phrase they guard is still
asserted, file-wide.

MUL-5442

Co-authored-by: multica-agent <github@multica.ai>
…ules one home each (MUL-5442)

Three cross-section duplications, each resolved toward the section that owns
the rule:

- comment reads: the workflow step and the Available Commands entry both
  explained what --roots-only / --summary / --thread --tail do. The step keeps
  the two reads it mandates and its anti-stale motive; flag semantics stay in
  Available Commands, which is the single discovery point. The saturation trap
  ("caps THREADS, not comments") and the pagination cursor labels stay put --
  they are load-bearing after MUL-5372 and remain asserted.
- --content-file: the comment add entry restated the guardrail Comment
  Formatting owns; it now names the rule and points there for the rationale.
- workdir path rule (MUL-4252): issue create carried its own copy of the
  stale-file rationale; it keeps the rule and defers the why.
- inbound attachments: trimmed to the pinned rule plus a pointer.

MUL-5442

Co-authored-by: multica-agent <github@multica.ai>
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
multica-docs Ready Ready Preview Aug 3, 2026 8:23am

Request Review

…intenance, trim the attachment restatement (MUL-5442)

Three follow-ups from review, each re-examined against what the text guards
today rather than against the fact that a test pinned it.

1. Agent Identity enumeration. Instruction Precedence and workflow step 4 were
   added in the same commit (#3802) and each carried its own list of actions
   Agent Identity can forbid -- and the lists disagreed: one named status
   changes, the other named issue create/update and delegation, neither
   contained the other. Merge them into Instruction Precedence, which owns the
   rule. Step 4 keeps only what that section cannot express: a delegation-only
   role stops once its delegation is delivered.

2. Squad maintenance. `multica squad member set-role` shipped to every run,
   including every agent that leads no squad and therefore has no squad whose
   roles it could change. Gate it on IsSquadLeader -- agent configuration, not
   per-run state, so the brief stays byte-stable across runs of one session
   (MUL-5377), the same predicate the workflow already branches on.

3. Inbound attachments. The section restated Output's no-clickable-local-path
   rule verbatim. Keep the framing Output cannot express -- a downloaded
   attachment feels shared but landed in a private workdir -- and point at
   Output for the rule. The delivery test now also asserts the pointed-at rule
   is present, so the pointer cannot dangle.

Brief size, plain issue task: 19,231 -> 18,009 bytes for an ordinary agent
(-6.4%), 20,718 -> 19,759 for a squad leader (-4.6%).

MUL-5442

Co-authored-by: multica-agent <github@multica.ai>
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