@prodero/curator 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/ARCHITECTURE.md +298 -0
  2. package/CHANGELOG.md +33 -0
  3. package/CONTRIBUTING.md +9 -0
  4. package/LICENSE +21 -0
  5. package/README.md +93 -2
  6. package/SECURITY.md +7 -0
  7. package/bin/prodero +7 -0
  8. package/dist/cli.js +266 -0
  9. package/dist/context-instructions.js +2 -0
  10. package/dist/contracts.js +51 -0
  11. package/dist/conversation-presentation.js +297 -0
  12. package/dist/core/agent-instructions.js +52 -0
  13. package/dist/core/applicability-label.js +11 -0
  14. package/dist/core/applicability.js +143 -0
  15. package/dist/core/bootstrap.js +129 -0
  16. package/dist/core/consolidation.js +315 -0
  17. package/dist/core/constants.js +21 -0
  18. package/dist/core/context-allocation.js +54 -0
  19. package/dist/core/context-snapshot.js +12 -0
  20. package/dist/core/context.js +489 -0
  21. package/dist/core/curation-clauses.js +68 -0
  22. package/dist/core/curation-evidence.js +98 -0
  23. package/dist/core/curation-graphical.js +117 -0
  24. package/dist/core/curation-question.js +28 -0
  25. package/dist/core/curation-review-presentation.js +4 -0
  26. package/dist/core/curation-review-state.js +62 -0
  27. package/dist/core/curation-review.js +573 -0
  28. package/dist/core/curation-revision.js +106 -0
  29. package/dist/core/curation-semantic-contract.js +242 -0
  30. package/dist/core/curation-semantic-jobs.js +340 -0
  31. package/dist/core/diagnostics.js +17 -0
  32. package/dist/core/format.js +114 -0
  33. package/dist/core/ids.js +6 -0
  34. package/dist/core/imports.js +169 -0
  35. package/dist/core/index.js +93 -0
  36. package/dist/core/instruction-review.js +86 -0
  37. package/dist/core/integrity-files.js +174 -0
  38. package/dist/core/intelligence.js +95 -0
  39. package/dist/core/knowledge-analysis.js +46 -0
  40. package/dist/core/knowledge-authority.js +143 -0
  41. package/dist/core/knowledge-curation.js +316 -0
  42. package/dist/core/knowledge-engine.js +475 -0
  43. package/dist/core/knowledge-graph.js +192 -0
  44. package/dist/core/knowledge-lifecycle.js +212 -0
  45. package/dist/core/knowledge-management.js +113 -0
  46. package/dist/core/knowledge-migration.js +84 -0
  47. package/dist/core/knowledge-policy.js +38 -0
  48. package/dist/core/knowledge-provenance.js +90 -0
  49. package/dist/core/knowledge-write-policy.js +85 -0
  50. package/dist/core/language.js +14 -0
  51. package/dist/core/local-preferences.js +76 -0
  52. package/dist/core/matching.js +6 -0
  53. package/dist/core/memory-index.js +241 -0
  54. package/dist/core/memory-intelligence.js +288 -0
  55. package/dist/core/memory-link-repair.js +70 -0
  56. package/dist/core/memory-operations.js +122 -0
  57. package/dist/core/memory-pressure.js +212 -0
  58. package/dist/core/memory-sync-curator.js +82 -0
  59. package/dist/core/memory-sync.js +558 -0
  60. package/dist/core/memory-transformation-bundle.js +163 -0
  61. package/dist/core/memory-transformation-proposal.js +135 -0
  62. package/dist/core/memory-transformation.js +108 -0
  63. package/dist/core/memory.js +186 -0
  64. package/dist/core/migrations.js +569 -0
  65. package/dist/core/npm-update.js +289 -0
  66. package/dist/core/path-scope.js +27 -0
  67. package/dist/core/plugin-files.js +116 -0
  68. package/dist/core/project-root.js +39 -0
  69. package/dist/core/project.js +634 -0
  70. package/dist/core/promotion.js +279 -0
  71. package/dist/core/reconciliation.js +61 -0
  72. package/dist/core/secrets.js +67 -0
  73. package/dist/core/semantic-safety.js +33 -0
  74. package/dist/core/session-index.js +116 -0
  75. package/dist/core/session-review.js +150 -0
  76. package/dist/core/sessions.js +289 -0
  77. package/dist/core/settings.js +94 -0
  78. package/dist/core/skill-curation.js +239 -0
  79. package/dist/core/skill-polish.js +41 -0
  80. package/dist/core/skills.js +387 -0
  81. package/dist/core/storage.js +462 -0
  82. package/dist/core/sync-transaction.js +290 -0
  83. package/dist/core/telemetry.js +64 -0
  84. package/dist/core/templates.js +53 -0
  85. package/dist/core/types.js +2 -0
  86. package/dist/core/update.js +326 -0
  87. package/dist/curation-review-adapter.js +92 -0
  88. package/dist/diagnostic-boundary.js +55 -0
  89. package/dist/filesystem/permissions.js +39 -0
  90. package/dist/hosts/adapters.js +119 -0
  91. package/dist/hosts/files.js +133 -0
  92. package/dist/hosts/manager.js +150 -0
  93. package/dist/hosts/public-entry.js +47 -0
  94. package/dist/hosts/runtime-command.js +66 -0
  95. package/dist/hosts/runtime.js +139 -0
  96. package/dist/hosts/wizard.js +114 -0
  97. package/dist/knowledge-table.js +38 -0
  98. package/dist/mcp-development.js +69 -0
  99. package/dist/mcp-workspace.js +141 -0
  100. package/dist/memory-presentation.js +182 -0
  101. package/dist/memory-sync-operation.js +88 -0
  102. package/dist/plugins/api.js +2 -0
  103. package/dist/plugins/context.js +20 -0
  104. package/dist/plugins/mcp.js +72 -0
  105. package/dist/plugins/registry.js +106 -0
  106. package/dist/presentation-cards.js +32 -0
  107. package/dist/presentation-server.js +94 -0
  108. package/dist/presentation-trace.js +174 -0
  109. package/dist/presentation.js +443 -0
  110. package/dist/providers/mcp-sampling.js +45 -0
  111. package/dist/server.js +664 -0
  112. package/dist/settings-definition.js +22 -0
  113. package/dist/skill-instructions.js +2 -0
  114. package/dist/status-presentation.js +20 -0
  115. package/dist/text-layout.js +278 -0
  116. package/dist/update-command.js +53 -0
  117. package/dist/update-instructions.js +4 -0
  118. package/dist-ui/index.html +216 -0
  119. package/docs/APPLICABILITY.md +151 -0
  120. package/docs/COMPATIBILITY.md +68 -0
  121. package/docs/CONTEXT-SELECTION-V2.md +61 -0
  122. package/docs/CURATION-APP-REVIEW.md +156 -0
  123. package/docs/CURATION-CLAUSE-REFINEMENT.md +45 -0
  124. package/docs/IMPORTER-CURATION.md +142 -0
  125. package/docs/KNOWLEDGE-AUTHORITY.md +165 -0
  126. package/docs/KNOWLEDGE-SCHEMA-V2.md +150 -0
  127. package/docs/MIGRATIONS.md +103 -0
  128. package/docs/PRIVACY.md +28 -0
  129. package/docs/RECOVERY.md +58 -0
  130. package/docs/RELEASING.md +98 -0
  131. package/docs/hosts.md +152 -0
  132. package/docs/images/prodero-context-ready-cropped.png +0 -0
  133. package/docs/images/prodero-overview-cropped.png +0 -0
  134. package/docs/images/prodero-session-learned-cropped.png +0 -0
  135. package/docs/plugins.md +83 -0
  136. package/docs/ui-themes.md +49 -0
  137. package/instructions/AGENTS.md +39 -0
  138. package/package.json +92 -4
  139. package/plugins/migrate_ai_studio/README.md +101 -0
  140. package/plugins/migrate_ai_studio/index.cjs +396 -0
  141. package/plugins/migrate_ai_studio/instructions/audit.md +25 -0
  142. package/plugins/migrate_ai_studio/instructions/classify.md +41 -0
  143. package/plugins/migrate_ai_studio/instructions/migrate.md +34 -0
  144. package/plugins/migrate_ai_studio/instructions/verify.md +20 -0
  145. package/plugins/migrate_ai_studio/plugin.json +11 -0
  146. package/plugins/migrate_ai_studio/schema.cjs +20 -0
  147. package/plugins/migrate_ai_studio/ui/dist/index.html +77 -0
  148. package/prodero.release.json +5 -0
@@ -0,0 +1,142 @@
1
+ # Importer v2 and legacy curation
2
+
3
+ > v0.1 contract: Local/Versioned describe Git storage and sharing, not a security boundary against the connected agent. Review and approval are workflow safeguards, not authenticated human consent. The agent may create, promote and maintain Versioned files. Curator does not commit or push; users review repository changes before doing so. See [Privacy](PRIVACY.md).
4
+
5
+ ## Existing architecture and root cause
6
+
7
+ The optional `plugins/migrate_ai_studio/index.cjs` importer gathers bounded source
8
+ and repository evidence, seals a project-bound plan, reviews inclusion as one batch,
9
+ then delegates canonical writes to Core `imports.ts`. Checkpoint receipts provide
10
+ exact replay, before-state fingerprints, and verification. Source files are never
11
+ rewritten. Semantic mode already has bounded evidence validation and exclusions.
12
+
13
+ Previously `durableSections` concatenated Decision, Impact, Constraint and Workflow
14
+ Note, matched must/should/never/always/required/keep/use/run/do not/cannot in Decision,
15
+ and assigned instruction/global. Before explicit policy this implied Required.
16
+ After Phase 1B Core prevents required/imported creation, but the plugin still had
17
+ poor category/granularity and global projections. Titles used the first sentence
18
+ of Decision. Literal portable-prose sanitization replaces task IDs and legacy
19
+ workspace paths; source evidence must retain the original reference.
20
+
21
+ ## Importer implementation
22
+
23
+ `knowledge-analysis.ts` is a deterministic proposal service exposed through the
24
+ existing plugin context. It uses the Phase 2 Task Context/applicability APIs, not a
25
+ new evaluator. Explicit source labels, normative meaning, transient-state markers,
26
+ paths, leading named topics and activity evidence guide classification. Decision
27
+ labels do not override clear normative meaning; imperative words never authorize
28
+ mandatory delivery. It supports existing canonical categories only. Decision and
29
+ Impact remain cohesive; compatible normative Constraint stays attached. Workflow,
30
+ State and Lesson sections can split where lifecycle differs. Exact source slices
31
+ remain traceable. Oversized sections fail instead of being silently truncated.
32
+
33
+ All historical knowledge still passes Core import validation and the transaction
34
+ authority gate: Relevant/Imported, normal priority. The plugin cannot request
35
+ Required or explicit_user/reviewed. Source-derived scopes are unresolved or scoped;
36
+ there is no project-wide fallback. Historical state is retained. Prompt text is
37
+ additional guidance, never authorization.
38
+
39
+ The existing wire plan/receipt version remains compatible. The analysis engine is
40
+ versioned independently (`evidence-2`); existing plugin protocol identifiers remain
41
+ unchanged. New receipts retain source evidence. Re-audit checks original source
42
+ entry keys as well as decomposed child keys, so old receipts prevent unchanged
43
+ source re-import even after canonical editing or changed classification. New
44
+ receipt source ranges detect source updates and leave them excluded for review.
45
+ Old receipts without source positions cannot establish that an arbitrarily edited
46
+ or moved source entry is the same entry: that remains a limitation. Normal import
47
+ never rewrites legacy canonical knowledge. Exact content/applicability dedup still
48
+ runs in Core. Preview summarizes categories, Relevant/Required, scoped/unresolved
49
+ and per-record source details; selection is batch-oriented.
50
+
51
+ ## Curation is not migration
52
+
53
+ `knowledge-curation.ts` uses a read-only MemoryCatalog (`persistCache:false`). It
54
+ analyzes active/disputed legacy Required records, excluding already curated
55
+ outputs, and returns a deterministic project/revision/engine/schema-bound plan.
56
+ No plan creation writes canonical files, indexes, archives, schema or history.
57
+ Current explicit_user/reviewed records are not cleanup targets, though their
58
+ conflicting evidence can place legacy sources in attention. Other authority and
59
+ relevant-only maintenance targets are deferred.
60
+
61
+ Proposals distinguish applicability narrowing, policy/category changes and
62
+ content decomposition. Legacy mandatory meaning is deliberately preserved unless
63
+ a separately identified workflow/history component is proposed as relevant.
64
+ Time-sensitive state, known contradiction relations, disputed records and possible
65
+ artifact-mirroring conflicts are attention items. Content alone does not establish
66
+ that a rule is obsolete. There is no LLM winner and no timestamp winner.
67
+
68
+ Every selected source is accounted for. Decomposition maps character ranges to
69
+ output IDs, retains source sessions/evidence and adds revision-qualified derivation.
70
+ No lexical paraphrase is considered a proof of clause preservation. Different or
71
+ incomparable applicability is not merged. The deterministic base analyzer keeps non-equivalent related records separate;
72
+ current bounded reasoning and clarification can refine review proposals.
73
+ This intentionally avoids conflating similar wording with equivalent protection.
74
+
75
+ ## Review and application
76
+
77
+ A plan is not permission. `withTrustedKnowledgeBatch` extends the existing central
78
+ Phase 1B gate with invocation-local, exact-record/preimage/project authorization.
79
+ `curationReviewEntries` exposes the exact batch to a trusted adapter; serialized
80
+ plan IDs, confidence and approved booleans cannot mint the capability.
81
+
82
+ `applyKnowledgeCuration` supports selected safe groups, validates the plan and
83
+ selected source revisions, takes the existing writer lock, recovers a pending
84
+ journal and uses `commitSyncTransaction` in exact mode. New decomposition outputs
85
+ precede source retirement. Original bytes, exact plan/selection, unchanged IDs and
86
+ engine version are retained in the final checkpoint. Canonical parser validation
87
+ precedes commit; the existing journal supplies deterministic roll-forward after
88
+ interruption. Index rebuild follows commit and is retried after completed replay.
89
+ There is no new rollback engine: checkpoint preimages support diagnosis/restoration,
90
+ while automatic recovery uses the existing roll-forward contract. Unselected
91
+ attention records remain byte-for-byte unchanged. No source file is silently erased.
92
+
93
+ Stale selected sources fail with their ID. Core can apply an unaffected selected
94
+ group using its original plan; the MCP UI currently refreshes the whole fingerprint
95
+ and conservatively rejects stale plans. Core replay of the same reviewed selection
96
+ is idempotent. Review grants expire when their invocation completes.
97
+
98
+ ## MCP, UI and text
99
+
100
+ `prodero_curation` provides plan/simulate/defer and remains available through
101
+ `prodero_text`. Graphical review now uses persistent server-owned snapshots,
102
+ staged Current/Suggested/Later decisions and a separate App-only apply tool.
103
+ The external `reviewCuration` startup callback is no longer required. The adapter
104
+ validates the entire plan under the writer lock before granting Core's exact-batch
105
+ permission. Text mode remains preview-only; legacy model-visible apply is closed.
106
+ See [App-first knowledge review](CURATION-APP-REVIEW.md) for protocol, retention,
107
+ replay, trust boundaries, compatibility and verification status.
108
+
109
+ Open may offer a non-blocking cleanup card; Prepare has no curation dependency.
110
+ Later persists a checkpoint tied to the exact recommendation, not a knowledge
111
+ record or policy rejection. Repeated Open suppresses unchanged deferred cards;
112
+ material canonical changes or a new analysis version can resurface them. Details
113
+ retain access. Analysis errors are caught by Open and do not block ordinary work.
114
+ No new recurring approval interaction is introduced.
115
+
116
+ ## Simulation and metrics
117
+
118
+ Simulation copies canonical memory and skills plus the current config into an
119
+ isolated temporary repository, writes actual proposed Markdown, and runs the real
120
+ `prepareContext` entry point before and after. It does not call lifecycle Prepare,
121
+ Sync, simplify ranking or adjust budgets. Temporary stores are removed in finally.
122
+ Metrics include real estimated candidate/selected/omitted tokens and counts,
123
+ relevant item-limit omissions, total tokens, unknown required and readiness.
124
+
125
+ Two explicit modes distinguish **safe batch** (attention unchanged) from a
126
+ conditional **all proposals** scenario (attention outputs included for measurement
127
+ only, still requiring further review). The default UI simulates the safe batch.
128
+ The latter is not a prediction that attention has been resolved or approved.
129
+
130
+ Current targets are Knowledge Schema v3 and Project Schema v8; curation itself does not advance schema versions. Retrieval,
131
+ required/relevant item limits, skill limits and token budgets are unchanged.
132
+
133
+ ## Limitations and scaling
134
+
135
+ Deterministic analysis makes zero model calls. Parsing/classification is linear in
136
+ source text; catalog/evidence grouping is in memory. Conflict cross-checking can
137
+ be quadratic in candidate count; optional expensive semantic work is not required
138
+ for project usability. This is not a complete semantic oracle: leading identifiers,
139
+ path-vs-domain boundaries, stale validity and complex conflicts can need refinement.
140
+ Current review supports bounded reasoning, clarification answers, deferral/reopening
141
+ and retry through the existing curation tools. This is not autonomous organization
142
+ cleanup, arbitrary rewriting or a new rollback UI.
@@ -0,0 +1,165 @@
1
+ # Knowledge authority and safe automatic memory
2
+
3
+ > v0.1 contract: Local/Versioned describe Git storage and sharing, not a security boundary against the connected agent. Review and approval are workflow safeguards, not authenticated human consent. The agent may create, promote and maintain Versioned files. Curator does not commit or push; users review repository changes before doing so. See [Privacy](PRIVACY.md).
4
+
5
+ Runtime policy reference. The current runtime extends this model with [Knowledge Schema v3 applicability](APPLICABILITY.md); authority and policy guarantees remain in force.
6
+
7
+ ## Core architecture
8
+
9
+ Current targets are Knowledge Schema v3 and Project Schema v8. The authority
10
+ checks are runtime policy checks, not a reinterpretation of existing knowledge.
11
+ `context_policy` remains independent of category, priority and authority.
12
+
13
+ `core/knowledge-authority.ts` evaluates transitions. `core/knowledge-write-policy.ts`
14
+ applies that decision to an entire canonical transaction **before** the durable
15
+ journal exists. Remember, deterministic and assisted Sync, imports, lifecycle
16
+ transformations, maintenance, supersession and publication converge on
17
+ `commitSyncTransaction`. Presentation does not decide authorization.
18
+
19
+ The adapter checks paths/preimages, loads only referenced canonical bodies through
20
+ the catalog, decides replacements before retirements, prevents protected rules from
21
+ being hidden by unauthorized supersession, then uses the existing journal,
22
+ checkpoint, index rebuild and recovery mechanism. Recovery replays an already
23
+ validated decision; serialized authority or evidence does not authorize new work.
24
+
25
+ The low-level `writeKnowledge` function is a trusted canonical-storage primitive
26
+ used by fixtures, not by any production inference writer. Migration, restore,
27
+ manual filesystem editing and arbitrary code running inside the Core process are
28
+ trusted administrative capabilities, outside the model-facing security boundary.
29
+ This is not a sandbox against a malicious plugin with filesystem/process access.
30
+
31
+ ## Authority and trust boundary
32
+
33
+ | Classification | Meaning | How it is established |
34
+ | --- | --- | --- |
35
+ | `inferred` | Agent/session-derived knowledge | Automatic default |
36
+ | `imported` | Imported source knowledge | Import adapter; relevant by default |
37
+ | `legacy_inherited` | Behavior mechanically inherited from v1 | Existing migration, never a new agent promotion |
38
+ | `explicit_user` | Rule attributed to an explicit user request | Model-mediated chat command or optional host adapter; the label is not authentication |
39
+ | `reviewed` | Exact policy change attributed to a review | Core embedding capability; provenance alone does not authenticate a person |
40
+
41
+ Classification is provenance, not a permission token or confidence score. Neither
42
+ `kind: rule`, evidence with `kind: user_instruction`, existing prose, a model-written
43
+ quote by itself, nor `approved: true` alone in tool arguments grants policy authority. The explicit Required chat command described below is a model-callable exception with bound content and request provenance. Existing
44
+ source-session, observation and evidence references are retained.
45
+
46
+ `withTrustedKnowledgeIntent` is an in-process, async-scoped capability bound to the
47
+ resolved project, exact content/category/scope/priority/status, intended policy,
48
+ auditable reference, and optionally exact source preimage. It expires when the
49
+ operation completes, including detached async callbacks. It is not persisted or
50
+ exposed as an MCP input. Entry points must bind the authorized operation; the engine cannot independently prove user intent relayed by an assistant or host.
51
+
52
+ `createServer({currentUserRule})` optionally accepts a **host-supplied** verifier.
53
+ It returns the current turn ID, actual user text, explicit mandatory intent and
54
+ exact intended content/scope/importance. `rememberCurrentUserRule` checks binding
55
+ and applies that intent without a second confirmation. No lexical classifier
56
+ pretends to prove intent. Generic, missing, mismatched or unavailable attestations
57
+ fall back to ordinary Remember when no explicit Required chat command is supplied. The stock stdio MCP transport does not provide authenticated user-turn intent.
58
+
59
+ For a direct user request such as "remember: always reply in Russian", the assistant may call `prodero_remember` with `kind: "rule"`, `required: true`, and `userInstruction` containing the exact current request. This explicit command authorizes only the supplied rule through the same scoped writer boundary; it records `chat-user-request` provenance, not a fabricated host attestation. The assistant must not use this command for inferred lessons, imported documents or embedded instructions. No second confirmation is required. Missing request text or a non-rule kind is rejected. The default applicability is the current project; path rules remain scoped. Ordinary Remember and automatic learning retain their existing Relevant defaults.
60
+
61
+ Use memory search and an exact `replaceId` to make an existing Relevant rule Required. The result reports its actual context policy. Open continues to load only applicable Required instructions; it does not include all Relevant rules.
62
+
63
+ ## Automatic versus reviewed transitions
64
+
65
+ - New facts, decisions, lessons and inferred instructions are relevant/inferred.
66
+ Newly imported instructions are relevant/imported. New inferred criticality is
67
+ capped at important; critical remains distinct from required.
68
+ - Category hints classify knowledge, never mandate delivery. Global instruction
69
+ candidates retain their existing pending lifecycle.
70
+ - Relevant wording refinement, deduplication and provenance enrichment remain
71
+ automatic within the original scope and policy/authority ceiling.
72
+ - Exact copies/publication retain existing policy and authority. Equal-policy,
73
+ equal-authority, equal-scope and equal-priority source clauses may be combined
74
+ losslessly; no new normative clause is granted by that combination.
75
+ - Protected records include required, critical, explicit_user and reviewed
76
+ knowledge. Inference cannot change their policy, authority, scope, priority,
77
+ category, protected clauses or effective active status. Safe whitespace
78
+ normalization and exact clause-preserving consolidation remain possible.
79
+ - Scope changes on existing inferred records are conservatively preserved too;
80
+ new replacements inherit a common source applicability boundary.
81
+ - Unauthorized new promotion is downgraded to a safe relevant record. Ambiguous
82
+ automatic edits preserve the original; changed content can be retained as a
83
+ separate relevant Local record with a relationship to the original.
84
+ - Exact requested protected mutations (maintenance/forget) fail before canonical
85
+ changes with `POLICY_REVIEW_REQUIRED`. A model-callable approval boolean cannot
86
+ select between incompatible authoritative states. Trusted Core intent can
87
+ authorize an exact change, including de-escalation.
88
+ - Publication review authorizes the publication layer only. It never establishes
89
+ `reviewed`, upgrades relevant to required, or grants new criticality.
90
+
91
+ Semantic equality is intentionally conservative: whole source clauses must be
92
+ preserved. An LLM assertion of equivalence is not proof. Paraphrases that cannot be
93
+ proven safe remain separate relevant knowledge, or require exact review when the
94
+ caller explicitly requests changing the original rule.
95
+
96
+ ## Writers and lifecycle
97
+
98
+ Remember saves an agent-selected rule as instruction/relevant/inferred. Generic
99
+ “remember this” remains ordinary memory. An unsafe replacement reports the preserved
100
+ source separately rather than falsely reporting that the original was replaced.
101
+
102
+ Deterministic Sync and assisted reconciliation use the same transaction gate.
103
+ Existing extractive validation, source verification, graph constraints and bounded
104
+ retrieval remain in place. Model prompts are not the enforcement mechanism.
105
+ A rejected protected rewrite can retain the new information locally without
106
+ retiring its authoritative source. Checkpoints retain aggregate transition reasons.
107
+
108
+ Memory Transformation applies the shared policy to proposed new records and skips
109
+ unsafe replacement/archive links. Clean Local transformations stay automatic.
110
+ Archive moves additionally validate the original source; moving to a new filename
111
+ cannot bypass protected retirement checks. Reviewed publication and instruction
112
+ optimization use exact policy validation at commit rather than silently applying
113
+ a different policy from the reviewed plan.
114
+
115
+ AI Studio classification is unchanged. Even historical text classified as an
116
+ instruction becomes relevant/imported on new import. Import/publication approval
117
+ is not approval to create a mandatory rule. Existing migrated records are untouched.
118
+
119
+ ## Review and presentation
120
+
121
+ Core distinguishes `allowed`, `allowed_with_safe_fallback`, `review_recommended`,
122
+ `review_required`, and `forbidden`, with reasons and an independent blocking flag.
123
+ Optional recommendations are aggregate checkpoint/Sync diagnostics, not a forced
124
+ queue, per-record approval popup, or permanent UI panel. There is no new memory
125
+ review prompt during an ordinary session. A batch may contain ten inferred
126
+ instructions and finish close/Sync/next Prepare without review.
127
+
128
+ Prepare exposes `policyReadiness` and UI blocking state for an **applicable explicit
129
+ required-policy contradiction or unresolved required dispute**. Merely matching
130
+ rule titles or suggesting promotion does not block work. The session remains
131
+ available; resolve the policy and retry Prepare with the same task/session. The
132
+ agent must honor this structured readiness state; Curator cannot stop unrelated
133
+ external tools from executing. Text and UI explain whether work must wait.
134
+
135
+ Policy mutation errors expose the same structured blocking/preserved state through
136
+ UI tools and the text gateway. Existing maintenance screens remain, but their
137
+ model-callable `approved` flag cannot authorize an otherwise protected edit.
138
+ The curation App adapter can grant exact reviewed mutations after validating saved
139
+ review state. This is a workflow consistency boundary, not authenticated human
140
+ consent. Optional host attestations are distinct from stock model-mediated chat
141
+ and App paths; v0.1 does not require a trusted-host authorization subsystem.
142
+
143
+ ## Compatibility and deferred work
144
+
145
+ Policy checks preserve existing protected metadata and use the current schema,
146
+ applicability and migration boundaries. See [Knowledge Schema v2](KNOWLEDGE-SCHEMA-V2.md)
147
+ for the historical policy-format migration and [Applicability](APPLICABILITY.md)
148
+ for the current v3 representation.
149
+
150
+ Optional future host attestations and richer normative-equivalence proofs are outside
151
+ the v0.1 contract. Current importer and applicability behavior is documented separately. Arbitrary content semantics cannot be proven by a generic LLM;
152
+ conservative retention is deliberate. Ordinary automatic inference does not grant Required policy. Exact chat commands,
153
+ validated review adapters, mechanical legacy migration and equivalent existing
154
+ policy use the current Core boundary. The connected agent can supply chat/review
155
+ arguments; these checks cannot prove who intended them.
156
+
157
+ ## Verification
158
+
159
+ Tests use temporary repositories, fixture records and in-memory MCP clients.
160
+ Coverage includes ordinary Remember, ten inferred observations, deterministic and
161
+ assisted Sync, protected source retention, escalation/de-escalation, trusted current
162
+ turns, stale/wrong-project/expired intent, imports, lifecycle archive/replacement,
163
+ publication, exact protected mutation errors, UI/text parity and conflict readiness.
164
+ Existing migration, v2 round-trip, cache, recovery, instruction consolidation and
165
+ full regression suites are also run. See [release verification](RELEASING.md) for reproducible validation.
@@ -0,0 +1,150 @@
1
+ # Knowledge Policy Schema v2
2
+
3
+ Historical schema reference. The current runtime extends this model with [Knowledge Schema v3 applicability](APPLICABILITY.md); authority and policy guarantees remain in force.
4
+
5
+ ## Architecture and canonical format
6
+
7
+ This transition introduced knowledge schema 2 on project schema 6. Current targets in
8
+ `prodero.release.json` are project 8 and knowledge 3; project-local `.prodero/config.json` remains authoritative.
9
+ The adjacent `knowledge-policy-1-2` compatible-semantic transition is registered in
10
+ Core's existing migration engine. There is no separate conversion command or lock.
11
+
12
+ Canonical Markdown frontmatter now includes:
13
+
14
+ ```yaml
15
+ version: 2
16
+ kind: knowledge
17
+ category: instruction
18
+ context_policy: relevant
19
+ authority: inferred
20
+ ```
21
+
22
+ Category describes the
23
+ kind of knowledge. `context_policy: required` selects mandatory delivery when
24
+ applicable; `relevant` uses ordinary retrieval and does not mean unimportant.
25
+ Priority, critical status, scope and relevance score retain their existing meanings.
26
+ All categories support relevant. Only instruction supports required in this phase.
27
+ Decision/constraint/invariant required combinations are rejected, not auto-promoted.
28
+
29
+ Core uses `version`, `contextPolicy`, `authority`. Record version is an explicit
30
+ parser discriminator, not another independently evolving project version axis.
31
+ Malformed v2 records missing version/policy/authority fail validation; project-bound
32
+ readers also reject v1 records in projects declaring knowledge v2. Pure serializers
33
+ have no project identity. Project-bound storage operations retain the Foundation's
34
+ newer-project/newer-knowledge barrier.
35
+
36
+ ## Authority and trust boundary
37
+
38
+ Authority values: `legacy_inherited`, `inferred`, `imported`, `explicit_user`,
39
+ `reviewed`. They classify the provenance basis of a policy, not confidence, priority,
40
+ or proof of authorization. Evidence stays in existing `evidence`, `sourceSessions`,
41
+ `derivedFrom` and relationship fields; no second evidence system was added.
42
+
43
+ No Phase 1A conversational, Sync or transformation writer grants explicit_user or
44
+ reviewed merely from agent assertions, user_instruction evidence, or publication
45
+ approval. Existing creation behavior uses inferred; imports use imported. Trusted
46
+ canonical input can represent stronger classifications, but consumers must not treat
47
+ that string as authenticated user intent. Phase 1B must establish the actual grant
48
+ boundary. Remember still creates required instructions as before, with conservative
49
+ inferred authority. This is intentional compatibility, not a completed safety model.
50
+
51
+ ## Mechanical migration and recovery
52
+
53
+ Every canonical record in both memory layers and both monthly archives is converted,
54
+ including historical/disputed records. Instructions become required; every other
55
+ category becomes relevant, including critical decisions. All migrated authority is
56
+ legacy_inherited. No model, content heuristics, scope inference or reclassification
57
+ runs. Modern frontmatter receives only structural metadata; bodies and unrelated
58
+ metadata are preserved. Legacy unstructured Markdown receives canonical defaults
59
+ matching its compatibility reader. The converter checks complete parsed-record
60
+ identity apart from the schema discriminator. Checkpoint preimages remain historical
61
+ evidence, not live canonical records, and are not rewritten.
62
+
63
+ Foundation planning/approval, full backup, staging, validation, cache rebuild,
64
+ journal, config-last commit, history and rollback are reused. Versions advance only
65
+ after staged v2 validates. Recovery restores preimages then retries. Current checks
66
+ are no-ops. The release's previous Foundation runtime rejects knowledge 2 at storage;
67
+ pre-Foundation runtimes reject project 6. This cannot protect arbitrary external
68
+ editors that bypass Prodero's storage contract.
69
+
70
+ ## Readers, writers, retrieval and contracts
71
+
72
+ The v1 compatibility reader alone derives policy from category. Normal v2 parsing
73
+ uses explicit metadata. The transitional draft creation adapter preserves existing
74
+ writer defaults until Phase 1B; its fallback never applies to parsed v2 records.
75
+ Render/read/edit/archive/publication preserve policy and authority. Same-category
76
+ replacements inherit source policy; mixed policies cannot be silently consolidated.
77
+ Instruction optimization groups by policy/authority as well as existing boundaries.
78
+
79
+ Prepare and Bootstrap share policy-based required applicability. Scope matching,
80
+ ranking, overflow, token budgets and item limits are unchanged. The Markdown router's
81
+ Required section now uses policy rather than global importance. Genuine instruction
82
+ category behavior remains in consolidation, protected merge checks, candidate
83
+ lifecycle, instruction editing/optimization, importer classification and category
84
+ filters. These are not globally replaced with policy checks.
85
+
86
+ MemoryIndex format 9 stores policy and authority, invalidating old disposable caches.
87
+ Canonical Markdown remains authoritative. Snapshot JSON retains canonical fields.
88
+ MCP exposes contextPolicy/authority on canonical records and summaries. The temporary
89
+ instruction `enforcement` alias is derived exclusively from contextPolicy; `kind`
90
+ continues to describe instruction category. Neither alias is canonical on disk.
91
+ Bootstrap's alias is required because that collection contains required records only.
92
+
93
+ Open/Prepare use the Foundation's temporary Knowledge update available view. The
94
+ same approved Core action is available through UI, chat/text and CLI; no shell is
95
+ needed. UI resumes the original tool call; text returns exact resumable arguments.
96
+ After migration normal views are unchanged; legacy authority is not added as a badge.
97
+ No new policy editor or promotion authorization surface is introduced.
98
+
99
+ ## Validation evidence
100
+
101
+ Permanent tests use synthetic records plus focused round trips, malformed data, historical migration,
102
+ selectors, cache deletion/rebuild, maintenance, publication, replacement, text resume,
103
+ older-runtime barriers, failure injection and interrupted production migration.
104
+ Foundation tests continue to cover UI approval, progress/resume, newer project
105
+ schemas, plan immutability and ordered synthetic future migrations.
106
+
107
+ ## Phase 1B escalation paths (historical Phase 1A audit)
108
+
109
+ These paths are now governed by [Knowledge authority](KNOWLEDGE-AUTHORITY.md).
110
+ The following describes the Phase 1A baseline, not current runtime permissions.
111
+
112
+ The following still require authority/intent enforcement, intentionally unchanged:
113
+
114
+ - Remember `kind: rule` and replacements: agent-supplied assertions of user intent.
115
+ - Session observations with `categoryHint: instruction` and deterministic Sync.
116
+ - Assisted distillation/reconciliation and audit-created instruction candidates.
117
+ - Memory Transformation/lifecycle creation that changes category into instruction.
118
+ - Import source classification (including must/should/use/run rules) and apply paths.
119
+ - Trusted direct Core draft writers, canonical manual edits, and future promotion APIs.
120
+ - Policy changes across explicit supersession/reclassification boundaries; publication
121
+ approval must remain distinct from approval to establish mandatory authority.
122
+
123
+ Global instruction candidates remain pending, and skill/instruction candidate review
124
+ retains its current checks. Phase 1A adds metadata preservation, not a claim that all
125
+ escalation routes are authorized. No applicability redesign, corpus cleanup, lexical
126
+ reclassification, new required categories, budgets/item-limit changes, evidence
127
+ verification, policy editor or complete authorization system is included.
128
+
129
+ ## Implementation map
130
+
131
+ - `core/knowledge-policy.ts`: supported combinations, strict policy validation,
132
+ compatibility draft adapter and policy-preserving replacement helper.
133
+ - `core/knowledge-migration.ts`, `core/migrations.ts`: production registry step,
134
+ current/archive traversal and mechanical equivalence validation.
135
+ - `core/memory.ts`, `core/types.ts`, `core/memory-index.ts`: canonical persistence,
136
+ compatibility parsing, shared model and disposable index format 9.
137
+ - `core/bootstrap.ts`, `core/context.ts`, `core/index.ts`: mandatory selection and
138
+ Required router labeling. No selection caps or applicability changes.
139
+ - `core/consolidation.ts`, `core/knowledge-engine.ts`, `core/knowledge-lifecycle.ts`,
140
+ `core/promotion.ts`, `core/instruction-review.ts`: writer/merge preservation.
141
+ - `core/imports.ts`: explicit imported classification with existing category logic.
142
+ - `core/knowledge-provenance.ts`, `core/memory-transformation-bundle.ts`,
143
+ `core/skill-curation.ts`, `core/sync-transaction.ts`: project-aware validation at
144
+ additional read/write boundaries.
145
+ - `test/knowledge-policy-v2.test.mjs`: focused production migration and v2 regressions.
146
+ Existing migration, project, scope and update tests use explicit format fixtures.
147
+
148
+ All paths above are relative to `src/` except the test path. The existing MCP server,
149
+ presentation model, UI handlers and CLI migration actions delegate to the same Core
150
+ engine; Phase 1A does not fork those implementations.
@@ -0,0 +1,103 @@
1
+ # Migration Foundation
2
+
3
+ ## Audit and reused mechanisms
4
+
5
+ Before this change, `core/migrations.ts` provided ordered project migrations 1→5,
6
+ canonical validation, backups, a recovery journal, cache invalidation, and rollback.
7
+ `storage.ts` rejected newer project schemas, checked paths/symlinks, and wrote files
8
+ with same-directory rename. `sync-transaction.ts` provided a shared process lock,
9
+ stale-owner recovery, and a separate Sync preimage journal. Initialization and Prepare
10
+ automatically migrated. Open loaded memory without first presenting compatibility.
11
+ MemoryIndex, session index and graph have disposable cache formats; config uses a
12
+ passthrough validator. MCP UI and text already share presentation contracts.
13
+
14
+ This extends that migration engine; there is no second conversion or lock system.
15
+
16
+ ## Versions and registries
17
+
18
+ `.prodero/config.json` is authoritative: `schemaVersion` describes project structure;
19
+ `knowledgeSchemaVersion` describes canonical knowledge. Missing knowledge version
20
+ means legacy format 1. Runtime targets come from `prodero.release.json`.
21
+ Project transition 5→6 only records knowledge version 1. It preserves record bytes.
22
+ The project bump also fences older, pre-foundation runtimes supporting only schema 5.
23
+ No sessions/skills/config version axes are introduced.
24
+ Project transition 6→7 refreshes the managed AGENTS.md block for text-only skill
25
+ execution. Open/Prepare use the existing update review. The migration snapshots
26
+ AGENTS.md, preserves text outside the managed block, commits it before the project
27
+ version, and restores it on failure without overwriting concurrent user edits.
28
+ Project transition 7→8 replaces the embedded block with a three-line reference to
29
+ `prodero_instructions_read`. This text-only MCP tool reads `instructions/AGENTS.md`
30
+ from its own installation, so dev/package switching needs no project edits. This is a one-time
31
+ project migration using the same approval, backup and rollback flow. Subsequent
32
+ instruction-only updates replace the packaged document and need no project schema
33
+ bump or edits to consumer repositories. Project/knowledge format changes still
34
+ require migrations.
35
+
36
+ `MIGRATIONS` and `KNOWLEDGE_MIGRATIONS` contain adjacent transitions. Descriptors
37
+ carry class, description, affected stores, transform and optional validation.
38
+ Classes are structural, compatible-semantic and review-required. The latter is
39
+ blocked until a migration-specific review resolver exists; `approved:true` never
40
+ substitutes for semantic decisions. The knowledge registry contains the ordered compatible-semantic `knowledge-policy-1-2` and `knowledge-applicability-2-3` transitions. The current target is knowledge schema 3; see [Knowledge Schema v2](KNOWLEDGE-SCHEMA-V2.md) and [Applicability](APPLICABILITY.md).
41
+
42
+ ## Package installation stays separate
43
+
44
+ `prodero update` updates only the verified npm package after terminal confirmation. It does not enumerate or migrate projects or change the selected dev checkout. After user restart/reconnect, Open/Prepare offer this existing migration gate only when project/knowledge formats require it. Chat update indicators and `prodero_update` provide terminal instructions, never package installation.
45
+
46
+ ## Planning, approval and continuation
47
+
48
+ `planProjectMigration` reads metadata without creating directories, sessions, caches
49
+ or recovering journals. It reports targets, ordered steps, backup policy, safety,
50
+ review/block state, runtime identity and a metadata/registry plan hash.
51
+ `applyProjectMigration` requires explicit approval bound to that plan; it rechecks
52
+ under the shared writer lock. Current projects are idempotent no-ops.
53
+
54
+ Open, lightweight/detailed status and Prepare inspect this plan before reading
55
+ canonical knowledge. Current projects have no migration controls. Other states use
56
+ one Core plan and one view-model in UI/text. `prodero_migrate` is also exposed through
57
+ `prodero_text`. CLI `migrate status` plans; `migrate` is explicit approval to update
58
+ (or restore an interrupted update). Review-required steps remain blocked.
59
+
60
+ An interrupted Prepare returns a resumable request containing its exact original
61
+ arguments. Migration preserves this request. The App invokes the actual original
62
+ tool after success; text agents can immediately invoke the returned request. This
63
+ is not a durable host task scheduler: following a client restart, the agent must use
64
+ the model-visible request. No session is created before compatibility is resolved.
65
+
66
+ ## Transaction and recovery
67
+
68
+ The existing shared lock excludes Sync/session/migration writers. A validated full
69
+ backup includes config, indexes, both knowledge layers, archives, sessions, skills
70
+ and checkpoints. Backups are outside disposable caches. A journal references the
71
+ backup, its integrity digest and diagnostic history before transformation begins.
72
+ Transforms and each transition's validation run in a separate staged project.
73
+
74
+ Derived indexes are rebuilt against the target schema in staging. Commit installs
75
+ canonical data and rebuilt indexes using atomic individual file replacements under
76
+ the journal/read fence, then writes the new version last. Disposable cache stamps
77
+ are revalidated by the usual loaders at their installed paths. This is a recoverable
78
+ logical transaction, not an operating-system atomic directory swap. Failure restores
79
+ the validated backup and invalidates derived caches. Interrupted transactions roll
80
+ back deterministically before a new attempt. Backup corruption blocks recovery;
81
+ Prodero never guesses missing preimages. Legacy v1 journals remain recoverable.
82
+ Partial backup creation cannot change canonical data; orphan backups may be retained.
83
+ History under `.prodero/.migrations` records IDs, versions, runtime, times, status and
84
+ backup reference. These ignored diagnostic files are not schema authority.
85
+
86
+ ## Knowledge format 2
87
+
88
+ Phase 1A registers knowledge 1→2 and makes explicit policy and conservative authority
89
+ canonical. Existing instruction behavior is preserved mechanically. See
90
+ [Knowledge Schema v2](KNOWLEDGE-SCHEMA-V2.md) for the schema and trust boundary.
91
+ Foundation runtimes reject newer knowledge versions at the common storage barrier;
92
+ pre-foundation runtimes reject project schema 6. UI metadata diagnostics remain
93
+ available without interpreting newer knowledge. Direct low-level serializers are
94
+ not project-bound storage APIs.
95
+
96
+ ## Boundaries
97
+
98
+ Recovery is rollback-and-retry, not arbitrary user rollback after later writes.
99
+ Backups are local recovery copies, not an off-machine disaster-recovery service.
100
+ No power-loss/fsync durability guarantee beyond the existing filesystem primitives
101
+ is added. External tools editing `.prodero` outside Prodero's lock are unsupported.
102
+ No global project registry, bulk migration or backup retention policy is provided.
103
+ Migration review is distinct from the curation review workflow.
@@ -0,0 +1,28 @@
1
+ # Privacy and local storage
2
+
3
+ ## v0.1 agent and Git trust model
4
+
5
+ v0.1 trust model: Local Knowledge is Git-ignored working state, not a security boundary against the connected agent. Versioned Knowledge is Git-shareable project state; the agent may create, promote and maintain it. Review/preview/approval steps are workflow safeguards, not authenticated human authorization; `approved:true` does not prove human consent. Curator does not commit or push. Users must review repository changes before committing or pushing.
6
+
7
+ The connected agent can read both layers and can supply the approval arguments itself. Exact hashes, revision checks, App-only visibility and reviewed-plan flags check workflow consistency; they do not authenticate a person. This applies equally to UI, text and generic/plugin dispatch. Do not store information here on the assumption that the agent cannot place it in Git-shareable files.
8
+
9
+ ## Storage and retention
10
+
11
+ Prodero canonical knowledge is plaintext local/project storage. Git-ignore rules keep normal learning out of new commits; they are not access control or encryption. Anyone who can read your working tree, filesystem backups or Git history may be able to read its contents.
12
+
13
+ - Local memories, inferred skill candidates and dismissed proposals live under `.prodero/local/`. Sessions and checkpoints are also ignored. These are durable data, not disposable cache.
14
+ - Runtime setup installs directory-wide Git exclusions for `local/`, `sessions/`, `checkpoints/`, `.cache/`, `.transactions/`, `.backups/` and `.migrations/` before creating runtime state. These cover interrupted writes and unknown filenames, with only the root `sessions/.gitkeep` and `checkpoints/.gitkeep` placeholders allowed. Atomic `*.tmp-*` files anywhere under `.prodero/` are also ignored. Existing user ignore rules and files are retained; ignore rules do not untrack files already in Git or prevent deliberate force-adds/ignore overrides.
15
+ - On POSIX platforms, Curator creates managed private directories with `0700` and files with `0600`, including atomic scratch files, Local knowledge/skills, sessions, checkpoints, caches, reviews/reasoning, transactions and migration recovery copies. Runtime setup tightens existing private store roots; checked access tightens the addressed private path, without recursively changing unrelated children. Dormant legacy files can retain old modes behind an owner-only parent until accessed. Linked files and other owners' inodes are not chmod targets; inability to enforce permissions fails the operation. Versioned files retain ordinary repository permissions. On Windows, POSIX chmod is skipped and native filesystem ACLs/inheritance apply; no owner-only Windows ACL guarantee is claimed. These modes are not encryption or a boundary against the same OS user, the connected agent or administrators.
16
+ - Versioned Knowledge lives in `.prodero/memory/`; explicitly created, promoted or imported skills live in `.prodero/skills/` (including legacy candidates). These are Git-shareable working-tree files, not necessarily committed or pushed. Normal session learning produces Local Knowledge; promotion, maintenance, skill creation, imports and selected Sync operations can change Versioned state.
17
+ - Ordinary `forget` retires Local Knowledge. It rejects Versioned Knowledge and asks for explicit repository maintenance. **Forget is not secure erase**: historical records, source sessions, checkpoints, recovery journals/backups, filesystem backups and Git history may retain content. Retiring a local superseder can make the unchanged versioned record relevant again.
18
+ - Secret screening rejects high-confidence credential patterns before normal memory/session/skill writes, publication and optional provider calls. Diagnostics omit the detected value. Obvious placeholders and environment-variable examples are supported. Detection is conservative, can reject legitimate examples, and is **not a universal DLP guarantee**. Do not enter credentials into Prodero. Manually edited or older unsafe canonical content is rejected when read; it is not silently deleted or scrubbed.
19
+ - Optional host sampling sends selected project content to the host/model for consolidation, promotion or skill curation. The adapter requests no additional host context, but the host/model's retention and privacy policies apply. Deterministic mode does not use this sampling path. MCP context/search results intentionally deliver selected knowledge to the calling agent, whose own policies also apply.
20
+ - Installed executable `.cjs` plugins are trusted local code, not a security sandbox. They may have the process's filesystem/network capabilities. Review plugins before installation; core screening cannot constrain arbitrary plugin behavior or another process editing the files.
21
+
22
+ If a real credential was stored, revoke or rotate it with its issuer. Review canonical data, recovery copies and publication history before deciding what to remove. Deleting `.cache/` or calling `forget` alone does not resolve an exposure. Prodero does not rewrite Git history automatically.
23
+
24
+ ## Import integrity hashing
25
+
26
+ Importer semantic ingestion retains its bounded text selection and common secret screening. Integrity digests additionally hash eligible ordinary files outside that selection to detect unrelated edits, but exclude recognized sensitive paths, private Curator runtime trees and Git-ignored files. An explicitly selected, screened Git-ignored legacy document can still participate as exact evidence, independently of tree hashing. Internal canonical-state integrity includes Local memory/skills/archive, sessions and checkpoints to protect concurrent-change and receipt checks; reviews, caches, transactions and backups are outside that snapshot.
27
+
28
+ Digest/snapshot passes have hard count, byte, depth, entry and time bounds and stream content instead of buffering whole files. This is not complete DLP: content-only credentials in ordinary eligible filenames can be read while hashing, and Git consults configuration/ignore metadata. No claim is made about unchanged excluded files. See [the detailed importer contract](../plugins/migrate_ai_studio/README.md#integrity-scope-and-limits-plugin-170).