Evolve
Use this skill when current work exposes a lesson that is likely to prevent a
future mistake. Fix and verify the current task first. Do not invoke it for a
one-off detail that has no recurring value.
Agent Context Patch is agent-first:
- The agent understands the project, judges evidence, chooses wording, and
prepares semantic changes.
- The deterministic commit kernel validates the plan envelope, paths, policy,
hashes, conflicts, and application. The Lifecycle Coordinator owns
deterministic proposal reconciliation and audit continuation. The Outcome
Interface validates and formats the ephemeral delivery result; the agent owns
detection, proposal meaning, and semantic lifecycle decisions. Neither
deterministic module judges project meaning or edits proposal prose.
auto is the default write policy for new workspaces. It requires the Node
kernel; if the kernel is unavailable, preserve the exact proposal, report
the reason, and use the approval path instead of pretending the patch was
applied.
Read references/protocol-v1.md for the normative v1 contract.
Context loading
For normal project work, load only:
- .agent-context/PROJECT_CONTEXT_INDEX.md
- .agent-context/PROJECT_PROFILE.md
- the relevant checklist for a domain enabled in config.yml
Do not load proposals, reports, or archive by default. Read config.yml and the
relevant reference only when evolving context.
Lifecycle reconciliation
For $evolve after-failure, $evolve approve, $evolve review-context, and
$evolve weekly, invoke the installed runtime's dedicated coordinator before
creating, approving, or reporting more proposal work. Invoke it again after a
new eligible auto proposal or an exact approval is persisted so the coordinator
owns the apply-and-audit continuation:
import { reconcileWorkspaceProposalLifecycles } from "./runtime/lifecycle.mjs";
const reconciliation = await reconcileWorkspaceProposalLifecycles({
workspaceRoot,
});
Resolve the module path from the installed Skill; the example path is relative
to this file, not the user's current directory. This is not a new public
command. Do not run it from init, update, installation, Agent startup, a
daemon, or a background scan.
Handle its content-safe outcomes as follows:
resume_exact_auto or resume_exact_authorized: report the resulting state;
do not append another Decision for an already-approved plan.
regenerate_required: re-read current sources and semantically rebuild the
history-free proposal; deterministic code must not choose new wording.
superseding_proposal_required: create a replacement proposal, write that
exact proposal ID in the old Supersession section, then reconcile again. The
coordinator alone verifies the cross-proposal edge before changing the old
status to superseded.
audit_recovery_required: stop. Matching after hashes do not prove that this
proposal applied; never invent the missing Attempt or silently reapply.
manual_recovery_required: stop automatic work and report the one
machine-readable reason.
approval_required: continue only through the existing informed approval
path.
settled: no additional lifecycle action is needed for that proposal.
If the lifecycle lock remains after a crash, verify that no coordinator is
active before manually removing only
.agent-context/.lifecycle-coordinator.lock. Never delete it based on age.
Delivery checkpoint
After the current fix is verified, run one delivery checkpoint only when at
least one high-signal event occurred:
failed_verification_later_passed
explicit_user_correction
independent_qa_defect
stale_context
first_fix_failed_then_passed
The Agent decides the semantic detect and propose stages. If a proposal was
created or an existing proposal was reconciled, pass the exact content-safe
Lifecycle Coordinator result as mechanical evidence; never synthesize the
apply stage. Finalize the task-level result through the installed Skill's
separate Outcome Interface:
import { finalizeEvolutionOutcome } from "./runtime/outcome.mjs";
const outcome = finalizeEvolutionOutcome({
detect,
propose,
proposalId,
reconciliation,
});
Omit proposalId and reconciliation for no_candidate or a semantic blocker.
Resolve the module path from the installed Skill. Print only outcome.receipt.text:
it covers detect, propose, and apply; every non-success stage includes one
stable machine-readable reason. Applied results may also include only a
content-safe proposal ID and sorted workspace-relative targets. Do not add
lesson prose, PatchPlan content, target content, secrets, conversation data, or
absolute paths to the receipt.
The valid state families are:
no_candidate / not_needed / not_attempted
skipped / blocked / not_attempted
candidate / blocked / not_attempted
candidate / created / applied | approval_required | blocked
skipped(existing_proposal) / not_needed(existing_proposal) / applied | approval_required | blocked
Any other combination is invalid and must fail closed. In particular, the
Outcome Interface cannot report applied without the exact proposal ID and a
verified applied audit from settled reconciliation. If finalization itself
rejects the inputs, report only invalid_evolution_outcome; do not hand-format
a success receipt.
If there is no high-signal trigger, stay silent: do not create a proposal or
durable context write merely to emit an outcome. detect: skipped is available
only when an explicit diagnostic result is required. The outcome and receipt
are ephemeral task results; proposal aggregates remain the durable audit source.
Hard invariants
- Never let evolution delay repair of the current task.
- Never apply a proposal until current_fix_status is verified.
- Workspace is the only active context scope in v1.
- User-global is valid only for a manually approved promotion proposal; the
workspace kernel cannot apply it.
- Supported write policies are propose and auto. New workspaces default to
auto; an existing workspace's explicit config remains authoritative.
- Deletion, cleanup, migration, domain activation, instruction-file changes,
and user-global promotion always require human approval.
- Approval covers one immutable PatchPlan and its plan_hash. Changed targets
require a new plan and new approval.
- The proposal aggregate itself is never a PatchPlan target. Decision and
Apply Attempt writes stay outside the kernel transaction.
- Never infer
applied from target content. Exact before hashes permit resume;
after hashes without an applied Attempt require audit recovery.
- Never hand-format a detect-to-apply success. The Outcome Interface requires
settled Lifecycle Coordinator evidence and strips unsafe detail.
- Every non-migration kernel call requires a complete current v1 config.
Future schemas remain read-only; legacy migration requires exact backups for
every changed existing file in the same approved transaction.
- Archive targets are create-only history. Approval can add a new snapshot but
cannot rewrite an existing archive file.
- A workspace proposal persists the complete JSON PatchPlan. Its target_files,
frontmatter plan_hash, Decision Log hashes, and Apply Attempt hashes must
agree with that plan.
- PatchPlan semanticOperation must equal proposal frontmatter operation. Auto
is possible only for semanticOperation add.
- Approval and application are separate internal states. Eligible auto plans
do not require a user decision;
$evolve approve handles only the exception
path that requires one.
- Active context changes use replace-before-add. Never append a rule before
checking for duplication, overlap, conflict, or a better replacement.
- Evidence is pointer-first and summary-first. Never persist secrets, raw
conversations, complete logs, customer data, or unnecessary absolute paths.
- Kit updates run only when the user invokes $evolve update. They never poll in
the background, emit telemetry, silently replace the installed skill, edit a
workspace, or authorize a workspace-schema migration.
Commands
$evolve init
Initialize or refresh the current workspace:
- Resolve the workspace root; a Git repository is one possible workspace, not
a separate scope.
- If config.yml has no schema_version, read references/legacy-migration.md and
remain read-only until a migration proposal is approved.
If it claims v1 but fails the complete config envelope, stop as invalid
rather than materializing missing templates.
- Inspect source-of-truth files and mark uncertainties rather than guessing.
- Detect candidate domains with evidence, confidence, and uncertainties.
- Build one InitPlan containing candidate domains, active files, exact patches,
and context impact. Split safe Active Context additions from approval-only
config or domain changes.
- Apply every eligible auto addition immediately. Request one concise decision
only when the plan also changes config or enabled domains; the user never
needs to copy a plan hash.
- Store only approved enabled_domains in config.yml. Materialize checklists
only for enabled domains; detected candidates remain temporary plan data.
- Give one compact receipt for applied changes and list only unresolved safety
exceptions. Do not dump the full InitPlan unless the user asks.
Auto cannot enable or disable domains.
$evolve after-failure
Run autonomously after a correction, failed verification, repeated mistake,
missed context read, or stale-context discovery. The user does not need to
invoke this command manually:
- Repair the current issue and verify it when possible.
- Reconcile unfinished proposal lifecycles before creating another aggregate;
handle every blocking outcome using the rules above.
- After verification, run the delivery checkpoint. Decide whether the lesson
is reusable. If not, finalize
no_candidate / not_needed / not_attempted
and print only its compact receipt.
- Compare it with active context using replace-before-add. Compare the
responsibility, trigger, reachable execution path, intended effect, and
observable verification rather than relying on shared nouns. Only when
related active rules suggest the same responsibility or failure shape, read
pointer-first summaries for those applied proposals and shortlist the few
aggregates needed to test subsumption. Do not scan full proposal history
after every failure.
- Create one evidence-backed proposal aggregate in proposals/.
- Use pending_current_fix while repair is not verified; otherwise use
proposed.
- Keep evidence as workspace-relative pointers and short result summaries.
- Evaluate authority, retention value, privacy, and the net active-context
change.
- When the patch adds an Active Context rule, give each new rule a stable ID
using the source proposal ID plus a one-based ordinal. Place a compact
acp-rule Markdown comment immediately above it with its source proposal and
subsumes: none. A replacement uses a new ID and names the replaced IDs;
never retrofit IDs through an unapproved bulk migration.
- For a workspace proposal, persist the full JSON PatchPlan under Proposed
Patch and compute plan_hash from its canonical JSON.
- Evaluate policy and all auto gates. When eligible, invoke Lifecycle
Reconciliation again. It persists the
policy_auto Decision, enters
approved, calls the Commit Kernel with the exact runtime plan, appends the
Apply Attempt, and enters applied only after success.
- Finalize the Agent-owned
detect and propose stages with the exact
reconciliation result through finalizeEvolutionOutcome. Print only
outcome.receipt.text; do not request approval, wait for a reply, or print
the full PatchPlan or plan hash on an applied path.
- If an auto gate fails, keep the exact proposal and let the Outcome Interface
report
approval_required or blocked with one machine-readable reason and
a safe next action when known. Ask for a decision only when the operation is
an allowed approval-only exception.
$evolve approve
This is the public exception path for a proposal that cannot use auto:
- Reconcile unfinished lifecycles. If the requested proposal was resumed to
applied or superseded, report that result and stop. If it needs regeneration,
supersession, audit recovery, or manual recovery, resolve that exact outcome
before requesting approval.
- Parse the four-tilde JSON block under Proposed Patch / PatchPlan JSON.
Reject prose-only or partial patch descriptions.
- Recompute canonical JSON SHA-256 and require it to equal frontmatter
plan_hash. Require target_files to equal the operation targets and every
existing Decision/Apply hash to equal the same value. Require
semanticOperation to equal frontmatter operation.
- Show a concise semantic summary followed by the complete immutable plan:
target contents, operations, before hashes, policy result, context delta,
and plan_hash. High-risk approval must be informed even though it is rare.
- Obtain explicit approval for the exact current plan. The user may simply
reply with approval; never require them to copy or repeat the hash.
- Persist a Decision Log entry and status approved. If this write fails, stop
before calling the kernel.
- Invoke Lifecycle Reconciliation again. It rechecks the exact plan, current
config, paths, mechanical privacy, and before hashes, adds runtime-only
absolute workspaceRoot and
planHash, then calls
applyPatchPlan(plan, {approvedPlanHash}). Approval
stays outside the hashed plan and must match plan_hash exactly.
- Let the kernel transaction update only the context targets and return its
raw status, reason, and per-target hash operations.
- Let the coordinator map that result to an Apply Attempt, add the attempt
timestamp and a content-free error summary, then append it immediately. On
success it sets status to applied; on conflict, failure, or rollback it keeps
status approved.
- If audit writeback fails, report audit_write_pending and retry it. Do not
create a separate receipt or claim lifecycle completion.
If a target changes before any decision or attempt, replace the plan and
recompute its hash. After audit history exists, create a superseding proposal
instead, write the replacement ID in the old Supersession section, and rerun
Lifecycle Reconciliation; one aggregate never mixes hashes from multiple plans.
Without the kernel, propose mode may apply the exact human-approved patch, but
must still record hashes and the result.
A user-global promotion has no workspace PatchPlan before an adapter resolves
its real target. Store only a sanitized candidate hash, keep status proposed,
and defer exact approval to the adapter plan. Never send it to the workspace
kernel.
$evolve review-context
Review active context against current sources. Use
references/cleanup-policy.md and references/context-budget.md.
- Reconcile unfinished proposal lifecycles before calculating proposal health.
- Rank authority separately from retention value.
- Detect stale, duplicated, conflicting, vague, or over-specific rules.
- Use a summary-first two-stage read: scan Active Context plus proposal IDs and
short summaries, then deeply inspect only the shortlist that may share the
same responsibility and behavior failure shape.
- Generalize across different implementation nouns only when one testable
invariant preserves the included verification guarantees. Record subsumed
rules and proposal IDs, preserved domain details, exclusions or
counterexamples, behavior lost, and net active-context change.
- Prefer tighten, merge, rewrite, supersede, or archive over another append.
- When bounded, content-safe task evidence is available for a stable rule ID,
distinguish
material_use, loaded_only, relevant_but_missed,
not_applicable, and unknown. Reading a context file alone is
loaded_only; absent task coverage is unknown, not evidence of disuse.
- Recommend only
retain, observe, narrow_route, rewrite_candidate, or
cleanup_candidate. Low use schedules review and never authorizes removal.
- Produce an exact cleanup proposal with what behavior would be lost and the
net context change.
- Require human approval for every semantic removal or replacement.
Thresholds trigger review and block auto; they never authorize truncation.
$evolve weekly
Reconcile unfinished proposal lifecycles first, then write a compact derived
report in reports/ covering:
- recurring signals and verification status
- applied improvements
- proposal triage
- stale, redundant, or conflicting active context
- a bounded effectiveness view for reviewed stable rule IDs: relevant-task
opportunities, material uses, recurrence after activation, last material-use
pointer, irrelevant-load observations, and explicit unknown coverage
- review signals independent of line count, including repeated failure after
activation, repeated loaded-only or irrelevant default loading, rapid active
additions, long auto-add sequences without cleanup, and undifferentiated
high-retention declarations with little known coverage
- recommended patches, cleanup, and possible cross-noun generalization
candidates for
$evolve review-context; the report never merges them
- next review priorities
Reports are rebuildable views, not sources of truth, and are not part of the
default context read. Inspect only explicitly available, content-safe task
evidence. Do not add a background scan, per-task receipt, raw usage ledger, or
mechanical hit-rate score.
Personal multi-repository dogfooding
When the user explicitly wants to establish or review their own long-running
use of this kit across repositories, read the experimental owner-dogfood guide
references/personal-dogfooding.zh-CN.md. Keep each repository workspace-first,
promote only evidence-backed patterns, and do not turn the review cadence into
mandatory ceremony when no real signal exists.
$evolve update
This is the only public Kit update entry point. Run it only when the user asks:
- Resolve the installed evolve skill path and read its manifest without
scanning workspaces.
- Query
https://github.com/Cherwayway/agent-context-patch/releases/latest, resolve
the latest stable Release to one GitHub-enforced immutable tag and source
commit, and compare its Kit Version with the installed version. Stop if the
Release is not marked immutable. If the check is unavailable, report that
and leave the current install usable. If the installed version is current
or newer, report that and stop; this command never downgrades an
installation.
- Download that exact Release and its published integrity metadata to a local
temporary directory. Verify the published archive checksum, the GitHub
Release tag and target commit, and the unpacked skill manifest version.
Require those identities to agree. Stop on missing metadata or any
mismatch.
- Execute the Bootstrap from the unpacked candidate Release in UpdateDryRun
mode against the resolved installed skill path. The candidate Release is
the update source; never run the installed Bootstrap as its own source.
- Show the complete UpdatePlan: installed and target versions, immutable tag
and commit, artifact checksum, exact installed and candidate managed-tree
hashes, whole-skill replacement scope, recovery copy, workspace-schema
impact, rollback behavior, and exact plan hash.
- Obtain explicit approval of that exact hash. A changed candidate, target,
or plan requires a new dry-run and new approval.
- Invoke the same candidate Release Bootstrap in UpdateApply mode with the
approved hash. Do not merge locally modified skill files or include an
instruction-file patch or workspace migration in this mechanical update.
- Report verification and recovery results. On failure, restore the prior
working skill when possible. If automatic restore fails, retain and report
the recovery copy; never claim success from an incomplete replacement.
- On success, report the installed version and tell the user to start a new
Agent task so the updated skill is loaded.
Version discovery sends no workspace path, context, source code, conversation,
or usage event. GitHub Release notifications are external; this skill provides
no daemon, scheduled check, telemetry, or silent upgrade.
Policy evaluation
Read context_write_policy from config.yml. auto is the default write policy
for newly initialized workspaces:
- auto: complete the same audited lifecycle immediately without a human
decision when every low-risk gate in references/protocol-v1.md passes.
- propose: an explicit cautious mode, or a preserved setting in an existing
workspace; create the exact record and wait for approval.
If an auto gate fails, keep the proposal and its machine-readable policy result,
but show the user only one concise exception by default:
requested_policy: auto
effective_policy: propose
reason: <machine-readable-reason>
The agent or kernel must not weaken a failed gate. A successful auto path must
end with one non-blocking receipt and no request for user action.
References
- references/protocol-v1.md
- references/config-schema.md
- references/proposal-schema.md
- references/legacy-migration.md
- references/domain-packs.md
- references/context-budget.md
- references/cleanup-policy.md
- references/privacy.md
- references/personal-dogfooding.zh-CN.md
- references/domain-coding.md
- references/domain-prd.md
- references/domain-seo.md
1---2name: evolve3description: Turn verified failures, repeated corrections, and stale workspace context into automatically applied low-risk workspace patches, with review reserved for safety exceptions, or explicitly check and safely update the installed Kit.4---56# Evolve78Use this skill when current work exposes a lesson that is likely to prevent a9future mistake. Fix and verify the current task first. Do not invoke it for a10one-off detail that has no recurring value.1112Agent Context Patch is agent-first:1314- The agent understands the project, judges evidence, chooses wording, and15 prepares semantic changes.16- The deterministic commit kernel validates the plan envelope, paths, policy,17 hashes, conflicts, and application. The Lifecycle Coordinator owns18 deterministic proposal reconciliation and audit continuation. The Outcome19 Interface validates and formats the ephemeral delivery result; the agent owns20 detection, proposal meaning, and semantic lifecycle decisions. Neither21 deterministic module judges project meaning or edits proposal prose.22- `auto` is the default write policy for new workspaces. It requires the Node23 kernel; if the kernel is unavailable, preserve the exact proposal, report24 the reason, and use the approval path instead of pretending the patch was25 applied.2627Read references/protocol-v1.md for the normative v1 contract.2829## Context loading3031For normal project work, load only:32331. .agent-context/PROJECT_CONTEXT_INDEX.md342. .agent-context/PROJECT_PROFILE.md353. the relevant checklist for a domain enabled in config.yml3637Do not load proposals, reports, or archive by default. Read config.yml and the38relevant reference only when evolving context.3940## Lifecycle reconciliation4142For `$evolve after-failure`, `$evolve approve`, `$evolve review-context`, and43`$evolve weekly`, invoke the installed runtime's dedicated coordinator before44creating, approving, or reporting more proposal work. Invoke it again after a45new eligible auto proposal or an exact approval is persisted so the coordinator46owns the apply-and-audit continuation:4748~~~js49import { reconcileWorkspaceProposalLifecycles } from "./runtime/lifecycle.mjs";5051const reconciliation = await reconcileWorkspaceProposalLifecycles({52 workspaceRoot,53});54~~~5556Resolve the module path from the installed Skill; the example path is relative57to this file, not the user's current directory. This is not a new public58command. Do not run it from `init`, `update`, installation, Agent startup, a59daemon, or a background scan.6061Handle its content-safe outcomes as follows:6263- `resume_exact_auto` or `resume_exact_authorized`: report the resulting state;64 do not append another Decision for an already-approved plan.65- `regenerate_required`: re-read current sources and semantically rebuild the66 history-free proposal; deterministic code must not choose new wording.67- `superseding_proposal_required`: create a replacement proposal, write that68 exact proposal ID in the old Supersession section, then reconcile again. The69 coordinator alone verifies the cross-proposal edge before changing the old70 status to superseded.71- `audit_recovery_required`: stop. Matching after hashes do not prove that this72 proposal applied; never invent the missing Attempt or silently reapply.73- `manual_recovery_required`: stop automatic work and report the one74 machine-readable reason.75- `approval_required`: continue only through the existing informed approval76 path.77- `settled`: no additional lifecycle action is needed for that proposal.7879If the lifecycle lock remains after a crash, verify that no coordinator is80active before manually removing only81`.agent-context/.lifecycle-coordinator.lock`. Never delete it based on age.8283## Delivery checkpoint8485After the current fix is verified, run one delivery checkpoint only when at86least one high-signal event occurred:8788- `failed_verification_later_passed`89- `explicit_user_correction`90- `independent_qa_defect`91- `stale_context`92- `first_fix_failed_then_passed`9394The Agent decides the semantic `detect` and `propose` stages. If a proposal was95created or an existing proposal was reconciled, pass the exact content-safe96Lifecycle Coordinator result as mechanical evidence; never synthesize the97`apply` stage. Finalize the task-level result through the installed Skill's98separate Outcome Interface:99100~~~js101import { finalizeEvolutionOutcome } from "./runtime/outcome.mjs";102103const outcome = finalizeEvolutionOutcome({104 detect,105 propose,106 proposalId,107 reconciliation,108});109~~~110111Omit `proposalId` and `reconciliation` for `no_candidate` or a semantic blocker.112Resolve the module path from the installed Skill. Print only `outcome.receipt.text`:113it covers `detect`, `propose`, and `apply`; every non-success stage includes one114stable machine-readable reason. Applied results may also include only a115content-safe proposal ID and sorted workspace-relative targets. Do not add116lesson prose, PatchPlan content, target content, secrets, conversation data, or117absolute paths to the receipt.118119The valid state families are:120121- `no_candidate / not_needed / not_attempted`122- `skipped / blocked / not_attempted`123- `candidate / blocked / not_attempted`124- `candidate / created / applied | approval_required | blocked`125- `skipped(existing_proposal) / not_needed(existing_proposal) / applied |126 approval_required | blocked`127128Any other combination is invalid and must fail closed. In particular, the129Outcome Interface cannot report `applied` without the exact proposal ID and a130verified applied audit from settled reconciliation. If finalization itself131rejects the inputs, report only `invalid_evolution_outcome`; do not hand-format132a success receipt.133134If there is no high-signal trigger, stay silent: do not create a proposal or135durable context write merely to emit an outcome. `detect: skipped` is available136only when an explicit diagnostic result is required. The outcome and receipt137are ephemeral task results; proposal aggregates remain the durable audit source.138139## Hard invariants140141- Never let evolution delay repair of the current task.142- Never apply a proposal until current_fix_status is verified.143- Workspace is the only active context scope in v1.144- User-global is valid only for a manually approved promotion proposal; the145 workspace kernel cannot apply it.146- Supported write policies are propose and auto. New workspaces default to147 auto; an existing workspace's explicit config remains authoritative.148- Deletion, cleanup, migration, domain activation, instruction-file changes,149 and user-global promotion always require human approval.150- Approval covers one immutable PatchPlan and its plan_hash. Changed targets151 require a new plan and new approval.152- The proposal aggregate itself is never a PatchPlan target. Decision and153 Apply Attempt writes stay outside the kernel transaction.154- Never infer `applied` from target content. Exact before hashes permit resume;155 after hashes without an applied Attempt require audit recovery.156- Never hand-format a detect-to-apply success. The Outcome Interface requires157 settled Lifecycle Coordinator evidence and strips unsafe detail.158- Every non-migration kernel call requires a complete current v1 config.159 Future schemas remain read-only; legacy migration requires exact backups for160 every changed existing file in the same approved transaction.161- Archive targets are create-only history. Approval can add a new snapshot but162 cannot rewrite an existing archive file.163- A workspace proposal persists the complete JSON PatchPlan. Its target_files,164 frontmatter plan_hash, Decision Log hashes, and Apply Attempt hashes must165 agree with that plan.166- PatchPlan semanticOperation must equal proposal frontmatter operation. Auto167 is possible only for semanticOperation add.168- Approval and application are separate internal states. Eligible auto plans169 do not require a user decision; `$evolve approve` handles only the exception170 path that requires one.171- Active context changes use replace-before-add. Never append a rule before172 checking for duplication, overlap, conflict, or a better replacement.173- Evidence is pointer-first and summary-first. Never persist secrets, raw174 conversations, complete logs, customer data, or unnecessary absolute paths.175- Kit updates run only when the user invokes $evolve update. They never poll in176 the background, emit telemetry, silently replace the installed skill, edit a177 workspace, or authorize a workspace-schema migration.178179## Commands180181### $evolve init182183Initialize or refresh the current workspace:1841851. Resolve the workspace root; a Git repository is one possible workspace, not186 a separate scope.1872. If config.yml has no schema_version, read references/legacy-migration.md and188 remain read-only until a migration proposal is approved.189 If it claims v1 but fails the complete config envelope, stop as invalid190 rather than materializing missing templates.1913. Inspect source-of-truth files and mark uncertainties rather than guessing.1924. Detect candidate domains with evidence, confidence, and uncertainties.1935. Build one InitPlan containing candidate domains, active files, exact patches,194 and context impact. Split safe Active Context additions from approval-only195 config or domain changes.1966. Apply every eligible auto addition immediately. Request one concise decision197 only when the plan also changes config or enabled domains; the user never198 needs to copy a plan hash.1997. Store only approved enabled_domains in config.yml. Materialize checklists200 only for enabled domains; detected candidates remain temporary plan data.2018. Give one compact receipt for applied changes and list only unresolved safety202 exceptions. Do not dump the full InitPlan unless the user asks.203204Auto cannot enable or disable domains.205206### $evolve after-failure207208Run autonomously after a correction, failed verification, repeated mistake,209missed context read, or stale-context discovery. The user does not need to210invoke this command manually:2112121. Repair the current issue and verify it when possible.2132. Reconcile unfinished proposal lifecycles before creating another aggregate;214 handle every blocking outcome using the rules above.2153. After verification, run the delivery checkpoint. Decide whether the lesson216 is reusable. If not, finalize `no_candidate / not_needed / not_attempted`217 and print only its compact receipt.2184. Compare it with active context using replace-before-add. Compare the219 responsibility, trigger, reachable execution path, intended effect, and220 observable verification rather than relying on shared nouns. Only when221 related active rules suggest the same responsibility or failure shape, read222 pointer-first summaries for those applied proposals and shortlist the few223 aggregates needed to test subsumption. Do not scan full proposal history224 after every failure.2255. Create one evidence-backed proposal aggregate in proposals/.2266. Use pending_current_fix while repair is not verified; otherwise use227 proposed.2287. Keep evidence as workspace-relative pointers and short result summaries.2298. Evaluate authority, retention value, privacy, and the net active-context230 change.2319. When the patch adds an Active Context rule, give each new rule a stable ID232 using the source proposal ID plus a one-based ordinal. Place a compact233 `acp-rule` Markdown comment immediately above it with its source proposal and234 `subsumes: none`. A replacement uses a new ID and names the replaced IDs;235 never retrofit IDs through an unapproved bulk migration.23610. For a workspace proposal, persist the full JSON PatchPlan under Proposed237 Patch and compute plan_hash from its canonical JSON.23811. Evaluate policy and all auto gates. When eligible, invoke Lifecycle239 Reconciliation again. It persists the `policy_auto` Decision, enters240 approved, calls the Commit Kernel with the exact runtime plan, appends the241 Apply Attempt, and enters applied only after success.24212. Finalize the Agent-owned `detect` and `propose` stages with the exact243 reconciliation result through `finalizeEvolutionOutcome`. Print only244 `outcome.receipt.text`; do not request approval, wait for a reply, or print245 the full PatchPlan or plan hash on an applied path.24613. If an auto gate fails, keep the exact proposal and let the Outcome Interface247 report `approval_required` or `blocked` with one machine-readable reason and248 a safe next action when known. Ask for a decision only when the operation is249 an allowed approval-only exception.250251### $evolve approve252253This is the public exception path for a proposal that cannot use auto:2542551. Reconcile unfinished lifecycles. If the requested proposal was resumed to256 applied or superseded, report that result and stop. If it needs regeneration,257 supersession, audit recovery, or manual recovery, resolve that exact outcome258 before requesting approval.2592. Parse the four-tilde JSON block under Proposed Patch / PatchPlan JSON.260 Reject prose-only or partial patch descriptions.2613. Recompute canonical JSON SHA-256 and require it to equal frontmatter262 plan_hash. Require target_files to equal the operation targets and every263 existing Decision/Apply hash to equal the same value. Require264 semanticOperation to equal frontmatter operation.2654. Show a concise semantic summary followed by the complete immutable plan:266 target contents, operations, before hashes, policy result, context delta,267 and plan_hash. High-risk approval must be informed even though it is rare.2685. Obtain explicit approval for the exact current plan. The user may simply269 reply with approval; never require them to copy or repeat the hash.2706. Persist a Decision Log entry and status approved. If this write fails, stop271 before calling the kernel.2727. Invoke Lifecycle Reconciliation again. It rechecks the exact plan, current273 config, paths, mechanical privacy, and before hashes, adds runtime-only274 absolute workspaceRoot and275 planHash, then calls `applyPatchPlan(plan, {approvedPlanHash})`. Approval276 stays outside the hashed plan and must match plan_hash exactly.2778. Let the kernel transaction update only the context targets and return its278 raw status, reason, and per-target hash operations.2799. Let the coordinator map that result to an Apply Attempt, add the attempt280 timestamp and a content-free error summary, then append it immediately. On281 success it sets status to applied; on conflict, failure, or rollback it keeps282 status approved.28310. If audit writeback fails, report audit_write_pending and retry it. Do not284 create a separate receipt or claim lifecycle completion.285286If a target changes before any decision or attempt, replace the plan and287recompute its hash. After audit history exists, create a superseding proposal288instead, write the replacement ID in the old Supersession section, and rerun289Lifecycle Reconciliation; one aggregate never mixes hashes from multiple plans.290Without the kernel, propose mode may apply the exact human-approved patch, but291must still record hashes and the result.292293A user-global promotion has no workspace PatchPlan before an adapter resolves294its real target. Store only a sanitized candidate hash, keep status proposed,295and defer exact approval to the adapter plan. Never send it to the workspace296kernel.297298### $evolve review-context299300Review active context against current sources. Use301references/cleanup-policy.md and references/context-budget.md.302303- Reconcile unfinished proposal lifecycles before calculating proposal health.304- Rank authority separately from retention value.305- Detect stale, duplicated, conflicting, vague, or over-specific rules.306- Use a summary-first two-stage read: scan Active Context plus proposal IDs and307 short summaries, then deeply inspect only the shortlist that may share the308 same responsibility and behavior failure shape.309- Generalize across different implementation nouns only when one testable310 invariant preserves the included verification guarantees. Record subsumed311 rules and proposal IDs, preserved domain details, exclusions or312 counterexamples, behavior lost, and net active-context change.313- Prefer tighten, merge, rewrite, supersede, or archive over another append.314- When bounded, content-safe task evidence is available for a stable rule ID,315 distinguish `material_use`, `loaded_only`, `relevant_but_missed`,316 `not_applicable`, and `unknown`. Reading a context file alone is317 `loaded_only`; absent task coverage is `unknown`, not evidence of disuse.318- Recommend only `retain`, `observe`, `narrow_route`, `rewrite_candidate`, or319 `cleanup_candidate`. Low use schedules review and never authorizes removal.320- Produce an exact cleanup proposal with what behavior would be lost and the321 net context change.322- Require human approval for every semantic removal or replacement.323324Thresholds trigger review and block auto; they never authorize truncation.325326### $evolve weekly327328Reconcile unfinished proposal lifecycles first, then write a compact derived329report in reports/ covering:3303311. recurring signals and verification status3322. applied improvements3333. proposal triage3344. stale, redundant, or conflicting active context3355. a bounded effectiveness view for reviewed stable rule IDs: relevant-task336 opportunities, material uses, recurrence after activation, last material-use337 pointer, irrelevant-load observations, and explicit unknown coverage3386. review signals independent of line count, including repeated failure after339 activation, repeated loaded-only or irrelevant default loading, rapid active340 additions, long auto-add sequences without cleanup, and undifferentiated341 high-retention declarations with little known coverage3427. recommended patches, cleanup, and possible cross-noun generalization343 candidates for `$evolve review-context`; the report never merges them3448. next review priorities345346Reports are rebuildable views, not sources of truth, and are not part of the347default context read. Inspect only explicitly available, content-safe task348evidence. Do not add a background scan, per-task receipt, raw usage ledger, or349mechanical hit-rate score.350351### Personal multi-repository dogfooding352353When the user explicitly wants to establish or review their own long-running354use of this kit across repositories, read the experimental owner-dogfood guide355`references/personal-dogfooding.zh-CN.md`. Keep each repository workspace-first,356promote only evidence-backed patterns, and do not turn the review cadence into357mandatory ceremony when no real signal exists.358359### $evolve update360361This is the only public Kit update entry point. Run it only when the user asks:3623631. Resolve the installed evolve skill path and read its manifest without364 scanning workspaces.3652. Query366 https://github.com/Cherwayway/agent-context-patch/releases/latest, resolve367 the latest stable Release to one GitHub-enforced immutable tag and source368 commit, and compare its Kit Version with the installed version. Stop if the369 Release is not marked immutable. If the check is unavailable, report that370 and leave the current install usable. If the installed version is current371 or newer, report that and stop; this command never downgrades an372 installation.3733. Download that exact Release and its published integrity metadata to a local374 temporary directory. Verify the published archive checksum, the GitHub375 Release tag and target commit, and the unpacked skill manifest version.376 Require those identities to agree. Stop on missing metadata or any377 mismatch.3784. Execute the Bootstrap from the unpacked candidate Release in UpdateDryRun379 mode against the resolved installed skill path. The candidate Release is380 the update source; never run the installed Bootstrap as its own source.3815. Show the complete UpdatePlan: installed and target versions, immutable tag382 and commit, artifact checksum, exact installed and candidate managed-tree383 hashes, whole-skill replacement scope, recovery copy, workspace-schema384 impact, rollback behavior, and exact plan hash.3856. Obtain explicit approval of that exact hash. A changed candidate, target,386 or plan requires a new dry-run and new approval.3877. Invoke the same candidate Release Bootstrap in UpdateApply mode with the388 approved hash. Do not merge locally modified skill files or include an389 instruction-file patch or workspace migration in this mechanical update.3908. Report verification and recovery results. On failure, restore the prior391 working skill when possible. If automatic restore fails, retain and report392 the recovery copy; never claim success from an incomplete replacement.3939. On success, report the installed version and tell the user to start a new394 Agent task so the updated skill is loaded.395396Version discovery sends no workspace path, context, source code, conversation,397or usage event. GitHub Release notifications are external; this skill provides398no daemon, scheduled check, telemetry, or silent upgrade.399400## Policy evaluation401402Read context_write_policy from config.yml. `auto` is the default write policy403for newly initialized workspaces:404405- auto: complete the same audited lifecycle immediately without a human406 decision when every low-risk gate in references/protocol-v1.md passes.407- propose: an explicit cautious mode, or a preserved setting in an existing408 workspace; create the exact record and wait for approval.409410If an auto gate fails, keep the proposal and its machine-readable policy result,411but show the user only one concise exception by default:412413~~~yaml414requested_policy: auto415effective_policy: propose416reason: <machine-readable-reason>417~~~418419The agent or kernel must not weaken a failed gate. A successful auto path must420end with one non-blocking receipt and no request for user action.421422## References423424- references/protocol-v1.md425- references/config-schema.md426- references/proposal-schema.md427- references/legacy-migration.md428- references/domain-packs.md429- references/context-budget.md430- references/cleanup-policy.md431- references/privacy.md432- references/personal-dogfooding.zh-CN.md433- references/domain-coding.md434- references/domain-prd.md435- references/domain-seo.md