agentera 3.0.0-dev.72 → 3.0.0-dev.75

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 (93) hide show
  1. package/README.md +111 -0
  2. package/bundle/.agentera-build-source.json +8 -0
  3. package/bundle/CHANGELOG.md +17 -17
  4. package/bundle/extract-corpus-parity.json +1 -1
  5. package/bundle/references/adapters/package-publication.json +49 -53
  6. package/bundle/references/adapters/package-registry.yaml +5 -1
  7. package/bundle/references/adapters/package-surface-characterization.md +6 -4
  8. package/bundle/references/analysis/evidence-tier-authority.yaml +45 -4
  9. package/bundle/references/analysis/personal-glossary-evaluation-authority.yaml +175 -0
  10. package/bundle/references/analysis/personal-glossary-evaluation-corpus.yaml +291 -0
  11. package/bundle/references/analysis/personal-glossary-holdout.yaml +192 -0
  12. package/bundle/references/analysis/verification-policy.yaml +8 -13
  13. package/bundle/references/artifacts/glossary-entry-contract.yaml +1533 -35
  14. package/bundle/references/cli/update-channels.yaml +2 -2
  15. package/bundle/references/cli/vocabulary.md +1 -1
  16. package/bundle/references/meta/retained-reference-authority.yaml +16 -1
  17. package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +11 -7
  18. package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +6 -3
  19. package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +13 -7
  20. package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +5 -0
  21. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +7 -0
  22. package/dist/.agentera-build-source.json +8 -0
  23. package/dist/analytics/extractCorpus/copilotSessions.js +13 -4
  24. package/dist/analytics/extractCorpus/core.js +223 -3
  25. package/dist/analytics/extractCorpus/corpus.js +18 -1
  26. package/dist/analytics/extractCorpus/cursorSessions.js +22 -4
  27. package/dist/analytics/extractCorpus/evidenceTiers.js +123 -17
  28. package/dist/analytics/extractCorpus/filesystemSources.js +4 -0
  29. package/dist/analytics/extractCorpus/index.js +2 -2
  30. package/dist/analytics/extractCorpus/jsonlSessions.js +52 -3
  31. package/dist/analytics/extractCorpus/sqliteSessions.js +12 -3
  32. package/dist/analytics/personalGlossaryAdmission.js +26 -46
  33. package/dist/analytics/personalGlossaryCandidateProjection.js +692 -0
  34. package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
  35. package/dist/analytics/personalGlossaryCandidateReadView.js +23 -0
  36. package/dist/analytics/personalGlossaryCurrentGeneration.js +25 -0
  37. package/dist/analytics/personalGlossaryDecision.js +203 -0
  38. package/dist/analytics/personalGlossaryExplicit.js +788 -0
  39. package/dist/analytics/personalGlossaryExplicitMining.js +285 -0
  40. package/dist/analytics/personalGlossaryExplicitScope.js +41 -0
  41. package/dist/analytics/personalGlossaryExplicitSegments.js +418 -0
  42. package/dist/analytics/personalGlossaryExplicitTypes.js +26 -0
  43. package/dist/analytics/personalGlossaryLexicalClassifier.js +175 -0
  44. package/dist/analytics/personalGlossaryProfile.js +13 -3
  45. package/dist/analytics/personalGlossaryRecurrence.js +618 -0
  46. package/dist/analytics/personalGlossaryReviewRecordStorage.js +428 -0
  47. package/dist/analytics/personalGlossaryReviewRecords.js +332 -0
  48. package/dist/capabilities/index.js +5 -1
  49. package/dist/capabilities/profile/instructions.js +50 -15
  50. package/dist/cli/commands/personalGlossaryCandidateReads.js +744 -0
  51. package/dist/cli/commands/personalGlossaryDecision.js +349 -0
  52. package/dist/cli/commands/personalGlossaryPublish.js +484 -0
  53. package/dist/cli/commands/personalGlossaryReviewRecordReads.js +209 -0
  54. package/dist/cli/commands/personalGlossaryReviewRecords.js +623 -0
  55. package/dist/cli/commands/prime/briefOrientation.js +118 -19
  56. package/dist/cli/commands/report.js +18 -2
  57. package/dist/cli/commands/schema.js +179 -0
  58. package/dist/cli/commands/verify.js +51 -9
  59. package/dist/cli/dispatch/lifecycle.js +51 -6
  60. package/dist/cli/help.js +48 -2
  61. package/dist/cli/migrationRequired.js +4 -1
  62. package/dist/core/atomicWriter.js +4 -1
  63. package/dist/core/developmentInvocation.js +4 -1
  64. package/dist/core/yaml.js +53 -1
  65. package/dist/eval/glossaryEvaluation.js +751 -0
  66. package/dist/eval/glossaryEvaluationProcess.js +29 -0
  67. package/dist/eval/glossaryEvaluationRunner.js +571 -0
  68. package/dist/eval/glossaryEvaluationSuccessReport.js +297 -0
  69. package/dist/registries/activationTuples.js +31 -3
  70. package/dist/registries/evidenceTierContract.js +4 -0
  71. package/dist/registries/explicitSegmentGrammarContract.js +619 -0
  72. package/dist/registries/glossaryCandidateContractPaths.js +6 -0
  73. package/dist/registries/glossaryCandidateContracts.js +820 -0
  74. package/dist/registries/glossaryCandidateDecisionAuthority.js +119 -0
  75. package/dist/registries/glossaryCandidateDecisionContract.js +62 -0
  76. package/dist/registries/glossaryCandidateProjectionAuthority.js +197 -0
  77. package/dist/registries/glossaryCandidateProjectionContract.js +104 -0
  78. package/dist/registries/glossaryEntryContract.js +105 -103
  79. package/dist/registries/glossaryEntryTemporal.js +12 -0
  80. package/dist/registries/glossaryMiningAuthority.js +764 -0
  81. package/dist/registries/glossaryProfileFullContract.js +24 -0
  82. package/dist/registries/glossaryReviewRecordsAuthority.js +426 -0
  83. package/dist/registries/glossaryReviewRecordsContract.js +129 -0
  84. package/dist/registries/glossaryTermIdentity.js +122 -0
  85. package/dist/registries/packagePublication.js +3 -3
  86. package/dist/registries/personalGlossaryContracts.js +1 -0
  87. package/dist/release/releaseMetadata.js +15 -8
  88. package/dist/upgrade/npxPlatformStatus.js +2 -1
  89. package/dist/upgrade/projectIntegration.js +7 -1
  90. package/dist/validate/activationArtifactEvidence.js +18 -4
  91. package/dist/validate/activationEvidenceManifest.js +101 -22
  92. package/package.json +2 -4
  93. package/dist/cli/commands/personalGlossary.js +0 -176
@@ -0,0 +1,209 @@
1
+ import { currentPersonalGlossaryReviewRecords, personalGlossaryReviewRecordsPath, readPersonalGlossaryReviewRecords, } from "../../analytics/personalGlossaryReviewRecords.js";
2
+ import { shellQuoteArgument } from "../../core/shell.js";
3
+ import { canonicalGlossaryJson, compareGlossaryUnicodeStrings } from "../../registries/glossaryTermIdentity.js";
4
+ import { glossaryEntryAuthorityPath } from "../../registries/glossaryEntryContract.js";
5
+ import { decodeListCursor, encodeListCursor, projectedListSnapshot } from "../../state/listCursor.js";
6
+ import { emitStructured } from "../structured.js";
7
+ const COLLECTION = "personal_glossary_review_records";
8
+ const CURSOR_VERSION = 1;
9
+ const MAX_CURSOR_UTF8_BYTES = 4_096;
10
+ function mapping(value) {
11
+ return value !== null && typeof value === "object" && !Array.isArray(value);
12
+ }
13
+ function listSyntax(value) {
14
+ return `${value.command} list [--status pending|terminal] [--limit N] [--cursor TOKEN] --format json`;
15
+ }
16
+ function exactSyntax(value) {
17
+ return `${value.command} get --review-id ID --candidate-id ID --candidate-revision REVISION --generation GENERATION --policy-version POLICY --format json`;
18
+ }
19
+ function failure(io, schemaVersion, command, syntax, example, body) {
20
+ emitStructured({ schemaVersion, command, status: "fail", error: { ...body, syntax, example } }, "json", io.out ?? ((text) => process.stdout.write(text)));
21
+ return 1;
22
+ }
23
+ function reviewSummary(record) {
24
+ return {
25
+ review_id: record.review_id,
26
+ candidate_id: record.candidate_id,
27
+ candidate_revision: record.candidate_revision,
28
+ candidate_capsule_sha256: record.candidate_capsule_sha256,
29
+ candidate_projection_sha256: record.candidate_projection_sha256,
30
+ host_receipt_sha256: record.host_receipt_sha256,
31
+ cli_decision_sha256: record.cli_decision_sha256,
32
+ semantic_fingerprint: record.semantic_fingerprint,
33
+ generation: record.generation,
34
+ policy_version: record.policy_version,
35
+ scope: record.scope,
36
+ reason: record.reason,
37
+ status: record.status,
38
+ disposition: record.disposition,
39
+ reopen_reason: record.reopen_reason,
40
+ queued_at: record.queued_at,
41
+ terminal_at: record.terminal_at,
42
+ expires_at: record.expires_at,
43
+ record_sha256: record.record_sha256,
44
+ };
45
+ }
46
+ function filters(options) {
47
+ return { status: options.status ?? null };
48
+ }
49
+ function reviewOrder(left, right) {
50
+ return Date.parse(right.queued_at) - Date.parse(left.queued_at) || compareGlossaryUnicodeStrings(left.review_id, right.review_id);
51
+ }
52
+ function serializedBytes(value) {
53
+ return Buffer.byteLength(`${JSON.stringify(value, null, 2)}\n`, "utf8");
54
+ }
55
+ function listFlags(options) {
56
+ return options.status ? ` --status ${shellQuoteArgument(options.status)}` : "";
57
+ }
58
+ function currentRecords(io, value, operation) {
59
+ const result = currentPersonalGlossaryReviewRecords();
60
+ if (result.status === "current")
61
+ return result;
62
+ return failure(io, value.retrievalSchemaVersion, `${value.command} ${operation}`, operation === "list" ? listSyntax(value) : exactSyntax(value), operation === "list" ? `${value.command} list --limit ${value.defaultLimit} --format json` : exactSyntax(value), {
63
+ class: result.status === "projection_unavailable" ? "current_binding_mismatch" : "review_records_unavailable",
64
+ message: result.status === "projection_unavailable"
65
+ ? "current review metadata cannot bind the current candidate projection"
66
+ : "the private current-user review records are unavailable or invalid",
67
+ recovery: result.status === "projection_unavailable"
68
+ ? "Create or repair the current candidate projection, then retry; no review metadata was changed."
69
+ : "Create or repair the private current-user review records, then retry; no review metadata was changed.",
70
+ });
71
+ }
72
+ /** Emit the bounded read-only list view for private review records. */
73
+ export function listPersonalGlossaryReviewRecords(io, options, value) {
74
+ const view = currentRecords(io, value, "list");
75
+ if (typeof view === "number")
76
+ return view;
77
+ const selectedFilters = filters(options);
78
+ const records = view.records.filter((record) => !options.status || record.status === options.status).sort(reviewOrder);
79
+ const snapshotId = projectedListSnapshot({ schemaVersion: value.retrievalSchemaVersion, command: `${value.command} list`, collection: COLLECTION, owner: value.owner, filters: selectedFilters, order: value.order, records: records.map((record) => record.record_sha256) });
80
+ let start = 0;
81
+ if (options.cursor) {
82
+ let cursor;
83
+ try {
84
+ cursor = decodeListCursor(options.cursor, personalGlossaryReviewRecordsPath(), glossaryEntryAuthorityPath());
85
+ }
86
+ catch {
87
+ return failure(io, value.retrievalSchemaVersion, `${value.command} list`, listSyntax(value), `${value.command} list --limit ${value.defaultLimit} --format json`, {
88
+ class: "cursor_invalid",
89
+ message: "review-list cursor is malformed or belongs to another local profile",
90
+ recovery: "Copy next_cursor exactly, or omit --cursor to restart from the current private review records; no review metadata was changed.",
91
+ });
92
+ }
93
+ if (cursor.version !== CURSOR_VERSION || cursor.collection !== COLLECTION || cursor.owner !== value.owner || cursor.limit !== options.limit || !mapping(cursor.filters) || canonicalGlossaryJson(cursor.filters) !== canonicalGlossaryJson(selectedFilters)) {
94
+ return failure(io, value.retrievalSchemaVersion, `${value.command} list`, listSyntax(value), `${value.command} list --limit ${value.defaultLimit} --format json`, {
95
+ class: "cursor_invalid",
96
+ message: "review-list cursor filters, owner, or limit do not match this request",
97
+ recovery: "Repeat the original status filter and limit, or omit --cursor to restart; no review metadata was changed.",
98
+ });
99
+ }
100
+ if (cursor.order !== value.order || cursor.snapshot_id !== snapshotId || typeof cursor.after !== "string") {
101
+ return failure(io, value.retrievalSchemaVersion, `${value.command} list`, listSyntax(value), `${value.command} list --limit ${value.defaultLimit} --format json`, {
102
+ class: "cursor_snapshot_unavailable",
103
+ message: "review-list cursor cannot resume the current private review snapshot",
104
+ recovery: "Omit --cursor to restart from the current private review records; no review metadata was changed.",
105
+ });
106
+ }
107
+ const position = records.findIndex((record) => record.review_id === cursor.after);
108
+ if (position < 0) {
109
+ return failure(io, value.retrievalSchemaVersion, `${value.command} list`, listSyntax(value), `${value.command} list --limit ${value.defaultLimit} --format json`, {
110
+ class: "cursor_snapshot_unavailable",
111
+ message: "review-list cursor continuation is unavailable",
112
+ recovery: "Omit --cursor to restart from the current private review records; no review metadata was changed.",
113
+ });
114
+ }
115
+ start = position + 1;
116
+ }
117
+ const entries = records.slice(start, start + options.limit);
118
+ const remaining = records.length - start - entries.length;
119
+ const nextCursor = remaining > 0 && entries.length > 0
120
+ ? encodeListCursor({ version: CURSOR_VERSION, collection: COLLECTION, owner: value.owner, filters: selectedFilters, limit: options.limit, order: value.order, snapshot_id: snapshotId, after: entries.at(-1).review_id }, personalGlossaryReviewRecordsPath(), glossaryEntryAuthorityPath())
121
+ : undefined;
122
+ const response = {
123
+ schemaVersion: value.retrievalSchemaVersion,
124
+ command: `${value.command} list`,
125
+ status: view.expired_records > 0 || view.stale_records > 0 ? "degraded" : "ok",
126
+ owner: value.owner,
127
+ entries: entries.map(reviewSummary),
128
+ counts: { total: records.length, candidate: records.length, returned: entries.length, remaining, omitted: remaining, continuation: remaining },
129
+ filters: selectedFilters,
130
+ snapshot: { id: snapshotId, first_page: !options.cursor, order: value.order, has_more: remaining > 0, candidate_count: records.length },
131
+ retention: { expired_records: view.expired_records, stale_records: view.stale_records, mutation: "forbidden" },
132
+ source: { kind: "user_local_review_records", owner: value.owner },
133
+ source_contract: {
134
+ authority: "references/artifacts/glossary-entry-contract.yaml",
135
+ cursor: value.cursorVocabulary,
136
+ cursor_authority: value.cursorAuthority,
137
+ cursor_binding: [...value.cursorBinding],
138
+ cursor_invalid_behavior: value.cursorInvalidBehavior,
139
+ cursor_unavailable_behavior: value.cursorUnavailableBehavior,
140
+ },
141
+ retrieval: {
142
+ get: `${value.command} get --review-id ID --candidate-id ID --candidate-revision REVISION --generation GENERATION --policy-version POLICY --format json`,
143
+ ...(nextCursor ? { continue: `${value.command} list${listFlags(options)} --limit ${options.limit} --cursor ${nextCursor} --format json` } : {}),
144
+ },
145
+ ...(remaining > 0 ? { omitted: true, omitted_count: remaining, omission_reason: "page_limit", next_cursor: nextCursor } : {}),
146
+ };
147
+ if (serializedBytes(response) > value.listMaxSerializedUtf8Bytes) {
148
+ return failure(io, value.retrievalSchemaVersion, `${value.command} list`, listSyntax(value), `${value.command} list --limit ${value.defaultLimit} --format json`, {
149
+ class: "output_bound_exceeded",
150
+ message: `review-list response exceeds its ${value.listMaxSerializedUtf8Bytes}-byte bound`,
151
+ recovery: "Request fewer rows and retry; no partial review metadata was returned.",
152
+ });
153
+ }
154
+ emitStructured(response, "json", io.out ?? ((text) => process.stdout.write(text)));
155
+ return 0;
156
+ }
157
+ /** Emit one bounded exact read after rechecking the current projection binding. */
158
+ export function getPersonalGlossaryReviewRecord(io, options, value) {
159
+ const view = currentRecords(io, value, "get");
160
+ if (typeof view === "number")
161
+ return view;
162
+ const raw = readPersonalGlossaryReviewRecords().store?.records.find((record) => record.review_id === options.reviewId);
163
+ if (!raw) {
164
+ return failure(io, value.retrievalSchemaVersion, `${value.command} get`, exactSyntax(value), exactSyntax(value), {
165
+ class: "not_found",
166
+ message: "review identity was not found in the current private record store",
167
+ recovery: "List the current private review records and retry with one returned identity; no review metadata was changed.",
168
+ });
169
+ }
170
+ const record = view.records.find((item) => item.review_id === options.reviewId);
171
+ if (!record) {
172
+ return failure(io, value.retrievalSchemaVersion, `${value.command} get`, exactSyntax(value), exactSyntax(value), {
173
+ class: "current_binding_mismatch",
174
+ message: "review identity is stale, expired, or not bound to the current candidate projection",
175
+ recovery: "List the current private review records and retry with one current identity; no review metadata was changed.",
176
+ });
177
+ }
178
+ if (record.candidate_id !== options.candidateId || record.candidate_revision !== options.candidateRevision || record.generation !== options.generation || record.policy_version !== options.policyVersion) {
179
+ return failure(io, value.retrievalSchemaVersion, `${value.command} get`, exactSyntax(value), exactSyntax(value), {
180
+ class: "current_binding_mismatch",
181
+ message: "review exact-read bindings do not match the current record",
182
+ recovery: "List the current private review records and copy every exact binding; no review metadata was changed.",
183
+ });
184
+ }
185
+ const response = {
186
+ schemaVersion: value.retrievalSchemaVersion,
187
+ command: `${value.command} get`,
188
+ status: "ok",
189
+ owner: value.owner,
190
+ record: reviewSummary(record),
191
+ source: { kind: "user_local_review_records", owner: value.owner },
192
+ source_contract: {
193
+ authority: "references/artifacts/glossary-entry-contract.yaml",
194
+ bindings: [...value.exactBindings],
195
+ max_serialized_utf8_bytes: value.exactMaxSerializedUtf8Bytes,
196
+ current_binding: "candidate_projection_sha256",
197
+ mutation: "forbidden",
198
+ },
199
+ };
200
+ if (serializedBytes(response) > value.exactMaxSerializedUtf8Bytes) {
201
+ return failure(io, value.retrievalSchemaVersion, `${value.command} get`, exactSyntax(value), exactSyntax(value), {
202
+ class: "output_bound_exceeded",
203
+ message: `review exact-read response exceeds its ${value.exactMaxSerializedUtf8Bytes}-byte bound`,
204
+ recovery: "Repair the private review records before retrying; no partial review metadata was returned.",
205
+ });
206
+ }
207
+ emitStructured(response, "json", io.out ?? ((text) => process.stdout.write(text)));
208
+ return 0;
209
+ }