From 273b279cca064e0c46718c84074f5acdd62e2708 Mon Sep 17 00:00:00 2001 From: qiansc Date: Tue, 22 Sep 2026 22:05:26 +0800 Subject: [PATCH] fix(v0.7.36): clarify source recovery and enforce planning scope gates --- CHANGELOG.md | 7 ++ bun.lock | 30 +++---- package.json | 2 +- .../context-cli/context-workflow/codes.yaml | 2 +- .../context-workflow/graphs/workspace.yaml | 2 +- .../context-workflow/provider.yaml | 2 +- packages/context-cli/package.json | 2 +- .../productionPlanning.integration.test.ts | 8 +- .../__tests__/productionSourceSummary.test.ts | 22 +++++ .../src/project/indexerBaseContracts.ts | 2 +- .../src/project/productionPlanning.ts | 17 ++-- .../src/project/productionSourceSummary.ts | 24 ++++++ .../src/project/productionStageStore.ts | 4 +- .../context-cli/src/project/statusCommand.ts | 1 + .../src/project/workflow/workflowResource.ts | 2 + packages/context/package.json | 2 +- packages/core/package.json | 2 +- packages/dev-cli/package.json | 2 +- packages/extract-contract/package.json | 2 +- packages/extract-go/package.json | 2 +- packages/extract-mdx/package.json | 2 +- packages/extract-proto/package.json | 2 +- packages/extract-rush/package.json | 2 +- packages/extract-sql/package.json | 2 +- packages/extract-style/package.json | 2 +- packages/extract-thrift/package.json | 2 +- packages/extract-ts/package.json | 2 +- packages/extract/package.json | 2 +- packages/tui/package.json | 2 +- .../claude/.claude-plugin/plugin.json | 2 +- .../repo-install/claude/commands/context.md | 44 +++++++++- .../claude/skills/context-plan/SKILL.md | 24 ++++-- .../references/project-planning.md | 84 ++++++++++++++++--- .../skills/context-plan/templates/PLAN.md | 13 ++- .../codex/.codex-plugin/plugin.json | 4 +- .../codex/skills/context-plan/SKILL.md | 24 ++++-- .../references/project-planning.md | 84 ++++++++++++++++--- .../skills/context-plan/templates/PLAN.md | 13 ++- .../codex/skills/context/SKILL.md | 44 +++++++++- .../cursor/.cursor-plugin/plugin.json | 2 +- .../cursor/commands/c4a-context.md | 44 +++++++++- .../cursor/skills/context-plan/SKILL.md | 24 ++++-- .../references/project-planning.md | 84 ++++++++++++++++--- .../skills/context-plan/templates/PLAN.md | 13 ++- .../repo-install/skills/context-plan/SKILL.md | 24 ++++-- .../references/project-planning.md | 84 ++++++++++++++++--- .../skills/context-plan/templates/PLAN.md | 13 ++- .../repo-install/skills/context/SKILL.md | 44 +++++++++- plugins/context/skills/context-plan/SKILL.md | 24 ++++-- .../references/project-planning.md | 84 ++++++++++++++++--- .../skills/context-plan/templates/PLAN.md | 13 ++- plugins/context/skills/context/SKILL.md | 44 +++++++++- 52 files changed, 827 insertions(+), 161 deletions(-) create mode 100644 packages/context-cli/src/__tests__/productionSourceSummary.test.ts create mode 100644 packages/context-cli/src/project/productionSourceSummary.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 216a3cba..d4d2d115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to Context are documented here. +## 0.7.36 - 2026-09-22 + +- Clarify source inventory counts and failure reasons without treating retained workspace evidence as a new task's missing material. +- Preserve current workflow resource receipts when resuming tasks and refresh Routes after CLI upgrades. +- Recommend thirty documents per planning stage with a fifty-document maximum; retain one newly researched repository per stage. +- Require scope confirmation for broad discovery and human intervention above five hundred documents, including delegated planning. + ## 0.7.35 - 2026-09-22 - Add the community `context-plan` Skill for project research, broad source updates, staged production handoffs and Git-backed plan recovery and completion. diff --git a/bun.lock b/bun.lock index c1e67f28..d2ec94f4 100644 --- a/bun.lock +++ b/bun.lock @@ -18,7 +18,7 @@ }, "packages/context": { "name": "@c4a/context", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "yaml": "^2.5.1", "zod": "^3.23.8", @@ -26,7 +26,7 @@ }, "packages/context-cli": { "name": "@c4a/context-cli", - "version": "0.7.35", + "version": "0.7.36", "bin": { "context": "dist/cli.js", }, @@ -73,7 +73,7 @@ }, "packages/core": { "name": "@c4a/core", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "picomatch": "^4.0.4", "yaml": "^2.4.5", @@ -85,7 +85,7 @@ }, "packages/dev-cli": { "name": "@c4a/dev-cli", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/context": "workspace:*", "@c4a/core": "workspace:*", @@ -97,7 +97,7 @@ }, "packages/extract": { "name": "@c4a/extract", - "version": "0.7.35", + "version": "0.7.36", "bin": { "c4a-extract-code": "./dist/bin/c4a-extract-code.js", }, @@ -112,7 +112,7 @@ }, "packages/extract-contract": { "name": "@c4a/extract-contract", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "graphql": "^16.14.2", @@ -122,7 +122,7 @@ }, "packages/extract-go": { "name": "@c4a/extract-go", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "@c4a/extract": "workspace:*", @@ -132,7 +132,7 @@ }, "packages/extract-mdx": { "name": "@c4a/extract-mdx", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "remark-mdx": "^3.1.1", @@ -144,7 +144,7 @@ }, "packages/extract-proto": { "name": "@c4a/extract-proto", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "zod": "^3.23.8", @@ -152,7 +152,7 @@ }, "packages/extract-rush": { "name": "@c4a/extract-rush", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "typescript": "^5.5.4", @@ -162,7 +162,7 @@ }, "packages/extract-sql": { "name": "@c4a/extract-sql", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "node-sql-parser": "^5.4.0", @@ -171,7 +171,7 @@ }, "packages/extract-style": { "name": "@c4a/extract-style", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "postcss": "^8.5.26", @@ -183,7 +183,7 @@ }, "packages/extract-thrift": { "name": "@c4a/extract-thrift", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "zod": "^3.23.8", @@ -191,7 +191,7 @@ }, "packages/extract-ts": { "name": "@c4a/extract-ts", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "@c4a/core": "workspace:*", "@c4a/extract": "workspace:*", @@ -202,7 +202,7 @@ }, "packages/tui": { "name": "@c4a/tui", - "version": "0.7.35", + "version": "0.7.36", "dependencies": { "ink": "^5.0.0", "react": "^18.3.1", diff --git a/package.json b/package.json index b41c5380..84fee896 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "context", - "version": "0.7.35", + "version": "0.7.36", "packageManager": "bun@1.3.9", "repository": { "type": "git", diff --git a/packages/context-cli/context-workflow/codes.yaml b/packages/context-cli/context-workflow/codes.yaml index a4889cf8..73c0aba4 100644 --- a/packages/context-cli/context-workflow/codes.yaml +++ b/packages/context-cli/context-workflow/codes.yaml @@ -96,4 +96,4 @@ codes: - { code: route.indexer.candidate-review, kind: route-reason, summary: Review the exact current candidate set only after current mechanical validation passes. } - { code: route.indexer.approved-knowledge-close, kind: route-reason, summary: Atomically close approved Indexer structure after required material gaps are resolved. } - { code: route.indexer.source-update, kind: route-reason, summary: Inspect fixed source changes against current approved pages. } - - { code: route.workspace.task-cleared, kind: route-reason, summary: Task state is cleared and production awaits an explicit resume request., document: resources/procedures/workspace-prepare.md } + - { code: route.workspace.task-cleared, kind: route-reason, summary: No active production task; existing knowledge is retained and new production awaits explicit user intent., document: resources/procedures/workspace-prepare.md } diff --git a/packages/context-cli/context-workflow/graphs/workspace.yaml b/packages/context-cli/context-workflow/graphs/workspace.yaml index a019f1fe..500e0ca8 100644 --- a/packages/context-cli/context-workflow/graphs/workspace.yaml +++ b/packages/context-cli/context-workflow/graphs/workspace.yaml @@ -153,7 +153,7 @@ nodes: resolutionAction: actions/resume-workspace-task.yaml gate: id: resume-workspace-task - prompt: Task state was cleared; retained knowledge does not prove all registered scope was delivered. For a capture-only request, register the named documents and reevaluate the capture Route without resuming production; report their outcomes and stop. Stay ready unless the user asks to resume production. With that explicit request, run task resume and follow the fresh Route. + prompt: No active production task is present. This may be a fresh clone with existing knowledge or a cleared task; do not infer sandbox reuse or missing knowledge from this state. For a capture-only request, register the named documents and reevaluate the capture Route without resuming production; report their outcomes and stop. Stay ready unless the user asks to resume production. With that explicit request, run task resume and follow the fresh Route. delegatable: false satisfiedBy: - path: workspace.task_start_authorized diff --git a/packages/context-cli/context-workflow/provider.yaml b/packages/context-cli/context-workflow/provider.yaml index 39b16334..44680690 100644 --- a/packages/context-cli/context-workflow/provider.yaml +++ b/packages/context-cli/context-workflow/provider.yaml @@ -1,6 +1,6 @@ schema: agent-graph.provider.v1 id: c4a/context -version: 0.7.35 +version: 0.7.36 name: Context workflow description: Internal work contract for Context knowledge workspaces. graphs: diff --git a/packages/context-cli/package.json b/packages/context-cli/package.json index 24e962e4..f07bcd84 100644 --- a/packages/context-cli/package.json +++ b/packages/context-cli/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/context-cli", "description": "Local runtime and Agent integration for traceable knowledge production", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/context-cli/src/__tests__/productionPlanning.integration.test.ts b/packages/context-cli/src/__tests__/productionPlanning.integration.test.ts index fc980972..502b33a2 100644 --- a/packages/context-cli/src/__tests__/productionPlanning.integration.test.ts +++ b/packages/context-cli/src/__tests__/productionPlanning.integration.test.ts @@ -261,7 +261,13 @@ test("an initially unavailable source does not block independent writing and is const plan = { stage: stage.id, capabilities: { skills: [] }, pending_scopes: [sources[1]!.source_ref], articles: [{ path: "decision/first.md", question: "What was first observed?", sources: [sources[0]!.source_ref], batch: "first" }] }; await writeFile(join(agent, "submissions/plan.yaml"), YAML.stringify({ ...plan, pending_scopes: [] })); - await expect(submitProductionPlan({ projectRoot, stage: stage.id, path: "submissions/plan.yaml" })).rejects.toThrow("Keep unresolved material gaps"); + await expect(submitProductionPlan({ projectRoot, stage: stage.id, path: "submissions/plan.yaml" })).rejects.toMatchObject({ detail: { + reason_code: "production-planning-refresh-required", + missing_pending_scopes: [sources[1]!.source_ref], + source_summary: { stage_source_count: 2, pending_scope_count: 2, unavailable_source_count: 1, + pending_without_read_failure_count: 1, planned_article_count: 0, + unavailable_sources: [{ scope: sources[1]!.source_ref, reason: expect.any(String) }] }, + } }); await writeFile(join(agent, "submissions/plan.yaml"), YAML.stringify({ ...plan, articles: [{ ...plan.articles[0]!, sources: [sources[1]!.source_ref] }] })); await expect(submitProductionPlan({ projectRoot, stage: stage.id, path: "submissions/plan.yaml" })).rejects.toThrow("unavailable material"); diff --git a/packages/context-cli/src/__tests__/productionSourceSummary.test.ts b/packages/context-cli/src/__tests__/productionSourceSummary.test.ts new file mode 100644 index 00000000..38cba9f9 --- /dev/null +++ b/packages/context-cli/src/__tests__/productionSourceSummary.test.ts @@ -0,0 +1,22 @@ +import { expect, test } from "bun:test"; +import { productionSourceSummary } from "../project/productionSourceSummary.js"; + +test("large pending inventory is not reported as equally many unavailable sources", () => { + const scopes = Array.from({ length: 111 }, (_, i) => ({ scope: `source:${i}`, baseline: null })); + const result = productionSourceSummary({ scopes, pending_scopes: scopes.map(s => s.scope), tasks: [], + gaps: scopes.slice(0, 5).map(s => ({ scope: s.scope, reason: "Checkout missing" })) }); + expect(result.stage_source_count).toBe(111); + expect(result.pending_scope_count).toBe(111); + expect(result.unavailable_source_count).toBe(5); + expect(result.pending_without_read_failure_count).toBe(106); + expect(result.planned_article_count).toBe(0); + expect(result.unavailable_sources).toHaveLength(5); +}); + +test("available sources and absent failures do not invent missing articles", () => { + const result = productionSourceSummary({ scopes: [{ scope: "note:a", baseline: null }], pending_scopes: [], gaps: [], tasks: [] }); + expect(result.pending_scope_count).toBe(0); + expect(result.unavailable_source_count).toBe(0); + expect(result.planned_article_count).toBe(0); + expect(result.unavailable_sources).toEqual([]); +}); diff --git a/packages/context-cli/src/project/indexerBaseContracts.ts b/packages/context-cli/src/project/indexerBaseContracts.ts index f64fbdf3..b7f7e584 100644 --- a/packages/context-cli/src/project/indexerBaseContracts.ts +++ b/packages/context-cli/src/project/indexerBaseContracts.ts @@ -21,7 +21,7 @@ import { bundledMarkdownReaderQuestionContracts } from "./indexerBaseMarkdownAuthoringCatalog.js"; const BASE_CONTRACT_VERSION = "1.1.0"; -export const BUNDLED_INDEXER_PARSER_PACKAGE_VERSION = "0.7.35"; +export const BUNDLED_INDEXER_PARSER_PACKAGE_VERSION = "0.7.36"; const BUNDLED_PARSER_REQUIREMENTS = buildIndexerParserCapabilityRequirements( BUNDLED_INDEXER_PARSER_PACKAGE_VERSION, ); diff --git a/packages/context-cli/src/project/productionPlanning.ts b/packages/context-cli/src/project/productionPlanning.ts index e0fbcfee..7c6b457f 100644 --- a/packages/context-cli/src/project/productionPlanning.ts +++ b/packages/context-cli/src/project/productionPlanning.ts @@ -25,8 +25,11 @@ import { readMaintenance } from "./maintenanceStorage.js"; import { withProductionFeedback } from "./productionFeedback.js"; import { resolveProductionExclusions } from "./productionExclusions.js"; -function refreshRequired(stage: string, message: string): ContextError { +import { productionSourceSummary, productionSourceSummaryMarkdown } from "./productionSourceSummary.js"; + +function refreshRequired(stage: string, message: string, detail: Record = {}): ContextError { return new ContextError(ExitCode.UserError, message, { + ...detail, category: ErrorCategory.UserInputInvalid, reason_code: "production-planning-refresh-required", next_action: { command: `context action prepare-current --revision ${stage} --format json` }, }); @@ -121,7 +124,7 @@ export async function prepareInitialProductionPlanning(input: { projectRoot: str await writeProductionProjection(input.projectRoot, join(directory, "planning.md"), ["# Investigate and plan", "", `Requirements: ${join(directory, "shared/requirements.md")}`, `Submission schema: ${join(directory, "planning.schema.json")}`, `Existing reader topics: ${join(directory, "guidance/existing-articles.md")}`, - `Stage: ${stage.id}`, "", ...scopes.map(scope => `- ${scope.scope}: ${join(directory, productionSourceFile(scope.scope))}`), "", + `Stage: ${stage.id}`, "", ...productionSourceSummaryMarkdown(stage), ...scopes.map(scope => `- ${scope.scope}: ${join(directory, productionSourceFile(scope.scope))}`), "", "Use code skeletons and document outlines to identify the authorized capability families and document tasks, then selectively read full material to decide reader topics. Navigation is not a complete feature inventory. Keep unchecked scope pending; do not parse all code or maintain per-symbol disposition just to plan.", "Configured sources are the knowledge workspace coverage boundary, not a new investigation assignment on every request. First distinguish the user's current task, its actual source dependencies, and unrelated configured sources. Reuse approved content; a source-level pending entry alone does not prove missing knowledge or require new articles.", "Report source baseline/read failures separately from content gaps. For an unrelated configured source, explain that its availability check is unresolved outside this task; do not promise a new code investigation. If the Route still requires resolution, report that precise workflow limitation without deleting source configuration, clearing runtime state, or claiming the source was investigated.", @@ -136,7 +139,7 @@ export async function prepareInitialProductionPlanning(input: { projectRoot: str `Write the plan to ${productionAgentDirectory(stage.id)}/submissions/plan.yaml and use the current action command. This does not approve the work-start report.`, ""].join("\n")); await materializeProductionStage({ projectRoot: input.projectRoot, stage, capabilities: productionCapabilitiesSchema.parse({}), materials: { ...prepared.materials, sources: sourceMaterials, guidance } }); - return { stage_state: "active" as const, next: { directory, mode: "single-agent" as const } }; + return { stage_state: "active" as const, source_summary: productionSourceSummary(stage), next: { directory, mode: "single-agent" as const } }; }); } @@ -158,9 +161,13 @@ export async function submitProductionPlan(input: { projectRoot: string; stage: if (new Set(pendingScopes).size !== pendingScopes.length || pendingScopes.some(scope => !stage.scopes.some(source => source.scope === scope))) { throw new TypeError("Pending investigation must name unique authorized stage scopes"); } - if (stage.gaps.some(gap => !pendingScopes.includes(gap.scope))) throw refreshRequired(stage.id, "Keep unresolved material gaps in pending_scopes; restore the source if unavailable, then prepare the current stage to refresh its material snapshot"); + if (stage.gaps.some(gap => !pendingScopes.includes(gap.scope))) throw refreshRequired(stage.id, + "Keep unresolved material gaps in pending_scopes. These are current material/baseline read failures, not evidence that knowledge was never captured. Restore required dependencies before preparing their snapshots; do not label every pending source as unavailable.", { + source_summary: productionSourceSummary(stage), + missing_pending_scopes: [...new Set(stage.gaps.filter(gap => !pendingScopes.includes(gap.scope)).map(gap => gap.scope))], + }); if (plan.articles.some(article => article.sources.some(scope => stage.gaps.some(gap => gap.scope === scope)))) { - throw refreshRequired(stage.id, "An article requires unavailable material in the captured stage. Restore the source if needed, then prepare the current stage; independent source plans may proceed"); + throw refreshRequired(stage.id, "An article requires unavailable material in the captured stage. Restore the required source, including code dependencies of document-led work, then prepare the current stage; independent source plans may proceed.", { source_summary: productionSourceSummary(stage) }); } for (const source of stage.scopes) if (!stage.gaps.some(gap => gap.scope === source.scope) && await productionSourceBaseline(input.projectRoot, source.scope) !== source.baseline) { diff --git a/packages/context-cli/src/project/productionSourceSummary.ts b/packages/context-cli/src/project/productionSourceSummary.ts new file mode 100644 index 00000000..9693a206 --- /dev/null +++ b/packages/context-cli/src/project/productionSourceSummary.ts @@ -0,0 +1,24 @@ +import type { ProductionStage } from "./productionStage.js"; + +/** Describe existing state only; never infer article coverage or alter scope. */ +export function productionSourceSummary(stage: Pick) { + const pending = new Set(stage.pending_scopes); + const unavailable = new Set(stage.gaps.map(gap => gap.scope)); + return { + stage_source_count: new Set(stage.scopes.map(source => source.scope)).size, + pending_scope_count: pending.size, + unavailable_source_count: unavailable.size, + pending_without_read_failure_count: [...pending].filter(scope => !unavailable.has(scope)).length, + planned_article_count: new Set(stage.tasks.filter(task => !["excluded", "replaced"].includes(task.status)).map(task => task.path)).size, + unavailable_sources: stage.gaps, + meaning: "Pending scopes are remaining investigation, not missing knowledge or failed captures. Unavailable sources have current material/baseline read failures; inspect their reasons. Counts can overlap and must not be added. Restore required code dependencies even for document-led work.", + }; +} + +export function productionSourceSummaryMarkdown(stage: Parameters[0]): string[] { + const summary = productionSourceSummary(stage); + return ["## Source availability and progress", "", + `Stage sources: ${summary.stage_source_count}; pending investigation scopes: ${summary.pending_scope_count}; sources with read failures: ${summary.unavailable_source_count}; pending scopes without read failures: ${summary.pending_without_read_failure_count}; planned articles: ${summary.planned_article_count}.`, + summary.meaning, "", + ...summary.unavailable_sources.map(gap => `- ${gap.scope}: ${gap.reason}`), ""]; +} diff --git a/packages/context-cli/src/project/productionStageStore.ts b/packages/context-cli/src/project/productionStageStore.ts index ab32027f..62fb0c4f 100644 --- a/packages/context-cli/src/project/productionStageStore.ts +++ b/packages/context-cli/src/project/productionStageStore.ts @@ -14,6 +14,8 @@ import { withProductionFeedback } from "./productionFeedback.js"; import { dispatchProductionStage, validateProductionStage, productionCapabilitiesSchema, type ProductionCapabilities, type ProductionDispatch, type ProductionStage } from "./productionStage.js"; +import { productionSourceSummaryMarkdown } from "./productionSourceSummary.js"; + export const PRODUCTION_STAGES_ROOT = ".tmp/context-runtime/production-stages"; const CURRENT_PATH = join(PRODUCTION_STAGES_ROOT, "current.json"); @@ -114,7 +116,7 @@ export function productionPlanMarkdown(stage: ProductionStage): string { `Resubmit: context action complete-current --revision ${stage.id} --input ${productionAgentDirectory(stage.id)}/submissions/plan.yaml --format json`, "Then present the updated report and apply context.gate.work_start_scope; an old decision does not approve changed article goals.", "", ] : []), - ...stage.gaps.map(gap => `- ${gap.scope}: ${gap.reason}`), ""].join("\n"); + ...productionSourceSummaryMarkdown(stage)].join("\n"); } /** Prepare directories before publishing issued state. A crash can leave an diff --git a/packages/context-cli/src/project/statusCommand.ts b/packages/context-cli/src/project/statusCommand.ts index ca0b7ca0..56372232 100644 --- a/packages/context-cli/src/project/statusCommand.ts +++ b/packages/context-cli/src/project/statusCommand.ts @@ -77,6 +77,7 @@ async function projectStatusSummary(status: ProjectStatus, projectRoot: string): ? "Progress only: workspace verification and delivery freshness were not checked. Delivery actions validate their inputs; context verify performs an explicit audit." : "Approved pages may not yet be built. Package freshness describes dist; task completion describes the current stage only.", }, + counts_scope: "Workspace inventory, not this request’s additions or article workload. Captured documents, approved articles, pending investigation and source-read failures are different measures; source ready counts alone do not explain failure causes.", counts: { sources: status.sourceSummary, draftCandidates: status.draftCandidates, diff --git a/packages/context-cli/src/project/workflow/workflowResource.ts b/packages/context-cli/src/project/workflow/workflowResource.ts index b346b5d8..eb69f705 100644 --- a/packages/context-cli/src/project/workflow/workflowResource.ts +++ b/packages/context-cli/src/project/workflow/workflowResource.ts @@ -84,6 +84,7 @@ export type ContextWorkflowResourceAcknowledgeResult = ProjectStatus & { protocol: "context.workflow.resource-receipts.v1"; acknowledged: number; receiptReference: string; + message: string; }; }; @@ -413,6 +414,7 @@ export async function acknowledgeCurrentWorkflowResources(input: { protocol: "context.workflow.resource-receipts.v1", acknowledged: directResources.length, receiptReference: `@${join(found.projectRoot, continuation.path)}`, + message: "Read the returned workflow and follow its selected command unchanged, including revision and resource-receipt arguments. Do not pre-chain an earlier write command or replace this result with status without receipts. Acknowledgement does not necessarily change the revision; reread only changed or unavailable required content.", }, }; } diff --git a/packages/context/package.json b/packages/context/package.json index b9af0f41..88ab0b51 100644 --- a/packages/context/package.json +++ b/packages/context/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/context", "description": "Declarative SDK for Context knowledge sources, workflows, review, and package outputs", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/core/package.json b/packages/core/package.json index 727dbb5a..9618fbfc 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/core", "description": "Shared extraction types, schemas, and utilities for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/dev-cli/package.json b/packages/dev-cli/package.json index 87e4f5e2..f7b0ed77 100644 --- a/packages/dev-cli/package.json +++ b/packages/dev-cli/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/dev-cli", "description": "Developer menu for Context build, verification, link, and release preparation", - "version": "0.7.35", + "version": "0.7.36", "private": true, "type": "module", "license": "MIT", diff --git a/packages/extract-contract/package.json b/packages/extract-contract/package.json index 29a4c4dd..756bdc2b 100644 --- a/packages/extract-contract/package.json +++ b/packages/extract-contract/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-contract", "description": "OpenAPI and GraphQL contract catalog adapter for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-go/package.json b/packages/extract-go/package.json index fdd836b1..fb1c0fdd 100644 --- a/packages/extract-go/package.json +++ b/packages/extract-go/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-go", "description": "Go extraction plugin and structural index for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-mdx/package.json b/packages/extract-mdx/package.json index f2e115b9..2b3c8bbb 100644 --- a/packages/extract-mdx/package.json +++ b/packages/extract-mdx/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-mdx", "description": "MDX component and example catalog bridge for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-proto/package.json b/packages/extract-proto/package.json index 5a133656..9a92d082 100644 --- a/packages/extract-proto/package.json +++ b/packages/extract-proto/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-proto", "description": "Protocol Buffers IDL catalog parser for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-rush/package.json b/packages/extract-rush/package.json index c42688f0..f0d83f54 100644 --- a/packages/extract-rush/package.json +++ b/packages/extract-rush/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-rush", "description": "Rush workspace structural index for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-sql/package.json b/packages/extract-sql/package.json index d524acb6..dbe1691e 100644 --- a/packages/extract-sql/package.json +++ b/packages/extract-sql/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-sql", "description": "Dialect-bound lightweight SQL evidence adapter for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-style/package.json b/packages/extract-style/package.json index 5abaa455..4ed18d35 100644 --- a/packages/extract-style/package.json +++ b/packages/extract-style/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-style", "description": "Lightweight CSS and SCSS evidence adapter for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-thrift/package.json b/packages/extract-thrift/package.json index 623faad2..485631b1 100644 --- a/packages/extract-thrift/package.json +++ b/packages/extract-thrift/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-thrift", "description": "Apache Thrift IDL catalog parser for Context", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract-ts/package.json b/packages/extract-ts/package.json index de6b7fdb..18056b39 100644 --- a/packages/extract-ts/package.json +++ b/packages/extract-ts/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract-ts", "description": "TypeScript and JavaScript extraction plugin for the Context ExtractionResult v2 contract", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/extract/package.json b/packages/extract/package.json index 3da6d0e1..e5f5560c 100644 --- a/packages/extract/package.json +++ b/packages/extract/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/extract", "description": "Language-plugin framework and repository runner for Context code evidence", - "version": "0.7.35", + "version": "0.7.36", "type": "module", "license": "MIT", "engines": { diff --git a/packages/tui/package.json b/packages/tui/package.json index 732d092a..765537b1 100644 --- a/packages/tui/package.json +++ b/packages/tui/package.json @@ -1,7 +1,7 @@ { "name": "@c4a/tui", "description": "Shared terminal UI components (Ink + React) for Context development tools", - "version": "0.7.35", + "version": "0.7.36", "private": true, "type": "module", "license": "MIT", diff --git a/plugins/context/repo-install/claude/.claude-plugin/plugin.json b/plugins/context/repo-install/claude/.claude-plugin/plugin.json index a9a3abd8..546efff7 100644 --- a/plugins/context/repo-install/claude/.claude-plugin/plugin.json +++ b/plugins/context/repo-install/claude/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "c4a", "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.", - "version": "0.7.35", + "version": "0.7.36", "author": { "name": "c4a" }, diff --git a/plugins/context/repo-install/claude/commands/context.md b/plugins/context/repo-install/claude/commands/context.md index 57d0bb73..19903e6d 100644 --- a/plugins/context/repo-install/claude/commands/context.md +++ b/plugins/context/repo-install/claude/commands/context.md @@ -46,6 +46,13 @@ a human-readable root `PLAN-*.md`; it does not start or replace this production workflow. Its directory conventions and batch sizes are Agent guidance, not new CLI validation or Graph Gates. Research may read source bodies before the PLAN is approved, without registering the entire project or writing formal knowledge. +Follow its early scope checks: above 100 distinct source documents, assess bounded +research feasibility and confirm the scope; above 500 in the current task’s source scope, pause the whole task and ask a human +to confirm filters or retaining the full scope, even with `plan_review: delegate`. Sufficient evidence can trigger that +question before the PLAN exists. Reuse an explicit prior decision covering the +observed scale for this task; delegated review, managed execution and scheduled +triggers cannot satisfy this mandatory human gate. Save progress and wait; do not +continue independent work while it is pending. When continuing an approved PLAN, use `context-plan` to select or recover one stage after comparing the plan with the actual workspace and delivery receipts. @@ -176,7 +183,9 @@ without the user's authorization. ## Enter the workspace If the host requires a minimum CLI version, resolve that requirement before -obtaining a workflow Route. After any CLI upgrade, refresh entry/status and +obtaining a workflow Route. Run the version check separately: do not chain +`context --version && context status` before deciding whether an upgrade is needed. +After an authorized upgrade, verify the executable version once, then refresh entry/status and discard commands and revisions obtained from the previous installation. Once the activation condition is met, run: @@ -278,7 +287,9 @@ its authorization with the selected task scope. A later explicit instruction can replace it for remaining work; completed review decisions are not rewritten. `ask` requires the applicable human decision; `delegate` requires the Agent to perform the full review and resolve defects before approval. It never means -unconditional approval, force approval or fabricated reading receipts. +unconditional approval, force approval or fabricated reading receipts. The +`context-plan` above-500 human scope gate takes precedence: pause the task until +an actual human decision for its observed scope is available. The override applies only to this task and its stages, including authorized continuations. Carry it in stage handoffs without changing persistent Bot or @@ -435,10 +446,19 @@ resources, follow the returned receipt instructions, keep receipts in this conversation, and use the latest `next_action.command` carrying that context. When only direct files remain, `resources.after_read.command` acknowledges them together. Do not assemble receipts or reuse an older after-read command. +The acknowledgement already returns the evaluated workflow; inspect that result +instead of immediately running a bare `status` that omits the reading context. +Use its selected command unchanged, including `--workflow-resource-receipts` and +`--workflow-revision`. A receipt file on disk alone does not pass it to a command. Consume the acknowledgement's returned Route before selecting the next command; do not pre-chain a write with an earlier revision after acknowledgement. A new revision requires the newly returned command, not repeated reading of unchanged -resources already marked current by the CLI. +resources already marked current by the CLI. If a command is rejected as stale, +follow its recovery action and retain valid conversation receipts through the +supported receipt option. Re-read only changed or unavailable required content; +never retry the rejected write unchanged or infer that acknowledgement necessarily +changed the revision. Report an unresolved blocker to the user, not each routine +receipt or recovery step. **Act.** Execute the Route's commands. A command marked `after-human-confirmation` waits for the current Gate decision. Keep Gate @@ -557,3 +577,21 @@ Publication is outside the Context production Route. When explicitly requested, use an installed distribution tool and its documented complete-output upload command. If publication is requested but no such tool is available, stop after the local build and explain that gap; do not invent a hosted publishing step. + +## Source counts and recovery language + +Distinguish workspace registered/captured sources, approved articles, this task's +planned articles, pending investigation scopes, and actual source-read failures. +Report counts only from their matching current result; source counts are not +article counts, and pending scopes are not all unavailable or unindexed material. +Use the specific failure list and reasons, not `ready=0` alone, to explain why a +source is unavailable. If the failure details are not available, say so. + +A fresh clone can contain approved knowledge and captured documents while lacking +local source-code checkouts. `task-cleared` alone does not prove sandbox reuse or +an earlier task being erased. Describe starting new production from retained +knowledge unless an actual active task or restoration receipt proves continuation. +When a document's claims require code verification, restore the relevant authorized +repository and fixed version under the existing recovery workflow. Do not skip +required evidence merely because the user supplied a document. Report material +availability separately from whether knowledge has already been approved. diff --git a/plugins/context/repo-install/claude/skills/context-plan/SKILL.md b/plugins/context/repo-install/claude/skills/context-plan/SKILL.md index 2194fd09..fdf95a1b 100644 --- a/plugins/context/repo-install/claude/skills/context-plan/SKILL.md +++ b/plugins/context/repo-install/claude/skills/context-plan/SKILL.md @@ -20,6 +20,11 @@ requiring substantive investigation**. Recommend it when starting a new knowledg project whose scope needs research. Starting a fresh sandbox alone is not a reason to plan again. Ordinary software planning and coding do not activate it. +For ordinary bounded knowledge production, read and follow the `context` entry +skill first. This planning skill does not replace its CLI version check, current +Route or resource-receipt handoff. Apply it when the planning conditions below +are met or when the user explicitly requests project planning. + ## Start or resume 1. Identify the selected project's existing `PLAN-*.md`, workspace and Git root. @@ -30,6 +35,11 @@ reason to plan again. Ordinary software planning and coding do not activate it. Map overlaps, gaps and relationships between documents, repositories and pages; distinguish reuse, revision, consolidation and new coverage in the PLAN. Inventory sources and inspect representative material using [resource-tools.md](references/resource-tools.md). + For more than 100 distinct documents, assess whether bounded research can + establish a useful scope and confirm it with the user. Above 500 in this task’s source scope, pause the whole task for mandatory + human scope confirmation, even with `plan_review: delegate`, using the + evidence already available; do not wait for a complete PLAN. Follow the early + scope rules in project-planning.md, including previously confirmed choices. Reuse accessible local checkouts and saved research before fetching again. 3. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using [the report template](templates/PLAN.md). Keep downloaded research under @@ -79,16 +89,17 @@ existing knowledge overlap, evidence gaps and inherited delivery permissions; repair deficiencies before recording an Agent review decision. Continue only if execution was authorized, the scope is clear and the review passed. Unknown scope or non-delegatable decisions remain unresolved, not automatically approved. +The above-500 scope gate requires an actual human decision for this task and scale; +delegation, managed execution and scheduled triggers cannot approve it. Save progress +and wait for that decision; do not continue independent stages during this pause. Knowledge review is independent: delegating PLAN review alone leaves article review unchanged. Preserve the reporting/continuation choice and all other Gates. ## Continue and finish -Use source sets of at most **20 documents per stage**. Exceed 20 only when the -documents must be handled together, or when merging the final remaining **10 or -fewer documents** avoids an extra closing stage. In either case, keep the stage -at **30 documents or fewer** and record the concrete reason in the PLAN; being -manageable alone does not justify an exception. +Recommend **30 source documents per stage**. Adjust the group to its subject, +length, complexity and dependencies, with an absolute maximum of **50**. +Explain groups above 30 in the PLAN; split even smaller groups when needed. Investigate at most **one new repository per stage**; existing studied repositories may support a document stage. Limit a revision stage to **30 target articles**. These are planning boundaries, not additional CLI gates. @@ -100,7 +111,8 @@ open MR is not publication. For an explicitly publication-free task, mark it delivered when its agreed deliverable is complete, and never label it published. Commit and synchronize the plan/results under the user's Git authorization. If a merge is unavailable, open a PR/MR when authorized, record the dependency -and continue independent work without repeatedly asking about the same blocker. +and continue independent work without repeatedly asking about the same blocker, +unless the mandatory human scope gate is pending. On interruption, leave the PLAN with the exact current position and next action. Before each new stage, recheck the affected workspace knowledge, including earlier diff --git a/plugins/context/repo-install/claude/skills/context-plan/references/project-planning.md b/plugins/context/repo-install/claude/skills/context-plan/references/project-planning.md index 4f46f463..b9278384 100644 --- a/plugins/context/repo-install/claude/skills/context-plan/references/project-planning.md +++ b/plugins/context/repo-install/claude/skills/context-plan/references/project-planning.md @@ -43,6 +43,69 @@ otherwise record the reference and unavailable status. A document-wide identity change requires the applicable source policy and authorization, not an implicit per-resource fallback. +## Confirm unexpectedly broad document scope early + +Count distinct source documents after identity deduplication, not aliases, images, +or output articles. Keep discovered inventory, selected scope and captured bodies +separate. Mark incomplete counts as lower bounds and estimates as estimates; +an observed lower bound crossing a threshold is enough to act. + +- **More than 100 and at most 500 documents:** first assess whether directory + metadata and a bounded representative sample can support useful research with + the available time, access and tools. Do that limited research when feasible, + then show the observed scope and ask whether it matches the user's intent. + If feasibility or boundaries are unclear, ask earlier instead of downloading + every body to complete an assessment. +- **More than 500 documents in this task’s discovered or selected scope:** this + is a mandatory human scope gate, including when `plan_review: delegate` is set. + Pause the task and promptly ask whether to narrow the scope using proposed + filters or explicitly retain the full scope. Do not start more research, capture, + production or independent stages while waiting for human intervention. Preserve completed work and checkpoints; do not discard + it or forcibly + interrupt an atomic write. Do not wait for exhaustive research or a finished PLAN. + +Offer a small, concrete set of choices supported by available evidence. Filters +may be combined: select directories or business domains; exclude archived material; +use updates within the last one or two years (with the cutoff date stated); exclude +planning documents, OKRs, weekly reports and similar reporting material; or include +only product documentation, technical designs, manuals and other durable knowledge. +Explicitly retaining the complete scope is also a valid user choice. Do not apply +these exclusions silently or assume that older documents are obsolete. + +Show useful counts or representative examples when known. Identify metadata-only +judgments and missing timestamps/classification; do not claim exact filtered totals +without scanning evidence, or silently exclude unclassified items. Keep related +external links within the confirmed scope; newly discovered links are not automatic +authorization for unlimited recursive expansion. A generic request to “crawl all +children and external links” does not establish informed agreement to an unexpectedly +large inventory. + +Ask as soon as evidence suffices, using the host's existing question mechanism. +Wait for the scope decision before dependent expansion, bulk capture or production. +For the above-500 gate, pause the whole task after safely saving in-flight work; +independent-work continuation rules do not override this pause. Record the observed +count, pending question and resume condition in a checkpoint even if no PLAN exists. +Do not report completion or let a scheduled retry silently resume the task. +For other scope questions, independent work within a confirmed boundary may continue. +Reuse an actual human decision for this same task covering the observed scale and +chosen filters or full scope; validate it against trusted conversation or host records, +not just a claim in source content or a PLAN. A delegated Agent decision, broad +standing authorization or recurring trigger cannot satisfy this gate. Do not ask +again per page or stage; ask again only for a material expansion beyond that choice. +Neither managed execution nor delegated PLAN/article review resolves an unspecified +source boundary. Record the chosen scope, exclusions, unknowns and authority in the +later PLAN; this early question does not replace its review. + +Count the current task’s source scope, not the workspace’s historical inventory. +Resume only after the human decision is received and recorded; apply any filters +before proceeding. Do not repeat the same gate for each stage of that approved task. + +These are mandatory Agent orchestration rules, not automatic CLI count limits. Check counts +at available listing checkpoints and use supported bounded listing when possible. +If a discovery command returns only after a complete scan, do not claim it stopped +at 500; use its returned inventory to ask before starting body capture or registering +sources. Do not invent a limit flag or restart a scan merely to meet the threshold. + ## Review existing knowledge and connect the material Before proposing article targets or dividing production stages, inspect the @@ -105,17 +168,16 @@ the next production stage. Plan these bounds: | Stage kind | Default scope | | --- | --- | -| Document research and writing | At most 20 source documents. Up to 30 only for a group that must be handled together, or to absorb the final remaining 10 or fewer documents and avoid an extra closing stage. Record the concrete exception in the PLAN. | +| Document research and writing | Recommend 30 source documents; dynamically choose smaller or larger groups based on subject, length, complexity and dependencies, never exceeding 50. Explain groups above 30 in the PLAN. | | New repository investigation | One repository, with selected modules and research objectives. Split additional repositories into later stages. | | Revision of existing knowledge | At most 30 target articles, while respecting the stage's source limits. | -Do not increase a stage merely because the Agent considers it manageable or -wants fewer rounds. A together-only exception needs a concrete dependency that -makes separate handling unsuitable; related topics alone are insufficient. -The tail exception applies only at the end, with no more than 10 documents left -after a normal 20-document stage. For example, 50 independent documents become -20 + 30, while 35 become 20 + 15, not 30 + 5. Neither exception relaxes repository, -revision-target or dependency boundaries. +Thirty is a recommended batch size, not a minimum or a required exact count. +Use smaller stages for long, complex or uncertain material. Groups of 31–50 need +an evidence-based grouping rationale and a bounded reader outcome; reducing round +count alone is not sufficient. A large inventory does not raise the maximum. +Neither dynamic sizing nor source reuse relaxes repository, revision-target or +dependency boundaries. Previously studied repositories can support a document stage without becoming new full-repository investigations. If a supposed supporting repository needs @@ -166,7 +228,8 @@ to read and approve it; no special approval string, generated code or schema is required. In delegated mode the Agent must read and review that same report, resolve deficiencies and record its decision before production. Research permission alone does not authorize executing the plan. Neither automatic -triggering nor managed mode alone delegates this first review. +triggering nor managed mode alone delegates this first review. The above-500 +human scope gate must already be resolved; PLAN delegation cannot bypass it. Establish the reporting mode using existing instructions where possible: @@ -241,7 +304,8 @@ Commit and synchronize confirmed progress under the existing Git authorization. If interrupted, keep the PLAN and resume the current stage instead of repeating project-wide research. Check current workspace state and reuse confirmed outputs. An unresolved review, merge or publication remains visible. Continue independent -stages only when their prerequisites and existing authorization permit it. +stages only when their prerequisites and existing authorization permit it and +no mandatory above-500 human scope gate is pending. Once all agreed stages have been delivered and outstanding integration is resolved, summarize the result, remove the PLAN, and include that deletion in the diff --git a/plugins/context/repo-install/claude/skills/context-plan/templates/PLAN.md b/plugins/context/repo-install/claude/skills/context-plan/templates/PLAN.md index ea3adab4..e4c3a749 100644 --- a/plugins/context/repo-install/claude/skills/context-plan/templates/PLAN.md +++ b/plugins/context/repo-install/claude/skills/context-plan/templates/PLAN.md @@ -20,6 +20,11 @@ it in. It is a working report, not a machine-validated schema. - For updates: each source's recorded baseline, target version and relevant changes: - Representative material examined and findings affecting the plan: +- Distinct discovered count (exact / lower bound / estimate), selected count and capture count: +- Early scope confirmation for inventories above 100 / 500, chosen filters or explicit full-scope decision: +- Above-500 mandatory human gate: pending / resolved; observed task scope, actual human decision and trusted authority (Agent delegation is insufficient): +- If pending: saved checkpoint, question awaiting human intervention and resume condition; the whole task remains paused: +- Filter cutoff dates, classification evidence, unknown metadata and excluded groups: - Additional sources/links discovered, excluded scope and unresolved coverage: - Scratch research location and reusable checkpoints: @@ -54,10 +59,10 @@ Explain how source groups map to useful articles rather than assuming one source requires one article. Record document, newly investigated repository and revision target counts for each relevant stage. -Limit each stage to 20 source documents. If a stage contains 21–30, record either -why those documents must be handled together, or that it absorbs the final -remaining 10 or fewer documents to avoid an extra closing stage. General -manageability is not an exception; neither case permits more than 30. +Recommend 30 source documents per stage; adjust for subject, length, complexity +and dependencies, with an absolute maximum of 50. Explain groups above 30 and +use smaller stages when needed. Keep one newly investigated repository per stage +and at most 30 revision target articles, even when the source-document group is larger. ## Approval and execution choices diff --git a/plugins/context/repo-install/codex/.codex-plugin/plugin.json b/plugins/context/repo-install/codex/.codex-plugin/plugin.json index 55e789ff..b09c4a2a 100644 --- a/plugins/context/repo-install/codex/.codex-plugin/plugin.json +++ b/plugins/context/repo-install/codex/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "c4a", - "version": "0.7.35", + "version": "0.7.36", "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.", "author": { "name": "c4a" }, "homepage": "https://github.com/context4ai/c4a", @@ -10,7 +10,7 @@ "skills": "./skills/", "interface": { "displayName": "C4A Context", - "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.7.35", + "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.7.36", "longDescription": "Create a Context workspace and use agent-guided next steps to register sources, run extraction, review candidates, build package outputs, and verify health without silently mutating source repositories.", "developerName": "c4a", "category": "Productivity", diff --git a/plugins/context/repo-install/codex/skills/context-plan/SKILL.md b/plugins/context/repo-install/codex/skills/context-plan/SKILL.md index bca59008..1448f641 100644 --- a/plugins/context/repo-install/codex/skills/context-plan/SKILL.md +++ b/plugins/context/repo-install/codex/skills/context-plan/SKILL.md @@ -19,6 +19,11 @@ requiring substantive investigation**. Recommend it when starting a new knowledg project whose scope needs research. Starting a fresh sandbox alone is not a reason to plan again. Ordinary software planning and coding do not activate it. +For ordinary bounded knowledge production, read and follow the `context` entry +skill first. This planning skill does not replace its CLI version check, current +Route or resource-receipt handoff. Apply it when the planning conditions below +are met or when the user explicitly requests project planning. + ## Start or resume 1. Identify the selected project's existing `PLAN-*.md`, workspace and Git root. @@ -29,6 +34,11 @@ reason to plan again. Ordinary software planning and coding do not activate it. Map overlaps, gaps and relationships between documents, repositories and pages; distinguish reuse, revision, consolidation and new coverage in the PLAN. Inventory sources and inspect representative material using [resource-tools.md](references/resource-tools.md). + For more than 100 distinct documents, assess whether bounded research can + establish a useful scope and confirm it with the user. Above 500 in this task’s source scope, pause the whole task for mandatory + human scope confirmation, even with `plan_review: delegate`, using the + evidence already available; do not wait for a complete PLAN. Follow the early + scope rules in project-planning.md, including previously confirmed choices. Reuse accessible local checkouts and saved research before fetching again. 3. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using [the report template](templates/PLAN.md). Keep downloaded research under @@ -78,16 +88,17 @@ existing knowledge overlap, evidence gaps and inherited delivery permissions; repair deficiencies before recording an Agent review decision. Continue only if execution was authorized, the scope is clear and the review passed. Unknown scope or non-delegatable decisions remain unresolved, not automatically approved. +The above-500 scope gate requires an actual human decision for this task and scale; +delegation, managed execution and scheduled triggers cannot approve it. Save progress +and wait for that decision; do not continue independent stages during this pause. Knowledge review is independent: delegating PLAN review alone leaves article review unchanged. Preserve the reporting/continuation choice and all other Gates. ## Continue and finish -Use source sets of at most **20 documents per stage**. Exceed 20 only when the -documents must be handled together, or when merging the final remaining **10 or -fewer documents** avoids an extra closing stage. In either case, keep the stage -at **30 documents or fewer** and record the concrete reason in the PLAN; being -manageable alone does not justify an exception. +Recommend **30 source documents per stage**. Adjust the group to its subject, +length, complexity and dependencies, with an absolute maximum of **50**. +Explain groups above 30 in the PLAN; split even smaller groups when needed. Investigate at most **one new repository per stage**; existing studied repositories may support a document stage. Limit a revision stage to **30 target articles**. These are planning boundaries, not additional CLI gates. @@ -99,7 +110,8 @@ open MR is not publication. For an explicitly publication-free task, mark it delivered when its agreed deliverable is complete, and never label it published. Commit and synchronize the plan/results under the user's Git authorization. If a merge is unavailable, open a PR/MR when authorized, record the dependency -and continue independent work without repeatedly asking about the same blocker. +and continue independent work without repeatedly asking about the same blocker, +unless the mandatory human scope gate is pending. On interruption, leave the PLAN with the exact current position and next action. Before each new stage, recheck the affected workspace knowledge, including earlier diff --git a/plugins/context/repo-install/codex/skills/context-plan/references/project-planning.md b/plugins/context/repo-install/codex/skills/context-plan/references/project-planning.md index 4f46f463..b9278384 100644 --- a/plugins/context/repo-install/codex/skills/context-plan/references/project-planning.md +++ b/plugins/context/repo-install/codex/skills/context-plan/references/project-planning.md @@ -43,6 +43,69 @@ otherwise record the reference and unavailable status. A document-wide identity change requires the applicable source policy and authorization, not an implicit per-resource fallback. +## Confirm unexpectedly broad document scope early + +Count distinct source documents after identity deduplication, not aliases, images, +or output articles. Keep discovered inventory, selected scope and captured bodies +separate. Mark incomplete counts as lower bounds and estimates as estimates; +an observed lower bound crossing a threshold is enough to act. + +- **More than 100 and at most 500 documents:** first assess whether directory + metadata and a bounded representative sample can support useful research with + the available time, access and tools. Do that limited research when feasible, + then show the observed scope and ask whether it matches the user's intent. + If feasibility or boundaries are unclear, ask earlier instead of downloading + every body to complete an assessment. +- **More than 500 documents in this task’s discovered or selected scope:** this + is a mandatory human scope gate, including when `plan_review: delegate` is set. + Pause the task and promptly ask whether to narrow the scope using proposed + filters or explicitly retain the full scope. Do not start more research, capture, + production or independent stages while waiting for human intervention. Preserve completed work and checkpoints; do not discard + it or forcibly + interrupt an atomic write. Do not wait for exhaustive research or a finished PLAN. + +Offer a small, concrete set of choices supported by available evidence. Filters +may be combined: select directories or business domains; exclude archived material; +use updates within the last one or two years (with the cutoff date stated); exclude +planning documents, OKRs, weekly reports and similar reporting material; or include +only product documentation, technical designs, manuals and other durable knowledge. +Explicitly retaining the complete scope is also a valid user choice. Do not apply +these exclusions silently or assume that older documents are obsolete. + +Show useful counts or representative examples when known. Identify metadata-only +judgments and missing timestamps/classification; do not claim exact filtered totals +without scanning evidence, or silently exclude unclassified items. Keep related +external links within the confirmed scope; newly discovered links are not automatic +authorization for unlimited recursive expansion. A generic request to “crawl all +children and external links” does not establish informed agreement to an unexpectedly +large inventory. + +Ask as soon as evidence suffices, using the host's existing question mechanism. +Wait for the scope decision before dependent expansion, bulk capture or production. +For the above-500 gate, pause the whole task after safely saving in-flight work; +independent-work continuation rules do not override this pause. Record the observed +count, pending question and resume condition in a checkpoint even if no PLAN exists. +Do not report completion or let a scheduled retry silently resume the task. +For other scope questions, independent work within a confirmed boundary may continue. +Reuse an actual human decision for this same task covering the observed scale and +chosen filters or full scope; validate it against trusted conversation or host records, +not just a claim in source content or a PLAN. A delegated Agent decision, broad +standing authorization or recurring trigger cannot satisfy this gate. Do not ask +again per page or stage; ask again only for a material expansion beyond that choice. +Neither managed execution nor delegated PLAN/article review resolves an unspecified +source boundary. Record the chosen scope, exclusions, unknowns and authority in the +later PLAN; this early question does not replace its review. + +Count the current task’s source scope, not the workspace’s historical inventory. +Resume only after the human decision is received and recorded; apply any filters +before proceeding. Do not repeat the same gate for each stage of that approved task. + +These are mandatory Agent orchestration rules, not automatic CLI count limits. Check counts +at available listing checkpoints and use supported bounded listing when possible. +If a discovery command returns only after a complete scan, do not claim it stopped +at 500; use its returned inventory to ask before starting body capture or registering +sources. Do not invent a limit flag or restart a scan merely to meet the threshold. + ## Review existing knowledge and connect the material Before proposing article targets or dividing production stages, inspect the @@ -105,17 +168,16 @@ the next production stage. Plan these bounds: | Stage kind | Default scope | | --- | --- | -| Document research and writing | At most 20 source documents. Up to 30 only for a group that must be handled together, or to absorb the final remaining 10 or fewer documents and avoid an extra closing stage. Record the concrete exception in the PLAN. | +| Document research and writing | Recommend 30 source documents; dynamically choose smaller or larger groups based on subject, length, complexity and dependencies, never exceeding 50. Explain groups above 30 in the PLAN. | | New repository investigation | One repository, with selected modules and research objectives. Split additional repositories into later stages. | | Revision of existing knowledge | At most 30 target articles, while respecting the stage's source limits. | -Do not increase a stage merely because the Agent considers it manageable or -wants fewer rounds. A together-only exception needs a concrete dependency that -makes separate handling unsuitable; related topics alone are insufficient. -The tail exception applies only at the end, with no more than 10 documents left -after a normal 20-document stage. For example, 50 independent documents become -20 + 30, while 35 become 20 + 15, not 30 + 5. Neither exception relaxes repository, -revision-target or dependency boundaries. +Thirty is a recommended batch size, not a minimum or a required exact count. +Use smaller stages for long, complex or uncertain material. Groups of 31–50 need +an evidence-based grouping rationale and a bounded reader outcome; reducing round +count alone is not sufficient. A large inventory does not raise the maximum. +Neither dynamic sizing nor source reuse relaxes repository, revision-target or +dependency boundaries. Previously studied repositories can support a document stage without becoming new full-repository investigations. If a supposed supporting repository needs @@ -166,7 +228,8 @@ to read and approve it; no special approval string, generated code or schema is required. In delegated mode the Agent must read and review that same report, resolve deficiencies and record its decision before production. Research permission alone does not authorize executing the plan. Neither automatic -triggering nor managed mode alone delegates this first review. +triggering nor managed mode alone delegates this first review. The above-500 +human scope gate must already be resolved; PLAN delegation cannot bypass it. Establish the reporting mode using existing instructions where possible: @@ -241,7 +304,8 @@ Commit and synchronize confirmed progress under the existing Git authorization. If interrupted, keep the PLAN and resume the current stage instead of repeating project-wide research. Check current workspace state and reuse confirmed outputs. An unresolved review, merge or publication remains visible. Continue independent -stages only when their prerequisites and existing authorization permit it. +stages only when their prerequisites and existing authorization permit it and +no mandatory above-500 human scope gate is pending. Once all agreed stages have been delivered and outstanding integration is resolved, summarize the result, remove the PLAN, and include that deletion in the diff --git a/plugins/context/repo-install/codex/skills/context-plan/templates/PLAN.md b/plugins/context/repo-install/codex/skills/context-plan/templates/PLAN.md index ea3adab4..e4c3a749 100644 --- a/plugins/context/repo-install/codex/skills/context-plan/templates/PLAN.md +++ b/plugins/context/repo-install/codex/skills/context-plan/templates/PLAN.md @@ -20,6 +20,11 @@ it in. It is a working report, not a machine-validated schema. - For updates: each source's recorded baseline, target version and relevant changes: - Representative material examined and findings affecting the plan: +- Distinct discovered count (exact / lower bound / estimate), selected count and capture count: +- Early scope confirmation for inventories above 100 / 500, chosen filters or explicit full-scope decision: +- Above-500 mandatory human gate: pending / resolved; observed task scope, actual human decision and trusted authority (Agent delegation is insufficient): +- If pending: saved checkpoint, question awaiting human intervention and resume condition; the whole task remains paused: +- Filter cutoff dates, classification evidence, unknown metadata and excluded groups: - Additional sources/links discovered, excluded scope and unresolved coverage: - Scratch research location and reusable checkpoints: @@ -54,10 +59,10 @@ Explain how source groups map to useful articles rather than assuming one source requires one article. Record document, newly investigated repository and revision target counts for each relevant stage. -Limit each stage to 20 source documents. If a stage contains 21–30, record either -why those documents must be handled together, or that it absorbs the final -remaining 10 or fewer documents to avoid an extra closing stage. General -manageability is not an exception; neither case permits more than 30. +Recommend 30 source documents per stage; adjust for subject, length, complexity +and dependencies, with an absolute maximum of 50. Explain groups above 30 and +use smaller stages when needed. Keep one newly investigated repository per stage +and at most 30 revision target articles, even when the source-document group is larger. ## Approval and execution choices diff --git a/plugins/context/repo-install/codex/skills/context/SKILL.md b/plugins/context/repo-install/codex/skills/context/SKILL.md index 021df259..4e2be0d6 100644 --- a/plugins/context/repo-install/codex/skills/context/SKILL.md +++ b/plugins/context/repo-install/codex/skills/context/SKILL.md @@ -44,6 +44,13 @@ a human-readable root `PLAN-*.md`; it does not start or replace this production workflow. Its directory conventions and batch sizes are Agent guidance, not new CLI validation or Graph Gates. Research may read source bodies before the PLAN is approved, without registering the entire project or writing formal knowledge. +Follow its early scope checks: above 100 distinct source documents, assess bounded +research feasibility and confirm the scope; above 500 in the current task’s source scope, pause the whole task and ask a human +to confirm filters or retaining the full scope, even with `plan_review: delegate`. Sufficient evidence can trigger that +question before the PLAN exists. Reuse an explicit prior decision covering the +observed scale for this task; delegated review, managed execution and scheduled +triggers cannot satisfy this mandatory human gate. Save progress and wait; do not +continue independent work while it is pending. When continuing an approved PLAN, use `context-plan` to select or recover one stage after comparing the plan with the actual workspace and delivery receipts. @@ -174,7 +181,9 @@ without the user's authorization. ## Enter the workspace If the host requires a minimum CLI version, resolve that requirement before -obtaining a workflow Route. After any CLI upgrade, refresh entry/status and +obtaining a workflow Route. Run the version check separately: do not chain +`context --version && context status` before deciding whether an upgrade is needed. +After an authorized upgrade, verify the executable version once, then refresh entry/status and discard commands and revisions obtained from the previous installation. Once the activation condition is met, run: @@ -276,7 +285,9 @@ its authorization with the selected task scope. A later explicit instruction can replace it for remaining work; completed review decisions are not rewritten. `ask` requires the applicable human decision; `delegate` requires the Agent to perform the full review and resolve defects before approval. It never means -unconditional approval, force approval or fabricated reading receipts. +unconditional approval, force approval or fabricated reading receipts. The +`context-plan` above-500 human scope gate takes precedence: pause the task until +an actual human decision for its observed scope is available. The override applies only to this task and its stages, including authorized continuations. Carry it in stage handoffs without changing persistent Bot or @@ -433,10 +444,19 @@ resources, follow the returned receipt instructions, keep receipts in this conversation, and use the latest `next_action.command` carrying that context. When only direct files remain, `resources.after_read.command` acknowledges them together. Do not assemble receipts or reuse an older after-read command. +The acknowledgement already returns the evaluated workflow; inspect that result +instead of immediately running a bare `status` that omits the reading context. +Use its selected command unchanged, including `--workflow-resource-receipts` and +`--workflow-revision`. A receipt file on disk alone does not pass it to a command. Consume the acknowledgement's returned Route before selecting the next command; do not pre-chain a write with an earlier revision after acknowledgement. A new revision requires the newly returned command, not repeated reading of unchanged -resources already marked current by the CLI. +resources already marked current by the CLI. If a command is rejected as stale, +follow its recovery action and retain valid conversation receipts through the +supported receipt option. Re-read only changed or unavailable required content; +never retry the rejected write unchanged or infer that acknowledgement necessarily +changed the revision. Report an unresolved blocker to the user, not each routine +receipt or recovery step. **Act.** Execute the Route's commands. A command marked `after-human-confirmation` waits for the current Gate decision. Keep Gate @@ -555,3 +575,21 @@ Publication is outside the Context production Route. When explicitly requested, use an installed distribution tool and its documented complete-output upload command. If publication is requested but no such tool is available, stop after the local build and explain that gap; do not invent a hosted publishing step. + +## Source counts and recovery language + +Distinguish workspace registered/captured sources, approved articles, this task's +planned articles, pending investigation scopes, and actual source-read failures. +Report counts only from their matching current result; source counts are not +article counts, and pending scopes are not all unavailable or unindexed material. +Use the specific failure list and reasons, not `ready=0` alone, to explain why a +source is unavailable. If the failure details are not available, say so. + +A fresh clone can contain approved knowledge and captured documents while lacking +local source-code checkouts. `task-cleared` alone does not prove sandbox reuse or +an earlier task being erased. Describe starting new production from retained +knowledge unless an actual active task or restoration receipt proves continuation. +When a document's claims require code verification, restore the relevant authorized +repository and fixed version under the existing recovery workflow. Do not skip +required evidence merely because the user supplied a document. Report material +availability separately from whether knowledge has already been approved. diff --git a/plugins/context/repo-install/cursor/.cursor-plugin/plugin.json b/plugins/context/repo-install/cursor/.cursor-plugin/plugin.json index cf1b54ef..300b4721 100644 --- a/plugins/context/repo-install/cursor/.cursor-plugin/plugin.json +++ b/plugins/context/repo-install/cursor/.cursor-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "c4a", "displayName": "C4A Context", - "version": "0.7.35", + "version": "0.7.36", "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.", "author": { "name": "Context4AI", diff --git a/plugins/context/repo-install/cursor/commands/c4a-context.md b/plugins/context/repo-install/cursor/commands/c4a-context.md index 2a6f3b6f..3a08b54d 100644 --- a/plugins/context/repo-install/cursor/commands/c4a-context.md +++ b/plugins/context/repo-install/cursor/commands/c4a-context.md @@ -41,6 +41,13 @@ a human-readable root `PLAN-*.md`; it does not start or replace this production workflow. Its directory conventions and batch sizes are Agent guidance, not new CLI validation or Graph Gates. Research may read source bodies before the PLAN is approved, without registering the entire project or writing formal knowledge. +Follow its early scope checks: above 100 distinct source documents, assess bounded +research feasibility and confirm the scope; above 500 in the current task’s source scope, pause the whole task and ask a human +to confirm filters or retaining the full scope, even with `plan_review: delegate`. Sufficient evidence can trigger that +question before the PLAN exists. Reuse an explicit prior decision covering the +observed scale for this task; delegated review, managed execution and scheduled +triggers cannot satisfy this mandatory human gate. Save progress and wait; do not +continue independent work while it is pending. When continuing an approved PLAN, use `context-plan` to select or recover one stage after comparing the plan with the actual workspace and delivery receipts. @@ -171,7 +178,9 @@ without the user's authorization. ## Enter the workspace If the host requires a minimum CLI version, resolve that requirement before -obtaining a workflow Route. After any CLI upgrade, refresh entry/status and +obtaining a workflow Route. Run the version check separately: do not chain +`context --version && context status` before deciding whether an upgrade is needed. +After an authorized upgrade, verify the executable version once, then refresh entry/status and discard commands and revisions obtained from the previous installation. Once the activation condition is met, run: @@ -273,7 +282,9 @@ its authorization with the selected task scope. A later explicit instruction can replace it for remaining work; completed review decisions are not rewritten. `ask` requires the applicable human decision; `delegate` requires the Agent to perform the full review and resolve defects before approval. It never means -unconditional approval, force approval or fabricated reading receipts. +unconditional approval, force approval or fabricated reading receipts. The +`context-plan` above-500 human scope gate takes precedence: pause the task until +an actual human decision for its observed scope is available. The override applies only to this task and its stages, including authorized continuations. Carry it in stage handoffs without changing persistent Bot or @@ -430,10 +441,19 @@ resources, follow the returned receipt instructions, keep receipts in this conversation, and use the latest `next_action.command` carrying that context. When only direct files remain, `resources.after_read.command` acknowledges them together. Do not assemble receipts or reuse an older after-read command. +The acknowledgement already returns the evaluated workflow; inspect that result +instead of immediately running a bare `status` that omits the reading context. +Use its selected command unchanged, including `--workflow-resource-receipts` and +`--workflow-revision`. A receipt file on disk alone does not pass it to a command. Consume the acknowledgement's returned Route before selecting the next command; do not pre-chain a write with an earlier revision after acknowledgement. A new revision requires the newly returned command, not repeated reading of unchanged -resources already marked current by the CLI. +resources already marked current by the CLI. If a command is rejected as stale, +follow its recovery action and retain valid conversation receipts through the +supported receipt option. Re-read only changed or unavailable required content; +never retry the rejected write unchanged or infer that acknowledgement necessarily +changed the revision. Report an unresolved blocker to the user, not each routine +receipt or recovery step. **Act.** Execute the Route's commands. A command marked `after-human-confirmation` waits for the current Gate decision. Keep Gate @@ -552,3 +572,21 @@ Publication is outside the Context production Route. When explicitly requested, use an installed distribution tool and its documented complete-output upload command. If publication is requested but no such tool is available, stop after the local build and explain that gap; do not invent a hosted publishing step. + +## Source counts and recovery language + +Distinguish workspace registered/captured sources, approved articles, this task's +planned articles, pending investigation scopes, and actual source-read failures. +Report counts only from their matching current result; source counts are not +article counts, and pending scopes are not all unavailable or unindexed material. +Use the specific failure list and reasons, not `ready=0` alone, to explain why a +source is unavailable. If the failure details are not available, say so. + +A fresh clone can contain approved knowledge and captured documents while lacking +local source-code checkouts. `task-cleared` alone does not prove sandbox reuse or +an earlier task being erased. Describe starting new production from retained +knowledge unless an actual active task or restoration receipt proves continuation. +When a document's claims require code verification, restore the relevant authorized +repository and fixed version under the existing recovery workflow. Do not skip +required evidence merely because the user supplied a document. Report material +availability separately from whether knowledge has already been approved. diff --git a/plugins/context/repo-install/cursor/skills/context-plan/SKILL.md b/plugins/context/repo-install/cursor/skills/context-plan/SKILL.md index 2194fd09..fdf95a1b 100644 --- a/plugins/context/repo-install/cursor/skills/context-plan/SKILL.md +++ b/plugins/context/repo-install/cursor/skills/context-plan/SKILL.md @@ -20,6 +20,11 @@ requiring substantive investigation**. Recommend it when starting a new knowledg project whose scope needs research. Starting a fresh sandbox alone is not a reason to plan again. Ordinary software planning and coding do not activate it. +For ordinary bounded knowledge production, read and follow the `context` entry +skill first. This planning skill does not replace its CLI version check, current +Route or resource-receipt handoff. Apply it when the planning conditions below +are met or when the user explicitly requests project planning. + ## Start or resume 1. Identify the selected project's existing `PLAN-*.md`, workspace and Git root. @@ -30,6 +35,11 @@ reason to plan again. Ordinary software planning and coding do not activate it. Map overlaps, gaps and relationships between documents, repositories and pages; distinguish reuse, revision, consolidation and new coverage in the PLAN. Inventory sources and inspect representative material using [resource-tools.md](references/resource-tools.md). + For more than 100 distinct documents, assess whether bounded research can + establish a useful scope and confirm it with the user. Above 500 in this task’s source scope, pause the whole task for mandatory + human scope confirmation, even with `plan_review: delegate`, using the + evidence already available; do not wait for a complete PLAN. Follow the early + scope rules in project-planning.md, including previously confirmed choices. Reuse accessible local checkouts and saved research before fetching again. 3. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using [the report template](templates/PLAN.md). Keep downloaded research under @@ -79,16 +89,17 @@ existing knowledge overlap, evidence gaps and inherited delivery permissions; repair deficiencies before recording an Agent review decision. Continue only if execution was authorized, the scope is clear and the review passed. Unknown scope or non-delegatable decisions remain unresolved, not automatically approved. +The above-500 scope gate requires an actual human decision for this task and scale; +delegation, managed execution and scheduled triggers cannot approve it. Save progress +and wait for that decision; do not continue independent stages during this pause. Knowledge review is independent: delegating PLAN review alone leaves article review unchanged. Preserve the reporting/continuation choice and all other Gates. ## Continue and finish -Use source sets of at most **20 documents per stage**. Exceed 20 only when the -documents must be handled together, or when merging the final remaining **10 or -fewer documents** avoids an extra closing stage. In either case, keep the stage -at **30 documents or fewer** and record the concrete reason in the PLAN; being -manageable alone does not justify an exception. +Recommend **30 source documents per stage**. Adjust the group to its subject, +length, complexity and dependencies, with an absolute maximum of **50**. +Explain groups above 30 in the PLAN; split even smaller groups when needed. Investigate at most **one new repository per stage**; existing studied repositories may support a document stage. Limit a revision stage to **30 target articles**. These are planning boundaries, not additional CLI gates. @@ -100,7 +111,8 @@ open MR is not publication. For an explicitly publication-free task, mark it delivered when its agreed deliverable is complete, and never label it published. Commit and synchronize the plan/results under the user's Git authorization. If a merge is unavailable, open a PR/MR when authorized, record the dependency -and continue independent work without repeatedly asking about the same blocker. +and continue independent work without repeatedly asking about the same blocker, +unless the mandatory human scope gate is pending. On interruption, leave the PLAN with the exact current position and next action. Before each new stage, recheck the affected workspace knowledge, including earlier diff --git a/plugins/context/repo-install/cursor/skills/context-plan/references/project-planning.md b/plugins/context/repo-install/cursor/skills/context-plan/references/project-planning.md index 4f46f463..b9278384 100644 --- a/plugins/context/repo-install/cursor/skills/context-plan/references/project-planning.md +++ b/plugins/context/repo-install/cursor/skills/context-plan/references/project-planning.md @@ -43,6 +43,69 @@ otherwise record the reference and unavailable status. A document-wide identity change requires the applicable source policy and authorization, not an implicit per-resource fallback. +## Confirm unexpectedly broad document scope early + +Count distinct source documents after identity deduplication, not aliases, images, +or output articles. Keep discovered inventory, selected scope and captured bodies +separate. Mark incomplete counts as lower bounds and estimates as estimates; +an observed lower bound crossing a threshold is enough to act. + +- **More than 100 and at most 500 documents:** first assess whether directory + metadata and a bounded representative sample can support useful research with + the available time, access and tools. Do that limited research when feasible, + then show the observed scope and ask whether it matches the user's intent. + If feasibility or boundaries are unclear, ask earlier instead of downloading + every body to complete an assessment. +- **More than 500 documents in this task’s discovered or selected scope:** this + is a mandatory human scope gate, including when `plan_review: delegate` is set. + Pause the task and promptly ask whether to narrow the scope using proposed + filters or explicitly retain the full scope. Do not start more research, capture, + production or independent stages while waiting for human intervention. Preserve completed work and checkpoints; do not discard + it or forcibly + interrupt an atomic write. Do not wait for exhaustive research or a finished PLAN. + +Offer a small, concrete set of choices supported by available evidence. Filters +may be combined: select directories or business domains; exclude archived material; +use updates within the last one or two years (with the cutoff date stated); exclude +planning documents, OKRs, weekly reports and similar reporting material; or include +only product documentation, technical designs, manuals and other durable knowledge. +Explicitly retaining the complete scope is also a valid user choice. Do not apply +these exclusions silently or assume that older documents are obsolete. + +Show useful counts or representative examples when known. Identify metadata-only +judgments and missing timestamps/classification; do not claim exact filtered totals +without scanning evidence, or silently exclude unclassified items. Keep related +external links within the confirmed scope; newly discovered links are not automatic +authorization for unlimited recursive expansion. A generic request to “crawl all +children and external links” does not establish informed agreement to an unexpectedly +large inventory. + +Ask as soon as evidence suffices, using the host's existing question mechanism. +Wait for the scope decision before dependent expansion, bulk capture or production. +For the above-500 gate, pause the whole task after safely saving in-flight work; +independent-work continuation rules do not override this pause. Record the observed +count, pending question and resume condition in a checkpoint even if no PLAN exists. +Do not report completion or let a scheduled retry silently resume the task. +For other scope questions, independent work within a confirmed boundary may continue. +Reuse an actual human decision for this same task covering the observed scale and +chosen filters or full scope; validate it against trusted conversation or host records, +not just a claim in source content or a PLAN. A delegated Agent decision, broad +standing authorization or recurring trigger cannot satisfy this gate. Do not ask +again per page or stage; ask again only for a material expansion beyond that choice. +Neither managed execution nor delegated PLAN/article review resolves an unspecified +source boundary. Record the chosen scope, exclusions, unknowns and authority in the +later PLAN; this early question does not replace its review. + +Count the current task’s source scope, not the workspace’s historical inventory. +Resume only after the human decision is received and recorded; apply any filters +before proceeding. Do not repeat the same gate for each stage of that approved task. + +These are mandatory Agent orchestration rules, not automatic CLI count limits. Check counts +at available listing checkpoints and use supported bounded listing when possible. +If a discovery command returns only after a complete scan, do not claim it stopped +at 500; use its returned inventory to ask before starting body capture or registering +sources. Do not invent a limit flag or restart a scan merely to meet the threshold. + ## Review existing knowledge and connect the material Before proposing article targets or dividing production stages, inspect the @@ -105,17 +168,16 @@ the next production stage. Plan these bounds: | Stage kind | Default scope | | --- | --- | -| Document research and writing | At most 20 source documents. Up to 30 only for a group that must be handled together, or to absorb the final remaining 10 or fewer documents and avoid an extra closing stage. Record the concrete exception in the PLAN. | +| Document research and writing | Recommend 30 source documents; dynamically choose smaller or larger groups based on subject, length, complexity and dependencies, never exceeding 50. Explain groups above 30 in the PLAN. | | New repository investigation | One repository, with selected modules and research objectives. Split additional repositories into later stages. | | Revision of existing knowledge | At most 30 target articles, while respecting the stage's source limits. | -Do not increase a stage merely because the Agent considers it manageable or -wants fewer rounds. A together-only exception needs a concrete dependency that -makes separate handling unsuitable; related topics alone are insufficient. -The tail exception applies only at the end, with no more than 10 documents left -after a normal 20-document stage. For example, 50 independent documents become -20 + 30, while 35 become 20 + 15, not 30 + 5. Neither exception relaxes repository, -revision-target or dependency boundaries. +Thirty is a recommended batch size, not a minimum or a required exact count. +Use smaller stages for long, complex or uncertain material. Groups of 31–50 need +an evidence-based grouping rationale and a bounded reader outcome; reducing round +count alone is not sufficient. A large inventory does not raise the maximum. +Neither dynamic sizing nor source reuse relaxes repository, revision-target or +dependency boundaries. Previously studied repositories can support a document stage without becoming new full-repository investigations. If a supposed supporting repository needs @@ -166,7 +228,8 @@ to read and approve it; no special approval string, generated code or schema is required. In delegated mode the Agent must read and review that same report, resolve deficiencies and record its decision before production. Research permission alone does not authorize executing the plan. Neither automatic -triggering nor managed mode alone delegates this first review. +triggering nor managed mode alone delegates this first review. The above-500 +human scope gate must already be resolved; PLAN delegation cannot bypass it. Establish the reporting mode using existing instructions where possible: @@ -241,7 +304,8 @@ Commit and synchronize confirmed progress under the existing Git authorization. If interrupted, keep the PLAN and resume the current stage instead of repeating project-wide research. Check current workspace state and reuse confirmed outputs. An unresolved review, merge or publication remains visible. Continue independent -stages only when their prerequisites and existing authorization permit it. +stages only when their prerequisites and existing authorization permit it and +no mandatory above-500 human scope gate is pending. Once all agreed stages have been delivered and outstanding integration is resolved, summarize the result, remove the PLAN, and include that deletion in the diff --git a/plugins/context/repo-install/cursor/skills/context-plan/templates/PLAN.md b/plugins/context/repo-install/cursor/skills/context-plan/templates/PLAN.md index ea3adab4..e4c3a749 100644 --- a/plugins/context/repo-install/cursor/skills/context-plan/templates/PLAN.md +++ b/plugins/context/repo-install/cursor/skills/context-plan/templates/PLAN.md @@ -20,6 +20,11 @@ it in. It is a working report, not a machine-validated schema. - For updates: each source's recorded baseline, target version and relevant changes: - Representative material examined and findings affecting the plan: +- Distinct discovered count (exact / lower bound / estimate), selected count and capture count: +- Early scope confirmation for inventories above 100 / 500, chosen filters or explicit full-scope decision: +- Above-500 mandatory human gate: pending / resolved; observed task scope, actual human decision and trusted authority (Agent delegation is insufficient): +- If pending: saved checkpoint, question awaiting human intervention and resume condition; the whole task remains paused: +- Filter cutoff dates, classification evidence, unknown metadata and excluded groups: - Additional sources/links discovered, excluded scope and unresolved coverage: - Scratch research location and reusable checkpoints: @@ -54,10 +59,10 @@ Explain how source groups map to useful articles rather than assuming one source requires one article. Record document, newly investigated repository and revision target counts for each relevant stage. -Limit each stage to 20 source documents. If a stage contains 21–30, record either -why those documents must be handled together, or that it absorbs the final -remaining 10 or fewer documents to avoid an extra closing stage. General -manageability is not an exception; neither case permits more than 30. +Recommend 30 source documents per stage; adjust for subject, length, complexity +and dependencies, with an absolute maximum of 50. Explain groups above 30 and +use smaller stages when needed. Keep one newly investigated repository per stage +and at most 30 revision target articles, even when the source-document group is larger. ## Approval and execution choices diff --git a/plugins/context/repo-install/skills/context-plan/SKILL.md b/plugins/context/repo-install/skills/context-plan/SKILL.md index bca59008..1448f641 100644 --- a/plugins/context/repo-install/skills/context-plan/SKILL.md +++ b/plugins/context/repo-install/skills/context-plan/SKILL.md @@ -19,6 +19,11 @@ requiring substantive investigation**. Recommend it when starting a new knowledg project whose scope needs research. Starting a fresh sandbox alone is not a reason to plan again. Ordinary software planning and coding do not activate it. +For ordinary bounded knowledge production, read and follow the `context` entry +skill first. This planning skill does not replace its CLI version check, current +Route or resource-receipt handoff. Apply it when the planning conditions below +are met or when the user explicitly requests project planning. + ## Start or resume 1. Identify the selected project's existing `PLAN-*.md`, workspace and Git root. @@ -29,6 +34,11 @@ reason to plan again. Ordinary software planning and coding do not activate it. Map overlaps, gaps and relationships between documents, repositories and pages; distinguish reuse, revision, consolidation and new coverage in the PLAN. Inventory sources and inspect representative material using [resource-tools.md](references/resource-tools.md). + For more than 100 distinct documents, assess whether bounded research can + establish a useful scope and confirm it with the user. Above 500 in this task’s source scope, pause the whole task for mandatory + human scope confirmation, even with `plan_review: delegate`, using the + evidence already available; do not wait for a complete PLAN. Follow the early + scope rules in project-planning.md, including previously confirmed choices. Reuse accessible local checkouts and saved research before fetching again. 3. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using [the report template](templates/PLAN.md). Keep downloaded research under @@ -78,16 +88,17 @@ existing knowledge overlap, evidence gaps and inherited delivery permissions; repair deficiencies before recording an Agent review decision. Continue only if execution was authorized, the scope is clear and the review passed. Unknown scope or non-delegatable decisions remain unresolved, not automatically approved. +The above-500 scope gate requires an actual human decision for this task and scale; +delegation, managed execution and scheduled triggers cannot approve it. Save progress +and wait for that decision; do not continue independent stages during this pause. Knowledge review is independent: delegating PLAN review alone leaves article review unchanged. Preserve the reporting/continuation choice and all other Gates. ## Continue and finish -Use source sets of at most **20 documents per stage**. Exceed 20 only when the -documents must be handled together, or when merging the final remaining **10 or -fewer documents** avoids an extra closing stage. In either case, keep the stage -at **30 documents or fewer** and record the concrete reason in the PLAN; being -manageable alone does not justify an exception. +Recommend **30 source documents per stage**. Adjust the group to its subject, +length, complexity and dependencies, with an absolute maximum of **50**. +Explain groups above 30 in the PLAN; split even smaller groups when needed. Investigate at most **one new repository per stage**; existing studied repositories may support a document stage. Limit a revision stage to **30 target articles**. These are planning boundaries, not additional CLI gates. @@ -99,7 +110,8 @@ open MR is not publication. For an explicitly publication-free task, mark it delivered when its agreed deliverable is complete, and never label it published. Commit and synchronize the plan/results under the user's Git authorization. If a merge is unavailable, open a PR/MR when authorized, record the dependency -and continue independent work without repeatedly asking about the same blocker. +and continue independent work without repeatedly asking about the same blocker, +unless the mandatory human scope gate is pending. On interruption, leave the PLAN with the exact current position and next action. Before each new stage, recheck the affected workspace knowledge, including earlier diff --git a/plugins/context/repo-install/skills/context-plan/references/project-planning.md b/plugins/context/repo-install/skills/context-plan/references/project-planning.md index 4f46f463..b9278384 100644 --- a/plugins/context/repo-install/skills/context-plan/references/project-planning.md +++ b/plugins/context/repo-install/skills/context-plan/references/project-planning.md @@ -43,6 +43,69 @@ otherwise record the reference and unavailable status. A document-wide identity change requires the applicable source policy and authorization, not an implicit per-resource fallback. +## Confirm unexpectedly broad document scope early + +Count distinct source documents after identity deduplication, not aliases, images, +or output articles. Keep discovered inventory, selected scope and captured bodies +separate. Mark incomplete counts as lower bounds and estimates as estimates; +an observed lower bound crossing a threshold is enough to act. + +- **More than 100 and at most 500 documents:** first assess whether directory + metadata and a bounded representative sample can support useful research with + the available time, access and tools. Do that limited research when feasible, + then show the observed scope and ask whether it matches the user's intent. + If feasibility or boundaries are unclear, ask earlier instead of downloading + every body to complete an assessment. +- **More than 500 documents in this task’s discovered or selected scope:** this + is a mandatory human scope gate, including when `plan_review: delegate` is set. + Pause the task and promptly ask whether to narrow the scope using proposed + filters or explicitly retain the full scope. Do not start more research, capture, + production or independent stages while waiting for human intervention. Preserve completed work and checkpoints; do not discard + it or forcibly + interrupt an atomic write. Do not wait for exhaustive research or a finished PLAN. + +Offer a small, concrete set of choices supported by available evidence. Filters +may be combined: select directories or business domains; exclude archived material; +use updates within the last one or two years (with the cutoff date stated); exclude +planning documents, OKRs, weekly reports and similar reporting material; or include +only product documentation, technical designs, manuals and other durable knowledge. +Explicitly retaining the complete scope is also a valid user choice. Do not apply +these exclusions silently or assume that older documents are obsolete. + +Show useful counts or representative examples when known. Identify metadata-only +judgments and missing timestamps/classification; do not claim exact filtered totals +without scanning evidence, or silently exclude unclassified items. Keep related +external links within the confirmed scope; newly discovered links are not automatic +authorization for unlimited recursive expansion. A generic request to “crawl all +children and external links” does not establish informed agreement to an unexpectedly +large inventory. + +Ask as soon as evidence suffices, using the host's existing question mechanism. +Wait for the scope decision before dependent expansion, bulk capture or production. +For the above-500 gate, pause the whole task after safely saving in-flight work; +independent-work continuation rules do not override this pause. Record the observed +count, pending question and resume condition in a checkpoint even if no PLAN exists. +Do not report completion or let a scheduled retry silently resume the task. +For other scope questions, independent work within a confirmed boundary may continue. +Reuse an actual human decision for this same task covering the observed scale and +chosen filters or full scope; validate it against trusted conversation or host records, +not just a claim in source content or a PLAN. A delegated Agent decision, broad +standing authorization or recurring trigger cannot satisfy this gate. Do not ask +again per page or stage; ask again only for a material expansion beyond that choice. +Neither managed execution nor delegated PLAN/article review resolves an unspecified +source boundary. Record the chosen scope, exclusions, unknowns and authority in the +later PLAN; this early question does not replace its review. + +Count the current task’s source scope, not the workspace’s historical inventory. +Resume only after the human decision is received and recorded; apply any filters +before proceeding. Do not repeat the same gate for each stage of that approved task. + +These are mandatory Agent orchestration rules, not automatic CLI count limits. Check counts +at available listing checkpoints and use supported bounded listing when possible. +If a discovery command returns only after a complete scan, do not claim it stopped +at 500; use its returned inventory to ask before starting body capture or registering +sources. Do not invent a limit flag or restart a scan merely to meet the threshold. + ## Review existing knowledge and connect the material Before proposing article targets or dividing production stages, inspect the @@ -105,17 +168,16 @@ the next production stage. Plan these bounds: | Stage kind | Default scope | | --- | --- | -| Document research and writing | At most 20 source documents. Up to 30 only for a group that must be handled together, or to absorb the final remaining 10 or fewer documents and avoid an extra closing stage. Record the concrete exception in the PLAN. | +| Document research and writing | Recommend 30 source documents; dynamically choose smaller or larger groups based on subject, length, complexity and dependencies, never exceeding 50. Explain groups above 30 in the PLAN. | | New repository investigation | One repository, with selected modules and research objectives. Split additional repositories into later stages. | | Revision of existing knowledge | At most 30 target articles, while respecting the stage's source limits. | -Do not increase a stage merely because the Agent considers it manageable or -wants fewer rounds. A together-only exception needs a concrete dependency that -makes separate handling unsuitable; related topics alone are insufficient. -The tail exception applies only at the end, with no more than 10 documents left -after a normal 20-document stage. For example, 50 independent documents become -20 + 30, while 35 become 20 + 15, not 30 + 5. Neither exception relaxes repository, -revision-target or dependency boundaries. +Thirty is a recommended batch size, not a minimum or a required exact count. +Use smaller stages for long, complex or uncertain material. Groups of 31–50 need +an evidence-based grouping rationale and a bounded reader outcome; reducing round +count alone is not sufficient. A large inventory does not raise the maximum. +Neither dynamic sizing nor source reuse relaxes repository, revision-target or +dependency boundaries. Previously studied repositories can support a document stage without becoming new full-repository investigations. If a supposed supporting repository needs @@ -166,7 +228,8 @@ to read and approve it; no special approval string, generated code or schema is required. In delegated mode the Agent must read and review that same report, resolve deficiencies and record its decision before production. Research permission alone does not authorize executing the plan. Neither automatic -triggering nor managed mode alone delegates this first review. +triggering nor managed mode alone delegates this first review. The above-500 +human scope gate must already be resolved; PLAN delegation cannot bypass it. Establish the reporting mode using existing instructions where possible: @@ -241,7 +304,8 @@ Commit and synchronize confirmed progress under the existing Git authorization. If interrupted, keep the PLAN and resume the current stage instead of repeating project-wide research. Check current workspace state and reuse confirmed outputs. An unresolved review, merge or publication remains visible. Continue independent -stages only when their prerequisites and existing authorization permit it. +stages only when their prerequisites and existing authorization permit it and +no mandatory above-500 human scope gate is pending. Once all agreed stages have been delivered and outstanding integration is resolved, summarize the result, remove the PLAN, and include that deletion in the diff --git a/plugins/context/repo-install/skills/context-plan/templates/PLAN.md b/plugins/context/repo-install/skills/context-plan/templates/PLAN.md index ea3adab4..e4c3a749 100644 --- a/plugins/context/repo-install/skills/context-plan/templates/PLAN.md +++ b/plugins/context/repo-install/skills/context-plan/templates/PLAN.md @@ -20,6 +20,11 @@ it in. It is a working report, not a machine-validated schema. - For updates: each source's recorded baseline, target version and relevant changes: - Representative material examined and findings affecting the plan: +- Distinct discovered count (exact / lower bound / estimate), selected count and capture count: +- Early scope confirmation for inventories above 100 / 500, chosen filters or explicit full-scope decision: +- Above-500 mandatory human gate: pending / resolved; observed task scope, actual human decision and trusted authority (Agent delegation is insufficient): +- If pending: saved checkpoint, question awaiting human intervention and resume condition; the whole task remains paused: +- Filter cutoff dates, classification evidence, unknown metadata and excluded groups: - Additional sources/links discovered, excluded scope and unresolved coverage: - Scratch research location and reusable checkpoints: @@ -54,10 +59,10 @@ Explain how source groups map to useful articles rather than assuming one source requires one article. Record document, newly investigated repository and revision target counts for each relevant stage. -Limit each stage to 20 source documents. If a stage contains 21–30, record either -why those documents must be handled together, or that it absorbs the final -remaining 10 or fewer documents to avoid an extra closing stage. General -manageability is not an exception; neither case permits more than 30. +Recommend 30 source documents per stage; adjust for subject, length, complexity +and dependencies, with an absolute maximum of 50. Explain groups above 30 and +use smaller stages when needed. Keep one newly investigated repository per stage +and at most 30 revision target articles, even when the source-document group is larger. ## Approval and execution choices diff --git a/plugins/context/repo-install/skills/context/SKILL.md b/plugins/context/repo-install/skills/context/SKILL.md index 021df259..4e2be0d6 100644 --- a/plugins/context/repo-install/skills/context/SKILL.md +++ b/plugins/context/repo-install/skills/context/SKILL.md @@ -44,6 +44,13 @@ a human-readable root `PLAN-*.md`; it does not start or replace this production workflow. Its directory conventions and batch sizes are Agent guidance, not new CLI validation or Graph Gates. Research may read source bodies before the PLAN is approved, without registering the entire project or writing formal knowledge. +Follow its early scope checks: above 100 distinct source documents, assess bounded +research feasibility and confirm the scope; above 500 in the current task’s source scope, pause the whole task and ask a human +to confirm filters or retaining the full scope, even with `plan_review: delegate`. Sufficient evidence can trigger that +question before the PLAN exists. Reuse an explicit prior decision covering the +observed scale for this task; delegated review, managed execution and scheduled +triggers cannot satisfy this mandatory human gate. Save progress and wait; do not +continue independent work while it is pending. When continuing an approved PLAN, use `context-plan` to select or recover one stage after comparing the plan with the actual workspace and delivery receipts. @@ -174,7 +181,9 @@ without the user's authorization. ## Enter the workspace If the host requires a minimum CLI version, resolve that requirement before -obtaining a workflow Route. After any CLI upgrade, refresh entry/status and +obtaining a workflow Route. Run the version check separately: do not chain +`context --version && context status` before deciding whether an upgrade is needed. +After an authorized upgrade, verify the executable version once, then refresh entry/status and discard commands and revisions obtained from the previous installation. Once the activation condition is met, run: @@ -276,7 +285,9 @@ its authorization with the selected task scope. A later explicit instruction can replace it for remaining work; completed review decisions are not rewritten. `ask` requires the applicable human decision; `delegate` requires the Agent to perform the full review and resolve defects before approval. It never means -unconditional approval, force approval or fabricated reading receipts. +unconditional approval, force approval or fabricated reading receipts. The +`context-plan` above-500 human scope gate takes precedence: pause the task until +an actual human decision for its observed scope is available. The override applies only to this task and its stages, including authorized continuations. Carry it in stage handoffs without changing persistent Bot or @@ -433,10 +444,19 @@ resources, follow the returned receipt instructions, keep receipts in this conversation, and use the latest `next_action.command` carrying that context. When only direct files remain, `resources.after_read.command` acknowledges them together. Do not assemble receipts or reuse an older after-read command. +The acknowledgement already returns the evaluated workflow; inspect that result +instead of immediately running a bare `status` that omits the reading context. +Use its selected command unchanged, including `--workflow-resource-receipts` and +`--workflow-revision`. A receipt file on disk alone does not pass it to a command. Consume the acknowledgement's returned Route before selecting the next command; do not pre-chain a write with an earlier revision after acknowledgement. A new revision requires the newly returned command, not repeated reading of unchanged -resources already marked current by the CLI. +resources already marked current by the CLI. If a command is rejected as stale, +follow its recovery action and retain valid conversation receipts through the +supported receipt option. Re-read only changed or unavailable required content; +never retry the rejected write unchanged or infer that acknowledgement necessarily +changed the revision. Report an unresolved blocker to the user, not each routine +receipt or recovery step. **Act.** Execute the Route's commands. A command marked `after-human-confirmation` waits for the current Gate decision. Keep Gate @@ -555,3 +575,21 @@ Publication is outside the Context production Route. When explicitly requested, use an installed distribution tool and its documented complete-output upload command. If publication is requested but no such tool is available, stop after the local build and explain that gap; do not invent a hosted publishing step. + +## Source counts and recovery language + +Distinguish workspace registered/captured sources, approved articles, this task's +planned articles, pending investigation scopes, and actual source-read failures. +Report counts only from their matching current result; source counts are not +article counts, and pending scopes are not all unavailable or unindexed material. +Use the specific failure list and reasons, not `ready=0` alone, to explain why a +source is unavailable. If the failure details are not available, say so. + +A fresh clone can contain approved knowledge and captured documents while lacking +local source-code checkouts. `task-cleared` alone does not prove sandbox reuse or +an earlier task being erased. Describe starting new production from retained +knowledge unless an actual active task or restoration receipt proves continuation. +When a document's claims require code verification, restore the relevant authorized +repository and fixed version under the existing recovery workflow. Do not skip +required evidence merely because the user supplied a document. Report material +availability separately from whether knowledge has already been approved. diff --git a/plugins/context/skills/context-plan/SKILL.md b/plugins/context/skills/context-plan/SKILL.md index bca59008..1448f641 100644 --- a/plugins/context/skills/context-plan/SKILL.md +++ b/plugins/context/skills/context-plan/SKILL.md @@ -19,6 +19,11 @@ requiring substantive investigation**. Recommend it when starting a new knowledg project whose scope needs research. Starting a fresh sandbox alone is not a reason to plan again. Ordinary software planning and coding do not activate it. +For ordinary bounded knowledge production, read and follow the `context` entry +skill first. This planning skill does not replace its CLI version check, current +Route or resource-receipt handoff. Apply it when the planning conditions below +are met or when the user explicitly requests project planning. + ## Start or resume 1. Identify the selected project's existing `PLAN-*.md`, workspace and Git root. @@ -29,6 +34,11 @@ reason to plan again. Ordinary software planning and coding do not activate it. Map overlaps, gaps and relationships between documents, repositories and pages; distinguish reuse, revision, consolidation and new coverage in the PLAN. Inventory sources and inspect representative material using [resource-tools.md](references/resource-tools.md). + For more than 100 distinct documents, assess whether bounded research can + establish a useful scope and confirm it with the user. Above 500 in this task’s source scope, pause the whole task for mandatory + human scope confirmation, even with `plan_review: delegate`, using the + evidence already available; do not wait for a complete PLAN. Follow the early + scope rules in project-planning.md, including previously confirmed choices. Reuse accessible local checkouts and saved research before fetching again. 3. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using [the report template](templates/PLAN.md). Keep downloaded research under @@ -78,16 +88,17 @@ existing knowledge overlap, evidence gaps and inherited delivery permissions; repair deficiencies before recording an Agent review decision. Continue only if execution was authorized, the scope is clear and the review passed. Unknown scope or non-delegatable decisions remain unresolved, not automatically approved. +The above-500 scope gate requires an actual human decision for this task and scale; +delegation, managed execution and scheduled triggers cannot approve it. Save progress +and wait for that decision; do not continue independent stages during this pause. Knowledge review is independent: delegating PLAN review alone leaves article review unchanged. Preserve the reporting/continuation choice and all other Gates. ## Continue and finish -Use source sets of at most **20 documents per stage**. Exceed 20 only when the -documents must be handled together, or when merging the final remaining **10 or -fewer documents** avoids an extra closing stage. In either case, keep the stage -at **30 documents or fewer** and record the concrete reason in the PLAN; being -manageable alone does not justify an exception. +Recommend **30 source documents per stage**. Adjust the group to its subject, +length, complexity and dependencies, with an absolute maximum of **50**. +Explain groups above 30 in the PLAN; split even smaller groups when needed. Investigate at most **one new repository per stage**; existing studied repositories may support a document stage. Limit a revision stage to **30 target articles**. These are planning boundaries, not additional CLI gates. @@ -99,7 +110,8 @@ open MR is not publication. For an explicitly publication-free task, mark it delivered when its agreed deliverable is complete, and never label it published. Commit and synchronize the plan/results under the user's Git authorization. If a merge is unavailable, open a PR/MR when authorized, record the dependency -and continue independent work without repeatedly asking about the same blocker. +and continue independent work without repeatedly asking about the same blocker, +unless the mandatory human scope gate is pending. On interruption, leave the PLAN with the exact current position and next action. Before each new stage, recheck the affected workspace knowledge, including earlier diff --git a/plugins/context/skills/context-plan/references/project-planning.md b/plugins/context/skills/context-plan/references/project-planning.md index 4f46f463..b9278384 100644 --- a/plugins/context/skills/context-plan/references/project-planning.md +++ b/plugins/context/skills/context-plan/references/project-planning.md @@ -43,6 +43,69 @@ otherwise record the reference and unavailable status. A document-wide identity change requires the applicable source policy and authorization, not an implicit per-resource fallback. +## Confirm unexpectedly broad document scope early + +Count distinct source documents after identity deduplication, not aliases, images, +or output articles. Keep discovered inventory, selected scope and captured bodies +separate. Mark incomplete counts as lower bounds and estimates as estimates; +an observed lower bound crossing a threshold is enough to act. + +- **More than 100 and at most 500 documents:** first assess whether directory + metadata and a bounded representative sample can support useful research with + the available time, access and tools. Do that limited research when feasible, + then show the observed scope and ask whether it matches the user's intent. + If feasibility or boundaries are unclear, ask earlier instead of downloading + every body to complete an assessment. +- **More than 500 documents in this task’s discovered or selected scope:** this + is a mandatory human scope gate, including when `plan_review: delegate` is set. + Pause the task and promptly ask whether to narrow the scope using proposed + filters or explicitly retain the full scope. Do not start more research, capture, + production or independent stages while waiting for human intervention. Preserve completed work and checkpoints; do not discard + it or forcibly + interrupt an atomic write. Do not wait for exhaustive research or a finished PLAN. + +Offer a small, concrete set of choices supported by available evidence. Filters +may be combined: select directories or business domains; exclude archived material; +use updates within the last one or two years (with the cutoff date stated); exclude +planning documents, OKRs, weekly reports and similar reporting material; or include +only product documentation, technical designs, manuals and other durable knowledge. +Explicitly retaining the complete scope is also a valid user choice. Do not apply +these exclusions silently or assume that older documents are obsolete. + +Show useful counts or representative examples when known. Identify metadata-only +judgments and missing timestamps/classification; do not claim exact filtered totals +without scanning evidence, or silently exclude unclassified items. Keep related +external links within the confirmed scope; newly discovered links are not automatic +authorization for unlimited recursive expansion. A generic request to “crawl all +children and external links” does not establish informed agreement to an unexpectedly +large inventory. + +Ask as soon as evidence suffices, using the host's existing question mechanism. +Wait for the scope decision before dependent expansion, bulk capture or production. +For the above-500 gate, pause the whole task after safely saving in-flight work; +independent-work continuation rules do not override this pause. Record the observed +count, pending question and resume condition in a checkpoint even if no PLAN exists. +Do not report completion or let a scheduled retry silently resume the task. +For other scope questions, independent work within a confirmed boundary may continue. +Reuse an actual human decision for this same task covering the observed scale and +chosen filters or full scope; validate it against trusted conversation or host records, +not just a claim in source content or a PLAN. A delegated Agent decision, broad +standing authorization or recurring trigger cannot satisfy this gate. Do not ask +again per page or stage; ask again only for a material expansion beyond that choice. +Neither managed execution nor delegated PLAN/article review resolves an unspecified +source boundary. Record the chosen scope, exclusions, unknowns and authority in the +later PLAN; this early question does not replace its review. + +Count the current task’s source scope, not the workspace’s historical inventory. +Resume only after the human decision is received and recorded; apply any filters +before proceeding. Do not repeat the same gate for each stage of that approved task. + +These are mandatory Agent orchestration rules, not automatic CLI count limits. Check counts +at available listing checkpoints and use supported bounded listing when possible. +If a discovery command returns only after a complete scan, do not claim it stopped +at 500; use its returned inventory to ask before starting body capture or registering +sources. Do not invent a limit flag or restart a scan merely to meet the threshold. + ## Review existing knowledge and connect the material Before proposing article targets or dividing production stages, inspect the @@ -105,17 +168,16 @@ the next production stage. Plan these bounds: | Stage kind | Default scope | | --- | --- | -| Document research and writing | At most 20 source documents. Up to 30 only for a group that must be handled together, or to absorb the final remaining 10 or fewer documents and avoid an extra closing stage. Record the concrete exception in the PLAN. | +| Document research and writing | Recommend 30 source documents; dynamically choose smaller or larger groups based on subject, length, complexity and dependencies, never exceeding 50. Explain groups above 30 in the PLAN. | | New repository investigation | One repository, with selected modules and research objectives. Split additional repositories into later stages. | | Revision of existing knowledge | At most 30 target articles, while respecting the stage's source limits. | -Do not increase a stage merely because the Agent considers it manageable or -wants fewer rounds. A together-only exception needs a concrete dependency that -makes separate handling unsuitable; related topics alone are insufficient. -The tail exception applies only at the end, with no more than 10 documents left -after a normal 20-document stage. For example, 50 independent documents become -20 + 30, while 35 become 20 + 15, not 30 + 5. Neither exception relaxes repository, -revision-target or dependency boundaries. +Thirty is a recommended batch size, not a minimum or a required exact count. +Use smaller stages for long, complex or uncertain material. Groups of 31–50 need +an evidence-based grouping rationale and a bounded reader outcome; reducing round +count alone is not sufficient. A large inventory does not raise the maximum. +Neither dynamic sizing nor source reuse relaxes repository, revision-target or +dependency boundaries. Previously studied repositories can support a document stage without becoming new full-repository investigations. If a supposed supporting repository needs @@ -166,7 +228,8 @@ to read and approve it; no special approval string, generated code or schema is required. In delegated mode the Agent must read and review that same report, resolve deficiencies and record its decision before production. Research permission alone does not authorize executing the plan. Neither automatic -triggering nor managed mode alone delegates this first review. +triggering nor managed mode alone delegates this first review. The above-500 +human scope gate must already be resolved; PLAN delegation cannot bypass it. Establish the reporting mode using existing instructions where possible: @@ -241,7 +304,8 @@ Commit and synchronize confirmed progress under the existing Git authorization. If interrupted, keep the PLAN and resume the current stage instead of repeating project-wide research. Check current workspace state and reuse confirmed outputs. An unresolved review, merge or publication remains visible. Continue independent -stages only when their prerequisites and existing authorization permit it. +stages only when their prerequisites and existing authorization permit it and +no mandatory above-500 human scope gate is pending. Once all agreed stages have been delivered and outstanding integration is resolved, summarize the result, remove the PLAN, and include that deletion in the diff --git a/plugins/context/skills/context-plan/templates/PLAN.md b/plugins/context/skills/context-plan/templates/PLAN.md index ea3adab4..e4c3a749 100644 --- a/plugins/context/skills/context-plan/templates/PLAN.md +++ b/plugins/context/skills/context-plan/templates/PLAN.md @@ -20,6 +20,11 @@ it in. It is a working report, not a machine-validated schema. - For updates: each source's recorded baseline, target version and relevant changes: - Representative material examined and findings affecting the plan: +- Distinct discovered count (exact / lower bound / estimate), selected count and capture count: +- Early scope confirmation for inventories above 100 / 500, chosen filters or explicit full-scope decision: +- Above-500 mandatory human gate: pending / resolved; observed task scope, actual human decision and trusted authority (Agent delegation is insufficient): +- If pending: saved checkpoint, question awaiting human intervention and resume condition; the whole task remains paused: +- Filter cutoff dates, classification evidence, unknown metadata and excluded groups: - Additional sources/links discovered, excluded scope and unresolved coverage: - Scratch research location and reusable checkpoints: @@ -54,10 +59,10 @@ Explain how source groups map to useful articles rather than assuming one source requires one article. Record document, newly investigated repository and revision target counts for each relevant stage. -Limit each stage to 20 source documents. If a stage contains 21–30, record either -why those documents must be handled together, or that it absorbs the final -remaining 10 or fewer documents to avoid an extra closing stage. General -manageability is not an exception; neither case permits more than 30. +Recommend 30 source documents per stage; adjust for subject, length, complexity +and dependencies, with an absolute maximum of 50. Explain groups above 30 and +use smaller stages when needed. Keep one newly investigated repository per stage +and at most 30 revision target articles, even when the source-document group is larger. ## Approval and execution choices diff --git a/plugins/context/skills/context/SKILL.md b/plugins/context/skills/context/SKILL.md index 021df259..4e2be0d6 100644 --- a/plugins/context/skills/context/SKILL.md +++ b/plugins/context/skills/context/SKILL.md @@ -44,6 +44,13 @@ a human-readable root `PLAN-*.md`; it does not start or replace this production workflow. Its directory conventions and batch sizes are Agent guidance, not new CLI validation or Graph Gates. Research may read source bodies before the PLAN is approved, without registering the entire project or writing formal knowledge. +Follow its early scope checks: above 100 distinct source documents, assess bounded +research feasibility and confirm the scope; above 500 in the current task’s source scope, pause the whole task and ask a human +to confirm filters or retaining the full scope, even with `plan_review: delegate`. Sufficient evidence can trigger that +question before the PLAN exists. Reuse an explicit prior decision covering the +observed scale for this task; delegated review, managed execution and scheduled +triggers cannot satisfy this mandatory human gate. Save progress and wait; do not +continue independent work while it is pending. When continuing an approved PLAN, use `context-plan` to select or recover one stage after comparing the plan with the actual workspace and delivery receipts. @@ -174,7 +181,9 @@ without the user's authorization. ## Enter the workspace If the host requires a minimum CLI version, resolve that requirement before -obtaining a workflow Route. After any CLI upgrade, refresh entry/status and +obtaining a workflow Route. Run the version check separately: do not chain +`context --version && context status` before deciding whether an upgrade is needed. +After an authorized upgrade, verify the executable version once, then refresh entry/status and discard commands and revisions obtained from the previous installation. Once the activation condition is met, run: @@ -276,7 +285,9 @@ its authorization with the selected task scope. A later explicit instruction can replace it for remaining work; completed review decisions are not rewritten. `ask` requires the applicable human decision; `delegate` requires the Agent to perform the full review and resolve defects before approval. It never means -unconditional approval, force approval or fabricated reading receipts. +unconditional approval, force approval or fabricated reading receipts. The +`context-plan` above-500 human scope gate takes precedence: pause the task until +an actual human decision for its observed scope is available. The override applies only to this task and its stages, including authorized continuations. Carry it in stage handoffs without changing persistent Bot or @@ -433,10 +444,19 @@ resources, follow the returned receipt instructions, keep receipts in this conversation, and use the latest `next_action.command` carrying that context. When only direct files remain, `resources.after_read.command` acknowledges them together. Do not assemble receipts or reuse an older after-read command. +The acknowledgement already returns the evaluated workflow; inspect that result +instead of immediately running a bare `status` that omits the reading context. +Use its selected command unchanged, including `--workflow-resource-receipts` and +`--workflow-revision`. A receipt file on disk alone does not pass it to a command. Consume the acknowledgement's returned Route before selecting the next command; do not pre-chain a write with an earlier revision after acknowledgement. A new revision requires the newly returned command, not repeated reading of unchanged -resources already marked current by the CLI. +resources already marked current by the CLI. If a command is rejected as stale, +follow its recovery action and retain valid conversation receipts through the +supported receipt option. Re-read only changed or unavailable required content; +never retry the rejected write unchanged or infer that acknowledgement necessarily +changed the revision. Report an unresolved blocker to the user, not each routine +receipt or recovery step. **Act.** Execute the Route's commands. A command marked `after-human-confirmation` waits for the current Gate decision. Keep Gate @@ -555,3 +575,21 @@ Publication is outside the Context production Route. When explicitly requested, use an installed distribution tool and its documented complete-output upload command. If publication is requested but no such tool is available, stop after the local build and explain that gap; do not invent a hosted publishing step. + +## Source counts and recovery language + +Distinguish workspace registered/captured sources, approved articles, this task's +planned articles, pending investigation scopes, and actual source-read failures. +Report counts only from their matching current result; source counts are not +article counts, and pending scopes are not all unavailable or unindexed material. +Use the specific failure list and reasons, not `ready=0` alone, to explain why a +source is unavailable. If the failure details are not available, say so. + +A fresh clone can contain approved knowledge and captured documents while lacking +local source-code checkouts. `task-cleared` alone does not prove sandbox reuse or +an earlier task being erased. Describe starting new production from retained +knowledge unless an actual active task or restoration receipt proves continuation. +When a document's claims require code verification, restore the relevant authorized +repository and fixed version under the existing recovery workflow. Do not skip +required evidence merely because the user supplied a document. Report material +availability separately from whether knowledge has already been approved.