diff --git a/docs/adr/0001-learning-extension-architecture.md b/docs/adr/0001-learning-extension-architecture.md index 0f7657e3a..230cbf7e8 100644 --- a/docs/adr/0001-learning-extension-architecture.md +++ b/docs/adr/0001-learning-extension-architecture.md @@ -2,7 +2,7 @@ Status: proposed on October 6, 2026, and revised on October 10, 2026 to follow the requirements the Replica maintainers agreed on. Needs review by the Replica maintainers. -The learning package, providers, CLI, and demos still work. Hub descriptions below record an earlier proposal, not what the [new Hub](../../hub/README.md) can do today. It does not collect comments, run learning jobs, store learning data, sign people in, or connect Copilot. Adding those features requires separate product and architecture decisions. +The learning package, providers, CLI, and demos implement this architecture. The [new Hub](../../hub/README.md) now stores review conversations, captures complete repository snapshots, connects Copilot, runs explicit learning jobs, records decisions, recalls accepted guidance, and redacts deleted comment text. Daily change-driven discovery remains separate work. ## Context @@ -96,9 +96,9 @@ Each import records whether every list page and reply page was present. The impo ### Integration with Hub -The earlier proposal had Hub run `replica-learning` for every step, so the package's rules applied throughout. It kept one store per repository outside any checkout. A background job imported review comments, removed deleted text, labeled new or edited comments, and proposed learnings. Administrators reviewed proposals, and the plugin read accepted learnings. The [new Hub](../../hub/README.md) does not run these steps. +Hub runs `replica-learning` for every step, so the package's rules apply throughout. It keeps one store per repository outside any checkout. An explicit background job imports review comments, removes deleted text, labels new or edited comments, and proposes learnings. Administrators review proposals, and recall returns accepted learnings for agents. -The package can label through the [Copilot SDK](https://github.com/github/copilot-sdk). Its session has no tools, refuses every permission request, and never sees who wrote a comment. Copilot chooses the model unless the store's configuration names one, and each run records the usage Copilot reports. The new Hub does not set up or authorize this connection. +The package can label through the [Copilot SDK](https://github.com/github/copilot-sdk). Its session has no tools, refuses every permission request, treats comment text as untrusted data rather than instructions, and never sees who wrote a comment. Copilot chooses the model unless the store's configuration names one, and each run records the usage Copilot reports. Hub supplies only a currently usable configured credential. The command still runs in a checkout, with data under `.replica/learning/`, for contributors and for other hosts. This complements #230: its discovery output can become labels, and its judge can become a consolidator. diff --git a/hub/docs/architecture.md b/hub/docs/architecture.md index 9f9299072..8afd32d4e 100644 --- a/hub/docs/architecture.md +++ b/hub/docs/architecture.md @@ -24,7 +24,7 @@ The [Pino integration](logging.md) writes structured application and HTTP logs t The [prototype details editor](frontend.md#prototype-metadata-edits) lets signed-in members edit visible prototypes and register drafts. Hub holds session authority and prototype visibility locks through the write and detail read-back. -The [background-job foundation](background-jobs.md) uses BullMQ with PostgreSQL and separate on-demand and scheduled worker processes. Setup migrates BullMQ's own schema independently of Prisma. Product processors and schedules are not registered yet. +The [background-job foundation](background-jobs.md) uses BullMQ with PostgreSQL and separate on-demand and scheduled worker processes. Setup migrates BullMQ's own schema independently of Prisma. Learnings registers on-demand run and redaction processors plus one scheduled recovery sweep. The [artifact storage domain](artifact-storage.md) selects filesystem or managed-identity Azure Blob storage behind one immutable-byte contract. Future product domains call this provider-neutral API, not SDK integrations directly. Startup validates explicitly configured storage, but no product route or processor consumes artifact bytes yet. @@ -46,7 +46,7 @@ The administrator session-revocation API and retained frontend show current Hub The deployment-wide Copilot connection API and retained `/settings/copilot` frontend require a live administrator session. Hub obtains a credential from the configured provider and verifies it through the separate `replica-learning` process, then locks the persistent connection generation and rereads authority before committing the connection and typed security audit together. The database stores the provider key and configuration digest, never the credential. -The [learning foundation](learning-foundation.md) validates private storage, isolates the command's environment and temporary state, bounds output and execution time, and provides a PostgreSQL execution lock plus repository-store preparation primitive. The [review backend](review-collaboration.md) now provides complete repository snapshots with stable actors, deleted-message markers, and ordered resolution history. Learning import, runs, decisions, redaction execution, and recall remain unimplemented. +The [learning foundation](learning-foundation.md) validates private storage, isolates the command's environment and temporary state, bounds output and execution time, and provides a PostgreSQL execution lock plus repository-store preparation primitive. The repository API reads exact review evidence, accepted guidance, recall, and persisted run history; records accept, edit, reject, and retire decisions through the package store; and queues explicit runs. Workers import complete [review backend](review-collaboration.md) snapshots, label and consolidate within fixed bounds, preserve usage and failures, and redact deleted comment text. ## Frontend diff --git a/hub/docs/background-jobs.md b/hub/docs/background-jobs.md index 57f348134..5c62b7af6 100644 --- a/hub/docs/background-jobs.md +++ b/hub/docs/background-jobs.md @@ -15,7 +15,7 @@ Each command starts one Node.js process consuming only its assigned queue. The A `ON_DEMAND_JOB_CONCURRENCY` and `SCHEDULED_JOB_CONCURRENCY` independently set the number of active jobs per worker process. Both default to one and accept integers from 1 through 100. CPU-heavy JavaScript still blocks that worker's event loop; move that work to a subprocess or an appropriate execution boundary when adding the domain. -`server/workers/configuration.ts` is the composition point for processors and schedules. Its empty registrations are intentional until product domains exist. Worker startup logs readiness after connecting; unknown job names fail permanently rather than disappearing. +`server/workers/configuration.ts` is the composition point for processors and schedules. Learnings registers explicit run and review-comment redaction work on `on-demand`. A one-minute scheduled recovery sweep re-enqueues queued runs and deleted-comment redactions with stable job IDs. Worker startup logs readiness after connecting; unknown job names fail permanently rather than disappearing. Worker readiness confirms initial connection only; it is not continuous consumer-health monitoring. A later connection error is logged but does not clear the combined runtime's worker-initialized signal. diff --git a/hub/docs/frontend.md b/hub/docs/frontend.md index 9d77e4649..b42516073 100644 --- a/hub/docs/frontend.md +++ b/hub/docs/frontend.md @@ -237,7 +237,7 @@ Errors use an HTTP status and `{ "error": "..." }`. Request schemas and the same The [product contracts](../client/application/hub/product-contracts/index.ts), [Learnings contracts](../client/application/hub/learnings-contracts/index.ts), [settings contracts](../client/application/hub/settings-contracts/index.ts), and [session contracts](../client/application/hub/session-contracts/index.ts) define those provisional records. The review adapter injects this request boundary into the retained review hooks without changing their default consumers. Persona selection, scenarios, diagnostics, fixture generation, and local mutation rules belong to the mock runtime, not these contracts. -The Learnings backend still needs all three listed endpoints. Its read response must make repository authorization authoritative, return access denial without suggestion or evidence data, distinguish Hub-wide Copilot connection state from repository decision permission, and return exact review digests, replacement targets, evidence and contradiction counts, accepted-learning integrity states, recall text, recent run results, and decimal AI-credit usage. Decision writes must reject a stale digest and validate decision-specific fields. Run and decision writes must reread repository-administrator authority and return visible `403`, `409`, or `422` errors rather than success-shaped empty data. The local handlers keep only tab-lifetime development state and do not provide persistence, jobs, repository discovery, review import, or Copilot execution. +The Learnings backend implements all three listed endpoints. Its read response makes current authorization authoritative, returns access denial without suggestion or evidence data, distinguishes Hub-wide Copilot connection state from decision permission, and returns exact repository evidence, accepted-learning integrity states, recall text, recent persisted run results, and decimal AI-credit usage. Decision writes validate decision-specific fields, invoke the package store, reject stale review digests with `409`, and record typed security audits. Run and decision writes reread current administrator authority. A run request captures and digests one complete repeatable-read review snapshot before it creates and queues a run; a changed, incomplete, or unavailable snapshot fails visibly rather than producing a no-op success. ## Removing mocks diff --git a/hub/docs/learning-foundation.md b/hub/docs/learning-foundation.md index 345ba0ace..f01adb28d 100644 --- a/hub/docs/learning-foundation.md +++ b/hub/docs/learning-foundation.md @@ -1,6 +1,6 @@ # Learning foundation -Hub can persist one deployment-wide Copilot connection and run the host-neutral [`replica-learning`](../../packages/learning/README.md) command through a bounded process boundary. The review backend can capture one complete repository snapshot, but learning imports, runs, decisions, redactions, and recalls are not connected yet. +Hub can persist one deployment-wide Copilot connection and run the host-neutral [`replica-learning`](../../packages/learning/README.md) command through a bounded process boundary. The repository Learnings API reads exact evidence, accepted guidance, recall previews, and persisted run history; records accept, edit, reject, and retire decisions; and queues explicit runs. Workers import complete review snapshots, label and consolidate them, and redact deleted comment text. The package remains the authority for consent, purpose, evidence, approval, redaction, and learning lifecycle rules. Hub does not reimplement those rules. @@ -22,9 +22,9 @@ Disconnecting removes the connection record and advances the generation. It does `REPLICA_LEARNING_ROOT` defaults to `storage/learning`. It must be a dedicated directory outside every configured static-file root. Hub rejects the filesystem root, the Hub application root, the shared `storage` root, the source public directory, the configured built-client directory and their descendants, files, and paths containing symbolic links. The check runs at startup and again when a repository store is prepared. -A future repository learning integration supplies the persisted repository UUID and package scope such as `github.com/repositories/123`. The store primitive creates `/repositories/` with mode `0700` and writes the package's default `config.json` with mode `0600` only when it is absent. Existing configuration remains operator-owned. +The repository learning integration supplies the persisted repository UUID and package scope `github.com/repositories/`. The store primitive creates `/repositories/` with mode `0700` and writes the package's default `config.json` with mode `0600` only when it is absent. Existing configuration remains operator-owned. -Hub does not create stores or invoke repository learning commands yet. +Decision commands use an existing store and never create one implicitly. The first complete review import prepares the store. ## Command boundary @@ -36,7 +36,27 @@ The runner starts Node.js with the configured CLI entry point, appends `--json`, Hub passes store paths and repository scope as command arguments, not inherited `REPLICA_LEARNING_*` variables. It does not pass database, authentication, workload-identity, storage, or other deployment credentials. Standard output is limited to 16 MiB, standard error to 1 MiB, and the default deadline is 60 seconds. A timeout, output overflow, cancellation, or surviving descendant kills the command's process group before Hub removes the temporary directory. -Later repository mutations use the PostgreSQL advisory-lock primitive for one Hub-wide learning execution at a time. Losing that database connection aborts the operation and its command through the shared signal. This preserves the CLI process boundary without moving package policy into Hub. +Repository decisions, runs, and redactions use the PostgreSQL advisory-lock primitive for one Hub-wide learning execution at a time. Losing that database connection aborts the operation and its command through the shared signal. This preserves the CLI process boundary without moving package policy into Hub. + +## Repository API + +The browser contracts are: + +- `GET /api/repositories/:repositoryId/learnings` +- `POST /api/repositories/:repositoryId/learnings/runs` +- `POST /api/repositories/:repositoryId/learnings/:learningId/decision` + +Current product authorization has Hub members and Hub administrators but no repository-specific role model. Signed-in members receive the Learnings contract's access-denied response without suggestion, evidence, permission, Copilot, or usage data. Hub administrators may read accepted guidance and recall previews and may make decisions. Every write rereads the live session and administrator authority immediately before it reaches the package store. + +The read response lists the ten newest persisted runs and decimal Copilot usage from runs started during the previous 30 days. It resolves every displayed package event against the current repository snapshot and shows the exact imported event body only when the event, episode, comment, Hub origin, and repository all match. Deleted comments remain visible as redacted evidence without text. + +Decision inputs follow the browser schema. Accept and reject require the exact reviewed digest; package `stale_review` failures return `409` rather than applying a changed suggestion. Reject and retire require a reason. Edited acceptance writes the proposed content to a private temporary file because command-line arguments must not carry review text. Successful and failed package decisions write typed security audits without storing content, evidence, or reasons. + +The run endpoint requires a usable Copilot connection. It captures and digests one complete repeatable-read repository review snapshot, creates or reuses the repository's active run, writes its typed request audit, and enqueues one idempotent on-demand job. Enqueue failure marks a newly created run failed. A scheduled recovery sweep re-enqueues queued runs. + +The worker claims a queued run only once under the learning execution lock. It recaptures the snapshot and refuses drift, prepares the private store, records the initial review and instruction grant when no earlier Hub review grant exists, imports with `--redact-deleted`, labels at most 400 comments and ten Copilot requests, and consolidates at most ten suggestions over the previous 90 days. It records partial label counts and AI-credit usage even when a later request fails. An incomplete collection, changed snapshot, ended consent, refused credential, or unreadable package result becomes a visible failed run. + +Soft deletion queues an idempotent package redaction job after the review transaction commits. The recovery sweep also finds deleted review comments, and every later import uses `--redact-deleted`, so a transient queue failure cannot make a deleted body permanently eligible. ## Configuration @@ -54,14 +74,6 @@ Later repository mutations use the PostgreSQL advisory-lock primitive for one Hu The environment-token mode may obtain its secret through a platform secret reference, but the learning child receives only the allowlisted values above. The GitHub App provider supplies a fresh credential for each command without changing that process boundary, so short-lived credentials are never durable connection identity. Organization Copilot model policy, budget controls, and installation revocation continue to apply to every request. -## Remaining integration seam - -Repository learning runs can consume `captureRepositoryReviewSnapshot()` from the [review backend](review-collaboration.md#learning-snapshot-seam). A future orchestration layer can: - -1. Authorize the repository operation. -2. Derive a stable package scope and prepare its store. -3. Acquire the learning execution lock. -4. Capture the complete repeatable-read review snapshot. -5. Invoke package import, labeling, consolidation, decision, redaction, or recall commands. +## Current limits -That integration must keep the package's consent and lifecycle rules intact. It must not create another Hub review store or omit deleted-message and resolution-history records from the imported snapshot. +The first production flow is explicit: a repository administrator requests a run. Hub does not yet schedule daily discovery runs based on comment changes. Repository-specific roles are also not modeled yet, so current product authorization uses live Hub administrator authority. The package remains authoritative for consent, evidence eligibility, lifecycle, recall, and redaction. diff --git a/hub/schema/learning-decision-operation.prisma b/hub/schema/learning-decision-operation.prisma new file mode 100644 index 000000000..cff77302b --- /dev/null +++ b/hub/schema/learning-decision-operation.prisma @@ -0,0 +1,21 @@ +model LearningDecisionOperation { + // ID columns + id String @id @default(uuid()) @db.Uuid + repositoryId String @map("repository_id") @db.Uuid + actorMembershipId String @map("actor_membership_id") @db.Uuid + + // Relations + repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) + actorMembership Membership @relation(fields: [actorMembershipId], references: [id], onDelete: Cascade) + + // Attribute columns + learningId String @map("learning_id") @db.VarChar(255) + decision String @db.VarChar(20) + + // Timestamp columns + createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3) + updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(3) + + @@index([repositoryId, createdAt]) + @@map("learning_decision_operations") +} diff --git a/hub/schema/learning-run-state.enum.prisma b/hub/schema/learning-run-state.enum.prisma new file mode 100644 index 000000000..9ea425d2b --- /dev/null +++ b/hub/schema/learning-run-state.enum.prisma @@ -0,0 +1,6 @@ +enum LearningRunState { + QUEUED + RUNNING + SUCCEEDED + FAILED +} diff --git a/hub/schema/learning-run.prisma b/hub/schema/learning-run.prisma new file mode 100644 index 000000000..df8fcbf3b --- /dev/null +++ b/hub/schema/learning-run.prisma @@ -0,0 +1,38 @@ +model LearningRun { + // ID columns + id String @id @default(uuid()) @db.Uuid + repositoryId String @map("repository_id") @db.Uuid + requestedById String? @map("requested_by_id") @db.Uuid + requestedByMembershipId String? @map("requested_by_membership_id") @db.Uuid + number Int @unique @default(autoincrement()) + + // Relations + repository Repository @relation(fields: [repositoryId], references: [id], onDelete: Cascade) + requestedBy User? @relation(fields: [requestedById], references: [id], onDelete: SetNull) + requestedByMembership Membership? @relation(fields: [requestedByMembershipId], references: [id], onDelete: SetNull) + + // Attribute columns + scheduled Boolean @default(false) + state LearningRunState @default(QUEUED) + commentsConsidered Int @default(0) @map("comments_considered") + commentsLabeled Int @default(0) @map("comments_labeled") + commentsRemaining Int @default(0) @map("comments_remaining") + suggestions Int @default(0) + suggestionsRemaining Int @default(0) @map("suggestions_remaining") + copilotRequests Int @default(0) @map("copilot_requests") + aiCredits Decimal @default(0) @map("ai_credits") @db.Decimal(20, 9) + snapshotDigest String @map("snapshot_digest") @db.VarChar(71) + failureCode String? @map("failure_code") @db.VarChar(60) + failureSummary String? @map("failure_summary") @db.VarChar(1000) + startedAt DateTime? @map("started_at") @db.Timestamptz(3) + finishedAt DateTime? @map("finished_at") @db.Timestamptz(3) + + // Timestamp columns + createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3) + updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(3) + + @@index([requestedById]) + @@index([requestedByMembershipId]) + @@index([repositoryId, createdAt]) + @@map("learning_runs") +} diff --git a/hub/schema/membership.prisma b/hub/schema/membership.prisma index 10f52ec08..6fd4bde6d 100644 --- a/hub/schema/membership.prisma +++ b/hub/schema/membership.prisma @@ -9,6 +9,8 @@ model Membership { sessions HubSession[] sensitiveAuthorizations SensitiveAuthorization[] copilotConnections CopilotConnection[] + learningRuns LearningRun[] + learningDecisionOperations LearningDecisionOperation[] // Attribute columns lifecycle MembershipLifecycle @default(ACTIVE) diff --git a/hub/schema/migrations/20261113190000_learning_run_foundation/migration.sql b/hub/schema/migrations/20261113190000_learning_run_foundation/migration.sql new file mode 100644 index 000000000..ca19602bb --- /dev/null +++ b/hub/schema/migrations/20261113190000_learning_run_foundation/migration.sql @@ -0,0 +1,98 @@ +CREATE TYPE "LearningRunState" AS ENUM ('QUEUED', 'RUNNING', 'SUCCEEDED', 'FAILED'); + +ALTER TABLE "review_comments" +ADD COLUMN "learning_redaction_actor" VARCHAR(300), +ADD COLUMN "learning_redacted_at" TIMESTAMPTZ(3); + +CREATE INDEX "review_comments_pending_learning_redaction_idx" +ON "review_comments"("deleted_at", "id") +WHERE "deleted_at" IS NOT NULL AND "learning_redacted_at" IS NULL; + +CREATE TABLE "learning_decision_operations" ( + "id" UUID NOT NULL, + "repository_id" UUID NOT NULL, + "actor_membership_id" UUID NOT NULL, + "learning_id" VARCHAR(255) NOT NULL, + "decision" VARCHAR(20) NOT NULL, + "created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "learning_decision_operations_pkey" PRIMARY KEY ("id"), + CONSTRAINT "learning_decision_operations_decision_check" + CHECK ("decision" IN ('accept', 'reject', 'retire')) +); + +CREATE INDEX "learning_decision_operations_repository_id_created_at_idx" +ON "learning_decision_operations"("repository_id", "created_at"); + +ALTER TABLE "learning_decision_operations" +ADD CONSTRAINT "learning_decision_operations_repository_id_fkey" +FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE "learning_decision_operations" +ADD CONSTRAINT "learning_decision_operations_actor_membership_id_fkey" +FOREIGN KEY ("actor_membership_id") REFERENCES "memberships"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +CREATE TABLE "learning_runs" ( + "id" UUID NOT NULL, + "repository_id" UUID NOT NULL, + "requested_by_id" UUID, + "requested_by_membership_id" UUID, + "number" SERIAL NOT NULL, + "scheduled" BOOLEAN NOT NULL DEFAULT false, + "state" "LearningRunState" NOT NULL DEFAULT 'QUEUED', + "comments_considered" INTEGER NOT NULL DEFAULT 0, + "comments_labeled" INTEGER NOT NULL DEFAULT 0, + "comments_remaining" INTEGER NOT NULL DEFAULT 0, + "suggestions" INTEGER NOT NULL DEFAULT 0, + "suggestions_remaining" INTEGER NOT NULL DEFAULT 0, + "copilot_requests" INTEGER NOT NULL DEFAULT 0, + "ai_credits" DECIMAL(20,9) NOT NULL DEFAULT 0, + "snapshot_digest" VARCHAR(71) NOT NULL, + "failure_code" VARCHAR(60), + "failure_summary" VARCHAR(1000), + "started_at" TIMESTAMPTZ(3), + "finished_at" TIMESTAMPTZ(3), + "created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "learning_runs_pkey" PRIMARY KEY ("id"), + CONSTRAINT "learning_runs_counts_check" CHECK ( + "comments_considered" >= 0 AND + "comments_labeled" >= 0 AND + "comments_remaining" >= 0 AND + "suggestions" >= 0 AND + "suggestions_remaining" >= 0 AND + "copilot_requests" >= 0 AND + "ai_credits" >= 0 + ), + CONSTRAINT "learning_runs_snapshot_digest_check" CHECK ( + "snapshot_digest" ~ '^sha256:[0-9a-f]{64}$' + ), + CONSTRAINT "learning_runs_result_check" CHECK ( + ("state" = 'FAILED' AND "failure_code" IS NOT NULL AND "failure_summary" IS NOT NULL AND "finished_at" IS NOT NULL) OR + ("state" = 'SUCCEEDED' AND "started_at" IS NOT NULL AND "failure_code" IS NULL AND "failure_summary" IS NULL AND "finished_at" IS NOT NULL) OR + ("state" = 'QUEUED' AND "started_at" IS NULL AND "failure_code" IS NULL AND "failure_summary" IS NULL AND "finished_at" IS NULL) OR + ("state" = 'RUNNING' AND "started_at" IS NOT NULL AND "failure_code" IS NULL AND "failure_summary" IS NULL AND "finished_at" IS NULL) + ) +); + +CREATE UNIQUE INDEX "learning_runs_number_key" ON "learning_runs"("number"); +CREATE INDEX "learning_runs_requested_by_id_idx" ON "learning_runs"("requested_by_id"); +CREATE INDEX "learning_runs_requested_by_membership_id_idx" ON "learning_runs"("requested_by_membership_id"); +CREATE INDEX "learning_runs_repository_id_created_at_idx" ON "learning_runs"("repository_id", "created_at"); +CREATE UNIQUE INDEX "learning_runs_active_repository_key" +ON "learning_runs"("repository_id") +WHERE "state" IN ('QUEUED', 'RUNNING'); + +ALTER TABLE "learning_runs" +ADD CONSTRAINT "learning_runs_repository_id_fkey" +FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE "learning_runs" +ADD CONSTRAINT "learning_runs_requested_by_id_fkey" +FOREIGN KEY ("requested_by_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +ALTER TABLE "learning_runs" +ADD CONSTRAINT "learning_runs_requested_by_membership_id_fkey" +FOREIGN KEY ("requested_by_membership_id") REFERENCES "memberships"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/hub/schema/repository.prisma b/hub/schema/repository.prisma index e9e5fe54f..8a21e42c8 100644 --- a/hub/schema/repository.prisma +++ b/hub/schema/repository.prisma @@ -3,7 +3,9 @@ model Repository { id String @id @default(uuid()) @db.Uuid // Relations - prototypes Prototype[] + learningRuns LearningRun[] + learningDecisionOperations LearningDecisionOperation[] + prototypes Prototype[] reviewThreads ReviewThread[] // Attribute columns diff --git a/hub/schema/review-comment.prisma b/hub/schema/review-comment.prisma index 8fedcb302..23e1e5ab4 100644 --- a/hub/schema/review-comment.prisma +++ b/hub/schema/review-comment.prisma @@ -18,6 +18,8 @@ model ReviewComment { body String editedAt DateTime? @map("edited_at") @db.Timestamptz(3) deletedAt DateTime? @map("deleted_at") @db.Timestamptz(3) + learningRedactionActor String? @map("learning_redaction_actor") @db.VarChar(300) + learningRedactedAt DateTime? @map("learning_redacted_at") @db.Timestamptz(3) // Timestamp columns createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3) diff --git a/hub/schema/user.prisma b/hub/schema/user.prisma index 48ee96f08..15a6c383d 100644 --- a/hub/schema/user.prisma +++ b/hub/schema/user.prisma @@ -4,6 +4,7 @@ model User { // Relations externalIdentities ExternalIdentity[] + learningRuns LearningRun[] membership Membership? profile UserProfile? prototypes Prototype[] diff --git a/hub/server/create-app/index.ts b/hub/server/create-app/index.ts index a1c99b9f1..3750bbb8e 100644 --- a/hub/server/create-app/index.ts +++ b/hub/server/create-app/index.ts @@ -16,6 +16,7 @@ export function createApp({ clientDirectory, copilotConnection, isReady, + learnings, logger, product, trustedProxyHops = 0, @@ -37,11 +38,19 @@ export function createApp({ authenticationSecurity(), ) app.use( - /^(?!\/api\/copilot-connection(?:\/|$))(?!\/api\/(?:auth|administrators\/authorizations|session-revocation\/authorizations)(?:\/|$))(?!\/api\/repositories\/[^/]+\/prototypes\/[^/]+(?:\/review-comments(?:\/|$)|\/?$)).*/i, + /^(?!\/api\/copilot-connection(?:\/|$))(?!\/api\/repositories\/[^/]+\/learnings(?:\/|$))(?!\/api\/(?:auth|administrators\/authorizations|session-revocation\/authorizations)(?:\/|$))(?!\/api\/repositories\/[^/]+\/prototypes\/[^/]+(?:\/review-comments(?:\/|$)|\/?$)).*/i, express.json(), ) - routes(app, { authentication, broadcast, copilotConnection, isReady, logger, product }) + routes(app, { + authentication, + broadcast, + copilotConnection, + isReady, + learnings, + logger, + product, + }) app.use("/api", respondNotFound) if (clientDirectory) { const directory = resolve(clientDirectory) diff --git a/hub/server/domains/learning/create-hub-review-collection/index.test.ts b/hub/server/domains/learning/create-hub-review-collection/index.test.ts new file mode 100644 index 000000000..bc18e2ccc --- /dev/null +++ b/hub/server/domains/learning/create-hub-review-collection/index.test.ts @@ -0,0 +1,132 @@ +import { describe, expect, it } from "vitest" + +import type { RepositoryReviewSnapshot } from "../../review-comments/types" +import { createHubReviewCollection } from "." + +const repositoryId = "11111111-2222-4333-8444-555555555555" +const prototypeId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa" +const author = { + userId: "22222222-2222-4222-8222-222222222222", + login: "mona", + name: "Mona", +} + +function snapshot(): RepositoryReviewSnapshot { + const createdAt = new Date("2026-11-13T10:00:00Z") + return { + snapshotId: "33333333-3333-4333-8333-333333333333", + capturedAt: new Date("2026-11-13T10:05:00Z"), + repository: { id: repositoryId, nameWithOwner: "team/design" }, + threads: [ + { + id: 101, + storageId: "77777777-7777-4777-8777-777777777777", + repositoryId, + prototype: { id: prototypeId, name: "Design", branch: "design" }, + buildNumber: 7, + anchor: { + schemaVersion: 1, + kind: "element", + route: { pathname: "/", search: "", hash: "" }, + selector: "#section", + accessibleName: "Section", + tagName: "section", + selectedText: "", + rect: { x: 0, y: 0, width: 100, height: 100 }, + viewport: { width: 1000, height: 800, scrollX: 0, scrollY: 0 }, + elementOffset: { x: 0, y: 0 }, + }, + activityVersion: 4, + createdAt, + updatedAt: createdAt, + resolvedAt: new Date("2026-11-13T10:04:00Z"), + resolvedBy: author, + root: { + id: 101, + storageId: "44444444-4444-4444-8444-444444444444", + rootId: null, + body: "Please align this section.", + author, + createdAt, + updatedAt: createdAt, + editedAt: null, + deletedAt: null, + }, + replies: [ + { + id: 102, + storageId: "55555555-5555-4555-8555-555555555555", + rootId: 101, + body: null, + author, + createdAt, + updatedAt: createdAt, + editedAt: null, + deletedAt: new Date("2026-11-13T10:03:00Z"), + }, + ], + resolutionHistory: [ + { + id: "66666666-6666-4666-8666-666666666666", + sequence: 1, + state: "resolved" as const, + actor: author, + occurredAt: new Date("2026-11-13T10:04:00Z"), + }, + ], + }, + ], + } +} + +describe("createHubReviewCollection()", () => { + it("writes a complete v1 log with UUID identities, deleted comments, and resolution history", () => { + const result = createHubReviewCollection(snapshot(), "https://hub.example.com") + const call = result.collection.calls[0] + if (!call) throw new Error("Expected one collection call.") + const thread = call.result.threads[0] + if (!thread) throw new Error("Expected one review thread.") + + expect(result.digest).toMatch(/^sha256:[0-9a-f]{64}$/) + expect(result.collection.reviewerIdentity).toBe("stable-user-id") + expect(call.result.target).toMatchObject({ + repository: `repositories/${repositoryId}`, + repositoryId, + scope: "repository", + }) + expect(thread.author).toMatchObject({ + hubUserId: author.userId, + avatarUrl: null, + }) + expect(thread.replies[0]).toMatchObject({ + id: 102, + body: null, + deletedAt: "2026-11-13T10:03:00.000Z", + }) + expect(thread.resolutionHistory).toEqual([ + { + id: "66666666-6666-4666-8666-666666666666", + sequence: 1, + state: "resolved", + at: "2026-11-13T10:04:00.000Z", + actor: { + login: "mona", + name: "Mona", + hubUserId: author.userId, + avatarUrl: null, + }, + }, + ]) + expect(thread.threadComplete).toBe(true) + expect(thread.repliesHasMore).toBe(false) + + const laterCapture = snapshot() + laterCapture.snapshotId = "88888888-8888-4888-8888-888888888888" + laterCapture.capturedAt = new Date("2026-11-13T10:06:00Z") + laterCapture.threads[0]!.updatedAt = new Date("2026-11-13T10:06:00Z") + laterCapture.threads[0]!.root.updatedAt = new Date("2026-11-13T10:06:00Z") + expect(createHubReviewCollection(laterCapture, "https://hub.example.com").digest).toBe( + result.digest, + ) + }) +}) diff --git a/hub/server/domains/learning/create-hub-review-collection/index.ts b/hub/server/domains/learning/create-hub-review-collection/index.ts new file mode 100644 index 000000000..bcdc9b1fb --- /dev/null +++ b/hub/server/domains/learning/create-hub-review-collection/index.ts @@ -0,0 +1,135 @@ +import { createHash } from "node:crypto" + +import type { RepositoryReviewSnapshot, ReviewMessage } from "../../review-comments/types.ts" + +const contentTrust = { + source: "hub_review_comments", + untrusted: true, + treatAs: "data", + appliesTo: "comment bodies, anchors and user-controlled display metadata", +} as const + +function actor(actor: { userId: string; login: string; name: string | null }) { + return { + login: actor.login, + name: actor.name, + hubUserId: actor.userId, + avatarUrl: null, + } +} + +function message( + value: ReviewMessage, + prototype: RepositoryReviewSnapshot["threads"][number]["prototype"], +) { + return { + id: value.id, + kind: value.rootId === null ? ("root" as const) : ("reply" as const), + body: value.body, + author: actor(value.author), + createdAt: value.createdAt.toISOString(), + updatedAt: value.updatedAt.toISOString(), + editedAt: value.editedAt?.toISOString() ?? null, + deletedAt: value.deletedAt?.toISOString() ?? null, + prototype: { + id: prototype.id, + name: prototype.name, + branch: prototype.branch, + }, + ...(value.rootId === null ? {} : { rootId: value.rootId }), + } +} + +function digestMessage(value: ReviewMessage) { + return { + id: value.id, + rootId: value.rootId, + body: value.body, + author: value.author, + createdAt: value.createdAt.toISOString(), + editedAt: value.editedAt?.toISOString() ?? null, + deletedAt: value.deletedAt?.toISOString() ?? null, + } +} + +function reviewState(snapshot: RepositoryReviewSnapshot) { + return { + repository: snapshot.repository, + threads: snapshot.threads.map((thread) => ({ + id: thread.id, + repositoryId: thread.repositoryId, + prototype: thread.prototype, + buildNumber: thread.buildNumber, + anchor: thread.anchor, + activityVersion: thread.activityVersion, + resolvedAt: thread.resolvedAt?.toISOString() ?? null, + resolvedBy: thread.resolvedBy, + root: digestMessage(thread.root), + replies: thread.replies.map(digestMessage), + resolutionHistory: thread.resolutionHistory.map((event) => ({ + id: event.id, + sequence: event.sequence, + state: event.state, + actor: event.actor, + occurredAt: event.occurredAt.toISOString(), + })), + })), + } +} + +export function createHubReviewCollection(snapshot: RepositoryReviewSnapshot, hubOrigin: string) { + const target = { + hubOrigin, + repository: `repositories/${snapshot.repository.id}`, + repositoryId: snapshot.repository.id, + scope: "repository", + } + const envelope = { + contentTrust, + target, + snapshotId: snapshot.snapshotId, + capturedAt: snapshot.capturedAt.toISOString(), + } + const threads = snapshot.threads.map((thread) => ({ + ...message(thread.root, thread.prototype), + buildNumber: thread.buildNumber, + anchor: thread.anchor, + resolvedAt: thread.resolvedAt?.toISOString() ?? null, + resolvedBy: thread.resolvedBy ? actor(thread.resolvedBy) : null, + resolutionHistory: thread.resolutionHistory.map((event) => ({ + id: event.id, + sequence: event.sequence, + state: event.state === "resolved" ? "resolved" : "unresolved", + at: event.occurredAt.toISOString(), + actor: actor(event.actor), + })), + activityVersion: thread.activityVersion, + replies: thread.replies.map((reply) => message(reply, thread.prototype)), + threadComplete: true, + repliesHasMore: false, + repliesNextCursor: null, + })) + const collection = { + kind: "replica.hub-review-collection/v1", + reviewerIdentity: "stable-user-id", + calls: [ + { + action: "list_repository_comments", + input: {}, + result: { + ...envelope, + scanComplete: true, + threads, + hasMore: false, + nextCursor: null, + }, + }, + ], + } + return { + collection, + digest: `sha256:${createHash("sha256") + .update(JSON.stringify(reviewState(snapshot))) + .digest("hex")}` as const, + } +} diff --git a/hub/server/domains/learning/create-learning-job-processors/index.ts b/hub/server/domains/learning/create-learning-job-processors/index.ts new file mode 100644 index 000000000..93393ae30 --- /dev/null +++ b/hub/server/domains/learning/create-learning-job-processors/index.ts @@ -0,0 +1,293 @@ +import type { Logger } from "pino" + +import { getCopilotConnectionStatus } from "../../copilot-connection/get-copilot-connection-status/index.ts" +import { resolveLocalSignInEnvironment } from "../../authentication/resolve-local-sign-in-environment/index.ts" +import { createReviewCommentLearningSource } from "../create-review-comment-learning-source/index.ts" +import { learningRunJob } from "../jobs/learning-run.ts" +import { recoverLearningRunsJob } from "../jobs/recover-learning-runs.ts" +import { redactReviewCommentJob } from "../jobs/redact-review-comment.ts" +import { prepareLearningStore } from "../prepare-learning-store/index.ts" +import { processLearningRun } from "../process-learning-run/index.ts" +import { processReviewCommentRedaction } from "../process-review-comment-redaction/index.ts" +import { reconcileLearningDecisionOperation } from "../reconcile-learning-decision-operation/index.ts" +import { readLearningConfiguration } from "../read-learning-configuration/index.ts" +import { createJobProcessor } from "../../../integrations/bullmq/create-job-processor/index.ts" +import { createJobQueue } from "../../../integrations/bullmq/create-job-queue/index.ts" +import { enqueueRecoverableJob } from "../../../integrations/bullmq/enqueue-recoverable-job/index.ts" +import { runLearningCommand } from "../../../integrations/learning/run-learning-command/index.ts" +import { LearningCommandError } from "../../../integrations/learning/run-learning-command/errors.ts" +import { CopilotCredentialError } from "../../../integrations/github/create-installation-access-token/errors.ts" +import { withLearningExecutionLock } from "../../../integrations/postgres/with-learning-execution-lock/index.ts" +import { getCopilotConnectionState } from "../../../repositories/copilot-connection-states/get-copilot-connection-state/index.ts" +import { advanceCopilotConnectionState } from "../../../repositories/copilot-connection-states/advance-copilot-connection-state/index.ts" +import { lockCopilotConnectionState } from "../../../repositories/copilot-connection-states/lock-copilot-connection-state/index.ts" +import { recordCopilotCredentialRefusal } from "../../../repositories/copilot-connection-states/record-copilot-credential-refusal/index.ts" +import { getCopilotConnection } from "../../../repositories/copilot-connections/get-copilot-connection/index.ts" +import { claimLearningRun } from "../../../repositories/learning-runs/claim-learning-run/index.ts" +import { finishLearningRun } from "../../../repositories/learning-runs/finish-learning-run/index.ts" +import { getLearningRun } from "../../../repositories/learning-runs/get-learning-run/index.ts" +import { listQueuedLearningRuns } from "../../../repositories/learning-runs/list-queued-learning-runs/index.ts" +import { deleteLearningDecisionOperation } from "../../../repositories/learning-decision-operations/delete-learning-decision-operation/index.ts" +import { listLearningDecisionOperations } from "../../../repositories/learning-decision-operations/list-learning-decision-operations/index.ts" +import { updateLearningRunProgress } from "../../../repositories/learning-runs/update-learning-run-progress/index.ts" +import { isEffectiveAdministrator } from "../../../repositories/memberships/is-effective-administrator/index.ts" +import { listDeletedReviewComments } from "../../../repositories/review-comments/list-deleted-review-comments/index.ts" +import { markReviewCommentLearningRedacted } from "../../../repositories/review-comments/mark-review-comment-learning-redacted/index.ts" +import { createSecurityAudit } from "../../../repositories/security-audits/create-security-audit/index.ts" +import { randomUUID } from "node:crypto" + +export function createLearningJobProcessors(environment: NodeJS.ProcessEnv, logger: Logger) { + let dependenciesPromise: ReturnType | undefined + function loadDependencies() { + return (async () => { + const resolvedEnvironment = resolveLocalSignInEnvironment(environment) + const configuration = await readLearningConfiguration(resolvedEnvironment) + const databaseUrl = resolvedEnvironment.DATABASE_URL + const hubOrigin = resolvedEnvironment.HUB_APPLICATION_ORIGIN + if (!databaseUrl || !hubOrigin) { + throw new Error("DATABASE_URL and HUB_APPLICATION_ORIGIN are required for learning jobs.") + } + const { prisma } = await import("../../../integrations/prisma/index.ts") + const source = createReviewCommentLearningSource(prisma, hubOrigin) + return { configuration, databaseUrl, prisma, source } + })() + } + function dependencies() { + dependenciesPromise ??= loadDependencies() + return dependenciesPromise + } + + const run = createJobProcessor(learningRunJob, async ({ runId }) => { + const { configuration, databaseUrl, prisma, source } = await dependencies() + let credentialSnapshot: + | { + connectionId: string + generation: bigint + credentialDigest: string + credentialProvider: string + } + | undefined + await processLearningRun(runId, { + claim: (id, startedAt) => claimLearningRun(prisma, id, startedAt), + capture: (repositoryId) => source.captureCompleteSnapshot({ repositoryId }), + finish: (id, input) => finishLearningRun(prisma, id, input), + getRun: (id) => getLearningRun(prisma, id), + now: () => new Date(), + isAdministrator: (membershipId) => isEffectiveAdministrator(prisma, membershipId), + prepare: (repositoryId) => + prepareLearningStore({ + applicationRoot: process.cwd(), + repositoryKey: repositoryId, + repositoryScope: `github.com/repositories/${repositoryId}`, + root: configuration.root, + staticDirectories: configuration.staticDirectories, + }), + refuseCredential: async () => { + if (!credentialSnapshot) return + const snapshot = credentialSnapshot + await prisma.$transaction(async (transaction) => { + const state = await lockCopilotConnectionState(transaction) + const connection = await getCopilotConnection(transaction) + if ( + !state || + !connection || + state.generation !== snapshot.generation || + connection.id !== snapshot.connectionId || + connection.credentialProvider !== snapshot.credentialProvider || + connection.credentialDigest !== snapshot.credentialDigest + ) { + return + } + if ( + !(await recordCopilotCredentialRefusal(transaction, { + credentialDigest: snapshot.credentialDigest, + credentialProvider: snapshot.credentialProvider, + refusedAt: new Date(), + })) + ) { + return + } + await advanceCopilotConnectionState(transaction) + await createSecurityAudit(transaction, { + actorMembershipId: connection.connectedByMembershipId, + connectionId: connection.id, + credentialProvider: snapshot.credentialProvider, + id: randomUUID(), + phase: "denied", + reason: "credential_refused", + type: "copilot_connection", + }) + }) + }, + runCommand: (arguments_, options) => + runLearningCommand(arguments_, { + cliPath: configuration.cliPath, + nodePath: configuration.nodePath, + ...options, + }), + credential: async () => { + const connection = await getCopilotConnection(prisma) + const state = await getCopilotConnectionState(prisma) + if (!state) return null + const status = getCopilotConnectionStatus( + connection + ? { + connectedBy: { + login: connection.connectedByMembership.user.profile?.login ?? null, + membershipId: connection.connectedByMembershipId, + name: connection.connectedByMembership.user.profile?.name ?? null, + }, + credentialDigest: connection.credentialDigest, + credentialProvider: connection.credentialProvider, + verifiedAt: connection.verifiedAt, + } + : null, + configuration.copilotCredentialProvider, + connection + ? await isEffectiveAdministrator(prisma, connection.connectedByMembershipId) + : false, + { + credentialDigest: state.refusedCredentialDigest, + credentialProvider: state.refusedCredentialProvider, + refusedAt: state.refusedAt, + }, + ) + if (!status.connected || !connection) return null + credentialSnapshot = { + connectionId: connection.id, + generation: state.generation, + credentialDigest: connection.credentialDigest, + credentialProvider: connection.credentialProvider, + } + try { + return await configuration.copilotCredentialProvider.getCredential() + } catch (error) { + if ( + error instanceof CopilotCredentialError && + (error.code === "installation_revoked" || error.code === "permission_denied") + ) { + throw new LearningCommandError(error.code, error.message, { cause: error }) + } + throw error + } + }, + updateProgress: (id, input) => updateLearningRunProgress(prisma, id, input), + withLock: (operation) => withLearningExecutionLock({ databaseUrl, run: operation }), + }) + }) + + const recover = createJobProcessor(recoverLearningRunsJob, async () => { + const { configuration, databaseUrl, prisma } = await dependencies() + const queue = createJobQueue({ name: "on-demand", databaseUrl, logger }) + try { + for (const queued of await listQueuedLearningRuns(prisma)) { + await enqueueRecoverableJob( + queue, + learningRunJob, + { runId: queued.id }, + `learning-run-${queued.id}`, + ) + } + let redactionCursor: { deletedAt: Date; id: string } | undefined + do { + const comments = await listDeletedReviewComments(prisma, { + ...(redactionCursor ? { after: redactionCursor } : {}), + }) + for (const comment of comments) { + await enqueueRecoverableJob( + queue, + redactReviewCommentJob, + { + repositoryId: comment.thread.repositoryId, + commentId: comment.publicId, + actor: comment.learningRedactionActor ?? `human:${comment.authorLogin}`, + }, + `learning-redact-${comment.thread.repositoryId}-${comment.publicId}`, + ) + } + const last = comments.at(-1) + redactionCursor = + comments.length === 100 && last?.deletedAt + ? { deletedAt: last.deletedAt, id: last.id } + : undefined + } while (redactionCursor) + for (const operation of await listLearningDecisionOperations(prisma)) { + try { + await reconcileLearningDecisionOperation(operation, { + finish: (input) => + prisma.$transaction(async (transaction) => { + const claimed = await deleteLearningDecisionOperation( + transaction, + input.operationId, + ) + if (claimed.count !== 1) return + await createSecurityAudit(transaction, { + id: input.auditId, + type: "learning_decision", + actorMembershipId: operation.actorMembershipId, + decision: operation.decision as "accept" | "reject" | "retire", + learningId: operation.learningId, + operationId: operation.id, + outcome: input.outcome, + ...(input.reason ? { reason: input.reason } : {}), + repositoryId: operation.repositoryId, + }) + }), + prepare: (repositoryId) => + prepareLearningStore({ + applicationRoot: process.cwd(), + repositoryKey: repositoryId, + repositoryScope: `github.com/repositories/${repositoryId}`, + root: configuration.root, + staticDirectories: configuration.staticDirectories, + }), + runCommand: (arguments_, options) => + runLearningCommand(arguments_, { + cliPath: configuration.cliPath, + nodePath: configuration.nodePath, + ...options, + }), + withLock: (operation_) => withLearningExecutionLock({ databaseUrl, run: operation_ }), + }) + } catch (error) { + logger.warn( + { + errorType: error instanceof Error ? error.name : "UnknownError", + operationId: operation.id, + repositoryId: operation.repositoryId, + }, + "Pending learning decision reconciliation failed", + ) + } + } + } finally { + await queue.close() + } + }) + + const redact = createJobProcessor(redactReviewCommentJob, async (input) => { + const { configuration, databaseUrl, prisma } = await dependencies() + await processReviewCommentRedaction(input, { + root: configuration.root, + markComplete: (completed) => markReviewCommentLearningRedacted(prisma, completed), + now: () => new Date(), + prepare: (repositoryId) => + prepareLearningStore({ + applicationRoot: process.cwd(), + repositoryKey: repositoryId, + repositoryScope: `github.com/repositories/${repositoryId}`, + root: configuration.root, + staticDirectories: configuration.staticDirectories, + }), + runCommand: (arguments_, options) => + runLearningCommand(arguments_, { + cliPath: configuration.cliPath, + nodePath: configuration.nodePath, + ...options, + }), + withLock: (operation) => withLearningExecutionLock({ databaseUrl, run: operation }), + }) + }) + + return { run, recover, redact } +} diff --git a/hub/server/domains/learning/create-review-comment-learning-source/index.test.ts b/hub/server/domains/learning/create-review-comment-learning-source/index.test.ts new file mode 100644 index 000000000..0ab4809b1 --- /dev/null +++ b/hub/server/domains/learning/create-review-comment-learning-source/index.test.ts @@ -0,0 +1,151 @@ +import { describe, expect, it, vi } from "vitest" +import type { RepositoryReviewSnapshot } from "../../review-comments/types" + +const { capture } = vi.hoisted(() => ({ capture: vi.fn() })) +vi.mock("../../review-comments/capture-repository-review-snapshot/index.ts", () => ({ + captureRepositoryReviewSnapshot: capture, +})) + +import { createReviewCommentLearningSource } from "." + +const repositoryId = "11111111-2222-4333-8444-555555555555" +const prototypeId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa" +const capturedAt = new Date("2026-11-13T10:00:00Z") + +function snapshot(): RepositoryReviewSnapshot { + const author = { + userId: "22222222-2222-4222-8222-222222222222", + login: "mona", + name: "Mona", + } + return { + snapshotId: "33333333-3333-4333-8333-333333333333", + capturedAt, + repository: { id: repositoryId, nameWithOwner: "team/design" }, + threads: [ + { + id: 101, + storageId: "77777777-7777-4777-8777-777777777777", + repositoryId, + prototype: { id: prototypeId, name: "Design", branch: "design" }, + buildNumber: 7, + anchor: { + schemaVersion: 1, + kind: "element", + route: { pathname: "/", search: "", hash: "" }, + selector: "#section", + accessibleName: "Section", + tagName: "section", + selectedText: "", + rect: { x: 0, y: 0, width: 100, height: 100 }, + viewport: { width: 1000, height: 800, scrollX: 0, scrollY: 0 }, + elementOffset: { x: 0, y: 0 }, + }, + activityVersion: 1, + createdAt: capturedAt, + updatedAt: capturedAt, + resolvedAt: null, + resolvedBy: null, + root: { + id: 101, + storageId: "44444444-4444-4444-8444-444444444444", + rootId: null, + body: "Please align this section.", + author, + createdAt: capturedAt, + updatedAt: capturedAt, + editedAt: null, + deletedAt: null, + }, + replies: [], + resolutionHistory: [], + }, + ], + } +} + +describe("createReviewCommentLearningSource()", () => { + it("keeps retained deleted bodies out of the package collection", async () => { + const value = snapshot() + value.threads[0]!.root = { + ...value.threads[0]!.root, + body: null, + deletedAt: capturedAt, + } + capture.mockResolvedValue(value) + const source = createReviewCommentLearningSource({} as never, "https://hub.example.com") + + const result = await source.captureCompleteSnapshot({ repositoryId }) + const collection = result.collection as { + calls: Array<{ + result: { threads: Array<{ body: string | null; deletedAt: string | null }> } + }> + } + + expect(collection.calls[0]?.result.threads[0]).toMatchObject({ + body: null, + deletedAt: capturedAt.toISOString(), + }) + }) + + it("resolves only evidence whose source and observed comment version match", async () => { + const value = snapshot() + capture.mockResolvedValue(value) + const source = createReviewCommentLearningSource({} as never, "https://hub.example.com") + + const result = await source.resolveEvidence({ + repositoryId, + references: [ + { + episodeId: "episode-1", + eventIds: ["event-1", "event-2"], + source: { + kind: "hub_review_comments", + hubOrigin: "https://hub.example.com", + repositoryId, + prototypeId, + threadId: 101, + commentId: 101, + }, + }, + { + episodeId: "episode-1", + eventIds: ["event-1"], + source: { + kind: "hub_review_comments", + hubOrigin: "https://hub.example.com", + repositoryId, + prototypeId: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb", + threadId: 101, + commentId: 101, + }, + }, + ], + events: [ + { + id: "event-1", + episodeId: "episode-1", + at: capturedAt.toISOString(), + payload: { commentId: 101, body: "Observed body" }, + }, + { + id: "event-2", + episodeId: "other-episode", + at: capturedAt.toISOString(), + payload: { commentId: 101, body: "Wrong episode" }, + }, + ], + }) + + expect(result[0]?.evidence).toEqual([ + expect.objectContaining({ + eventId: "event-1", + commentId: 101, + body: "Observed body", + authorLogin: "mona", + prototypeId, + }), + ]) + expect(result[1]?.evidence).toEqual([]) + }) +}) diff --git a/hub/server/domains/learning/create-review-comment-learning-source/index.ts b/hub/server/domains/learning/create-review-comment-learning-source/index.ts new file mode 100644 index 000000000..cdd5ad4cf --- /dev/null +++ b/hub/server/domains/learning/create-review-comment-learning-source/index.ts @@ -0,0 +1,81 @@ +import type { PrismaClient } from "../../../generated/prisma/client.ts" +import { captureRepositoryReviewSnapshot } from "../../review-comments/capture-repository-review-snapshot/index.ts" +import { createHubReviewCollection } from "../create-hub-review-collection/index.ts" +import type { + LearningObservationEvent, + ReviewCommentLearningSource, +} from "../review-comment-learning-source/types.ts" + +function eventMap(events: LearningObservationEvent[]) { + return new Map(events.map((event) => [event.id, event])) +} + +export function createReviewCommentLearningSource( + database: Pick, + hubOrigin: string, +): ReviewCommentLearningSource { + return { + async captureCompleteSnapshot({ repositoryId }) { + const snapshot = await captureRepositoryReviewSnapshot(database, repositoryId) + const { collection, digest } = createHubReviewCollection(snapshot, hubOrigin) + return { collection, digest, capturedAt: snapshot.capturedAt } + }, + async resolveEvidence({ repositoryId, references, events }) { + const snapshot = await captureRepositoryReviewSnapshot(database, repositoryId) + const comments = new Map( + snapshot.threads.flatMap((thread) => + [thread.root, ...thread.replies].map( + (comment) => [comment.id, { comment, thread }] as const, + ), + ), + ) + const observations = eventMap(events) + return references.map((reference, referenceIndex) => { + if ( + reference.source.kind !== "hub_review_comments" || + reference.source.hubOrigin !== hubOrigin || + reference.source.repositoryId !== repositoryId || + reference.source.commentId === undefined + ) { + return { referenceIndex, evidence: [] } + } + const stored = comments.get(reference.source.commentId) + if (!stored) return { referenceIndex, evidence: [] } + if ( + (reference.source.prototypeId !== undefined && + reference.source.prototypeId !== stored.thread.prototype.id) || + (reference.source.threadId !== undefined && + reference.source.threadId !== stored.thread.id) + ) { + return { referenceIndex, evidence: [] } + } + const evidence = reference.eventIds.flatMap((eventId) => { + const event = observations.get(eventId) + if ( + !event || + event.episodeId !== reference.episodeId || + event.payload.commentId !== stored.comment.id + ) { + return [] + } + return [ + { + eventId, + commentId: stored.comment.id, + body: stored.comment.deletedAt ? null : event.payload.body, + authorLogin: stored.comment.author.login, + authorAvatarUrl: null, + prototypeId: stored.thread.prototype.id, + prototypeName: stored.thread.prototype.name ?? stored.thread.prototype.branch, + createdAt: (stored.comment.deletedAt + ? stored.comment.createdAt + : new Date(event.at) + ).toISOString(), + }, + ] + }) + return { referenceIndex, evidence } + }) + }, + } +} diff --git a/hub/server/domains/learning/execute-learning-decision/index.test.ts b/hub/server/domains/learning/execute-learning-decision/index.test.ts new file mode 100644 index 000000000..0ca723e66 --- /dev/null +++ b/hub/server/domains/learning/execute-learning-decision/index.test.ts @@ -0,0 +1,72 @@ +import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join } from "node:path" +import { describe, expect, it, vi } from "vitest" + +import { runLearningCommand } from "../../../integrations/learning/run-learning-command" +import { validatePrivateStorageRoot } from "../../../utils/validate-private-storage-root" +import { executeLearningDecision } from "." + +vi.mock("../../../integrations/learning/run-learning-command", () => ({ + runLearningCommand: vi.fn(), +})) +vi.mock("../../../utils/validate-private-storage-root", () => ({ + validatePrivateStorageRoot: vi.fn(), +})) + +describe("executeLearningDecision()", () => { + it("passes a dash-leading reason through a private file instead of process arguments", async () => { + const directory = await mkdtemp(join(tmpdir(), "replica-learning-decision-test-")) + try { + await writeFile(join(directory, "config.json"), "{}") + vi.mocked(validatePrivateStorageRoot).mockResolvedValue(directory) + vi.mocked(runLearningCommand).mockImplementation(async (arguments_) => { + expect(arguments_).not.toContain("-private repository context") + const index = arguments_.indexOf("--reason-file") + expect(index).toBeGreaterThan(-1) + const path = arguments_[index + 1] + if (!path) throw new Error("Expected reason file path.") + expect(await readFile(path, "utf8")).toBe("-private repository context") + return {} + }) + + await expect( + executeLearningDecision({ + actor: "human:mona", + applicationRoot: "/app", + cliPath: "/app/replica-learning.mjs", + decision: { decision: "retire", reason: "-private repository context" }, + learningId: "mem_1", + nodePath: "/node", + operationId: "22222222-2222-4222-8222-222222222222", + repositoryId: "11111111-2222-4333-8444-555555555555", + root: "/private/learning", + staticDirectories: [], + }), + ).resolves.toEqual({ notice: "Learning retired." }) + } finally { + await rm(directory, { recursive: true, force: true }) + } + }) + + it("propagates an inaccessible store so durable reconciliation stays pending", async () => { + vi.mocked(validatePrivateStorageRoot).mockRejectedValue( + Object.assign(new Error("denied"), { code: "EACCES" }), + ) + + await expect( + executeLearningDecision({ + actor: "human:mona", + applicationRoot: "/app", + cliPath: "/app/replica-learning.mjs", + decision: { decision: "retire", reason: "obsolete" }, + learningId: "mem_1", + nodePath: "/node", + operationId: "22222222-2222-4222-8222-222222222222", + repositoryId: "11111111-2222-4333-8444-555555555555", + root: "/private/learning", + staticDirectories: [], + }), + ).rejects.toMatchObject({ code: "EACCES" }) + }) +}) diff --git a/hub/server/domains/learning/execute-learning-decision/index.ts b/hub/server/domains/learning/execute-learning-decision/index.ts new file mode 100644 index 000000000..02bf035ba --- /dev/null +++ b/hub/server/domains/learning/execute-learning-decision/index.ts @@ -0,0 +1,84 @@ +import { access, mkdtemp, rm, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { resolve } from "node:path" + +import { runLearningCommand } from "../../../integrations/learning/run-learning-command/index.ts" +import { validatePrivateStorageRoot } from "../../../utils/validate-private-storage-root/index.ts" +import { LearningCommandError } from "../../../integrations/learning/run-learning-command/errors.ts" +import type { LearningDecision } from "../types.ts" + +export async function executeLearningDecision(input: { + actor: string + applicationRoot?: string + cliPath: string + decision: LearningDecision + learningId: string + nodePath: string + operationId: string + repositoryId: string + root: string + signal?: AbortSignal + staticDirectories: string[] +}) { + const applicationRoot = input.applicationRoot ?? process.cwd() + const directory = await validatePrivateStorageRoot( + resolve(input.root, "repositories", input.repositoryId), + { + applicationRoot, + excludedDirectories: input.staticDirectories, + name: "REPLICA_LEARNING_ROOT", + publicRoot: resolve(applicationRoot, "public"), + }, + ) + try { + await access(resolve(directory, "config.json")) + } catch (error) { + if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error + throw new LearningCommandError("not_found", "That learning no longer exists.") + } + const arguments_ = [input.decision.decision, input.learningId] + arguments_.push("--operation-id", input.operationId) + if (input.decision.decision !== "retire") { + arguments_.push("--digest", input.decision.digest) + } + arguments_.push("--by", input.actor) + let temporaryDirectory: string | undefined + try { + if (input.decision.decision !== "accept") { + temporaryDirectory = await mkdtemp(resolve(tmpdir(), "replica-learning-decision-")) + const reasonPath = resolve(temporaryDirectory, "reason.txt") + await writeFile(reasonPath, input.decision.reason, { mode: 0o600 }) + arguments_.push("--reason-file", reasonPath) + } + if (input.decision.decision === "accept" && input.decision.content !== undefined) { + temporaryDirectory = await mkdtemp(resolve(tmpdir(), "replica-learning-decision-")) + const contentPath = resolve(temporaryDirectory, "content.txt") + await writeFile(contentPath, input.decision.content, { mode: 0o600 }) + arguments_.push("--content-file", contentPath) + } + await runLearningCommand( + [ + ...arguments_, + "--dir", + directory, + "--repository", + `github.com/repositories/${input.repositoryId}`, + ], + { + cliPath: input.cliPath, + nodePath: input.nodePath, + signal: input.signal, + }, + ) + } finally { + if (temporaryDirectory) await rm(temporaryDirectory, { recursive: true }) + } + return { + notice: + input.decision.decision === "accept" + ? "Learning accepted." + : input.decision.decision === "reject" + ? "Suggestion rejected." + : "Learning retired.", + } +} diff --git a/hub/server/domains/learning/get-learning-overview/index.test.ts b/hub/server/domains/learning/get-learning-overview/index.test.ts new file mode 100644 index 000000000..38a496784 --- /dev/null +++ b/hub/server/domains/learning/get-learning-overview/index.test.ts @@ -0,0 +1,220 @@ +import { access } from "node:fs/promises" +import { beforeEach, describe, expect, it, vi } from "vitest" + +import { runLearningCommand } from "../../../integrations/learning/run-learning-command" +import { validatePrivateStorageRoot } from "../../../utils/validate-private-storage-root" +import { getLearningOverview } from "." + +vi.mock("node:fs/promises", () => ({ access: vi.fn() })) +vi.mock("../../../integrations/learning/run-learning-command", () => ({ + runLearningCommand: vi.fn(), +})) +vi.mock("../../../utils/validate-private-storage-root", () => ({ + validatePrivateStorageRoot: vi.fn(), +})) + +describe("getLearningOverview()", () => { + beforeEach(() => { + vi.mocked(validatePrivateStorageRoot).mockResolvedValue("/private/learning/repositories/repo") + vi.mocked(access).mockResolvedValue(undefined) + }) + + it("uses only the review source's exact event resolution for displayed evidence", async () => { + vi.mocked(runLearningCommand) + .mockResolvedValueOnce([ + { + withheld: false, + record: { + id: "mem_1", + state: "proposed", + content: "Use visible labels.", + reviewDigest: `sha256:${"a".repeat(64)}`, + evidence: [ + { + episodeId: "episode-1", + eventIds: ["event-1"], + source: { + kind: "hub_review_comments", + repositoryId: "11111111-2222-4333-8444-555555555555", + commentId: 17, + }, + }, + { + episodeId: "foreign-episode", + eventIds: ["foreign-event"], + source: { kind: "hub_review_comments", repositoryId: "foreign", commentId: 18 }, + }, + ], + contradictions: [], + support: { distinctReviewers: 2, distinctPrototypes: 1 }, + proposal: { lifecycle: { targets: [] } }, + }, + status: { + recallEligible: false, + problems: [], + conflicts: [], + }, + }, + ]) + .mockResolvedValueOnce({ text: "", memories: [] }) + .mockResolvedValueOnce({ + events: [ + { + id: "event-1", + episodeId: "episode-1", + at: "2026-11-01T10:00:00.000Z", + payload: { commentId: 17, body: "The field needs a visible label." }, + }, + ], + }) + const resolveEvidence = vi.fn().mockResolvedValue([ + { + referenceIndex: 0, + evidence: [ + { + eventId: "event-1", + commentId: 17, + body: "The field needs a visible label.", + authorLogin: "reviewer", + authorAvatarUrl: null, + prototypeId: "prototype-1", + prototypeName: "Signup", + createdAt: "2026-11-01T10:00:00.000Z", + }, + ], + }, + ]) + + const result = await getLearningOverview({ + applicationRoot: "/app", + cliPath: "/app/replica-learning.mjs", + evidenceSource: { resolveEvidence }, + nodePath: "/node", + repositoryId: "11111111-2222-4333-8444-555555555555", + root: "/private/learning", + staticDirectories: [], + viewer: "github:mona", + }) + + expect(resolveEvidence).toHaveBeenCalledWith({ + repositoryId: "11111111-2222-4333-8444-555555555555", + references: [ + { + episodeId: "episode-1", + eventIds: ["event-1"], + source: { + kind: "hub_review_comments", + repositoryId: "11111111-2222-4333-8444-555555555555", + commentId: 17, + }, + }, + { + episodeId: "foreign-episode", + eventIds: ["foreign-event"], + source: { kind: "hub_review_comments", repositoryId: "foreign", commentId: 18 }, + }, + ], + events: [ + { + id: "event-1", + episodeId: "episode-1", + at: "2026-11-01T10:00:00.000Z", + payload: { commentId: 17, body: "The field needs a visible label." }, + }, + ], + }) + expect(result.suggestions).toHaveLength(1) + expect(result.suggestions[0]?.evidence).toEqual([ + { + eventId: "event-1", + commentId: 17, + body: "The field needs a visible label.", + authorLogin: "reviewer", + authorAvatarUrl: null, + prototypeId: "prototype-1", + prototypeName: "Signup", + createdAt: "2026-11-01T10:00:00.000Z", + }, + ]) + expect(result.suggestions[0]?.otherEvidenceCount).toBe(1) + }) + + it("propagates an inaccessible store instead of reporting an empty overview", async () => { + vi.mocked(access).mockRejectedValue(Object.assign(new Error("denied"), { code: "EACCES" })) + + await expect( + getLearningOverview({ + applicationRoot: "/app", + cliPath: "/app/replica-learning.mjs", + nodePath: "/node", + repositoryId: "11111111-2222-4333-8444-555555555555", + root: "/private/learning", + staticDirectories: [], + viewer: "human:mona", + }), + ).rejects.toMatchObject({ code: "EACCES" }) + }) + + it("loads observations and the repository snapshot once for all suggestions", async () => { + function proposal(id: string, eventId: string, commentId: number) { + return { + withheld: false, + record: { + id, + state: "proposed" as const, + content: `Guidance ${id}`, + reviewDigest: `sha256:${(id === "mem_1" ? "a" : "b").repeat(64)}`, + evidence: [ + { + episodeId: `episode-${commentId}`, + eventIds: [eventId], + source: { + kind: "hub_review_comments", + repositoryId: "11111111-2222-4333-8444-555555555555", + commentId, + }, + }, + ], + contradictions: [], + proposal: { lifecycle: { targets: [] } }, + }, + status: { recallEligible: false, problems: [], conflicts: [] }, + } + } + const memories = [proposal("mem_1", "event-1", 17), proposal("mem_2", "event-2", 18)] + vi.mocked(runLearningCommand) + .mockResolvedValueOnce(memories) + .mockResolvedValueOnce({ text: "", memories: [] }) + .mockResolvedValueOnce({ + events: [ + { + id: "event-1", + episodeId: "episode-17", + at: "2026-11-01T10:00:00Z", + payload: { commentId: 17, body: "one" }, + }, + { + id: "event-2", + episodeId: "episode-18", + at: "2026-11-01T11:00:00Z", + payload: { commentId: 18, body: "two" }, + }, + ], + }) + const resolveEvidence = vi.fn().mockResolvedValue([]) + + await getLearningOverview({ + applicationRoot: "/app", + cliPath: "/app/replica-learning.mjs", + evidenceSource: { resolveEvidence }, + nodePath: "/node", + repositoryId: "11111111-2222-4333-8444-555555555555", + root: "/private/learning", + staticDirectories: [], + viewer: "human:mona", + }) + + expect(resolveEvidence).toHaveBeenCalledOnce() + expect(vi.mocked(runLearningCommand)).toHaveBeenCalledTimes(3) + }) +}) diff --git a/hub/server/domains/learning/get-learning-overview/index.ts b/hub/server/domains/learning/get-learning-overview/index.ts new file mode 100644 index 000000000..f02c000c9 --- /dev/null +++ b/hub/server/domains/learning/get-learning-overview/index.ts @@ -0,0 +1,288 @@ +import { access } from "node:fs/promises" +import { resolve } from "node:path" +import { z } from "zod" + +import { runLearningCommand } from "../../../integrations/learning/run-learning-command/index.ts" +import { LearningCommandError } from "../../../integrations/learning/run-learning-command/errors.ts" +import { validatePrivateStorageRoot } from "../../../utils/validate-private-storage-root/index.ts" +import type { ReviewCommentLearningSource } from "../review-comment-learning-source/types.ts" +import type { AcceptedLearning, LearningSuggestion } from "../types.ts" + +const referenceSchema = z + .object({ + episodeId: z.string().min(1), + eventIds: z.array(z.string().min(1)), + source: z + .object({ + kind: z.string().optional(), + hubOrigin: z.string().optional(), + repositoryId: z.string().optional(), + prototypeId: z.string().optional(), + threadId: z.number().int().positive().optional(), + commentId: z.number().int().positive().optional(), + }) + .loose(), + }) + .loose() +const memorySchema = z + .object({ + withheld: z.boolean(), + record: z + .object({ + id: z.string().min(1), + state: z.enum(["proposed", "accepted", "rejected", "retired"]), + content: z.string().optional(), + reviewDigest: z.string().optional(), + evidence: z.array(referenceSchema).optional(), + contradictions: z.array(referenceSchema).optional(), + support: z + .object({ + distinctReviewers: z.number().int().nonnegative(), + distinctPrototypes: z.number().int().nonnegative(), + }) + .loose() + .optional(), + proposal: z + .object({ + lifecycle: z + .object({ targets: z.array(z.string()).optional() }) + .loose() + .optional(), + }) + .loose() + .optional(), + accepted: z + .object({ + at: z.string().optional(), + edited: z.boolean().optional(), + by: z.object({ id: z.string().optional() }).loose().optional(), + }) + .loose() + .optional(), + }) + .loose(), + status: z + .object({ + recallEligible: z.boolean(), + identityNeedsReview: z.boolean().optional(), + superseded: z.boolean().optional(), + problems: z.array(z.string()), + conflicts: z.array(z.string()), + }) + .loose(), + }) + .loose() +const recallSchema = z + .object({ + text: z.string(), + memories: z.array(z.object({ id: z.string() }).loose()), + }) + .loose() +const observationsSchema = z + .object({ + events: z.array( + z + .object({ + id: z.string().min(1), + episodeId: z.string().min(1), + at: z.string().min(1), + payload: z + .object({ + commentId: z.number().int().positive(), + body: z.string().nullable(), + }) + .loose(), + }) + .loose(), + ), + }) + .loose() + +function login(identity: string | undefined) { + return identity?.replace(/^(?:github|human):/, "") || null +} + +export async function getLearningOverview(input: { + applicationRoot?: string + cliPath: string + evidenceSource?: Pick + nodePath: string + repositoryId: string + root: string + staticDirectories: string[] + viewer: string +}) { + const applicationRoot = input.applicationRoot ?? process.cwd() + const directory = await validatePrivateStorageRoot( + resolve(input.root, "repositories", input.repositoryId), + { + applicationRoot, + excludedDirectories: input.staticDirectories, + name: "REPLICA_LEARNING_ROOT", + publicRoot: resolve(applicationRoot, "public"), + }, + ) + try { + await access(resolve(directory, "config.json")) + } catch (error) { + if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error + return { + loadError: null, + identityReviewCount: 0, + suggestions: [], + learnings: [], + recall: { text: "", count: 0 }, + } + } + const commandOptions = { cliPath: input.cliPath, nodePath: input.nodePath } + const commonArguments = [ + "--dir", + directory, + "--repository", + `github.com/repositories/${input.repositoryId}`, + ] + const [rawMemories, rawRecall] = await Promise.all([ + runLearningCommand(["memories", ...commonArguments], commandOptions), + runLearningCommand( + ["recall", "--preview", "--by", input.viewer, ...commonArguments], + commandOptions, + ), + ]) + const memories = z.array(memorySchema).parse(rawMemories) + const recall = recallSchema.parse(rawRecall) + const recalledIds = new Set(recall.memories.map((memory) => memory.id)) + const records = new Map(memories.map((item) => [item.record.id, item])) + const proposed = memories.filter( + (item) => + item.record.state === "proposed" && + !item.withheld && + !item.status.identityNeedsReview && + item.status.problems.length === 0 && + item.status.conflicts.length === 0, + ) + let loadError: string | null = null + const suggestions: LearningSuggestion[] = [] + if (proposed.length > 0 && !input.evidenceSource) { + loadError = + "Review comment evidence is not available yet, so Hub withheld learning suggestions." + } else if (input.evidenceSource) { + const prepared = proposed.map((item) => { + if (!item.record.content || !item.record.reviewDigest) { + throw new LearningCommandError( + "unreadable_output", + "replica-learning returned output Hub could not read.", + ) + } + const evidenceReferences = item.record.evidence ?? [] + const contradictionReferences = item.record.contradictions ?? [] + return { + item, + content: item.record.content, + reviewDigest: item.record.reviewDigest, + evidenceReferences, + contradictionReferences, + references: [...evidenceReferences, ...contradictionReferences], + } + }) + const references = prepared.flatMap((entry) => entry.references) + const eventIds = [...new Set(references.flatMap((reference) => reference.eventIds))] + const events = [] + for (let index = 0; index < eventIds.length; index += 100) { + const batch = eventIds.slice(index, index + 100) + const result = observationsSchema.parse( + await runLearningCommand( + [ + "observations", + "--purpose", + "review", + ...batch.flatMap((eventId) => ["--event", eventId]), + ...commonArguments, + ], + commandOptions, + ), + ) + events.push(...result.events) + } + const resolved = + references.length === 0 + ? [] + : await input.evidenceSource.resolveEvidence({ + repositoryId: input.repositoryId, + references, + events, + }) + const byIndex = new Map(resolved.map((entry) => [entry.referenceIndex, entry.evidence])) + let referenceOffset = 0 + for (const { + item, + content, + reviewDigest, + evidenceReferences, + contradictionReferences, + references: itemReferences, + } of prepared) { + const evidence = evidenceReferences.flatMap( + (_, index) => byIndex.get(referenceOffset + index) ?? [], + ) + const contradictions = contradictionReferences.flatMap( + (_, index) => byIndex.get(referenceOffset + evidenceReferences.length + index) ?? [], + ) + suggestions.push({ + id: item.record.id, + content, + reviewDigest, + support: item.record.support + ? { + reviewers: item.record.support.distinctReviewers, + prototypes: item.record.support.distinctPrototypes, + } + : null, + replaces: (item.record.proposal?.lifecycle?.targets ?? []).map((id) => ({ + id, + content: records.get(id)?.withheld ? null : (records.get(id)?.record.content ?? null), + })), + evidence, + otherEvidenceCount: evidenceReferences.filter( + (_, index) => (byIndex.get(referenceOffset + index) ?? []).length === 0, + ).length, + contradictions, + otherContradictionsCount: contradictionReferences.filter( + (_, index) => + (byIndex.get(referenceOffset + evidenceReferences.length + index) ?? []).length === 0, + ).length, + }) + referenceOffset += itemReferences.length + } + } + const learnings: AcceptedLearning[] = memories + .filter((item) => item.record.state === "accepted") + .map((item) => ({ + id: item.record.id, + content: item.withheld ? null : (item.record.content ?? null), + acceptedBy: login(item.record.accepted?.by?.id), + acceptedAt: item.record.accepted?.at ?? null, + edited: item.record.accepted?.edited === true, + status: + item.status.problems.length > 0 + ? "damaged" + : item.status.identityNeedsReview && !item.status.superseded + ? "identity-review" + : recalledIds.has(item.record.id) + ? "recalled" + : item.status.recallEligible + ? "budget-excluded" + : "not-recalled", + })) + return { + loadError, + identityReviewCount: memories.filter( + (item) => + (item.record.state === "proposed" || item.record.state === "accepted") && + item.status.identityNeedsReview && + !item.status.superseded, + ).length, + suggestions, + learnings, + recall: { text: recall.text, count: recall.memories.length }, + } +} diff --git a/hub/server/domains/learning/jobs/learning-run.ts b/hub/server/domains/learning/jobs/learning-run.ts new file mode 100644 index 000000000..17cb293cf --- /dev/null +++ b/hub/server/domains/learning/jobs/learning-run.ts @@ -0,0 +1,7 @@ +import { z } from "zod" + +export const learningRunJob = { + name: "learning.run", + schema: z.object({ runId: z.uuid() }).strict(), + options: { attempts: 120, backoff: { type: "fixed", delay: 30_000 } }, +} diff --git a/hub/server/domains/learning/jobs/recover-learning-runs.ts b/hub/server/domains/learning/jobs/recover-learning-runs.ts new file mode 100644 index 000000000..0635d1b88 --- /dev/null +++ b/hub/server/domains/learning/jobs/recover-learning-runs.ts @@ -0,0 +1,7 @@ +import { z } from "zod" + +export const recoverLearningRunsJob = { + name: "learning.recover-runs", + schema: z.object({}).strict(), + options: { attempts: 3, backoff: { type: "exponential", delay: 5_000 } }, +} diff --git a/hub/server/domains/learning/jobs/redact-review-comment.ts b/hub/server/domains/learning/jobs/redact-review-comment.ts new file mode 100644 index 000000000..8258abf7f --- /dev/null +++ b/hub/server/domains/learning/jobs/redact-review-comment.ts @@ -0,0 +1,13 @@ +import { z } from "zod" + +export const redactReviewCommentJob = { + name: "learning.redact-review-comment", + schema: z + .object({ + repositoryId: z.uuid(), + commentId: z.number().int().positive(), + actor: z.string().regex(/^(?:github|human):\S+$/), + }) + .strict(), + options: { attempts: 120, backoff: { type: "fixed", delay: 30_000 } }, +} diff --git a/hub/server/domains/learning/process-learning-run/index.test.ts b/hub/server/domains/learning/process-learning-run/index.test.ts new file mode 100644 index 000000000..289374731 --- /dev/null +++ b/hub/server/domains/learning/process-learning-run/index.test.ts @@ -0,0 +1,272 @@ +import { describe, expect, it, vi } from "vitest" + +import { LearningCommandError } from "../../../integrations/learning/run-learning-command/errors" +import { processLearningRun } from "." + +type Dependencies = Parameters[1] +type RunRecord = Awaited> + +function dependencies(overrides: Partial = {}) { + const commands: string[][] = [] + const finished: Array<{ id: string; input: unknown }> = [] + const progress: Array<{ id: string; input: unknown }> = [] + const run: Exclude = { + id: "11111111-2222-4333-8444-555555555555", + repositoryId: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa", + snapshotDigest: "sha256:snapshot", + state: "QUEUED", + startedAt: new Date("2026-11-13T09:59:00Z"), + requestedBy: { profile: { login: "mona" } }, + requestedByMembershipId: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb", + } + async function withLock(operation: (signal: AbortSignal) => Promise) { + return await operation(new AbortController().signal) + } + const base: Dependencies = { + claim: vi.fn(() => { + run.state = "RUNNING" + return Promise.resolve(true) + }), + capture: vi.fn().mockResolvedValue({ + collection: { kind: "replica.hub-review-collection/v1" }, + digest: "sha256:snapshot", + capturedAt: new Date("2026-11-13T09:00:00Z"), + }), + finish: vi.fn((id: string, input: Parameters[1]) => { + finished.push({ id, input }) + return Promise.resolve() + }), + getRun: vi.fn().mockImplementation(() => Promise.resolve(run)), + now: vi.fn(() => new Date("2026-11-13T10:00:00Z")), + isAdministrator: vi.fn().mockResolvedValue(true), + prepare: vi.fn().mockResolvedValue({ + directory: "/private/repository", + repositoryScope: "github.com/repositories/repository", + }), + runCommand: vi.fn((arguments_: string[]) => { + commands.push(arguments_) + if (arguments_[0] === "grants" && arguments_[1] === "list") { + return Promise.resolve([]) + } + if (arguments_[0] === "grants" && arguments_[1] === "add") { + return Promise.resolve({ id: "grant-1" }) + } + if (arguments_[0] === "import") { + return Promise.resolve({ complete: true, problems: [] }) + } + if (arguments_[0] === "label") { + return Promise.resolve({ + considered: 4, + labeled: 3, + remaining: 1, + usage: { requests: 2, nanoAiu: 2_500_000 }, + }) + } + return Promise.resolve({ + status: "complete", + proposals: [{ id: "proposal-1", updatedAt: "2026-11-13T10:00:00Z" }], + overBudget: 1, + }) + }), + credential: vi.fn().mockResolvedValue({ githubToken: "token" }), + updateProgress: vi.fn((id: string, input: Parameters[1]) => { + progress.push({ id, input }) + return Promise.resolve() + }), + withLock, + } + return { ...base, ...overrides, commands, finished, progress, run } +} + +describe("processLearningRun()", () => { + it("claims once, imports with redaction, records usage, and finishes success", async () => { + const deps = dependencies() + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(deps.claim).toHaveBeenCalledOnce() + expect(deps.commands.find((arguments_) => arguments_[0] === "import")).toContain( + "--redact-deleted", + ) + expect(deps.progress.at(-1)).toEqual({ + id: "11111111-2222-4333-8444-555555555555", + input: { + commentsConsidered: 4, + commentsLabeled: 3, + commentsRemaining: 1, + copilotRequests: 2, + aiCredits: "0.0025", + }, + }) + expect(deps.finished[0]).toMatchObject({ + input: { + state: "SUCCEEDED", + suggestions: 1, + suggestionsRemaining: 1, + }, + }) + }) + + it("finishes visibly failed when the imported snapshot is incomplete", async () => { + const deps = dependencies({ + runCommand: vi.fn((arguments_: string[]) => { + if (arguments_[0] === "grants" && arguments_[1] === "list") { + return Promise.resolve([]) + } + if (arguments_[0] === "grants" && arguments_[1] === "add") { + return Promise.resolve({ id: "grant-1" }) + } + if (arguments_[0] === "import") { + return Promise.resolve({ complete: false, problems: ["missing reply page"] }) + } + return Promise.reject(new Error("Later commands must not run.")) + }), + }) + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(deps.finished[0]).toMatchObject({ + input: { + state: "FAILED", + failureCode: "incomplete_collection", + failureSummary: "The repository review snapshot is incomplete: missing reply page", + }, + }) + }) + + it("resumes a run left running after a worker interruption", async () => { + const deps = dependencies() + deps.run.state = "RUNNING" + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(deps.claim).not.toHaveBeenCalled() + expect(deps.finished[0]).toMatchObject({ input: { state: "SUCCEEDED" } }) + }) + + it("retries a recovered running job when another learning mutation holds the lock", async () => { + const deps = dependencies({ + withLock: () => Promise.reject(new Error("Another learning operation is still running.")), + }) + deps.run.state = "RUNNING" + + await expect(processLearningRun("11111111-2222-4333-8444-555555555555", deps)).rejects.toThrow( + "Another learning operation is still running.", + ) + expect(deps.finished).toEqual([]) + }) + + it("fails before store writes when the requester's authority was revoked", async () => { + const deps = dependencies({ + isAdministrator: vi.fn().mockResolvedValue(false), + }) + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(deps.runCommand).not.toHaveBeenCalled() + expect(deps.finished[0]).toMatchObject({ + input: { + state: "FAILED", + failureCode: "not_authorized", + }, + }) + }) + + it("preserves partial label usage when Copilot fails", async () => { + const refuseCredential = vi.fn().mockResolvedValue(undefined) + const deps = dependencies({ + refuseCredential, + runCommand: vi.fn((arguments_: string[]) => { + if (arguments_[0] === "grants" && arguments_[1] === "list") { + return Promise.resolve([]) + } + if (arguments_[0] === "grants" && arguments_[1] === "add") { + return Promise.resolve({ id: "grant-1" }) + } + if (arguments_[0] === "import") { + return Promise.resolve({ complete: true, problems: [] }) + } + if (arguments_[0] === "label") { + return Promise.reject( + new LearningCommandError("unauthorized", "Copilot refused the credential.", { + result: { + considered: 3, + labeled: 2, + remaining: 1, + usage: { requests: 2, nanoAiu: 1_250_000 }, + }, + }), + ) + } + return Promise.reject(new Error("Consolidation must not run.")) + }), + }) + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(deps.progress).toEqual([ + { + id: "11111111-2222-4333-8444-555555555555", + input: { + commentsConsidered: 3, + commentsLabeled: 2, + commentsRemaining: 1, + copilotRequests: 2, + aiCredits: "0.00125", + }, + }, + ]) + expect(refuseCredential).toHaveBeenCalledOnce() + expect(deps.finished[0]).toMatchObject({ + input: { + state: "FAILED", + failureCode: "unauthorized", + failureSummary: "Copilot refused the credential.", + }, + }) + }) + + it("does not record credential refusal when Copilot is simply not connected", async () => { + const refuseCredential = vi.fn() + const deps = dependencies({ + credential: vi.fn().mockResolvedValue(null), + refuseCredential, + }) + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(refuseCredential).not.toHaveBeenCalled() + expect(deps.finished[0]).toMatchObject({ + input: { + state: "FAILED", + failureCode: "copilot_not_connected", + }, + }) + }) + + it("records refusal when the configured installation can no longer mint a credential", async () => { + const refuseCredential = vi.fn().mockResolvedValue(undefined) + const deps = dependencies({ + credential: vi + .fn() + .mockRejectedValue( + new LearningCommandError( + "installation_revoked", + "The configured GitHub App installation is unavailable.", + ), + ), + refuseCredential, + }) + + await processLearningRun("11111111-2222-4333-8444-555555555555", deps) + + expect(refuseCredential).toHaveBeenCalledOnce() + expect(deps.finished[0]).toMatchObject({ + input: { + state: "FAILED", + failureCode: "installation_revoked", + failureSummary: "The configured GitHub App installation is unavailable.", + }, + }) + }) +}) diff --git a/hub/server/domains/learning/process-learning-run/index.ts b/hub/server/domains/learning/process-learning-run/index.ts new file mode 100644 index 000000000..85f3e4e0c --- /dev/null +++ b/hub/server/domains/learning/process-learning-run/index.ts @@ -0,0 +1,314 @@ +import { mkdtemp, rm, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { resolve } from "node:path" +import { z } from "zod" + +import { LearningCommandError } from "../../../integrations/learning/run-learning-command/errors.ts" + +const grantListSchema = z.array( + z + .object({ + grant: z + .object({ + id: z.string().min(1), + sources: z.array(z.string()), + }) + .loose(), + activePurposes: z.array(z.string()), + expired: z.boolean(), + }) + .loose(), +) +const addedGrantSchema = z.object({ id: z.string().min(1) }).loose() +const importSchema = z + .object({ + complete: z.boolean(), + problems: z.array(z.string()), + }) + .loose() +const labelSchema = z + .object({ + considered: z.number().int().nonnegative(), + labeled: z.number().int().nonnegative(), + remaining: z.number().int().nonnegative(), + usage: z + .object({ + requests: z.number().int().nonnegative(), + nanoAiu: z.number().int().nonnegative(), + }) + .loose(), + }) + .loose() +const consolidateSchema = z + .object({ + status: z.string(), + proposals: z.array(z.object({ updatedAt: z.string().optional() }).loose()), + overBudget: z.number().int().nonnegative().optional(), + }) + .loose() + +function credits(nanoAiu: number) { + const padded = nanoAiu.toString().padStart(10, "0") + return `${padded.slice(0, -9)}.${padded.slice(-9)}`.replace(/\.?0+$/, "") || "0" +} + +export async function processLearningRun( + runId: string, + dependencies: { + claim(runId: string, startedAt: Date): Promise + capture(repositoryId: string): Promise<{ + collection: unknown + digest: string + capturedAt: Date + }> + finish( + runId: string, + input: + | { + state: "SUCCEEDED" + suggestions: number + suggestionsRemaining: number + finishedAt: Date + } + | { + state: "FAILED" + failureCode: string + failureSummary: string + finishedAt: Date + }, + ): Promise + getRun(runId: string): Promise<{ + id: string + repositoryId: string + snapshotDigest: string + startedAt: Date | null + state: "QUEUED" | "RUNNING" | "SUCCEEDED" | "FAILED" + requestedBy: { profile: { login: string | null } | null } | null + requestedByMembershipId: string | null + } | null> + now(): Date + prepare(repositoryId: string): Promise<{ directory: string; repositoryScope: string }> + isAdministrator(membershipId: string): Promise + refuseCredential?(): Promise + runCommand( + arguments_: string[], + options?: { githubToken?: string; timeoutMs?: number; signal?: AbortSignal }, + ): Promise + credential(): Promise<{ githubToken?: string } | null> + updateProgress( + runId: string, + input: { + commentsConsidered: number + commentsLabeled: number + commentsRemaining: number + copilotRequests: number + aiCredits: string + }, + ): Promise + withLock(run: (signal: AbortSignal) => Promise): Promise + }, +) { + const run = await dependencies.getRun(runId) + if (!run || !["QUEUED", "RUNNING"].includes(run.state)) return + try { + await dependencies.withLock(async (signal) => { + if (run.state === "QUEUED" && !(await dependencies.claim(runId, dependencies.now()))) return + const current = await dependencies.getRun(runId) + if (!current) throw new Error("The claimed learning run disappeared.") + if (current.state !== "RUNNING") return + const actor = current.requestedBy?.profile?.login + if ( + !actor || + !current.requestedByMembershipId || + !(await dependencies.isAdministrator(current.requestedByMembershipId)) + ) { + throw new LearningCommandError( + "not_authorized", + "The person who requested this run is no longer an administrator.", + ) + } + const snapshot = await dependencies.capture(current.repositoryId) + if (snapshot.digest !== current.snapshotDigest) { + throw new LearningCommandError( + "snapshot_changed", + "Repository review comments changed before this learning run started. Request another run.", + ) + } + const store = await dependencies.prepare(current.repositoryId) + const common = ["--dir", store.directory, "--repository", store.repositoryScope] + const grants = grantListSchema.parse( + await dependencies.runCommand(["grants", "list", ...common], { signal }), + ) + const sourceGrants = grants.filter((entry) => + entry.grant.sources.includes("hub_review_comments"), + ) + let grantIds = sourceGrants + .filter( + (entry) => + !entry.expired && + entry.activePurposes.includes("review") && + entry.activePurposes.includes("instruction"), + ) + .map((entry) => entry.grant.id) + if (grantIds.length === 0) { + if (sourceGrants.length > 0) { + throw new LearningCommandError( + "grant_inactive", + "Consent to use this repository's review comments ended.", + ) + } + const grant = addedGrantSchema.parse( + await dependencies.runCommand( + [ + "grants", + "add", + "--purpose", + "review", + "--purpose", + "instruction", + "--source", + "hub_review_comments", + "--basis", + "A repository administrator explicitly requested this learning run.", + "--by", + `human:${actor}`, + ...common, + ], + { signal }, + ), + ) + grantIds = [grant.id] + } + + const temporary = await mkdtemp(resolve(tmpdir(), "replica-learning-run-")) + try { + const collectionPath = resolve(temporary, "review-collection.json") + await writeFile(collectionPath, JSON.stringify(snapshot.collection), { mode: 0o600 }) + const imported = importSchema.parse( + await dependencies.runCommand( + [ + "import", + "hub-comments", + collectionPath, + ...grantIds.flatMap((grantId) => ["--grant", grantId]), + "--actor", + "system:replica-hub", + "--redact-deleted", + ...common, + ], + { signal }, + ), + ) + if (!imported.complete) { + throw new LearningCommandError( + "incomplete_collection", + `The repository review snapshot is incomplete: ${imported.problems.join(" ")}`, + ) + } + } finally { + await rm(temporary, { recursive: true }) + } + + const credential = await dependencies.credential() + if (!credential) { + throw new LearningCommandError("copilot_not_connected", "Copilot is not connected.") + } + let labeled: z.infer + try { + labeled = labelSchema.parse( + await dependencies.runCommand( + [ + "label", + "--since", + new Date(snapshot.capturedAt.getTime() - 90 * 24 * 60 * 60 * 1000).toISOString(), + "--limit", + "400", + "--max-requests", + "10", + ...common, + ], + { ...credential, signal, timeoutMs: 30 * 60 * 1000 }, + ), + ) + } catch (error) { + if (error instanceof LearningCommandError && error.result) { + const partial = labelSchema.safeParse(error.result) + if (partial.success) { + await dependencies.updateProgress(runId, { + commentsConsidered: partial.data.considered, + commentsLabeled: partial.data.labeled, + commentsRemaining: partial.data.remaining, + copilotRequests: partial.data.usage.requests, + aiCredits: credits(partial.data.usage.nanoAiu), + }) + } + } + throw error + } + await dependencies.updateProgress(runId, { + commentsConsidered: labeled.considered, + commentsLabeled: labeled.labeled, + commentsRemaining: labeled.remaining, + copilotRequests: labeled.usage.requests, + aiCredits: credits(labeled.usage.nanoAiu), + }) + const consolidated = consolidateSchema.parse( + await dependencies.runCommand( + [ + "consolidate", + "--from", + new Date(snapshot.capturedAt.getTime() - 90 * 24 * 60 * 60 * 1000).toISOString(), + "--to", + snapshot.capturedAt.toISOString(), + "--actor", + "system:replica-hub", + "--max", + "10", + ...common, + ], + { signal }, + ), + ) + if (consolidated.status !== "complete") { + throw new LearningCommandError( + "incomplete_collection", + "The learning store did not collect the complete review window.", + ) + } + await dependencies.finish(runId, { + state: "SUCCEEDED", + suggestions: consolidated.proposals.filter((proposal) => { + if (!proposal.updatedAt || !current.startedAt) return false + const updatedAt = Date.parse(proposal.updatedAt) + return Number.isFinite(updatedAt) && updatedAt >= current.startedAt.getTime() + }).length, + suggestionsRemaining: consolidated.overBudget ?? 0, + finishedAt: dependencies.now(), + }) + }) + } catch (error) { + if ( + error instanceof Error && + error.message === "Another learning operation is still running." + ) { + throw error + } + const current = await dependencies.getRun(runId) + if (current?.state === "QUEUED") throw error + if ( + error instanceof LearningCommandError && + ["unauthorized", "installation_revoked", "permission_denied"].includes(error.code) + ) { + await dependencies.refuseCredential?.() + } + const code = error instanceof LearningCommandError ? error.code : "failed" + const message = + error instanceof LearningCommandError ? error.message : "Hub could not finish this run." + await dependencies.finish(runId, { + state: "FAILED", + failureCode: code.slice(0, 60), + failureSummary: message.slice(0, 1_000), + finishedAt: dependencies.now(), + }) + } +} diff --git a/hub/server/domains/learning/process-review-comment-redaction/index.test.ts b/hub/server/domains/learning/process-review-comment-redaction/index.test.ts new file mode 100644 index 000000000..26d80124b --- /dev/null +++ b/hub/server/domains/learning/process-review-comment-redaction/index.test.ts @@ -0,0 +1,126 @@ +import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join } from "node:path" + +import { describe, expect, it, vi } from "vitest" + +import { processReviewCommentRedaction } from "." + +type Dependencies = Parameters[1] + +async function withLearningLock(run: (signal: AbortSignal) => Promise) { + return await run(new AbortController().signal) +} + +describe("processReviewCommentRedaction()", () => { + it("serializes redaction through the learning lock and does nothing without a store", async () => { + let lockCalls = 0 + async function withLock(run: (signal: AbortSignal) => Promise) { + lockCalls++ + return await withLearningLock(run) + } + const prepare = vi.fn().mockResolvedValue({ + directory: "/private/repository", + repositoryScope: "github.com/repositories/repository", + }) + const runCommand: Dependencies["runCommand"] = vi.fn() + const markComplete = vi.fn().mockResolvedValue(undefined) + + await processReviewCommentRedaction( + { repositoryId: "repository", commentId: 101, actor: "human:mona" }, + { + root: "/private", + markComplete, + now: () => new Date("2026-11-13T10:00:00Z"), + prepare, + runCommand, + withLock, + }, + ) + + expect(lockCalls).toBe(1) + expect(prepare).not.toHaveBeenCalled() + expect(runCommand).not.toHaveBeenCalled() + expect(markComplete).not.toHaveBeenCalled() + }) + + it("redacts by Hub comment ID while holding the store lock", async () => { + const root = await mkdtemp(join(tmpdir(), "replica-redaction-")) + await mkdir(join(root, "repositories", "repository"), { recursive: true }) + await writeFile(join(root, "repositories", "repository", "config.json"), "{}") + try { + let lockCalls = 0 + async function withLock(run: (signal: AbortSignal) => Promise) { + lockCalls++ + return await withLearningLock(run) + } + const prepare = vi.fn().mockResolvedValue({ + directory: join(root, "repositories", "repository"), + repositoryScope: "github.com/repositories/repository", + }) + const runCommand: Dependencies["runCommand"] = vi.fn().mockResolvedValue(undefined) + const markComplete = vi.fn().mockResolvedValue(undefined) + await processReviewCommentRedaction( + { repositoryId: "repository", commentId: 101, actor: "human:mona" }, + { + root, + markComplete, + now: () => new Date("2026-11-13T10:00:00Z"), + prepare, + runCommand, + withLock, + }, + ) + + expect(lockCalls).toBe(1) + expect(prepare).toHaveBeenCalledWith("repository") + const [arguments_, options] = vi.mocked(runCommand).mock.calls[0] ?? [] + expect(arguments_).toEqual([ + "redact", + "--comment", + "101", + "--by", + "human:mona", + "--dir", + join(root, "repositories", "repository"), + "--repository", + "github.com/repositories/repository", + ]) + expect(options?.signal).toBeInstanceOf(AbortSignal) + expect(markComplete).toHaveBeenCalledWith({ + repositoryId: "repository", + commentId: 101, + redactedAt: new Date("2026-11-13T10:00:00Z"), + }) + } finally { + await rm(root, { recursive: true, force: true }) + } + }) + + it("keeps redaction pending when the store is inaccessible", async () => { + const root = await mkdtemp(join(tmpdir(), "replica-redaction-")) + await mkdir(join(root, "repositories", "repository"), { recursive: true }) + await writeFile(join(root, "repositories", "repository", "config.json"), "{}") + try { + const markComplete = vi.fn() + await expect( + processReviewCommentRedaction( + { repositoryId: "repository", commentId: 101, actor: "human:mona" }, + { + root, + markComplete, + now: () => new Date(), + prepare: vi + .fn() + .mockRejectedValue(Object.assign(new Error("denied"), { code: "EACCES" })), + runCommand: vi.fn(), + withLock: withLearningLock, + }, + ), + ).rejects.toMatchObject({ code: "EACCES" }) + expect(markComplete).not.toHaveBeenCalled() + } finally { + await rm(root, { recursive: true, force: true }) + } + }) +}) diff --git a/hub/server/domains/learning/process-review-comment-redaction/index.ts b/hub/server/domains/learning/process-review-comment-redaction/index.ts new file mode 100644 index 000000000..288e83808 --- /dev/null +++ b/hub/server/domains/learning/process-review-comment-redaction/index.ts @@ -0,0 +1,48 @@ +import { access } from "node:fs/promises" +import { resolve } from "node:path" + +export async function processReviewCommentRedaction( + input: { repositoryId: string; commentId: number; actor: string }, + dependencies: { + root: string + prepare(repositoryId: string): Promise<{ directory: string; repositoryScope: string }> + runCommand(arguments_: string[], options: { signal: AbortSignal }): Promise + markComplete(input: { + repositoryId: string + commentId: number + redactedAt: Date + }): Promise + now(): Date + withLock(run: (signal: AbortSignal) => Promise): Promise + }, +) { + await dependencies.withLock(async (signal) => { + const directory = resolve(dependencies.root, "repositories", input.repositoryId) + try { + await access(resolve(directory, "config.json")) + } catch (error) { + if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error + return + } + const store = await dependencies.prepare(input.repositoryId) + await dependencies.runCommand( + [ + "redact", + "--comment", + input.commentId.toString(), + "--by", + input.actor, + "--dir", + store.directory, + "--repository", + store.repositoryScope, + ], + { signal }, + ) + await dependencies.markComplete({ + repositoryId: input.repositoryId, + commentId: input.commentId, + redactedAt: dependencies.now(), + }) + }) +} diff --git a/hub/server/domains/learning/reconcile-learning-decision-operation/index.test.ts b/hub/server/domains/learning/reconcile-learning-decision-operation/index.test.ts new file mode 100644 index 000000000..4263ddb20 --- /dev/null +++ b/hub/server/domains/learning/reconcile-learning-decision-operation/index.test.ts @@ -0,0 +1,70 @@ +import { describe, expect, it, vi } from "vitest" + +import { reconcileLearningDecisionOperation } from "." + +const operation = { + id: "11111111-2222-4333-8444-555555555555", + actorMembershipId: "22222222-2222-4222-8222-222222222222", + decision: "accept", + learningId: "mem_1", + repositoryId: "33333333-3333-4333-8333-333333333333", +} + +describe("reconcileLearningDecisionOperation()", () => { + it("records success when the package store contains the intended decision", async () => { + const finish = vi.fn().mockResolvedValue(undefined) + + await reconcileLearningDecisionOperation(operation, { + finish, + prepare: vi + .fn() + .mockResolvedValue({ directory: "/private/store", repositoryScope: "github.com/x/y" }), + runCommand: vi.fn().mockResolvedValue({ + state: "accepted", + }), + withLock: async (run) => await run(new AbortController().signal), + }) + + expect(finish).toHaveBeenCalledWith( + expect.objectContaining({ + operationId: operation.id, + outcome: "succeeded", + }), + ) + }) + + it("keeps the durable intent pending when the package store cannot be read", async () => { + const finish = vi.fn() + + await expect( + reconcileLearningDecisionOperation(operation, { + finish, + prepare: vi.fn().mockRejectedValue(Object.assign(new Error("denied"), { code: "EACCES" })), + runCommand: vi.fn(), + withLock: async (run) => await run(new AbortController().signal), + }), + ).rejects.toMatchObject({ code: "EACCES" }) + expect(finish).not.toHaveBeenCalled() + }) + + it("records failure after an interrupted command left the proposal undecided", async () => { + const finish = vi.fn().mockResolvedValue(undefined) + + await reconcileLearningDecisionOperation(operation, { + finish, + prepare: vi + .fn() + .mockResolvedValue({ directory: "/private/store", repositoryScope: "github.com/x/y" }), + runCommand: vi.fn().mockResolvedValue({ state: null }), + withLock: async (run) => await run(new AbortController().signal), + }) + + expect(finish).toHaveBeenCalledWith( + expect.objectContaining({ + operationId: operation.id, + outcome: "failed", + reason: "interrupted_or_failed", + }), + ) + }) +}) diff --git a/hub/server/domains/learning/reconcile-learning-decision-operation/index.ts b/hub/server/domains/learning/reconcile-learning-decision-operation/index.ts new file mode 100644 index 000000000..c6ae9360b --- /dev/null +++ b/hub/server/domains/learning/reconcile-learning-decision-operation/index.ts @@ -0,0 +1,66 @@ +import { randomUUID } from "node:crypto" +import { z } from "zod" + +const resultSchema = z + .object({ + state: z.enum(["proposed", "accepted", "rejected", "retired"]).nullable(), + }) + .loose() + +export async function reconcileLearningDecisionOperation( + operation: { + id: string + actorMembershipId: string + decision: string + learningId: string + repositoryId: string + }, + dependencies: { + finish(input: { + auditId: string + operationId: string + outcome: "succeeded" | "failed" + reason?: string + }): Promise + prepare(repositoryId: string): Promise<{ directory: string; repositoryScope: string }> + runCommand(arguments_: string[], options: { signal: AbortSignal }): Promise + withLock(run: (signal: AbortSignal) => Promise): Promise + }, +) { + const expected = { + accept: "accepted", + reject: "rejected", + retire: "retired", + }[operation.decision] + if (!expected) throw new Error("The pending learning decision is invalid.") + await dependencies.withLock(async (signal) => { + let outcome: "succeeded" | "failed" = "failed" + let reason = "interrupted_or_failed" + const store = await dependencies.prepare(operation.repositoryId) + const result = resultSchema.parse( + await dependencies.runCommand( + [ + "operation-status", + operation.learningId, + "--operation-id", + operation.id, + "--dir", + store.directory, + "--repository", + store.repositoryScope, + ], + { signal }, + ), + ) + if (result.state === expected) { + outcome = "succeeded" + reason = "" + } + await dependencies.finish({ + auditId: randomUUID(), + operationId: operation.id, + outcome, + ...(reason ? { reason } : {}), + }) + }) +} diff --git a/hub/server/domains/learning/review-comment-learning-source/types.ts b/hub/server/domains/learning/review-comment-learning-source/types.ts new file mode 100644 index 000000000..b6c5ecdc9 --- /dev/null +++ b/hub/server/domains/learning/review-comment-learning-source/types.ts @@ -0,0 +1,37 @@ +import type { LearningEvidence } from "../types.ts" + +export interface LearningEvidenceReference { + episodeId: string + eventIds: string[] + source: { + kind?: string + hubOrigin?: string + repositoryId?: string + prototypeId?: string + threadId?: number + commentId?: number + } +} + +export interface LearningObservationEvent { + id: string + episodeId: string + at: string + payload: { + commentId: number + body: string | null + } +} + +export interface ReviewCommentLearningSource { + resolveEvidence(input: { + repositoryId: string + references: LearningEvidenceReference[] + events: LearningObservationEvent[] + }): Promise> + captureCompleteSnapshot(input: { repositoryId: string }): Promise<{ + collection: unknown + digest: `sha256:${string}` + capturedAt: Date + }> +} diff --git a/hub/server/domains/learning/types.ts b/hub/server/domains/learning/types.ts new file mode 100644 index 000000000..2278f6dab --- /dev/null +++ b/hub/server/domains/learning/types.ts @@ -0,0 +1,36 @@ +export interface LearningEvidence { + eventId: string + commentId: number + body: string | null + authorLogin: string + authorAvatarUrl: string | null + prototypeId: string + prototypeName: string + createdAt: string +} + +export interface LearningSuggestion { + id: string + content: string + reviewDigest: string + support: { reviewers: number; prototypes: number } | null + replaces: Array<{ id: string; content: string | null }> + evidence: LearningEvidence[] + otherEvidenceCount: number + contradictions: LearningEvidence[] + otherContradictionsCount: number +} + +export interface AcceptedLearning { + id: string + content: string | null + acceptedBy: string | null + acceptedAt: string | null + edited: boolean + status: "recalled" | "not-recalled" | "budget-excluded" | "damaged" | "identity-review" +} + +export type LearningDecision = + | { decision: "accept"; digest: string; content?: string } + | { decision: "reject"; digest: string; reason: string } + | { decision: "retire"; reason: string } diff --git a/hub/server/domains/review-comments/create-review-comment-service/index.ts b/hub/server/domains/review-comments/create-review-comment-service/index.ts index e110df545..62cc331dc 100644 --- a/hub/server/domains/review-comments/create-review-comment-service/index.ts +++ b/hub/server/domains/review-comments/create-review-comment-service/index.ts @@ -63,6 +63,14 @@ export function createReviewCommentService( sessionDigest: string, userId: string, ) => Promise = () => Promise.resolve(true), + options: { + onDeleted?: (input: { + repositoryId: string + commentId: number + actorLogin: string + }) => Promise + withDeleteLock?: (operation: () => Promise) => Promise + } = {}, ): ReviewCommentService { const repository = createReviewCommentRepository(database) return { @@ -113,15 +121,40 @@ export function createReviewCommentService( return serializeReviewThread(result.value) }, async deleteComment(input) { - const result = await runReviewMutation(() => - repository.deleteComment({ - ...input, - authorize: (transaction) => - authorizeMutation(transaction, input.sessionDigest, input.actor.userId), - }), - ) + function operation() { + return runReviewMutation(() => + repository.deleteComment({ + ...input, + authorize: (transaction) => + authorizeMutation(transaction, input.sessionDigest, input.actor.userId), + }), + ) + } + let result + try { + result = options.withDeleteLock + ? await options.withDeleteLock(operation) + : await operation() + } catch (error) { + if ( + error instanceof Error && + error.message === "Another learning operation is still running." + ) { + throw new ReviewCommentError( + "conflict", + "A learning operation is using review comments. Try again.", + ) + } + throw error + } if (!result.ok) throw persistenceError(result.reason) - return serializeReviewThread(result.value) + const thread = serializeReviewThread(result.value) + await options.onDeleted?.({ + repositoryId: input.repositoryId, + commentId: input.commentId, + actorLogin: input.actor.login, + }) + return thread }, async setResolution(input) { const result = await runReviewMutation(() => diff --git a/hub/server/domains/review-comments/review-comments.db.test.ts b/hub/server/domains/review-comments/review-comments.db.test.ts index 031b9a233..5a9d22d90 100644 --- a/hub/server/domains/review-comments/review-comments.db.test.ts +++ b/hub/server/domains/review-comments/review-comments.db.test.ts @@ -362,6 +362,15 @@ describe("review comments", () => { editedAt, deletedAt: deletedReply?.deletedAt, }) + await expect( + prisma.reviewComment.findUniqueOrThrow({ + where: { publicId: reply.id }, + select: { learningRedactionActor: true, learningRedactedAt: true }, + }), + ).resolves.toEqual({ + learningRedactionActor: `human:${author.login}`, + learningRedactedAt: null, + }) await expect( service.editComment({ repositoryId: repository.id, @@ -566,9 +575,15 @@ describe("review comments", () => { expect(storedFirst).toMatchObject({ buildNumber: 4, anchor }) expect(storedFirst?.root.author).toEqual(author) expect(storedFirst?.replies.map(({ author: replyAuthor }) => replyAuthor)).toEqual([reviewer]) - expect(storedFirst?.resolutionHistory.map(({ state, actor }) => ({ state, actor }))).toEqual([ - { state: "resolved", actor: reviewer }, - ]) + expect(storedFirst?.root.author.userId).toMatch(/^[0-9a-f-]{36}$/) + expect(storedFirst?.replies[0]?.author.userId).toMatch(/^[0-9a-f-]{36}$/) + expect( + storedFirst?.resolutionHistory.map(({ state, actor }) => ({ + state, + actor, + })), + ).toEqual([{ state: "resolved", actor: reviewer }]) + expect(storedFirst?.resolutionHistory[0]?.actor.userId).toMatch(/^[0-9a-f-]{36}$/) const storedSecond = snapshot.threads.find(({ buildNumber }) => buildNumber === 9) expect(storedSecond).toMatchObject({ anchor: areaAnchor, diff --git a/hub/server/index.test.ts b/hub/server/index.test.ts index 8b1127bd1..afc05c00d 100644 --- a/hub/server/index.test.ts +++ b/hub/server/index.test.ts @@ -140,6 +140,8 @@ describe("server runtime", () => { .mockResolvedValue(authentication) const copilotConnection = { applicationOrigin: "http://127.0.0.1:5173" } const createCopilotConnectionRouteDependencies = vi.fn().mockResolvedValue(copilotConnection) + const learnings = { applicationOrigin: "http://127.0.0.1:5173" } + const createLearningsRouteDependencies = vi.fn().mockResolvedValue(learnings) const disableAuthenticationProviders = vi.fn() const product = {} const createProductRouteDependencies = vi.fn().mockReturnValue(product) @@ -165,6 +167,9 @@ describe("server runtime", () => { "./routes/api/copilot-connection/create-copilot-connection-route-dependencies/index.ts", () => ({ createCopilotConnectionRouteDependencies }), ) + vi.doMock("./routes/api/learnings/create-learnings-route-dependencies/index.ts", () => ({ + createLearningsRouteDependencies, + })) await expect(import("./index.ts")).resolves.toBeDefined() @@ -182,8 +187,13 @@ describe("server runtime", () => { logger, administrators, ) + expect(createLearningsRouteDependencies).toHaveBeenCalledWith( + environment, + authentication.currentSession, + logger, + ) expect(runApi).toHaveBeenCalledWith( - expect.objectContaining({ authentication, copilotConnection, product }), + expect.objectContaining({ authentication, copilotConnection, learnings, product }), ) }) @@ -257,6 +267,7 @@ describe("server runtime", () => { it("loads route-owned authentication composition when auth is configured", async () => { const createAuthenticationRouteDependencies = vi.fn() const createCopilotConnectionRouteDependencies = vi.fn() + const createLearningsRouteDependencies = vi.fn() const disableAuthenticationProviders = vi.fn() const product = { listRepositories: vi.fn(), findRepositoryIndex: vi.fn() } const createProductRouteDependencies = vi.fn().mockReturnValue(product) @@ -274,6 +285,9 @@ describe("server runtime", () => { const copilotConnection = { applicationOrigin: "https://hub.example.test", } + const learnings = { + applicationOrigin: "https://hub.example.test", + } vi.stubEnv("HUB_APPLICATION_ORIGIN", "https://hub.example.test") vi.stubEnv("GITHUB_CLIENT_ID", "github-client") vi.mocked(parseRuntimeConfig).mockReturnValue({ @@ -282,6 +296,7 @@ describe("server runtime", () => { }) createAuthenticationRouteDependencies.mockResolvedValue(authentication) createCopilotConnectionRouteDependencies.mockResolvedValue(copilotConnection) + createLearningsRouteDependencies.mockResolvedValue(learnings) vi.doMock("./routes/api/auth/create-authentication-route-dependencies/index.ts", () => ({ createAuthenticationRouteDependencies, disableAuthenticationProviders, @@ -293,6 +308,9 @@ describe("server runtime", () => { "./routes/api/copilot-connection/create-copilot-connection-route-dependencies/index.ts", () => ({ createCopilotConnectionRouteDependencies }), ) + vi.doMock("./routes/api/learnings/create-learnings-route-dependencies/index.ts", () => ({ + createLearningsRouteDependencies, + })) await expect(import("./index.ts")).resolves.toBeDefined() @@ -303,9 +321,14 @@ describe("server runtime", () => { logger, administrators, ) + expect(createLearningsRouteDependencies).toHaveBeenCalledWith( + process.env, + authentication.currentSession, + logger, + ) expect(disableAuthenticationProviders).not.toHaveBeenCalled() expect(runApi).toHaveBeenCalledWith( - expect.objectContaining({ authentication, copilotConnection, product }), + expect.objectContaining({ authentication, copilotConnection, learnings, product }), ) }) }) diff --git a/hub/server/index.ts b/hub/server/index.ts index 93eb5ca13..910d9b21f 100644 --- a/hub/server/index.ts +++ b/hub/server/index.ts @@ -17,6 +17,7 @@ import { jobProcessors } from "./workers/configuration.ts" import { runJobWorker } from "./workers/run-job-worker/index.ts" import type { AuthenticationRouteDependencies } from "./routes/api/auth/types.ts" import type { CopilotConnectionRouteDependencies } from "./routes/api/copilot-connection/types.ts" +import type { LearningsRouteDependencies } from "./routes/api/learnings/types.ts" import type { ProductRouteDependencies } from "./routes/api/product/types.ts" class AuthenticationConfigurationError extends Error {} @@ -44,6 +45,7 @@ try { const trustedProxyHops = runsApi ? configuredTrustedProxyHops : 0 let authentication: AuthenticationRouteDependencies | undefined let copilotConnection: CopilotConnectionRouteDependencies | undefined + let learnings: LearningsRouteDependencies | undefined let product: ProductRouteDependencies | undefined if (runsApi) { const authenticationEnvironment = resolveLocalSignInEnvironment(process.env) @@ -82,9 +84,6 @@ try { try { if (authenticationConfiguration.providerConfigured) { authentication = await createAuthenticationRouteDependencies(authenticationEnvironment) - const { createProductRouteDependencies } = - await import("./routes/api/product/create-product-route-dependencies/index.ts") - product = createProductRouteDependencies() const { createCopilotConnectionRouteDependencies } = await import("./routes/api/copilot-connection/create-copilot-connection-route-dependencies/index.ts") copilotConnection = await createCopilotConnectionRouteDependencies( @@ -92,6 +91,21 @@ try { logger, authentication.administrators, ) + const { createLearningsRouteDependencies } = + await import("./routes/api/learnings/create-learnings-route-dependencies/index.ts") + const learningDependencies = await createLearningsRouteDependencies( + authenticationEnvironment, + authentication.currentSession, + logger, + ) + learnings = learningDependencies + const { createProductRouteDependencies } = + await import("./routes/api/product/create-product-route-dependencies/index.ts") + product = createProductRouteDependencies({ + onReviewCommentDeleted: (input) => learningDependencies.redactComment(input), + withReviewCommentDeleteLock: (operation) => + learningDependencies.serializeReviewCommentDeletion(operation), + }) } else { await disableAuthenticationProviders() } @@ -113,6 +127,7 @@ try { isReady: isStorageReady, authentication, copilotConnection, + learnings, product, trustedProxyHops, }) @@ -127,6 +142,7 @@ try { isStorageReady, authentication, copilotConnection, + learnings, product, trustedProxyHops, }) diff --git a/hub/server/integrations/bullmq/enqueue-recoverable-job/index.test.ts b/hub/server/integrations/bullmq/enqueue-recoverable-job/index.test.ts new file mode 100644 index 000000000..e12077a61 --- /dev/null +++ b/hub/server/integrations/bullmq/enqueue-recoverable-job/index.test.ts @@ -0,0 +1,37 @@ +import { describe, expect, it, vi } from "vitest" + +import { enqueueRecoverableJob } from "." + +describe("enqueueRecoverableJob()", () => { + it("replaces a retained failed job before re-enqueueing pending work", async () => { + const remove = vi.fn().mockResolvedValue(undefined) + const existing = { + getState: vi.fn().mockResolvedValue("failed"), + remove, + } + const add = vi.fn().mockResolvedValue({ id: "job-1" }) + const queue = { getJob: vi.fn().mockResolvedValue(existing), add } + const definition = { name: "test.job", schema: { parse: (value: unknown) => value } } + + await enqueueRecoverableJob(queue as never, definition as never, { value: 1 }, "job-1") + + expect(remove).toHaveBeenCalledOnce() + expect(add).toHaveBeenCalledOnce() + }) + + it("keeps an active job with the stable ID", async () => { + const existing = { + getState: vi.fn().mockResolvedValue("active"), + remove: vi.fn(), + } + const add = vi.fn() + const queue = { getJob: vi.fn().mockResolvedValue(existing), add } + const definition = { name: "test.job", schema: { parse: (value: unknown) => value } } + + await expect( + enqueueRecoverableJob(queue as never, definition as never, { value: 1 }, "job-1"), + ).resolves.toBe(existing) + expect(existing.remove).not.toHaveBeenCalled() + expect(add).not.toHaveBeenCalled() + }) +}) diff --git a/hub/server/integrations/bullmq/enqueue-recoverable-job/index.ts b/hub/server/integrations/bullmq/enqueue-recoverable-job/index.ts new file mode 100644 index 000000000..d2c98ca08 --- /dev/null +++ b/hub/server/integrations/bullmq/enqueue-recoverable-job/index.ts @@ -0,0 +1,20 @@ +import type { JobDefinition, JobQueue } from "../types.ts" +import { enqueueJob } from "../enqueue-job/index.ts" + +export async function enqueueRecoverableJob( + queue: JobQueue, + definition: JobDefinition, + payload: T, + jobId: string, +) { + const existing = await queue.getJob(jobId) + if (existing) { + const state = await existing.getState() + if (state === "failed" || state === "completed") { + await existing.remove() + } else { + return existing + } + } + return enqueueJob(queue, definition, payload, { jobId }) +} diff --git a/hub/server/integrations/learning/run-learning-command/errors.ts b/hub/server/integrations/learning/run-learning-command/errors.ts index 99a9eb400..985a2a24c 100644 --- a/hub/server/integrations/learning/run-learning-command/errors.ts +++ b/hub/server/integrations/learning/run-learning-command/errors.ts @@ -1,9 +1,11 @@ export class LearningCommandError extends Error { readonly code: string + readonly result: unknown - constructor(code: string, message: string, options?: ErrorOptions) { + constructor(code: string, message: string, options?: ErrorOptions & { result?: unknown }) { super(message, options) this.name = "LearningCommandError" this.code = code + this.result = options?.result } } diff --git a/hub/server/integrations/learning/run-learning-command/index.test.ts b/hub/server/integrations/learning/run-learning-command/index.test.ts index 12e5d95f9..1b394b248 100644 --- a/hub/server/integrations/learning/run-learning-command/index.test.ts +++ b/hub/server/integrations/learning/run-learning-command/index.test.ts @@ -59,6 +59,23 @@ describe("runLearningCommand()", () => { expect(result.environment.COPILOT_GITHUB_TOKEN).toBeUndefined() }) + it("preserves valid JSON progress from a failed command", async () => { + await expect( + runLearningCommand(["label"], { + cliPath: resolve(fixtures, "fail-with-json.mjs"), + environment: { PATH: process.env.PATH }, + }), + ).rejects.toMatchObject({ + code: "unauthorized", + result: { + considered: 3, + labeled: 2, + remaining: 1, + usage: { requests: 2, nanoAiu: 1_250_000 }, + }, + }) + }) + it.each([ ["stdout", "outputLimit"], ["stderr", "errorLimit"], diff --git a/hub/server/integrations/learning/run-learning-command/index.ts b/hub/server/integrations/learning/run-learning-command/index.ts index b5766f048..512519764 100644 --- a/hub/server/integrations/learning/run-learning-command/index.ts +++ b/hub/server/integrations/learning/run-learning-command/index.ts @@ -215,12 +215,21 @@ export async function runLearningCommand( const stderr = Buffer.concat(errors).toString("utf8").trim() if (code !== 0) { const match = errorPattern.exec(stderr) + let result: unknown + if (stdout.trim()) { + try { + result = JSON.parse(stdout) + } catch { + result = undefined + } + } reject( new LearningCommandError( match?.[1] ?? (code === 2 ? "invalid_request" : "learning_failed"), match?.[2]?.trim() || stderr.split("\n")[0]?.replace(/^error:\s*/, "") || "replica-learning failed.", + { result }, ), ) return diff --git a/hub/server/repositories/learning-decision-operations/create-learning-decision-operation/index.ts b/hub/server/repositories/learning-decision-operations/create-learning-decision-operation/index.ts new file mode 100644 index 000000000..9d93e05de --- /dev/null +++ b/hub/server/repositories/learning-decision-operations/create-learning-decision-operation/index.ts @@ -0,0 +1,14 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function createLearningDecisionOperation( + database: Pick, + input: { + id: string + repositoryId: string + actorMembershipId: string + learningId: string + decision: "accept" | "reject" | "retire" + }, +) { + return database.learningDecisionOperation.create({ data: input }) +} diff --git a/hub/server/repositories/learning-decision-operations/delete-learning-decision-operation/index.ts b/hub/server/repositories/learning-decision-operations/delete-learning-decision-operation/index.ts new file mode 100644 index 000000000..ed351f01f --- /dev/null +++ b/hub/server/repositories/learning-decision-operations/delete-learning-decision-operation/index.ts @@ -0,0 +1,8 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function deleteLearningDecisionOperation( + database: Pick, + operationId: string, +) { + return database.learningDecisionOperation.deleteMany({ where: { id: operationId } }) +} diff --git a/hub/server/repositories/learning-decision-operations/list-learning-decision-operations/index.ts b/hub/server/repositories/learning-decision-operations/list-learning-decision-operations/index.ts new file mode 100644 index 000000000..b18bdfbc8 --- /dev/null +++ b/hub/server/repositories/learning-decision-operations/list-learning-decision-operations/index.ts @@ -0,0 +1,11 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function listLearningDecisionOperations( + database: Pick, + limit = 100, +) { + return database.learningDecisionOperation.findMany({ + orderBy: [{ createdAt: "asc" }, { id: "asc" }], + take: limit, + }) +} diff --git a/hub/server/repositories/learning-runs/claim-learning-run/index.test.ts b/hub/server/repositories/learning-runs/claim-learning-run/index.test.ts new file mode 100644 index 000000000..bc5e1ccb7 --- /dev/null +++ b/hub/server/repositories/learning-runs/claim-learning-run/index.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it, vi } from "vitest" + +import { claimLearningRun } from "." + +describe("claimLearningRun()", () => { + it("claims only queued runs and reports whether this worker won", async () => { + const updateMany = vi + .fn() + .mockResolvedValueOnce({ count: 1 }) + .mockResolvedValueOnce({ count: 0 }) + const database = { learningRun: { updateMany } } + const startedAt = new Date("2026-11-13T10:00:00Z") + + await expect(claimLearningRun(database, "run-1", startedAt)).resolves.toBe(true) + await expect(claimLearningRun(database, "run-1", startedAt)).resolves.toBe(false) + expect(updateMany).toHaveBeenNthCalledWith(1, { + where: { id: "run-1", state: "QUEUED" }, + data: { state: "RUNNING", startedAt }, + }) + }) +}) diff --git a/hub/server/repositories/learning-runs/claim-learning-run/index.ts b/hub/server/repositories/learning-runs/claim-learning-run/index.ts new file mode 100644 index 000000000..a443f7d8d --- /dev/null +++ b/hub/server/repositories/learning-runs/claim-learning-run/index.ts @@ -0,0 +1,18 @@ +export async function claimLearningRun( + database: { + learningRun: { + updateMany(input: { + where: { id: string; state: "QUEUED" } + data: { state: "RUNNING"; startedAt: Date } + }): Promise<{ count: number }> + } + }, + runId: string, + startedAt: Date, +) { + const changed = await database.learningRun.updateMany({ + where: { id: runId, state: "QUEUED" }, + data: { state: "RUNNING", startedAt }, + }) + return changed.count === 1 +} diff --git a/hub/server/repositories/learning-runs/create-learning-run/index.db.test.ts b/hub/server/repositories/learning-runs/create-learning-run/index.db.test.ts new file mode 100644 index 000000000..b7a323d5b --- /dev/null +++ b/hub/server/repositories/learning-runs/create-learning-run/index.db.test.ts @@ -0,0 +1,33 @@ +import { randomUUID } from "node:crypto" +import { describe, expect, it } from "vitest" + +import { prisma } from "../../../integrations/prisma" +import { createLearningRun } from "." + +describe("createLearningRun()", () => { + it("reuses one active run after concurrent requests without aborting the transaction", async () => { + const repositoryId = randomUUID() + const userId = randomUUID() + const membershipId = randomUUID() + await prisma.repository.create({ + data: { id: repositoryId, nameWithOwner: "team/design", defaultBranch: "main" }, + }) + await prisma.user.create({ data: { id: userId } }) + await prisma.membership.create({ data: { id: membershipId, userId } }) + const input = { + repositoryId, + requestedById: userId, + requestedByMembershipId: membershipId, + snapshotDigest: `sha256:${"a".repeat(64)}`, + } + + const results = await Promise.all([ + prisma.$transaction((transaction) => createLearningRun(transaction, input)), + prisma.$transaction((transaction) => createLearningRun(transaction, input)), + ]) + + expect(new Set(results.map(({ run }) => run.id)).size).toBe(1) + expect(results.filter(({ created }) => created)).toHaveLength(1) + expect(await prisma.learningRun.count()).toBe(1) + }) +}) diff --git a/hub/server/repositories/learning-runs/create-learning-run/index.ts b/hub/server/repositories/learning-runs/create-learning-run/index.ts new file mode 100644 index 000000000..0a51e373e --- /dev/null +++ b/hub/server/repositories/learning-runs/create-learning-run/index.ts @@ -0,0 +1,29 @@ +import { randomUUID } from "node:crypto" +import type { Prisma } from "../../../generated/prisma/client.ts" + +export async function createLearningRun( + database: Pick, + input: { + repositoryId: string + requestedById: string + requestedByMembershipId: string + snapshotDigest: string + }, +) { + const id = randomUUID() + const created = await database.learningRun.createMany({ + data: { id, ...input }, + skipDuplicates: true, + }) + const run = await database.learningRun.findFirst({ + where: + created.count === 1 + ? { id } + : { + repositoryId: input.repositoryId, + state: { in: ["QUEUED", "RUNNING"] }, + }, + }) + if (!run) throw new Error("The active learning run could not be found.") + return { run, created: created.count === 1 } +} diff --git a/hub/server/repositories/learning-runs/finish-learning-run/index.ts b/hub/server/repositories/learning-runs/finish-learning-run/index.ts new file mode 100644 index 000000000..737d32786 --- /dev/null +++ b/hub/server/repositories/learning-runs/finish-learning-run/index.ts @@ -0,0 +1,24 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function finishLearningRun( + database: Pick, + runId: string, + input: + | { + state: "SUCCEEDED" + suggestions: number + suggestionsRemaining: number + finishedAt: Date + } + | { + state: "FAILED" + failureCode: string + failureSummary: string + finishedAt: Date + }, +) { + return database.learningRun.updateMany({ + where: { id: runId, state: { in: ["QUEUED", "RUNNING"] } }, + data: input, + }) +} diff --git a/hub/server/repositories/learning-runs/get-learning-run/index.ts b/hub/server/repositories/learning-runs/get-learning-run/index.ts new file mode 100644 index 000000000..94c920795 --- /dev/null +++ b/hub/server/repositories/learning-runs/get-learning-run/index.ts @@ -0,0 +1,15 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function getLearningRun( + database: Pick, + runId: string, +) { + return database.learningRun.findUnique({ + where: { id: runId }, + include: { + repository: true, + requestedBy: { include: { profile: true } }, + requestedByMembership: true, + }, + }) +} diff --git a/hub/server/repositories/learning-runs/list-learning-runs/index.db.test.ts b/hub/server/repositories/learning-runs/list-learning-runs/index.db.test.ts new file mode 100644 index 000000000..55e5244a0 --- /dev/null +++ b/hub/server/repositories/learning-runs/list-learning-runs/index.db.test.ts @@ -0,0 +1,125 @@ +import { randomUUID } from "node:crypto" +import { describe, expect, it } from "vitest" + +import { prisma } from "../../../integrations/prisma" +import { updateLearningRunProgress } from "../update-learning-run-progress" +import { listLearningRuns } from "." + +describe("listLearningRuns()", () => { + it("returns recent state and sums decimal usage from the previous 30 days", async () => { + const repositoryId = randomUUID() + const userId = randomUUID() + await prisma.repository.create({ + data: { id: repositoryId, nameWithOwner: "team/design", defaultBranch: "main" }, + }) + await prisma.user.create({ data: { id: userId } }) + await prisma.userProfile.create({ + data: { userId, provider: "github", login: "mona", name: "Mona" }, + }) + await prisma.learningRun.createMany({ + data: [ + { + repositoryId, + snapshotDigest: `sha256:${"a".repeat(64)}`, + requestedById: userId, + state: "SUCCEEDED", + startedAt: new Date("2026-11-12T10:00:00Z"), + finishedAt: new Date("2026-11-12T10:10:00Z"), + commentsConsidered: 4, + commentsLabeled: 2, + suggestions: 1, + copilotRequests: 1, + aiCredits: "0.021", + createdAt: new Date("2026-11-12T10:00:00Z"), + }, + { + repositoryId, + snapshotDigest: `sha256:${"b".repeat(64)}`, + scheduled: true, + state: "FAILED", + failureCode: "copilot_refused", + failureSummary: "Copilot refused the credential.", + finishedAt: new Date("2026-09-01T10:01:00Z"), + copilotRequests: 1, + aiCredits: "0.5", + createdAt: new Date("2026-09-01T10:00:00Z"), + }, + ], + }) + + const result = await listLearningRuns(prisma, repositoryId, new Date("2026-11-13T10:00:00Z")) + + expect(result.usageCredits).toBe("0.021") + expect(result.active).toBe(false) + expect(result.runs).toHaveLength(2) + expect(result.runs[0]?.startedBy).toEqual({ type: "user", login: "mona" }) + expect(result.runs[0]?.state).toBe("succeeded") + expect(result.runs[0]?.result?.type).toBe("succeeded") + if (result.runs[0]?.result?.type !== "succeeded") throw new Error("Expected success result.") + expect(result.runs[0].result.commentsConsidered).toBe(4) + expect(result.runs[0]?.usage).toEqual({ credits: "0.021", requests: 1 }) + expect(result.runs[1]?.startedBy).toEqual({ type: "daily" }) + expect(result.runs[1]?.state).toBe("failed") + expect(result.runs[1]?.result).toEqual({ + type: "failed", + summary: "Copilot refused the credential.", + }) + }) + + it("allows only one queued or running record for a repository", async () => { + const repositoryId = randomUUID() + await prisma.repository.create({ + data: { id: repositoryId, nameWithOwner: "team/design", defaultBranch: "main" }, + }) + await prisma.learningRun.create({ + data: { repositoryId, snapshotDigest: `sha256:${"a".repeat(64)}` }, + }) + + await expect( + prisma.learningRun.create({ + data: { + repositoryId, + snapshotDigest: `sha256:${"b".repeat(64)}`, + state: "RUNNING", + startedAt: new Date(), + }, + }), + ).rejects.toThrow() + }) + + it("accumulates recovered labeling work without replacing earlier usage", async () => { + const repositoryId = randomUUID() + await prisma.repository.create({ + data: { id: repositoryId, nameWithOwner: "team/design", defaultBranch: "main" }, + }) + const run = await prisma.learningRun.create({ + data: { + repositoryId, + snapshotDigest: `sha256:${"a".repeat(64)}`, + state: "RUNNING", + startedAt: new Date(), + commentsConsidered: 4, + commentsLabeled: 3, + commentsRemaining: 2, + copilotRequests: 1, + aiCredits: "0.001", + }, + }) + await updateLearningRunProgress(prisma, run.id, { + commentsConsidered: 2, + commentsLabeled: 1, + commentsRemaining: 0, + copilotRequests: 1, + aiCredits: "0.0025", + }) + + const updated = await prisma.learningRun.findUniqueOrThrow({ where: { id: run.id } }) + expect(updated).toMatchObject({ + commentsConsidered: 6, + commentsLabeled: 4, + commentsRemaining: 0, + copilotRequests: 2, + }) + expect(updated.aiCredits.toString()).toBe("0.0035") + }) +}) diff --git a/hub/server/repositories/learning-runs/list-learning-runs/index.ts b/hub/server/repositories/learning-runs/list-learning-runs/index.ts new file mode 100644 index 000000000..ced1a6c55 --- /dev/null +++ b/hub/server/repositories/learning-runs/list-learning-runs/index.ts @@ -0,0 +1,57 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export async function listLearningRuns( + database: Pick, + repositoryId: string, + now: Date, +) { + const [records, usage] = await Promise.all([ + database.learningRun.findMany({ + where: { repositoryId }, + include: { requestedBy: { include: { profile: true } } }, + orderBy: [{ createdAt: "desc" }, { number: "desc" }], + take: 10, + }), + database.learningRun.aggregate({ + where: { + repositoryId, + startedAt: { gte: new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000) }, + }, + _sum: { aiCredits: true }, + }), + ]) + return { + active: records.some((record) => record.state === "QUEUED" || record.state === "RUNNING"), + usageCredits: usage._sum.aiCredits?.toString() ?? "0", + runs: records.map((record) => ({ + id: record.number, + startedAt: (record.startedAt ?? record.createdAt).toISOString(), + startedBy: record.scheduled + ? ({ type: "daily" } as const) + : record.requestedBy?.profile?.login + ? ({ type: "user", login: record.requestedBy.profile.login } as const) + : ({ type: "unknown" } as const), + state: record.state.toLowerCase() as "queued" | "running" | "succeeded" | "failed", + result: + record.state === "SUCCEEDED" + ? { + type: "succeeded" as const, + commentsConsidered: record.commentsConsidered, + commentsLabeled: record.commentsLabeled, + commentsRemaining: record.commentsRemaining, + suggestions: record.suggestions, + suggestionsRemaining: record.suggestionsRemaining, + } + : record.state === "FAILED" + ? { + type: "failed" as const, + summary: record.failureSummary ?? "Hub could not finish this learning run.", + } + : null, + usage: + record.copilotRequests > 0 + ? { credits: record.aiCredits.toString(), requests: record.copilotRequests } + : null, + })), + } +} diff --git a/hub/server/repositories/learning-runs/list-queued-learning-runs/index.ts b/hub/server/repositories/learning-runs/list-queued-learning-runs/index.ts new file mode 100644 index 000000000..4fe426e23 --- /dev/null +++ b/hub/server/repositories/learning-runs/list-queued-learning-runs/index.ts @@ -0,0 +1,13 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function listQueuedLearningRuns( + database: Pick, + limit = 100, +) { + return database.learningRun.findMany({ + where: { state: { in: ["QUEUED", "RUNNING"] } }, + orderBy: [{ createdAt: "asc" }, { id: "asc" }], + take: limit, + select: { id: true }, + }) +} diff --git a/hub/server/repositories/learning-runs/update-learning-run-progress/index.ts b/hub/server/repositories/learning-runs/update-learning-run-progress/index.ts new file mode 100644 index 000000000..a18ec8a33 --- /dev/null +++ b/hub/server/repositories/learning-runs/update-learning-run-progress/index.ts @@ -0,0 +1,24 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function updateLearningRunProgress( + database: Pick, + runId: string, + input: { + commentsConsidered: number + commentsLabeled: number + commentsRemaining: number + copilotRequests: number + aiCredits: string + }, +) { + return database.learningRun.updateMany({ + where: { id: runId, state: "RUNNING" }, + data: { + commentsConsidered: { increment: input.commentsConsidered }, + commentsLabeled: { increment: input.commentsLabeled }, + commentsRemaining: input.commentsRemaining, + copilotRequests: { increment: input.copilotRequests }, + aiCredits: { increment: input.aiCredits }, + }, + }) +} diff --git a/hub/server/repositories/prototype-index/find-active-repository/index.ts b/hub/server/repositories/prototype-index/find-active-repository/index.ts new file mode 100644 index 000000000..5c00239ca --- /dev/null +++ b/hub/server/repositories/prototype-index/find-active-repository/index.ts @@ -0,0 +1,11 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function findActiveRepository( + database: Pick, + repositoryId: string, +) { + return database.repository.findFirst({ + where: { id: repositoryId, removedAt: null }, + select: { id: true, nameWithOwner: true, defaultBranch: true }, + }) +} diff --git a/hub/server/repositories/review-comments/create-review-comment-repository/index.ts b/hub/server/repositories/review-comments/create-review-comment-repository/index.ts index 60ae7bb44..465598c32 100644 --- a/hub/server/repositories/review-comments/create-review-comment-repository/index.ts +++ b/hub/server/repositories/review-comments/create-review-comment-repository/index.ts @@ -366,7 +366,11 @@ export function createReviewCommentRepository(database: Database) { if (changed.count !== 1) return { ok: false, reason: "conflict" } await transaction.reviewComment.update({ where: { id: comment.id }, - data: { deletedAt: new Date() }, + data: { + deletedAt: new Date(), + learningRedactionActor: `human:${input.actor.login}`, + learningRedactedAt: null, + }, }) } const stored = await findStoredThread( diff --git a/hub/server/repositories/review-comments/list-deleted-review-comments/index.ts b/hub/server/repositories/review-comments/list-deleted-review-comments/index.ts new file mode 100644 index 000000000..c124e0af5 --- /dev/null +++ b/hub/server/repositories/review-comments/list-deleted-review-comments/index.ts @@ -0,0 +1,32 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function listDeletedReviewComments( + database: Pick, + input: { after?: { deletedAt: Date; id: string }; limit?: number } = {}, +) { + const limit = input.limit ?? 100 + return database.reviewComment.findMany({ + where: { + deletedAt: { not: null }, + learningRedactedAt: null, + ...(input.after + ? { + OR: [ + { deletedAt: { gt: input.after.deletedAt } }, + { deletedAt: input.after.deletedAt, id: { gt: input.after.id } }, + ], + } + : {}), + }, + orderBy: [{ deletedAt: "asc" }, { id: "asc" }], + take: limit, + select: { + publicId: true, + id: true, + deletedAt: true, + authorLogin: true, + learningRedactionActor: true, + thread: { select: { repositoryId: true } }, + }, + }) +} diff --git a/hub/server/repositories/review-comments/mark-review-comment-learning-redacted/index.ts b/hub/server/repositories/review-comments/mark-review-comment-learning-redacted/index.ts new file mode 100644 index 000000000..aa8744f2c --- /dev/null +++ b/hub/server/repositories/review-comments/mark-review-comment-learning-redacted/index.ts @@ -0,0 +1,16 @@ +import type { Prisma } from "../../../generated/prisma/client.ts" + +export function markReviewCommentLearningRedacted( + database: Pick, + input: { repositoryId: string; commentId: number; redactedAt: Date }, +) { + return database.reviewComment.updateMany({ + where: { + publicId: input.commentId, + deletedAt: { not: null }, + learningRedactedAt: null, + thread: { repositoryId: input.repositoryId }, + }, + data: { learningRedactedAt: input.redactedAt }, + }) +} diff --git a/hub/server/repositories/security-audits/create-security-audit/types.ts b/hub/server/repositories/security-audits/create-security-audit/types.ts index 51e6535e4..581298deb 100644 --- a/hub/server/repositories/security-audits/create-security-audit/types.ts +++ b/hub/server/repositories/security-audits/create-security-audit/types.ts @@ -218,6 +218,26 @@ export interface CopilotConnectionAudit extends SecurityAuditEvent { reason?: string } +export interface LearningDecisionAudit extends SecurityAuditEvent { + type: "learning_decision" + actorMembershipId: string + decision: "accept" | "reject" | "retire" + learningId: string + operationId: string + outcome: "requested" | "succeeded" | "failed" + reason?: string + repositoryId: string +} + +export interface LearningRunAudit extends SecurityAuditEvent { + type: "learning_run" + actorMembershipId: string + outcome: "requested" | "failed" + reason?: string + repositoryId: string + runId: string +} + export type CreateSecurityAuditEvent = | AuthenticationAttemptDeniedAudit | BootstrapAttemptDeniedAudit @@ -246,3 +266,5 @@ export type CreateSecurityAuditEvent = | AuthenticationProviderLifecycleAudit | AuthenticationProvidersReconcileFailedAudit | SessionRevocationAdvancedAudit + | LearningDecisionAudit + | LearningRunAudit diff --git a/hub/server/repositories/security-audits/get-security-audit-data/index.ts b/hub/server/repositories/security-audits/get-security-audit-data/index.ts index 13b3e9d5d..bc25248ff 100644 --- a/hub/server/repositories/security-audits/get-security-audit-data/index.ts +++ b/hub/server/repositories/security-audits/get-security-audit-data/index.ts @@ -303,5 +303,43 @@ export function getSecurityAuditData( ...(event.reason ? { reason: event.reason } : {}), }, } + case "learning_decision": + return { + id: event.id, + action: + event.outcome === "requested" + ? `learning.${event.decision}.requested` + : `learning.${event.decision}`, + outcome: + event.outcome === "requested" + ? null + : event.outcome === "succeeded" + ? SecurityAuditOutcome.SUCCESS + : SecurityAuditOutcome.FAILURE, + targetType: "learning", + targetId: event.learningId, + context: { + actorMembershipId: event.actorMembershipId, + operationId: event.operationId, + repositoryId: event.repositoryId, + ...(event.reason ? { reason: event.reason } : {}), + }, + } + case "learning_run": + return { + id: event.id, + action: event.outcome === "requested" ? "learning.run.requested" : "learning.run.failed", + outcome: + event.outcome === "requested" + ? SecurityAuditOutcome.SUCCESS + : SecurityAuditOutcome.FAILURE, + targetType: "learning_run", + targetId: event.runId, + context: { + actorMembershipId: event.actorMembershipId, + repositoryId: event.repositoryId, + ...(event.reason ? { reason: event.reason } : {}), + }, + } } } diff --git a/hub/server/repositories/security-audits/parse-security-audit-event/index.test.ts b/hub/server/repositories/security-audits/parse-security-audit-event/index.test.ts index 4ea4e250e..17171b442 100644 --- a/hub/server/repositories/security-audits/parse-security-audit-event/index.test.ts +++ b/hub/server/repositories/security-audits/parse-security-audit-event/index.test.ts @@ -64,4 +64,36 @@ describe("parseSecurityAuditEvent()", () => { expect(parseSecurityAuditEvent(event)).toEqual(event) }) + + it("accepts a content-free repository learning decision audit", () => { + const event = { + actorMembershipId: "8a2479e7-3ca4-46f8-9749-c35d8e4eb09e", + decision: "accept" as const, + id: "5dd31031-6f1c-4c16-87c2-aee5342145cc", + learningId: "mem_1", + operationId: "e02c9c4c-f661-4618-8ff5-ab9cf10eaece", + outcome: "succeeded" as const, + repositoryId: "df75faa4-ed4c-44ed-8db0-443cc3b426ed", + type: "learning_decision" as const, + } + + expect(parseSecurityAuditEvent(event)).toEqual(event) + expect(parseSecurityAuditEvent({ ...event, outcome: "requested" })).toEqual({ + ...event, + outcome: "requested", + }) + }) + + it("accepts a bounded learning run request audit", () => { + const event = { + actorMembershipId: "8a2479e7-3ca4-46f8-9749-c35d8e4eb09e", + id: "5dd31031-6f1c-4c16-87c2-aee5342145cc", + outcome: "requested" as const, + repositoryId: "df75faa4-ed4c-44ed-8db0-443cc3b426ed", + runId: "e02c9c4c-f661-4618-8ff5-ab9cf10eaece", + type: "learning_run" as const, + } + + expect(parseSecurityAuditEvent(event)).toEqual(event) + }) }) diff --git a/hub/server/repositories/security-audits/parse-security-audit-event/index.ts b/hub/server/repositories/security-audits/parse-security-audit-event/index.ts index 914feb7d1..2cab5a830 100644 --- a/hub/server/repositories/security-audits/parse-security-audit-event/index.ts +++ b/hub/server/repositories/security-audits/parse-security-audit-event/index.ts @@ -277,6 +277,30 @@ const eventSchema = z.discriminatedUnion("type", [ type: z.literal("copilot_connection"), }) .strict(), + z + .object({ + actorMembershipId: z.uuid(), + decision: z.enum(["accept", "reject", "retire"]), + id: z.uuid(), + learningId: z.string().min(1).max(255), + operationId: z.uuid(), + outcome: z.enum(["requested", "succeeded", "failed"]), + reason: z.string().min(1).max(100).optional(), + repositoryId: z.uuid(), + type: z.literal("learning_decision"), + }) + .strict(), + z + .object({ + actorMembershipId: z.uuid(), + id: z.uuid(), + outcome: z.enum(["requested", "failed"]), + reason: z.string().min(1).max(100).optional(), + repositoryId: z.uuid(), + runId: z.uuid(), + type: z.literal("learning_run"), + }) + .strict(), ]) export function parseSecurityAuditEvent(input: unknown): ParsedSecurityAuditEvent { diff --git a/hub/server/repositories/security-audits/parse-security-audit-event/types.ts b/hub/server/repositories/security-audits/parse-security-audit-event/types.ts index 9f7d4cb42..a72e92a27 100644 --- a/hub/server/repositories/security-audits/parse-security-audit-event/types.ts +++ b/hub/server/repositories/security-audits/parse-security-audit-event/types.ts @@ -27,6 +27,8 @@ import type { AllHubSessionsEndedAudit, SessionCreatedAudit, SessionEndedAudit, + LearningDecisionAudit, + LearningRunAudit, } from "../create-security-audit/types.ts" export type ParsedSecurityAuditEvent = @@ -65,3 +67,5 @@ export type ParsedSecurityAuditEvent = providerKeys: ProviderKey[] }) | SessionRevocationAdvancedAudit + | LearningDecisionAudit + | LearningRunAudit diff --git a/hub/server/routes/api/learnings/create-learnings-route-dependencies/index.ts b/hub/server/routes/api/learnings/create-learnings-route-dependencies/index.ts new file mode 100644 index 000000000..c9540aae8 --- /dev/null +++ b/hub/server/routes/api/learnings/create-learnings-route-dependencies/index.ts @@ -0,0 +1,328 @@ +import { randomUUID } from "node:crypto" +import type { Logger } from "pino" + +import { getCopilotConnectionStatus } from "../../../../domains/copilot-connection/get-copilot-connection-status/index.ts" +import { ReviewCommentError } from "../../../../domains/review-comments/errors.ts" +import { executeLearningDecision } from "../../../../domains/learning/execute-learning-decision/index.ts" +import { createReviewCommentLearningSource } from "../../../../domains/learning/create-review-comment-learning-source/index.ts" +import { getLearningOverview } from "../../../../domains/learning/get-learning-overview/index.ts" +import { learningRunJob } from "../../../../domains/learning/jobs/learning-run.ts" +import { redactReviewCommentJob } from "../../../../domains/learning/jobs/redact-review-comment.ts" +import type { ReviewCommentLearningSource } from "../../../../domains/learning/review-comment-learning-source/types.ts" +import { readLearningConfiguration } from "../../../../domains/learning/read-learning-configuration/index.ts" +import { createJobQueue } from "../../../../integrations/bullmq/create-job-queue/index.ts" +import { enqueueJob } from "../../../../integrations/bullmq/enqueue-job/index.ts" +import { LearningCommandError } from "../../../../integrations/learning/run-learning-command/errors.ts" +import { withLearningExecutionLock } from "../../../../integrations/postgres/with-learning-execution-lock/index.ts" +import { prisma } from "../../../../integrations/prisma/index.ts" +import { getCopilotConnectionState } from "../../../../repositories/copilot-connection-states/get-copilot-connection-state/index.ts" +import { getCopilotConnection } from "../../../../repositories/copilot-connections/get-copilot-connection/index.ts" +import { createLearningRun } from "../../../../repositories/learning-runs/create-learning-run/index.ts" +import { finishLearningRun } from "../../../../repositories/learning-runs/finish-learning-run/index.ts" +import { listLearningRuns } from "../../../../repositories/learning-runs/list-learning-runs/index.ts" +import { createLearningDecisionOperation } from "../../../../repositories/learning-decision-operations/create-learning-decision-operation/index.ts" +import { deleteLearningDecisionOperation } from "../../../../repositories/learning-decision-operations/delete-learning-decision-operation/index.ts" +import { isEffectiveAdministrator } from "../../../../repositories/memberships/is-effective-administrator/index.ts" +import { findActiveRepository } from "../../../../repositories/prototype-index/find-active-repository/index.ts" +import { createSecurityAudit } from "../../../../repositories/security-audits/create-security-audit/index.ts" +import { LearningsError } from "../errors.ts" +import { isDefinitiveDecisionRejection } from "../is-definitive-decision-rejection/index.ts" +import type { CurrentSessionDependencies } from "../../auth/types.ts" +import type { LearningsRouteDependencies } from "../types.ts" + +export async function createLearningsRouteDependencies( + environment: NodeJS.ProcessEnv, + currentSession: CurrentSessionDependencies, + logger: Logger, + options: { source?: ReviewCommentLearningSource } = {}, +): Promise { + const configuration = await readLearningConfiguration(environment) + const applicationOrigin = environment.HUB_APPLICATION_ORIGIN + const databaseUrl = environment.DATABASE_URL + if (!applicationOrigin || !databaseUrl) { + throw new Error("HUB_APPLICATION_ORIGIN and DATABASE_URL are required for the Learnings API.") + } + const source = options.source ?? createReviewCommentLearningSource(prisma, applicationOrigin) + + async function getCopilot() { + const connection = await getCopilotConnection(prisma) + const state = await getCopilotConnectionState(prisma) + if (!state) throw new Error("The Copilot connection state is unavailable.") + const status = getCopilotConnectionStatus( + connection + ? { + connectedBy: { + login: connection.connectedByMembership.user.profile?.login ?? null, + membershipId: connection.connectedByMembershipId, + name: connection.connectedByMembership.user.profile?.name ?? null, + }, + credentialDigest: connection.credentialDigest, + credentialProvider: connection.credentialProvider, + verifiedAt: connection.verifiedAt, + } + : null, + configuration.copilotCredentialProvider, + connection + ? await isEffectiveAdministrator(prisma, connection.connectedByMembershipId) + : false, + { + credentialDigest: state.refusedCredentialDigest, + credentialProvider: state.refusedCredentialProvider, + refusedAt: state.refusedAt, + }, + ) + if (status.refusedAt) { + return { state: "refused" as const, refusedAt: status.refusedAt.toISOString() } + } + return status.connected + ? { state: "connected" as const, connectedBy: status.connectedBy?.login ?? null } + : { state: "not-connected" as const } + } + + return { + applicationOrigin, + currentSession, + findRepository: (repositoryId) => findActiveRepository(prisma, repositoryId), + getOverview: async ({ repositoryId, viewer }) => { + try { + return await getLearningOverview({ + ...configuration, + evidenceSource: source, + repositoryId, + viewer, + }) + } catch (error) { + if (!(error instanceof LearningCommandError)) throw error + logger.warn( + { learningFailureCode: error.code, repositoryId }, + "Repository learning overview failed", + ) + return { + loadError: "Hub could not read this repository's learning store.", + identityReviewCount: 0, + suggestions: [], + learnings: [], + recall: { text: "", count: 0 }, + } + } + }, + getCopilot, + listRuns: (repositoryId) => listLearningRuns(prisma, repositoryId, new Date()), + requestRun: async ({ actorMembershipId, repositoryId, requestedById }) => { + if ((await getCopilot()).state !== "connected") { + throw new LearningsError( + 409, + "copilot_not_connected", + "Connect Copilot before looking for learnings.", + ) + } + let snapshot + try { + snapshot = await source.captureCompleteSnapshot({ repositoryId }) + } catch (error) { + if (error instanceof ReviewCommentError && error.code === "not_found") { + throw new LearningsError(404, "repository_not_found", "Repository not found.", { + cause: error, + }) + } + throw new LearningsError( + 409, + "review_snapshot_unavailable", + "Hub could not capture a complete repository review snapshot.", + { cause: error }, + ) + } + const { run, created } = await prisma.$transaction(async (transaction) => { + const result = await createLearningRun(transaction, { + repositoryId, + requestedById, + requestedByMembershipId: actorMembershipId, + snapshotDigest: snapshot.digest, + }) + if (result.created) { + await createSecurityAudit(transaction, { + id: randomUUID(), + type: "learning_run", + actorMembershipId, + outcome: "requested", + repositoryId, + runId: result.run.id, + }) + } + return result + }) + const queue = createJobQueue({ name: "on-demand", databaseUrl, logger }) + try { + await enqueueJob( + queue, + learningRunJob, + { runId: run.id }, + { jobId: `learning-run-${run.id}` }, + ) + } catch (error) { + if (created) { + await finishLearningRun(prisma, run.id, { + state: "FAILED", + failureCode: "enqueue_failed", + failureSummary: "Hub could not queue this learning run.", + finishedAt: new Date(), + }) + await createSecurityAudit(prisma, { + id: randomUUID(), + type: "learning_run", + actorMembershipId, + outcome: "failed", + reason: "enqueue_failed", + repositoryId, + runId: run.id, + }) + } + throw new LearningsError( + 503, + "learning_run_unavailable", + "Hub could not queue this learning run.", + { cause: error }, + ) + } finally { + await queue.close() + } + return { notice: created ? "Learning run requested." : "Learning run already in progress." } + }, + redactComment: async ({ repositoryId, commentId, actorLogin }) => { + const queue = createJobQueue({ name: "on-demand", databaseUrl, logger }) + try { + await enqueueJob( + queue, + redactReviewCommentJob, + { + repositoryId, + commentId, + actor: `human:${actorLogin}`, + }, + { jobId: `learning-redact-${repositoryId}-${commentId}` }, + ) + } catch (error) { + logger.warn( + { + errorType: error instanceof Error ? error.name : "UnknownError", + repositoryId, + commentId, + }, + "Review comment was deleted but its learning redaction could not be queued", + ) + } finally { + await queue.close() + } + }, + serializeReviewCommentDeletion: (operation) => + withLearningExecutionLock({ + databaseUrl, + run: () => operation(), + }), + decide: async ({ actorMembershipId, ...input }) => { + const operationId = randomUUID() + let operationCreated = false + try { + const result = await withLearningExecutionLock({ + databaseUrl, + run: async (signal) => { + if (!(await isEffectiveAdministrator(prisma, actorMembershipId))) { + throw new LearningsError( + 403, + "repository_administrator_required", + "Repository administrator access is required.", + ) + } + await prisma.$transaction(async (transaction) => { + await createLearningDecisionOperation(transaction, { + id: operationId, + actorMembershipId, + decision: input.decision.decision, + learningId: input.learningId, + repositoryId: input.repositoryId, + }) + await createSecurityAudit(transaction, { + id: randomUUID(), + type: "learning_decision", + actorMembershipId, + decision: input.decision.decision, + learningId: input.learningId, + operationId, + outcome: "requested", + repositoryId: input.repositoryId, + }) + }) + operationCreated = true + return executeLearningDecision({ + ...configuration, + ...input, + operationId, + signal, + }) + }, + }) + try { + await prisma.$transaction(async (transaction) => { + const claimed = await deleteLearningDecisionOperation(transaction, operationId) + if (claimed.count !== 1) return + await createSecurityAudit(transaction, { + id: randomUUID(), + type: "learning_decision", + actorMembershipId, + decision: input.decision.decision, + learningId: input.learningId, + operationId, + outcome: "succeeded", + repositoryId: input.repositoryId, + }) + }) + } catch (error) { + logger.error( + { + errorType: error instanceof Error ? error.name : "UnknownError", + learningId: input.learningId, + repositoryId: input.repositoryId, + }, + "The learning decision succeeded but its security audit could not be saved", + ) + throw error + } + return result + } catch (error) { + if (operationCreated && isDefinitiveDecisionRejection(error)) { + await prisma.$transaction(async (transaction) => { + const claimed = await deleteLearningDecisionOperation(transaction, operationId) + if (claimed.count !== 1) return + await createSecurityAudit(transaction, { + id: randomUUID(), + type: "learning_decision", + actorMembershipId, + decision: input.decision.decision, + learningId: input.learningId, + operationId, + outcome: "failed", + reason: + error instanceof LearningCommandError || error instanceof LearningsError + ? error.code.slice(0, 100) + : "decision_rejected", + repositoryId: input.repositoryId, + }) + }) + throw error + } + if ( + error instanceof Error && + error.message === "Another learning operation is still running." + ) { + throw new LearningsError( + 409, + "learning_execution_busy", + "Another learning operation is still running.", + { cause: error }, + ) + } + throw error + } + }, + } +} diff --git a/hub/server/routes/api/learnings/decision/post/index.ts b/hub/server/routes/api/learnings/decision/post/index.ts new file mode 100644 index 000000000..74e4594ea --- /dev/null +++ b/hub/server/routes/api/learnings/decision/post/index.ts @@ -0,0 +1,93 @@ +import type { RequestHandler } from "express" +import { z } from "zod" + +import { readLearningSession } from "../../read-learning-session/index.ts" +import { respondLearningError } from "../../respond-learning-error/index.ts" +import type { LearningsRouteDependencies } from "../../types.ts" + +const digest = z.string().regex(/^sha256:[0-9a-f]{64}$/) +const decisionSchema = z.discriminatedUnion("decision", [ + z + .object({ + decision: z.literal("accept"), + digest, + content: z.string().trim().min(1).max(2000).optional(), + }) + .strict(), + z + .object({ + decision: z.literal("reject"), + digest, + reason: z.string().trim().min(1).max(500), + }) + .strict(), + z + .object({ + decision: z.literal("retire"), + reason: z.string().trim().min(1).max(500), + }) + .strict(), +]) +const learningIdSchema = z + .string() + .regex(/^[a-z0-9._~-]+$/i) + .refine((value) => value !== "." && value !== "..") + +export function post(dependencies: LearningsRouteDependencies): RequestHandler { + return async (request, response, next) => { + try { + const repositoryId = z.uuid().safeParse(request.params.repositoryId) + const learningId = learningIdSchema.safeParse(request.params.learningId) + if (!repositoryId.success || !learningId.success) { + response.status(400).json({ + code: "invalid_learning_address", + error: "Enter a valid learning address.", + }) + return + } + const decision = decisionSchema.safeParse(request.body) + if (!decision.success) { + response.status(422).json({ + code: "invalid_learning_decision", + error: "Review the learning decision and try again.", + }) + return + } + const initial = await readLearningSession(request, dependencies) + if (!initial || initial.role !== "ADMINISTRATOR") { + response.status(403).json({ + code: "repository_administrator_required", + error: "Repository administrator access is required.", + }) + return + } + if (!(await dependencies.findRepository(repositoryId.data))) { + response.status(404).json({ code: "repository_not_found", error: "Repository not found." }) + return + } + const current = await readLearningSession(request, dependencies) + if ( + !current || + current.membershipId !== initial.membershipId || + current.role !== "ADMINISTRATOR" + ) { + response.status(403).json({ + code: "repository_administrator_required", + error: "Repository administrator access is required.", + }) + return + } + response.json( + await dependencies.decide({ + repositoryId: repositoryId.data, + learningId: learningId.data, + actor: `human:${current.login}`, + actorMembershipId: current.membershipId, + decision: decision.data, + }), + ) + } catch (error) { + if (!respondLearningError(response, error)) next(error) + } + } +} diff --git a/hub/server/routes/api/learnings/errors.ts b/hub/server/routes/api/learnings/errors.ts new file mode 100644 index 000000000..2c58c494f --- /dev/null +++ b/hub/server/routes/api/learnings/errors.ts @@ -0,0 +1,11 @@ +export class LearningsError extends Error { + readonly code: string + readonly status: number + + constructor(status: number, code: string, message: string, options?: ErrorOptions) { + super(message, options) + this.name = "LearningsError" + this.code = code + this.status = status + } +} diff --git a/hub/server/routes/api/learnings/get/index.ts b/hub/server/routes/api/learnings/get/index.ts new file mode 100644 index 000000000..6fa680ff6 --- /dev/null +++ b/hub/server/routes/api/learnings/get/index.ts @@ -0,0 +1,67 @@ +import type { RequestHandler } from "express" +import { z } from "zod" + +import { readLearningSession } from "../read-learning-session/index.ts" +import type { LearningsRouteDependencies } from "../types.ts" + +export function get(dependencies: LearningsRouteDependencies): RequestHandler { + return async (request, response, next) => { + try { + const repositoryId = z.uuid().safeParse(request.params.repositoryId) + if (!repositoryId.success) { + response.status(400).json({ + code: "invalid_repository", + error: "Enter a valid repository address.", + }) + return + } + const initial = await readLearningSession(request, dependencies) + if (!initial) { + response.status(401).json({ code: "sign_in_required", error: "Sign in to continue." }) + return + } + const repository = await dependencies.findRepository(repositoryId.data) + if (!repository) { + response.status(404).json({ code: "repository_not_found", error: "Repository not found." }) + return + } + if (initial.role !== "ADMINISTRATOR") { + response.json({ accessDenied: true, repository, canAdministerHub: false }) + return + } + + const [overview, copilot, runSummary] = await Promise.all([ + dependencies.getOverview({ + repositoryId: repository.id, + viewer: `human:${initial.login}`, + }), + dependencies.getCopilot(), + dependencies.listRuns(repository.id), + ]) + const current = await readLearningSession(request, dependencies) + if (!current || current.membershipId !== initial.membershipId) { + response.status(401).json({ code: "sign_in_required", error: "Sign in to continue." }) + return + } + if (current.role !== "ADMINISTRATOR") { + response.json({ accessDenied: true, repository, canAdministerHub: false }) + return + } + const runAvailable = + dependencies.requestRun !== undefined && copilot.state === "connected" && !runSummary.active + response.json({ + accessDenied: false, + repository, + canAdministerHub: true, + permissions: { decide: true, requestRun: dependencies.requestRun !== undefined }, + copilot, + usageCredits: runSummary.usageCredits, + runAvailable, + ...overview, + runs: runSummary.runs, + }) + } catch (error) { + next(error) + } + } +} diff --git a/hub/server/routes/api/learnings/index.test.ts b/hub/server/routes/api/learnings/index.test.ts new file mode 100644 index 000000000..bb514afc0 --- /dev/null +++ b/hub/server/routes/api/learnings/index.test.ts @@ -0,0 +1,370 @@ +import { once } from "node:events" +import { createServer } from "node:http" +import type { AddressInfo } from "node:net" +import express from "express" +import type { RequestHandler } from "express" +import { describe, expect, it, vi } from "vitest" + +import { LearningCommandError } from "../../../integrations/learning/run-learning-command/errors.ts" +import { post as postDecision } from "./decision/post/index.ts" +import { get as getLearnings } from "./get/index.ts" +import { post as postRun } from "./runs/post/index.ts" +import type { LearningsRouteDependencies } from "./types.ts" + +const repositoryId = "11111111-2222-4333-8444-555555555555" +const repository = { + id: repositoryId, + nameWithOwner: "team/design", + defaultBranch: "main", +} +const session = { + membershipId: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa", + userId: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb", + provider: "github", + login: "mona", + name: "Mona", + role: "ADMINISTRATOR" as const, +} + +function dependencies( + overrides: Partial = {}, +): LearningsRouteDependencies { + return { + applicationOrigin: "http://127.0.0.1:5173", + currentSession: { restore: vi.fn().mockResolvedValue(session) }, + findRepository: vi.fn().mockResolvedValue(repository), + getOverview: vi.fn().mockResolvedValue({ + loadError: null, + identityReviewCount: 1, + suggestions: [], + learnings: [], + recall: { text: "", count: 0 }, + }), + getCopilot: vi.fn().mockResolvedValue({ state: "connected", connectedBy: "mona" }), + listRuns: vi.fn().mockResolvedValue({ runs: [], usageCredits: "0", active: false }), + decide: vi.fn().mockResolvedValue({ notice: "Learning accepted." }), + redactComment: vi.fn().mockResolvedValue(undefined), + serializeReviewCommentDeletion: (operation) => operation(), + ...overrides, + } +} + +async function withRoute( + method: "get" | "post", + path: string, + handler: RequestHandler, + operation: (baseUrl: string) => Promise, +) { + const app = express() + app.use(express.json()) + if (method === "get") app.get(path, handler) + else app.post(path, handler) + const server = createServer(app) + server.listen(0, "127.0.0.1") + await once(server, "listening") + try { + const { port } = server.address() as AddressInfo + await operation(`http://127.0.0.1:${port}`) + } finally { + await new Promise((resolve, reject) => { + server.close((error) => (error ? reject(error) : resolve())) + }) + } +} + +const headers = { cookie: "hub_session=current-session" } + +describe("learning routes", () => { + it("returns no learning data or permissions to a signed-in non-administrator", async () => { + const member = { ...session, role: "MEMBER" as const } + const findRepository = vi.fn().mockResolvedValue(repository) + const getOverview = vi.fn() + const getCopilot = vi.fn() + const listRuns = vi.fn() + const deps = dependencies({ + currentSession: { restore: vi.fn().mockResolvedValue(member) }, + findRepository, + getOverview, + getCopilot, + listRuns, + }) + + await withRoute( + "get", + "/api/repositories/:repositoryId/learnings", + getLearnings(deps), + async (baseUrl) => { + const response = await fetch(`${baseUrl}/api/repositories/${repositoryId}/learnings`, { + headers, + }) + + expect(response.status).toBe(200) + expect(await response.json()).toEqual({ + accessDenied: true, + repository, + canAdministerHub: false, + }) + expect(getOverview).not.toHaveBeenCalled() + expect(getCopilot).not.toHaveBeenCalled() + expect(listRuns).not.toHaveBeenCalled() + }, + ) + }) + + it("maps the administrator overview, exact evidence, and run history", async () => { + const evidence = { + eventId: "review-comment-17", + commentId: 17, + body: "The form needs a visible label.", + authorLogin: "reviewer", + authorAvatarUrl: "https://avatars.example/reviewer", + prototypeId: "22222222-3333-4444-8555-666666666666", + prototypeName: "Signup", + createdAt: "2026-10-02T14:00:00Z", + } + const suggestion = { + id: "mem_7eb35ba21bbe6c45a9a296b4", + content: "Show a visible label above every form field.", + reviewDigest: `sha256:${"a".repeat(64)}`, + support: { reviewers: 1, prototypes: 1 }, + replaces: [], + evidence: [evidence], + otherEvidenceCount: 2, + contradictions: [], + otherContradictionsCount: 0, + } + const run = { + id: 8, + startedAt: "2026-10-03T14:00:00Z", + startedBy: { type: "user" as const, login: "mona" }, + state: "succeeded" as const, + result: { + type: "succeeded" as const, + commentsConsidered: 4, + commentsLabeled: 2, + commentsRemaining: 0, + suggestions: 1, + suggestionsRemaining: 0, + }, + usage: { credits: "0.021", requests: 1 }, + } + const deps = dependencies({ + getOverview: vi.fn().mockResolvedValue({ + loadError: null, + identityReviewCount: 1, + suggestions: [suggestion], + learnings: [], + recall: { text: "Approved team learnings", count: 0 }, + }), + listRuns: vi.fn().mockResolvedValue({ + runs: [run], + usageCredits: "0.021", + active: false, + }), + }) + + await withRoute( + "get", + "/api/repositories/:repositoryId/learnings", + getLearnings(deps), + async (baseUrl) => { + const response = await fetch(`${baseUrl}/api/repositories/${repositoryId}/learnings`, { + headers, + }) + + expect(response.status).toBe(200) + expect(await response.json()).toEqual({ + accessDenied: false, + repository, + canAdministerHub: true, + permissions: { decide: true, requestRun: false }, + copilot: { state: "connected", connectedBy: "mona" }, + usageCredits: "0.021", + runAvailable: false, + loadError: null, + identityReviewCount: 1, + suggestions: [suggestion], + learnings: [], + recall: { text: "Approved team learnings", count: 0 }, + runs: [run], + }) + }, + ) + }) + + it("does not enqueue a run while a complete review snapshot provider is unavailable", async () => { + const requestRun = vi.fn() + const deps = dependencies({ requestRun: undefined }) + + await withRoute( + "post", + "/api/repositories/:repositoryId/learnings/runs", + postRun(deps), + async (baseUrl) => { + const response = await fetch(`${baseUrl}/api/repositories/${repositoryId}/learnings/runs`, { + method: "POST", + headers, + }) + + expect(response.status).toBe(409) + expect(await response.json()).toEqual({ + code: "review_snapshot_unavailable", + error: + "Learnings cannot run until Hub can capture a complete repository review snapshot.", + }) + expect(requestRun).not.toHaveBeenCalled() + }, + ) + }) + + it("requests a run with the live administrator identity", async () => { + const requestRun = vi.fn().mockResolvedValue({ notice: "Learning run requested." }) + const deps = dependencies({ requestRun }) + + await withRoute( + "post", + "/api/repositories/:repositoryId/learnings/runs", + postRun(deps), + async (baseUrl) => { + const response = await fetch(`${baseUrl}/api/repositories/${repositoryId}/learnings/runs`, { + method: "POST", + headers, + }) + + expect(response.status).toBe(202) + expect(await response.json()).toEqual({ notice: "Learning run requested." }) + expect(requestRun).toHaveBeenCalledWith({ + actorMembershipId: session.membershipId, + repositoryId, + requestedById: session.userId, + }) + }, + ) + }) + + it("rejects an invalid decision before calling the package-store boundary", async () => { + const decide = vi.fn() + const deps = dependencies({ decide }) + + await withRoute( + "post", + "/api/repositories/:repositoryId/learnings/:learningId/decision", + postDecision(deps), + async (baseUrl) => { + const response = await fetch( + `${baseUrl}/api/repositories/${repositoryId}/learnings/mem_1/decision`, + { + method: "POST", + headers: { ...headers, "content-type": "application/json" }, + body: JSON.stringify({ decision: "accept" }), + }, + ) + + expect(response.status).toBe(422) + expect(await response.json()).toEqual({ + code: "invalid_learning_decision", + error: "Review the learning decision and try again.", + }) + expect(decide).not.toHaveBeenCalled() + }, + ) + }) + + it("surfaces a stale digest as a conflict", async () => { + const decide = vi + .fn() + .mockRejectedValue(new LearningCommandError("stale_digest", "The reviewed digest is stale.")) + const deps = dependencies({ decide }) + + await withRoute( + "post", + "/api/repositories/:repositoryId/learnings/:learningId/decision", + postDecision(deps), + async (baseUrl) => { + const response = await fetch( + `${baseUrl}/api/repositories/${repositoryId}/learnings/mem_1/decision`, + { + method: "POST", + headers: { ...headers, "content-type": "application/json" }, + body: JSON.stringify({ + decision: "reject", + digest: `sha256:${"b".repeat(64)}`, + reason: "Not durable guidance.", + }), + }, + ) + + expect(response.status).toBe(409) + expect(await response.json()).toEqual({ + code: "stale_digest", + error: "The reviewed digest is stale.", + }) + }, + ) + }) + + it.each([ + [ + "accept", + { + decision: "accept", + digest: `sha256:${"a".repeat(64)}`, + }, + "Learning accepted.", + ], + [ + "edit", + { + decision: "accept", + digest: `sha256:${"a".repeat(64)}`, + content: "Use visible labels.", + }, + "Learning accepted.", + ], + [ + "reject", + { + decision: "reject", + digest: `sha256:${"a".repeat(64)}`, + reason: "The evidence does not generalize.", + }, + "Suggestion rejected.", + ], + ["retire", { decision: "retire", reason: "The guidance is obsolete." }, "Learning retired."], + ] as const)( + "passes the %s command arguments and returns its notice", + async (_name, input, notice) => { + const decide = vi.fn().mockResolvedValue({ notice }) + const deps = dependencies({ decide }) + + await withRoute( + "post", + "/api/repositories/:repositoryId/learnings/:learningId/decision", + postDecision(deps), + async (baseUrl) => { + const response = await fetch( + `${baseUrl}/api/repositories/mem-repo/learnings/mem_1/decision`.replace( + "mem-repo", + repositoryId, + ), + { + method: "POST", + headers: { ...headers, "content-type": "application/json" }, + body: JSON.stringify(input), + }, + ) + + expect(response.status).toBe(200) + expect(await response.json()).toEqual({ notice }) + expect(decide).toHaveBeenCalledWith({ + repositoryId, + learningId: "mem_1", + actor: "human:mona", + actorMembershipId: session.membershipId, + decision: input, + }) + }, + ) + }, + ) +}) diff --git a/hub/server/routes/api/learnings/is-definitive-decision-rejection/index.test.ts b/hub/server/routes/api/learnings/is-definitive-decision-rejection/index.test.ts new file mode 100644 index 000000000..1e04371fa --- /dev/null +++ b/hub/server/routes/api/learnings/is-definitive-decision-rejection/index.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from "vitest" + +import { LearningCommandError } from "../../../../integrations/learning/run-learning-command/errors" +import { isDefinitiveDecisionRejection } from "." + +describe("isDefinitiveDecisionRejection()", () => { + it.each(["not_found", "stale_review", "invalid_transition"])( + "finalizes the durable operation after %s", + (code) => { + expect(isDefinitiveDecisionRejection(new LearningCommandError(code, "rejected"))).toBe(true) + }, + ) + + it.each(["timeout", "unreadable_output", "output_too_large", "learning_failed"])( + "preserves the durable operation after ambiguous %s", + (code) => { + expect(isDefinitiveDecisionRejection(new LearningCommandError(code, "unknown"))).toBe(false) + }, + ) +}) diff --git a/hub/server/routes/api/learnings/is-definitive-decision-rejection/index.ts b/hub/server/routes/api/learnings/is-definitive-decision-rejection/index.ts new file mode 100644 index 000000000..8710f0b0d --- /dev/null +++ b/hub/server/routes/api/learnings/is-definitive-decision-rejection/index.ts @@ -0,0 +1,22 @@ +import { LearningCommandError } from "../../../../integrations/learning/run-learning-command/errors.ts" +import { LearningsError } from "../errors.ts" + +const rejectedDecisionCodes = new Set([ + "human_required", + "identity_revalidation_required", + "invalid_input", + "invalid_record", + "invalid_request", + "invalid_transition", + "not_found", + "not_installed", + "purpose_not_granted", + "stale_review", +]) + +export function isDefinitiveDecisionRejection(error: unknown) { + return ( + error instanceof LearningsError || + (error instanceof LearningCommandError && rejectedDecisionCodes.has(error.code)) + ) +} diff --git a/hub/server/routes/api/learnings/read-learning-session/index.ts b/hub/server/routes/api/learnings/read-learning-session/index.ts new file mode 100644 index 000000000..b2b5047df --- /dev/null +++ b/hub/server/routes/api/learnings/read-learning-session/index.ts @@ -0,0 +1,10 @@ +import { hubSessionCookieName } from "../../../../integrations/express/hub-session-cookie-name/index.ts" +import { readCookie } from "../../../../integrations/express/read-cookie/index.ts" +import type { Request } from "express" + +import { readProductSession } from "../../product/read-product-session/index.ts" +import type { LearningsRouteDependencies } from "../types.ts" + +export function readLearningSession(request: Request, dependencies: LearningsRouteDependencies) { + return readProductSession(readCookie(request, hubSessionCookieName), dependencies.currentSession) +} diff --git a/hub/server/routes/api/learnings/respond-learning-error/index.ts b/hub/server/routes/api/learnings/respond-learning-error/index.ts new file mode 100644 index 000000000..f93a9688a --- /dev/null +++ b/hub/server/routes/api/learnings/respond-learning-error/index.ts @@ -0,0 +1,20 @@ +import type { Response } from "express" + +import { LearningCommandError } from "../../../../integrations/learning/run-learning-command/errors.ts" +import { LearningsError } from "../errors.ts" + +const staleCodes = new Set(["digest_mismatch", "stale_digest", "stale_review"]) +const notFoundCodes = new Set(["not_found", "memory_not_found"]) + +export function respondLearningError(response: Response, error: unknown): boolean { + if (error instanceof LearningsError) { + response.status(error.status).json({ code: error.code, error: error.message }) + return true + } + if (error instanceof LearningCommandError) { + const status = staleCodes.has(error.code) ? 409 : notFoundCodes.has(error.code) ? 404 : 422 + response.status(status).json({ code: error.code, error: error.message }) + return true + } + return false +} diff --git a/hub/server/routes/api/learnings/runs/post/index.ts b/hub/server/routes/api/learnings/runs/post/index.ts new file mode 100644 index 000000000..012fff732 --- /dev/null +++ b/hub/server/routes/api/learnings/runs/post/index.ts @@ -0,0 +1,62 @@ +import type { RequestHandler } from "express" +import { z } from "zod" + +import { readLearningSession } from "../../read-learning-session/index.ts" +import { respondLearningError } from "../../respond-learning-error/index.ts" +import type { LearningsRouteDependencies } from "../../types.ts" + +export function post(dependencies: LearningsRouteDependencies): RequestHandler { + return async (request, response, next) => { + try { + const repositoryId = z.uuid().safeParse(request.params.repositoryId) + if (!repositoryId.success) { + response.status(400).json({ + code: "invalid_repository", + error: "Enter a valid repository address.", + }) + return + } + const initial = await readLearningSession(request, dependencies) + if (!initial || initial.role !== "ADMINISTRATOR") { + response.status(403).json({ + code: "repository_administrator_required", + error: "Repository administrator access is required.", + }) + return + } + if (!(await dependencies.findRepository(repositoryId.data))) { + response.status(404).json({ code: "repository_not_found", error: "Repository not found." }) + return + } + const current = await readLearningSession(request, dependencies) + if ( + !current || + current.membershipId !== initial.membershipId || + current.role !== "ADMINISTRATOR" + ) { + response.status(403).json({ + code: "repository_administrator_required", + error: "Repository administrator access is required.", + }) + return + } + if (!dependencies.requestRun) { + response.status(409).json({ + code: "review_snapshot_unavailable", + error: + "Learnings cannot run until Hub can capture a complete repository review snapshot.", + }) + return + } + response.status(202).json( + await dependencies.requestRun({ + actorMembershipId: current.membershipId, + repositoryId: repositoryId.data, + requestedById: current.userId, + }), + ) + } catch (error) { + if (!respondLearningError(response, error)) next(error) + } + } +} diff --git a/hub/server/routes/api/learnings/types.ts b/hub/server/routes/api/learnings/types.ts new file mode 100644 index 000000000..f430e74ed --- /dev/null +++ b/hub/server/routes/api/learnings/types.ts @@ -0,0 +1,73 @@ +import type { CurrentSessionDependencies } from "../auth/types.ts" +import type { + AcceptedLearning, + LearningDecision, + LearningEvidence, + LearningSuggestion, +} from "../../../domains/learning/types.ts" + +export type { AcceptedLearning, LearningDecision, LearningEvidence, LearningSuggestion } + +export interface LearningRun { + id: number + startedAt: string + startedBy: { type: "daily" } | { type: "user"; login: string } | { type: "unknown" } + state: "queued" | "running" | "succeeded" | "failed" + result: + | { + type: "succeeded" + commentsConsidered: number + commentsLabeled: number + commentsRemaining: number + suggestions: number + suggestionsRemaining: number + } + | { type: "failed"; summary: string } + | null + usage: { credits: string; requests: number } | null +} + +export interface LearningsRouteDependencies { + applicationOrigin: string + currentSession: CurrentSessionDependencies + findRepository(repositoryId: string): Promise<{ + id: string + nameWithOwner: string + defaultBranch: string + } | null> + getOverview(input: { repositoryId: string; viewer: string }): Promise<{ + loadError: string | null + identityReviewCount: number + suggestions: LearningSuggestion[] + learnings: AcceptedLearning[] + recall: { text: string; count: number } + }> + getCopilot(): Promise< + | { state: "connected"; connectedBy: string | null } + | { state: "not-connected" } + | { state: "refused"; refusedAt: string | null } + > + listRuns(repositoryId: string): Promise<{ + runs: LearningRun[] + usageCredits: string + active: boolean + }> + requestRun?: (input: { + actorMembershipId: string + repositoryId: string + requestedById: string + }) => Promise<{ notice: string }> + decide(input: { + repositoryId: string + learningId: string + actor: string + actorMembershipId: string + decision: LearningDecision + }): Promise<{ notice: string }> + redactComment(input: { + repositoryId: string + commentId: number + actorLogin: string + }): Promise + serializeReviewCommentDeletion(operation: () => Promise): Promise +} diff --git a/hub/server/routes/api/product/create-product-route-dependencies/index.ts b/hub/server/routes/api/product/create-product-route-dependencies/index.ts index 8acb16128..b8aa10c10 100644 --- a/hub/server/routes/api/product/create-product-route-dependencies/index.ts +++ b/hub/server/routes/api/product/create-product-route-dependencies/index.ts @@ -23,10 +23,18 @@ interface CreateProductRouteDependenciesOptions { sessionDigest: string, userId: string, ) => Promise + onReviewCommentDeleted?: (input: { + repositoryId: string + commentId: number + actorLogin: string + }) => Promise + withReviewCommentDeleteLock?: (operation: () => Promise) => Promise } export function createProductRouteDependencies({ authorizeReviewMutation, + onReviewCommentDeleted, + withReviewCommentDeleteLock, }: CreateProductRouteDependenciesOptions = {}): ProductRouteDependencies { const authorizeReview = authorizeReviewMutation ?? @@ -45,7 +53,10 @@ export function createProductRouteDependencies({ return restored?.userId === userId }) return { - reviewComments: createReviewCommentService(prisma, authorizeReview), + reviewComments: createReviewCommentService(prisma, authorizeReview, { + onDeleted: onReviewCommentDeleted, + withDeleteLock: withReviewCommentDeleteLock, + }), listRepositories: () => listRepositories(prisma), findRepositoryIndex: (repositoryId, filters) => findRepositoryIndex(prisma, repositoryId, filters), diff --git a/hub/server/routes/api/security-audits/present-security-audit/index.test.ts b/hub/server/routes/api/security-audits/present-security-audit/index.test.ts index 7dddfd039..36f234471 100644 --- a/hub/server/routes/api/security-audits/present-security-audit/index.test.ts +++ b/hub/server/routes/api/security-audits/present-security-audit/index.test.ts @@ -397,6 +397,61 @@ describe("presentSecurityAudit()", () => { outcome: "success", }), }, + { + label: "repository learning acceptance", + event: { + actorMembershipId, + decision: "accept", + id: auditId, + learningId: "mem_1", + operationId: sessionId, + outcome: "succeeded", + repositoryId: providerId, + type: "learning_decision", + }, + expected: expectedRecord({ + action: "learning.accept", + actor: { membershipId: actorMembershipId }, + context: { repositoryId: providerId, learningId: "mem_1", operationId: sessionId }, + outcome: "success", + }), + }, + { + label: "repository learning acceptance request", + event: { + actorMembershipId, + decision: "accept", + id: auditId, + learningId: "mem_1", + operationId: sessionId, + outcome: "requested", + repositoryId: providerId, + type: "learning_decision", + }, + expected: expectedRecord({ + action: "learning.accept.requested", + actor: { membershipId: actorMembershipId }, + context: { repositoryId: providerId, learningId: "mem_1", operationId: sessionId }, + outcome: null, + }), + }, + { + label: "repository learning run request", + event: { + actorMembershipId, + id: auditId, + outcome: "requested", + repositoryId: providerId, + runId: sessionId, + type: "learning_run", + }, + expected: expectedRecord({ + action: "learning.run.requested", + actor: { membershipId: actorMembershipId }, + context: { repositoryId: providerId, runId: sessionId }, + outcome: "success", + }), + }, ...( [ ["connected", "success", true, undefined], diff --git a/hub/server/routes/api/security-audits/present-security-audit/index.ts b/hub/server/routes/api/security-audits/present-security-audit/index.ts index cfd10bc25..c8f1a50ac 100644 --- a/hub/server/routes/api/security-audits/present-security-audit/index.ts +++ b/hub/server/routes/api/security-audits/present-security-audit/index.ts @@ -62,6 +62,17 @@ function actorFor(record: SecurityAuditListRecord) { const parsed = actorContextSchema.safeParse(record.context) return parsed.success ? { membershipId: parsed.data.actorMembershipId } : null } + case "learning.accept": + case "learning.accept.requested": + case "learning.reject": + case "learning.reject.requested": + case "learning.retire": + case "learning.retire.requested": + case "learning.run.requested": + case "learning.run.failed": { + const parsed = actorContextSchema.safeParse(record.context) + return parsed.success ? { membershipId: parsed.data.actorMembershipId } : null + } default: return null } @@ -316,6 +327,36 @@ function contextFor(record: SecurityAuditListRecord): Record handleApiReadyGet(request, response, { isReady, logger }), @@ -118,6 +121,20 @@ export function routes(app: Express, dependencies: RouteDependencies = {}): void ) } } + if (learnings) { + app.get("/api/repositories/:repositoryId/learnings", handleLearningsGet(learnings)) + app.post( + "/api/repositories/:repositoryId/learnings/runs", + requireOrigin(learnings.applicationOrigin), + handleLearningRunPost(learnings), + ) + app.post( + "/api/repositories/:repositoryId/learnings/:learningId/decision", + requireOrigin(learnings.applicationOrigin), + express.json({ limit: "4kb", strict: true }), + handleLearningDecisionPost(learnings), + ) + } if (authentication.administrators) { app.get("/api/security-audits", handleSecurityAuditsGet(authentication.administrators)) app.get("/api/administrators", handleAdministratorsGet(authentication.administrators)) diff --git a/hub/server/routes/types.ts b/hub/server/routes/types.ts index 7a2812833..4dd6c66fa 100644 --- a/hub/server/routes/types.ts +++ b/hub/server/routes/types.ts @@ -3,11 +3,13 @@ import type { Logger } from "pino" import type { Broadcast } from "../integrations/ws/types.ts" import type { AuthenticationRouteDependencies } from "./api/auth/types.ts" import type { CopilotConnectionRouteDependencies } from "./api/copilot-connection/types.ts" +import type { LearningsRouteDependencies } from "./api/learnings/types.ts" import type { ProductRouteDependencies } from "./api/product/types.ts" export interface RouteDependencies { authentication?: AuthenticationRouteDependencies copilotConnection?: CopilotConnectionRouteDependencies + learnings?: LearningsRouteDependencies product?: ProductRouteDependencies broadcast?: Broadcast isReady?: () => Promise diff --git a/hub/server/run-api/index.ts b/hub/server/run-api/index.ts index 058223b73..6568b8e23 100644 --- a/hub/server/run-api/index.ts +++ b/hub/server/run-api/index.ts @@ -6,6 +6,7 @@ import type { Logger } from "pino" import { createApp } from "../create-app/index.ts" import type { AuthenticationRouteDependencies } from "../routes/api/auth/types.ts" import type { CopilotConnectionRouteDependencies } from "../routes/api/copilot-connection/types.ts" +import type { LearningsRouteDependencies } from "../routes/api/learnings/types.ts" import type { ProductRouteDependencies } from "../routes/api/product/types.ts" import { attachRealtimeServer } from "../integrations/ws/attach-realtime-server/index.ts" import { shutdownServer } from "../shutdown-server/index.ts" @@ -15,6 +16,7 @@ export async function runApi({ logger, authentication, copilotConnection, + learnings, product, trustedProxyHops = 0, shutdownTimeoutMs = 30_000, @@ -27,6 +29,7 @@ export async function runApi({ logger: Logger authentication?: AuthenticationRouteDependencies copilotConnection?: CopilotConnectionRouteDependencies + learnings?: LearningsRouteDependencies product?: ProductRouteDependencies trustedProxyHops?: number shutdownTimeoutMs?: number @@ -67,6 +70,7 @@ export async function runApi({ : undefined, } : undefined, + learnings, product, trustedProxyHops, }), diff --git a/hub/server/start-server-processes/index.ts b/hub/server/start-server-processes/index.ts index 81709530f..06e80cf61 100644 --- a/hub/server/start-server-processes/index.ts +++ b/hub/server/start-server-processes/index.ts @@ -3,6 +3,7 @@ import type { Logger } from "pino" import { openDatabase } from "../integrations/postgres/open-database/index.ts" import type { AuthenticationRouteDependencies } from "../routes/api/auth/types.ts" import type { CopilotConnectionRouteDependencies } from "../routes/api/copilot-connection/types.ts" +import type { LearningsRouteDependencies } from "../routes/api/learnings/types.ts" import type { ProductRouteDependencies } from "../routes/api/product/types.ts" import { runApi } from "../run-api/index.ts" import { jobProcessors } from "../workers/configuration.ts" @@ -20,6 +21,7 @@ export async function startServerProcesses(options: { isStorageReady?: () => Promise authentication?: AuthenticationRouteDependencies copilotConnection?: CopilotConnectionRouteDependencies + learnings?: LearningsRouteDependencies product?: ProductRouteDependencies trustedProxyHops?: number }) { diff --git a/hub/server/workers/configuration.test.ts b/hub/server/workers/configuration.test.ts new file mode 100644 index 000000000..b3c4f0ec0 --- /dev/null +++ b/hub/server/workers/configuration.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "vitest" + +import { jobProcessors, jobSchedules } from "./configuration" + +describe("learning worker configuration", () => { + it("keeps explicit runs and redactions on demand and recovery on the scheduled queue", () => { + expect(jobProcessors["on-demand"].map(({ name }) => name)).toEqual([ + "learning.run", + "learning.redact-review-comment", + ]) + expect(jobProcessors.scheduled.map(({ name }) => name)).toEqual(["learning.recover-runs"]) + expect(jobSchedules).toEqual([ + expect.objectContaining({ + id: "learning-run-recovery", + repeat: { every: 60_000 }, + }), + ]) + }) +}) diff --git a/hub/server/workers/configuration.ts b/hub/server/workers/configuration.ts index d815c0b07..25753e492 100644 --- a/hub/server/workers/configuration.ts +++ b/hub/server/workers/configuration.ts @@ -4,11 +4,15 @@ import type { JobQueueName, JobScheduleRepeat, } from "../integrations/bullmq/types.ts" +import { createLearningJobProcessors } from "../domains/learning/create-learning-job-processors/index.ts" +import { recoverLearningRunsJob } from "../domains/learning/jobs/recover-learning-runs.ts" +import { logger } from "../integrations/pino/index.ts" + +const learning = createLearningJobProcessors(process.env, logger) -// Product processors and schedules are added here when their domains are built. export const jobProcessors: Record = { - "on-demand": [], - scheduled: [], + "on-demand": [learning.run, learning.redact], + scheduled: [learning.recover], } export const jobSchedules: { @@ -16,4 +20,11 @@ export const jobSchedules: { definition: JobDefinition payload: unknown repeat: JobScheduleRepeat -}[] = [] +}[] = [ + { + id: "learning-run-recovery", + definition: recoverLearningRunsJob, + payload: {}, + repeat: { every: 60_000 }, + }, +] diff --git a/hub/test/database/learning-migration/index.db.test.ts b/hub/test/database/learning-migration/index.db.test.ts new file mode 100644 index 000000000..e2b36d0db --- /dev/null +++ b/hub/test/database/learning-migration/index.db.test.ts @@ -0,0 +1,157 @@ +import { execFile } from "node:child_process" +import { randomBytes, randomUUID } from "node:crypto" +import { readFile, readdir } from "node:fs/promises" +import { join } from "node:path" +import { fileURLToPath } from "node:url" +import { promisify } from "node:util" +import pg from "pg" +import { describe, expect, it } from "vitest" + +const timeoutMs = 60_000 + +describe("learning migration", () => { + it( + "preserves deleted review comments as pending redaction and enforces run states", + async () => { + const adminUrl = process.env.TEST_DATABASE_URL + if (!adminUrl) throw new Error("TEST_DATABASE_URL is required.") + const name = `replica_learning_upgrade_${randomBytes(8).toString("hex")}` + const admin = new pg.Client({ connectionString: adminUrl }) + await admin.connect() + let created = false + try { + await admin.query(`CREATE DATABASE ${pg.escapeIdentifier(name)}`) + created = true + const databaseUrl = new URL(adminUrl) + databaseUrl.pathname = name + const database = new pg.Client({ connectionString: databaseUrl.toString() }) + await database.connect() + try { + const hubRoot = fileURLToPath(new URL("../../../", import.meta.url)) + const migrationsRoot = join(hubRoot, "schema/migrations") + const learningMigration = "20261113190000_learning_run_foundation" + const baseMigrations = (await readdir(migrationsRoot, { withFileTypes: true })) + .filter((entry) => entry.isDirectory() && entry.name < learningMigration) + .map((entry) => entry.name) + .sort() + for (const migrationName of baseMigrations) { + const sql = await readFile(join(migrationsRoot, migrationName, "migration.sql"), "utf8") + if (migrationName === "20261104190000_entra_oidc_authentication") { + const statements = sql.split("\n") + await database.query(statements.slice(0, 2).join("\n")) + await database.query(statements.slice(2).join("\n")) + } else { + await database.query(sql) + } + } + + const repositoryId = randomUUID() + const prototypeId = randomUUID() + const buildId = randomUUID() + const userId = randomUUID() + const membershipId = randomUUID() + const threadId = randomUUID() + const commentId = randomUUID() + await database.query( + `INSERT INTO repositories (id, name_with_owner, default_branch) + VALUES ($1, 'team/design', 'main')`, + [repositoryId], + ) + await database.query(`INSERT INTO users (id) VALUES ($1)`, [userId]) + await database.query(`INSERT INTO memberships (id, user_id) VALUES ($1, $2)`, [ + membershipId, + userId, + ]) + await database.query( + `INSERT INTO prototypes (id, repository_id, branch_name, name, registered_at) + VALUES ($1, $2, 'prototype/checkout', 'Checkout', clock_timestamp())`, + [prototypeId, repositoryId], + ) + await database.query( + `INSERT INTO builds (id, prototype_id, number, state) + VALUES ($1, $2, 4, 'successful')`, + [buildId, prototypeId], + ) + await database.query( + `INSERT INTO review_threads + (id, repository_id, prototype_id, build_id, anchor) + VALUES ($1, $2, $3, $4, '{"kind":"element"}')`, + [threadId, repositoryId, prototypeId, buildId], + ) + await database.query( + `INSERT INTO review_comments + (id, thread_id, author_id, author_login, body, deleted_at) + VALUES ($1, $2, $3, 'mona', 'Retained deleted text', clock_timestamp())`, + [commentId, threadId, userId], + ) + + const options = { + cwd: hubRoot, + env: { ...process.env, DATABASE_URL: databaseUrl.toString() }, + timeout: timeoutMs, + } + const run = promisify(execFile) + for (const migrationName of baseMigrations) { + await run( + "prisma", + [ + "migrate", + "resolve", + "--applied", + migrationName, + "--config", + join(hubRoot, "prisma7.config.ts"), + ], + options, + ) + } + await run( + "prisma", + ["migrate", "deploy", "--config", join(hubRoot, "prisma7.config.ts")], + options, + ) + + const deleted = await database.query( + `SELECT learning_redaction_actor, learning_redacted_at + FROM review_comments WHERE id = $1`, + [commentId], + ) + expect(deleted.rows).toEqual([ + { learning_redaction_actor: null, learning_redacted_at: null }, + ]) + const digest = `sha256:${"a".repeat(64)}` + await expect( + database.query( + `INSERT INTO learning_runs + (id, repository_id, requested_by_id, requested_by_membership_id, + snapshot_digest, state, finished_at) + VALUES ($1, $2, $3, $4, $5, 'SUCCEEDED', clock_timestamp())`, + [randomUUID(), repositoryId, userId, membershipId, digest], + ), + ).rejects.toMatchObject({ code: "23514" }) + await expect( + database.query( + `INSERT INTO learning_runs + (id, repository_id, requested_by_id, requested_by_membership_id, + snapshot_digest, state, started_at, finished_at, failure_summary) + VALUES ($1, $2, $3, $4, $5, 'FAILED', clock_timestamp(), + clock_timestamp(), 'failed')`, + [randomUUID(), repositoryId, userId, membershipId, digest], + ), + ).rejects.toMatchObject({ code: "23514" }) + } finally { + await database.end() + } + } finally { + try { + if (created) { + await admin.query(`DROP DATABASE ${pg.escapeIdentifier(name)} WITH (FORCE)`) + } + } finally { + await admin.end() + } + } + }, + timeoutMs, + ) +}) diff --git a/hub/test/fixtures/learning/fail-with-json.mjs b/hub/test/fixtures/learning/fail-with-json.mjs new file mode 100644 index 000000000..f0c889982 --- /dev/null +++ b/hub/test/fixtures/learning/fail-with-json.mjs @@ -0,0 +1,10 @@ +process.stdout.write( + JSON.stringify({ + considered: 3, + labeled: 2, + remaining: 1, + usage: { requests: 2, nanoAiu: 1250000 }, + }), +) +process.stderr.write("error (unauthorized): Copilot refused the credential.\n") +process.exitCode = 1 diff --git a/packages/learning/README.md b/packages/learning/README.md index 26f68d991..191831478 100644 --- a/packages/learning/README.md +++ b/packages/learning/README.md @@ -6,7 +6,7 @@ The design and its trade-offs are in [ADR 0001](../../docs/adr/0001-learning-ext ## What the first loop does -The package turns saved Hub review comments into guidance that a person approved. Its CLI, providers, and demos work independently. The [new Hub](../../hub/README.md) does not collect comments or run these steps automatically. +The package turns saved Hub review comments into guidance that a person approved. Its CLI, providers, and demos work independently. The [new Hub](../../hub/README.md) captures complete repository review snapshots and runs the explicit learning loop through this command boundary. 1. A person records consent for named purposes, such as review and instruction. 2. A host imports one complete snapshot of a repository's comments. Each review thread becomes an episode pinned to its prototype and to the Build the reviewer commented on. @@ -102,7 +102,7 @@ Programmatic inputs must use plain JSON objects and dense arrays with enumerable ### Reviewer identity -Hosts should include the authenticated GitHub numeric user ID as `author.githubId` and `resolvedBy.githubId` alongside the unchanged `login` in Hub comment snapshots. The importer uses `github-user:/` as the actor's identity and keeps the login in `actor.login` only for display. Renaming an account therefore does not create another reviewer, and two actual accounts that used the same login stay distinct. A stable GitHub identity requires an explicit GitHub host in the scope. Local-development hosts instead supply the real Hub user ID as `localId`, only with scope host `local`; these actors use `hub-user:/`, not fabricated GitHub IDs. IDs must be positive safe integers, the two fields cannot appear together, and invalid supplied IDs are refused without falling back to a login. +Hosts should include a stable authenticated user ID alongside the unchanged `login` in Hub comment snapshots. GitHub numeric identities use `githubId` and become `github-user:/`. A Hub UUID uses `hubUserId` and becomes `hub-user:/`. Legacy local numeric identities may use `localId` only with scope host `local`. The importer keeps the login in `actor.login` only for display, so renaming an account does not create another reviewer and two actual accounts that used the same login stay distinct. A snapshot may name only one stable identity field; invalid supplied IDs are refused without falling back to a login. Repository and prototype source identifiers may likewise be legacy positive integers or UUIDs. Old snapshots with neither ID remain readable as asserted login-based identities. Hosts opt into stable identities by adding top-level `reviewerIdentity: "stable-user-id"` to the collection log; numeric author or resolver IDs also imply that policy for callers that omit the declaration. Any other supplied declaration is refused. A valid import records that policy for the exact Hub origin and repository ID, even when the capture is filtered, incomplete, or empty, without changing its filters or completeness or collecting more comments. Hosts must still import valid empty captures rather than skip them, so old guidance cannot remain usable just because no author was returned. Active review consent remains required; a refused import changes nothing. diff --git a/packages/learning/contracts/v1/common.schema.json b/packages/learning/contracts/v1/common.schema.json index 9b5006483..c45747638 100644 --- a/packages/learning/contracts/v1/common.schema.json +++ b/packages/learning/contracts/v1/common.schema.json @@ -24,6 +24,18 @@ "minimum": 1, "maximum": 9007199254740991 }, + "sourceIdentifier": { + "description": "A stable source-system identifier, either a legacy positive integer or a UUID.", + "oneOf": [ + { + "$ref": "#/$defs/positiveInteger" + }, + { + "type": "string", + "pattern": "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$" + } + ] + }, "count": { "type": "integer", "minimum": 0, @@ -108,7 +120,7 @@ "login": { "description": "The login shown at import time, for display only. Stable actor IDs, not this mutable login, identify reviewers.", "type": "string", - "pattern": "^[A-Za-z0-9_-]{1,256}$" + "pattern": "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$" }, "model": { "type": "string", @@ -163,10 +175,10 @@ "pattern": "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$" }, "repositoryId": { - "$ref": "#/$defs/positiveInteger" + "$ref": "#/$defs/sourceIdentifier" }, "prototypeId": { - "$ref": "#/$defs/positiveInteger" + "$ref": "#/$defs/sourceIdentifier" }, "prototypeName": { "type": "string", diff --git a/packages/learning/contracts/v1/memory-record.schema.json b/packages/learning/contracts/v1/memory-record.schema.json index d55310740..ff7f3a6fb 100644 --- a/packages/learning/contracts/v1/memory-record.schema.json +++ b/packages/learning/contracts/v1/memory-record.schema.json @@ -161,6 +161,10 @@ "edited": { "type": "boolean" }, + "operationId": { + "type": "string", + "pattern": "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$" + }, "note": { "type": "string", "minLength": 1, @@ -186,6 +190,10 @@ "type": "string", "minLength": 1, "maxLength": 2000 + }, + "operationId": { + "type": "string", + "pattern": "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$" } } }, @@ -204,6 +212,10 @@ "type": "string", "minLength": 1, "maxLength": 2000 + }, + "operationId": { + "type": "string", + "pattern": "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$" } } }, diff --git a/packages/learning/index.d.mts b/packages/learning/index.d.mts index 21caa9273..b065bfe93 100644 --- a/packages/learning/index.d.mts +++ b/packages/learning/index.d.mts @@ -43,8 +43,8 @@ export interface SourcePin { kind: string hubOrigin?: string repository?: string - repositoryId?: number - prototypeId?: number + repositoryId?: number | string + prototypeId?: number | string prototypeName?: string branch?: string buildNumber?: number @@ -267,7 +267,7 @@ export interface HubReviewCollection { meta: { hubOrigin: string repository: string - repositoryId: number + repositoryId: number | string snapshotId: string capturedAt: Timestamp } @@ -358,14 +358,16 @@ export interface MemoryRecord { reviewedDigest: Digest edited: boolean note?: string + operationId?: string } rejected?: { by: Actor at: Timestamp reviewedDigest: Digest reason: string + operationId?: string } - retired?: { by?: Actor; at: Timestamp; reason: string } + retired?: { by?: Actor; at: Timestamp; reason: string; operationId?: string } provenance: Provenance createdAt: Timestamp updatedAt: Timestamp @@ -758,6 +760,11 @@ export interface LearningStore { versions?: Array } > + findMemoryOperation( + context: LearningContext, + id: string, + operationId: string, + ): Promise<{ state: MemoryState | null }> queryMemory( context: LearningContext, query?: { states?: MemoryState[]; kinds?: MemoryKind[]; purpose?: Purpose }, @@ -765,17 +772,17 @@ export interface LearningStore { acceptMemory( context: LearningContext, id: string, - input: { expectedDigest: Digest; content?: string; note?: string }, + input: { expectedDigest: Digest; content?: string; note?: string; operationId?: string }, ): Promise rejectMemory( context: LearningContext, id: string, - input: { expectedDigest: Digest; reason: string }, + input: { expectedDigest: Digest; reason: string; operationId?: string }, ): Promise retireMemory( context: LearningContext, id: string, - input: { reason: string }, + input: { reason: string; operationId?: string }, ): Promise supersedeMemory( context: LearningContext, diff --git a/packages/learning/src/cli.mjs b/packages/learning/src/cli.mjs index 6671dddc7..c58e22978 100644 --- a/packages/learning/src/cli.mjs +++ b/packages/learning/src/cli.mjs @@ -31,6 +31,8 @@ Inspect 100 event IDs and only their containing episodes memories [--state ]... Learnings with their state and whether they are recalled show [--history] One learning, its evidence, and its digests + operation-status --operation-id + Whether one host decision operation is in intact history verify Re-check every record's schema, digest, and history copilot status Whether Copilot answers here, as whom, and with which models @@ -61,8 +63,8 @@ Capture and propose Review (a person decides; --by github:) accept --digest --by [--content-file ] [--note ] - reject --digest --by --reason - retire --by --reason + reject --digest --by (--reason | --reason-file ) + retire --by (--reason | --reason-file ) supersede ... --with --by [--reason ] Only for a learning that recall uses and that replaces nothing yet @@ -108,6 +110,8 @@ const OPTIONS = { history: { type: "boolean" }, digest: { type: "string" }, "content-file": { type: "string" }, + "reason-file": { type: "string" }, + "operation-id": { type: "string" }, note: { type: "string" }, with: { type: "string" }, task: { type: "string" }, @@ -234,6 +238,8 @@ async function run(session) { return memories(session) case "show": return show(session) + case "operation-status": + return operationStatus(session) case "accept": case "reject": return review(session, command) @@ -800,6 +806,7 @@ async function show(session) { ) return } + const lines = [ ...head, `Content: ${quoted(record.content, 4000)}`, @@ -859,6 +866,18 @@ async function show(session) { session.out(item, lines.join("\n")) } +async function operationStatus(session) { + const id = argument(session, 1, "memory ID") + const operationId = session.values["operation-id"] + if (!operationId) throw new UsageError("Name the host operation with --operation-id.") + const { store } = await open(session) + const result = await store.findMemoryOperation(context(session, actor(session)), id, operationId) + session.out( + result, + result.state ? `${operationId}: ${result.state}` : `${operationId}: not found`, + ) +} + async function review(session, command) { const id = argument(session, 1, "memory ID") const digest = session.values.digest @@ -876,6 +895,7 @@ async function review(session, command) { expectedDigest: digest, content, note: session.values.note, + operationId: session.values["operation-id"], }) session.out( record, @@ -883,25 +903,41 @@ async function review(session, command) { ) return } - if (!session.values.reason) throw new UsageError("Say why with --reason.") + const reason = await reasonOf(session) const record = await store.rejectMemory(context(session, principal), id, { expectedDigest: digest, - reason: session.values.reason, + reason, + operationId: session.values["operation-id"], }) session.out(record, `Rejected ${id}. The reason is kept with it.`) } async function retire(session) { const id = argument(session, 1, "memory ID") - if (!session.values.reason) throw new UsageError("Say why with --reason.") + const reason = await reasonOf(session) const principal = person(session) const { store } = await open(session) const record = await store.retireMemory(context(session, principal), id, { - reason: session.values.reason, + reason, + operationId: session.values["operation-id"], }) session.out(record, `Retired ${id}. It is no longer recalled; its history stays.`) } +async function reasonOf(session) { + const file = session.values["reason-file"] + if (file !== undefined && session.values.reason !== undefined) + throw new UsageError("Pass either --reason or --reason-file, not both.") + if (file === undefined) { + if (!session.values.reason) throw new UsageError("Say why with --reason or --reason-file.") + return session.values.reason + } + const bytes = await readFile(path.resolve(session.cwd, file)) + const reason = decodeUtf8(bytes, file).replace(/\r?\n$/, "") + if (!reason) throw new UsageError("The reason file is empty.") + return reason +} + async function redact(session) { if (session.values.comment !== undefined) return redactHubComment(session) const eventId = argument(session, 1, "event ID") diff --git a/packages/learning/src/contracts-validators.cjs b/packages/learning/src/contracts-validators.cjs index 9e3e5b3c1..45e553904 100644 --- a/packages/learning/src/contracts-validators.cjs +++ b/packages/learning/src/contracts-validators.cjs @@ -8,4 +8,4 @@ Number.isFinite(milliseconds) && new Date(milliseconds).toISOString() === `${value.slice(0, 23)}Z` ) -} })["date-time"];const pattern4 = new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$", "u");function validate56(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate56.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate56.errors = vErrors;return errors === 0;}validate56.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema23 = {"description":"A person, agent, or system. asserted marks an identity the host could not authenticate.","type":"object","additionalProperties":false,"required":["kind","id"],"properties":{"kind":{"enum":["human","agent","system","service"]},"id":{"description":"A prefix such as github: and a name. The name has no whitespace, control characters, Unicode format characters, or code points from the tag block, U+E0000 to U+E007F, because each can make an ID read as another.","type":"string","minLength":3,"maxLength":300,"pattern":"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},"role":{"$ref":"#/$defs/slug"},"login":{"description":"The login shown at import time, for display only. Stable actor IDs, not this mutable login, identify reviewers.","type":"string","pattern":"^[A-Za-z0-9_-]{1,256}$"},"model":{"type":"string","minLength":1,"maxLength":200},"asserted":{"type":"boolean"}}};const pattern5 = new RegExp("^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$", "u");const pattern7 = new RegExp("^[A-Za-z0-9_-]{1,256}$", "u");const schema24 = {"type":"string","minLength":1,"maxLength":128,"pattern":"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"};const pattern6 = new RegExp("^[a-z0-9]+(?:[._-][a-z0-9]+)*$", "u");function validate59(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate59.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate59.errors = vErrors;return errors === 0;}validate59.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate58(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate58.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate58.errors = vErrors;return errors === 0;}validate58.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema25 = {"description":"Who a record belongs to. Hosts derive it from the caller's access, never from agent input.","type":"object","additionalProperties":false,"minProperties":1,"properties":{"host":{"description":"The Git or Hub host, such as github.com, when the scope comes from a repository URL. The same owner/name on two hosts never shares records.","type":"string","maxLength":261,"pattern":"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},"organization":{"$ref":"#/$defs/scopeName"},"team":{"$ref":"#/$defs/scopeName"},"repository":{"description":"owner/name in lowercase.","type":"string","pattern":"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},"product":{"$ref":"#/$defs/scopeName"}}};const pattern8 = new RegExp("^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$", "u");const pattern10 = new RegExp("^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$", "u");const schema26 = {"type":"string","minLength":1,"maxLength":100,"pattern":"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"};function validate63(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate63.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 100){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 100},message:"must NOT have more than 100 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate63.errors = vErrors;return errors === 0;}validate63.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate62(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate62.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate62.errors = vErrors;return errors === 0;}validate62.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema27 = {"description":"What a record may be used for. Permission for one purpose never implies another.","enum":["review","instruction","evaluation","analytics","training","publication"]};function validate68(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate68.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!((((((data === "review") || (data === "instruction")) || (data === "evaluation")) || (data === "analytics")) || (data === "training")) || (data === "publication"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema27.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate68.errors = vErrors;return errors === 0;}validate68.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema28 = {"description":"SHA-256 of the RFC 8785 canonical JSON of a value.","type":"string","pattern":"^sha256:[0-9a-f]{64}$"};const pattern11 = new RegExp("^sha256:[0-9a-f]{64}$", "u");function validate71(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate71.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate71.errors = vErrors;return errors === 0;}validate71.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate73(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate73.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate73.errors = vErrors;return errors === 0;}validate73.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate52(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/audit-entry.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate52.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.at === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.actor === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "actor"},message:"must have required property '"+"actor"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.operation === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "operation"},message:"must have required property '"+"operation"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.scope === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.subjects === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "subjects"},message:"must have required property '"+"subjects"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.outcome === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "outcome"},message:"must have required property '"+"outcome"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.provider === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "provider"},message:"must have required property '"+"provider"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data.digest === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key0 in data){if(!(func1.call(schema19.properties, key0))){const err10 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.schemaVersion !== undefined){if("replica.audit/v1" !== data.schemaVersion){const err11 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.audit/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data.id !== undefined){if(!(validate54(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate54.errors : vErrors.concat(validate54.errors);errors = vErrors.length;}}if(data.at !== undefined){if(!(validate56(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate56.errors : vErrors.concat(validate56.errors);errors = vErrors.length;}}if(data.actor !== undefined){if(!(validate58(data.actor, {instancePath:instancePath+"/actor",parentData:data,parentDataProperty:"actor",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate58.errors : vErrors.concat(validate58.errors);errors = vErrors.length;}}if(data.operation !== undefined){let data4 = data.operation;if(!((((((((((((((data4 === "grant.add") || (data4 === "grant.withdraw")) || (data4 === "collection.import")) || (data4 === "observation.append")) || (data4 === "evidence.redact")) || (data4 === "annotation.add")) || (data4 === "consolidation.run")) || (data4 === "memory.propose")) || (data4 === "memory.accept")) || (data4 === "memory.reject")) || (data4 === "memory.retire")) || (data4 === "memory.supersede")) || (data4 === "memory.recall")) || (data4 === "export.create"))){const err12 = {instancePath:instancePath+"/operation",schemaPath:"#/properties/operation/enum",keyword:"enum",params:{allowedValues: schema19.properties.operation.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.scope !== undefined){if(!(validate62(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate62.errors : vErrors.concat(validate62.errors);errors = vErrors.length;}}if(data.purpose !== undefined){if(!(validate68(data.purpose, {instancePath:instancePath+"/purpose",parentData:data,parentDataProperty:"purpose",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors);errors = vErrors.length;}}if(data.subjects !== undefined){let data7 = data.subjects;if(Array.isArray(data7)){if(data7.length > 10000){const err13 = {instancePath:instancePath+"/subjects",schemaPath:"#/properties/subjects/maxItems",keyword:"maxItems",params:{limit: 10000},message:"must NOT have more than 10000 items"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}const len0 = data7.length;for(let i0=0; i0 2000){const err21 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(func2(data13) < 1){const err22 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data.provider !== undefined){let data14 = data.provider;if(data14 && typeof data14 == "object" && !Array.isArray(data14)){if(data14.id === undefined){const err24 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}if(data14.version === undefined){const err25 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}for(const key2 in data14){if(!((key2 === "id") || (key2 === "version"))){const err26 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}if(data14.id !== undefined){if(!(validate73(data14.id, {instancePath:instancePath+"/provider/id",parentData:data14,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate73.errors : vErrors.concat(validate73.errors);errors = vErrors.length;}}if(data14.version !== undefined){let data16 = data14.version;if(typeof data16 === "string"){if(func2(data16) > 64){const err27 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(func2(data16) < 1){const err28 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}else {const err29 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}}else {const err30 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data.digest !== undefined){if(!(validate71(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors);errors = vErrors.length;}}}else {const err31 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}validate52.errors = vErrors;return errors === 0;}validate52.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.collection = validate76;const schema30 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/collection.schema.json","title":"Replica evidence collection v1","description":"One import of source evidence for a time window. complete is true only when every page and reply continuation was present. A window that no complete collection covers is reported as incomplete, never as empty.","type":"object","additionalProperties":false,"required":["schemaVersion","id","source","scope","snapshotId","snapshotDigest","capturedAt","filters","complete","problems","counts","importedAt","importedBy","digest"],"properties":{"schemaVersion":{"const":"replica.collection/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"source":{"$ref":"common.schema.json#/$defs/source"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"snapshotId":{"type":"string","pattern":"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"},"snapshotDigest":{"description":"The digest of the snapshot's normalized contents. Each scope stores one collection per snapshotId, and importing the snapshot again matches this digest.","$ref":"common.schema.json#/$defs/digest"},"reviewerIdentity":{"description":"Once a Hub source opts into stable identities, login-only evidence from that source serves review only.","const":"stable-user-id"},"capturedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"filters":{"type":"object","additionalProperties":false,"required":["resolution","read","from","to"],"properties":{"resolution":{"enum":["all","unresolved","resolved"]},"read":{"enum":["all","unread","read"]},"from":{"anyOf":[{"$ref":"common.schema.json#/$defs/timestamp"},{"type":"null"}]},"to":{"anyOf":[{"$ref":"common.schema.json#/$defs/timestamp"},{"type":"null"}]}}},"complete":{"type":"boolean"},"problems":{"type":"array","maxItems":1000,"items":{"type":"string","minLength":1,"maxLength":2000}},"counts":{"type":"object","additionalProperties":false,"required":["threads","messages","episodes","events"],"properties":{"threads":{"$ref":"common.schema.json#/$defs/count"},"messages":{"$ref":"common.schema.json#/$defs/count"},"episodes":{"$ref":"common.schema.json#/$defs/count"},"events":{"$ref":"common.schema.json#/$defs/count"}}},"importedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"importedBy":{"$ref":"common.schema.json#/$defs/actor"},"digest":{"$ref":"common.schema.json#/$defs/digest"}}};function validate77(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate77.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate77.errors = vErrors;return errors === 0;}validate77.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema32 = {"description":"Where an episode or a piece of evidence came from, pinned to the exact Build when there is one.","type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"$ref":"#/$defs/sourceKind"},"hubOrigin":{"$ref":"#/$defs/origin"},"repository":{"type":"string","pattern":"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},"repositoryId":{"$ref":"#/$defs/positiveInteger"},"prototypeId":{"$ref":"#/$defs/positiveInteger"},"prototypeName":{"type":"string","minLength":1,"maxLength":1024},"branch":{"type":"string","minLength":1,"maxLength":1024},"buildNumber":{"$ref":"#/$defs/positiveInteger"},"buildId":{"$ref":"#/$defs/positiveInteger"},"commitSha":{"$ref":"#/$defs/commitSha"},"threadId":{"$ref":"#/$defs/positiveInteger"},"commentId":{"$ref":"#/$defs/positiveInteger"},"sessionId":{"type":"string","minLength":1,"maxLength":200}}};const schema33 = {"description":"Where evidence came from, such as hub_review_comments.","type":"string","pattern":"^[a-z][a-z0-9_]{1,63}$"};const pattern14 = new RegExp("^[a-z][a-z0-9_]{1,63}$", "u");function validate80(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate80.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern14.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9_]{1,63}$"},message:"must match pattern \""+"^[a-z][a-z0-9_]{1,63}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate80.errors = vErrors;return errors === 0;}validate80.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema34 = {"description":"An HTTP or HTTPS origin without credentials, path, query, or fragment.","type":"string","maxLength":2048,"pattern":"^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"};const pattern15 = new RegExp("^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$", "u");function validate82(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate82.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 2048){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!pattern15.test(data)){const err1 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate82.errors = vErrors;return errors === 0;}validate82.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema35 = {"type":"integer","minimum":1,"maximum":9007199254740991};function validate84(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate84.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 1 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate84.errors = vErrors;return errors === 0;}validate84.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema36 = {"type":"string","pattern":"^[0-9a-f]{40}$"};const pattern17 = new RegExp("^[0-9a-f]{40}$", "u");function validate89(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate89.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern17.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{40}$"},message:"must match pattern \""+"^[0-9a-f]{40}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate89.errors = vErrors;return errors === 0;}validate89.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate79(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate79.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(func1.call(schema32.properties, key0))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate80(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate80.errors : vErrors.concat(validate80.errors);errors = vErrors.length;}}if(data.hubOrigin !== undefined){if(!(validate82(data.hubOrigin, {instancePath:instancePath+"/hubOrigin",parentData:data,parentDataProperty:"hubOrigin",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate82.errors : vErrors.concat(validate82.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data2 = data.repository;if(typeof data2 === "string"){if(!pattern10.test(data2)){const err2 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.repositoryId !== undefined){if(!(validate84(data.repositoryId, {instancePath:instancePath+"/repositoryId",parentData:data,parentDataProperty:"repositoryId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeId !== undefined){if(!(validate84(data.prototypeId, {instancePath:instancePath+"/prototypeId",parentData:data,parentDataProperty:"prototypeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeName !== undefined){let data5 = data.prototypeName;if(typeof data5 === "string"){if(func2(data5) > 1024){const err4 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data5) < 1){const err5 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.branch !== undefined){let data6 = data.branch;if(typeof data6 === "string"){if(func2(data6) > 1024){const err7 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data6) < 1){const err8 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.buildNumber !== undefined){if(!(validate84(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.buildId !== undefined){if(!(validate84(data.buildId, {instancePath:instancePath+"/buildId",parentData:data,parentDataProperty:"buildId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.commitSha !== undefined){if(!(validate89(data.commitSha, {instancePath:instancePath+"/commitSha",parentData:data,parentDataProperty:"commitSha",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate89.errors : vErrors.concat(validate89.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate84(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.commentId !== undefined){if(!(validate84(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.sessionId !== undefined){let data12 = data.sessionId;if(typeof data12 === "string"){if(func2(data12) > 200){const err10 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data12) < 1){const err11 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate79.errors = vErrors;return errors === 0;}validate79.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate94(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate94.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate94.errors = vErrors;return errors === 0;}validate94.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate99(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate99.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate99.errors = vErrors;return errors === 0;}validate99.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate101(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate101.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate101.errors = vErrors;return errors === 0;}validate101.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema40 = {"type":"integer","minimum":0,"maximum":9007199254740991};function validate105(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate105.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 0 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate105.errors = vErrors;return errors === 0;}validate105.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate111(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate111.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate111.errors = vErrors;return errors === 0;}validate111.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const pattern20 = new RegExp("^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", "u");function validate76(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/collection.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate76.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.source === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "source"},message:"must have required property '"+"source"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.scope === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.snapshotId === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "snapshotId"},message:"must have required property '"+"snapshotId"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.snapshotDigest === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "snapshotDigest"},message:"must have required property '"+"snapshotDigest"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.capturedAt === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "capturedAt"},message:"must have required property '"+"capturedAt"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.filters === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "filters"},message:"must have required property '"+"filters"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.complete === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "complete"},message:"must have required property '"+"complete"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data.problems === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "problems"},message:"must have required property '"+"problems"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(data.counts === undefined){const err10 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "counts"},message:"must have required property '"+"counts"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.importedAt === undefined){const err11 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "importedAt"},message:"must have required property '"+"importedAt"+"'"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(data.importedBy === undefined){const err12 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "importedBy"},message:"must have required property '"+"importedBy"+"'"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(data.digest === undefined){const err13 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}for(const key0 in data){if(!(func1.call(schema30.properties, key0))){const err14 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data.schemaVersion !== undefined){if("replica.collection/v1" !== data.schemaVersion){const err15 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.collection/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data.id !== undefined){if(!(validate77(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate77.errors : vErrors.concat(validate77.errors);errors = vErrors.length;}}if(data.source !== undefined){if(!(validate79(data.source, {instancePath:instancePath+"/source",parentData:data,parentDataProperty:"source",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate79.errors : vErrors.concat(validate79.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate94(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate94.errors : vErrors.concat(validate94.errors);errors = vErrors.length;}}if(data.snapshotId !== undefined){let data4 = data.snapshotId;if(typeof data4 === "string"){if(!pattern20.test(data4)){const err16 = {instancePath:instancePath+"/snapshotId",schemaPath:"#/properties/snapshotId/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"+"\""};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}else {const err17 = {instancePath:instancePath+"/snapshotId",schemaPath:"#/properties/snapshotId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data.snapshotDigest !== undefined){if(!(validate99(data.snapshotDigest, {instancePath:instancePath+"/snapshotDigest",parentData:data,parentDataProperty:"snapshotDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate99.errors : vErrors.concat(validate99.errors);errors = vErrors.length;}}if(data.reviewerIdentity !== undefined){if("stable-user-id" !== data.reviewerIdentity){const err18 = {instancePath:instancePath+"/reviewerIdentity",schemaPath:"#/properties/reviewerIdentity/const",keyword:"const",params:{allowedValue: "stable-user-id"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data.capturedAt !== undefined){if(!(validate101(data.capturedAt, {instancePath:instancePath+"/capturedAt",parentData:data,parentDataProperty:"capturedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate101.errors : vErrors.concat(validate101.errors);errors = vErrors.length;}}if(data.filters !== undefined){let data8 = data.filters;if(data8 && typeof data8 == "object" && !Array.isArray(data8)){if(data8.resolution === undefined){const err19 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "resolution"},message:"must have required property '"+"resolution"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data8.read === undefined){const err20 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "read"},message:"must have required property '"+"read"+"'"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}if(data8.from === undefined){const err21 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(data8.to === undefined){const err22 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}for(const key1 in data8){if(!((((key1 === "resolution") || (key1 === "read")) || (key1 === "from")) || (key1 === "to"))){const err23 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data8.resolution !== undefined){let data9 = data8.resolution;if(!(((data9 === "all") || (data9 === "unresolved")) || (data9 === "resolved"))){const err24 = {instancePath:instancePath+"/filters/resolution",schemaPath:"#/properties/filters/properties/resolution/enum",keyword:"enum",params:{allowedValues: schema30.properties.filters.properties.resolution.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data8.read !== undefined){let data10 = data8.read;if(!(((data10 === "all") || (data10 === "unread")) || (data10 === "read"))){const err25 = {instancePath:instancePath+"/filters/read",schemaPath:"#/properties/filters/properties/read/enum",keyword:"enum",params:{allowedValues: schema30.properties.filters.properties.read.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}if(data8.from !== undefined){let data11 = data8.from;const _errs17 = errors;let valid2 = false;const _errs18 = errors;if(!(validate101(data11, {instancePath:instancePath+"/filters/from",parentData:data8,parentDataProperty:"from",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate101.errors : vErrors.concat(validate101.errors);errors = vErrors.length;}var _valid0 = _errs18 === errors;valid2 = valid2 || _valid0;const _errs19 = errors;if(data11 !== null){const err26 = {instancePath:instancePath+"/filters/from",schemaPath:"#/properties/filters/properties/from/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}var _valid0 = _errs19 === errors;valid2 = valid2 || _valid0;if(!valid2){const err27 = {instancePath:instancePath+"/filters/from",schemaPath:"#/properties/filters/properties/from/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}else {errors = _errs17;if(vErrors !== null){if(_errs17){vErrors.length = _errs17;}else {vErrors = null;}}}}if(data8.to !== undefined){let data12 = data8.to;const _errs22 = errors;let valid3 = false;const _errs23 = errors;if(!(validate101(data12, {instancePath:instancePath+"/filters/to",parentData:data8,parentDataProperty:"to",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate101.errors : vErrors.concat(validate101.errors);errors = vErrors.length;}var _valid1 = _errs23 === errors;valid3 = valid3 || _valid1;const _errs24 = errors;if(data12 !== null){const err28 = {instancePath:instancePath+"/filters/to",schemaPath:"#/properties/filters/properties/to/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}var _valid1 = _errs24 === errors;valid3 = valid3 || _valid1;if(!valid3){const err29 = {instancePath:instancePath+"/filters/to",schemaPath:"#/properties/filters/properties/to/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}else {errors = _errs22;if(vErrors !== null){if(_errs22){vErrors.length = _errs22;}else {vErrors = null;}}}}}else {const err30 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data.complete !== undefined){if(typeof data.complete !== "boolean"){const err31 = {instancePath:instancePath+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data.problems !== undefined){let data14 = data.problems;if(Array.isArray(data14)){if(data14.length > 1000){const err32 = {instancePath:instancePath+"/problems",schemaPath:"#/properties/problems/maxItems",keyword:"maxItems",params:{limit: 1000},message:"must NOT have more than 1000 items"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}const len0 = data14.length;for(let i0=0; i0 2000){const err33 = {instancePath:instancePath+"/problems/" + i0,schemaPath:"#/properties/problems/items/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}if(func2(data15) < 1){const err34 = {instancePath:instancePath+"/problems/" + i0,schemaPath:"#/properties/problems/items/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}else {const err35 = {instancePath:instancePath+"/problems/" + i0,schemaPath:"#/properties/problems/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}}else {const err36 = {instancePath:instancePath+"/problems",schemaPath:"#/properties/problems/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data.counts !== undefined){let data16 = data.counts;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){if(data16.threads === undefined){const err37 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "threads"},message:"must have required property '"+"threads"+"'"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}if(data16.messages === undefined){const err38 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "messages"},message:"must have required property '"+"messages"+"'"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}if(data16.episodes === undefined){const err39 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "episodes"},message:"must have required property '"+"episodes"+"'"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}if(data16.events === undefined){const err40 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "events"},message:"must have required property '"+"events"+"'"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}for(const key2 in data16){if(!((((key2 === "threads") || (key2 === "messages")) || (key2 === "episodes")) || (key2 === "events"))){const err41 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data16.threads !== undefined){if(!(validate105(data16.threads, {instancePath:instancePath+"/counts/threads",parentData:data16,parentDataProperty:"threads",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate105.errors : vErrors.concat(validate105.errors);errors = vErrors.length;}}if(data16.messages !== undefined){if(!(validate105(data16.messages, {instancePath:instancePath+"/counts/messages",parentData:data16,parentDataProperty:"messages",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate105.errors : vErrors.concat(validate105.errors);errors = vErrors.length;}}if(data16.episodes !== undefined){if(!(validate105(data16.episodes, {instancePath:instancePath+"/counts/episodes",parentData:data16,parentDataProperty:"episodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate105.errors : vErrors.concat(validate105.errors);errors = vErrors.length;}}if(data16.events !== undefined){if(!(validate105(data16.events, {instancePath:instancePath+"/counts/events",parentData:data16,parentDataProperty:"events",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate105.errors : vErrors.concat(validate105.errors);errors = vErrors.length;}}}else {const err42 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data.importedAt !== undefined){if(!(validate101(data.importedAt, {instancePath:instancePath+"/importedAt",parentData:data,parentDataProperty:"importedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate101.errors : vErrors.concat(validate101.errors);errors = vErrors.length;}}if(data.importedBy !== undefined){if(!(validate111(data.importedBy, {instancePath:instancePath+"/importedBy",parentData:data,parentDataProperty:"importedBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate111.errors : vErrors.concat(validate111.errors);errors = vErrors.length;}}if(data.digest !== undefined){if(!(validate99(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate99.errors : vErrors.concat(validate99.errors);errors = vErrors.length;}}}else {const err43 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}validate76.errors = vErrors;return errors === 0;}validate76.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.consentGrant = validate115;const schema42 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/consent-grant.schema.json","title":"Replica consent grant v1","description":"Permission to use evidence from named sources, in one scope, for named purposes. A host decides at read time whether a record may be used for a purpose: some active grant in the record's scope must name the purpose and the record's source, and cover the evidence's original time. Reading feedback, publishing it, and training on it are separate purposes. A grant is never edited; a withdrawal record ends a purpose.","type":"object","additionalProperties":false,"required":["schemaVersion","id","scope","purposes","sources","grantedBy","grantedAt","basis","digest"],"properties":{"schemaVersion":{"const":"replica.consent-grant/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"purposes":{"$ref":"common.schema.json#/$defs/purposes"},"sources":{"type":"array","minItems":1,"maxItems":20,"items":{"$ref":"common.schema.json#/$defs/sourceKind"}},"grantedBy":{"$ref":"common.schema.json#/$defs/humanActor"},"grantedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"expiresAt":{"$ref":"common.schema.json#/$defs/timestamp"},"evidenceFrom":{"description":"Covers only evidence whose original time is at or after this time. Omit to cover earlier evidence too.","$ref":"common.schema.json#/$defs/timestamp"},"evidenceUntil":{"description":"Covers only evidence whose original time is before this time. Omit for no upper bound.","$ref":"common.schema.json#/$defs/timestamp"},"basis":{"description":"Why this use is allowed, such as a team agreement or a study consent form.","type":"string","minLength":1,"maxLength":2000},"digest":{"$ref":"common.schema.json#/$defs/digest"}}};function validate116(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate116.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate116.errors = vErrors;return errors === 0;}validate116.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate118(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate118.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate118.errors = vErrors;return errors === 0;}validate118.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema45 = {"type":"array","minItems":1,"maxItems":6,"items":{"$ref":"#/$defs/purpose"}};function validate124(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate124.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!((((((data === "review") || (data === "instruction")) || (data === "evaluation")) || (data === "analytics")) || (data === "training")) || (data === "publication"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema27.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate124.errors = vErrors;return errors === 0;}validate124.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate123(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate123.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 6){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 6},message:"must NOT have more than 6 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.length < 1){const err1 = {instancePath,schemaPath:"#/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}const len0 = data.length;for(let i0=0; i0 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate130.errors = vErrors;return errors === 0;}validate130.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate129(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate129.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(validate130(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate130.errors : vErrors.concat(validate130.errors);errors = vErrors.length;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind !== undefined){if("human" !== data.kind){const err0 = {instancePath:instancePath+"/kind",schemaPath:"#/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "human"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}else {const err1 = {instancePath,schemaPath:"#/allOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate129.errors = vErrors;return errors === 0;}validate129.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate134(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate134.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate134.errors = vErrors;return errors === 0;}validate134.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate139(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate139.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate139.errors = vErrors;return errors === 0;}validate139.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate115(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/consent-grant.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate115.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.scope === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.purposes === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "purposes"},message:"must have required property '"+"purposes"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.sources === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "sources"},message:"must have required property '"+"sources"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.grantedBy === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "grantedBy"},message:"must have required property '"+"grantedBy"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.grantedAt === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "grantedAt"},message:"must have required property '"+"grantedAt"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.basis === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "basis"},message:"must have required property '"+"basis"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.digest === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}for(const key0 in data){if(!(func1.call(schema42.properties, key0))){const err9 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.schemaVersion !== undefined){if("replica.consent-grant/v1" !== data.schemaVersion){const err10 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.consent-grant/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.id !== undefined){if(!(validate116(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate116.errors : vErrors.concat(validate116.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate118(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate118.errors : vErrors.concat(validate118.errors);errors = vErrors.length;}}if(data.purposes !== undefined){if(!(validate123(data.purposes, {instancePath:instancePath+"/purposes",parentData:data,parentDataProperty:"purposes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate123.errors : vErrors.concat(validate123.errors);errors = vErrors.length;}}if(data.sources !== undefined){let data4 = data.sources;if(Array.isArray(data4)){if(data4.length > 20){const err11 = {instancePath:instancePath+"/sources",schemaPath:"#/properties/sources/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(data4.length < 1){const err12 = {instancePath:instancePath+"/sources",schemaPath:"#/properties/sources/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}const len0 = data4.length;for(let i0=0; i0 2000){const err14 = {instancePath:instancePath+"/basis",schemaPath:"#/properties/basis/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(func2(data11) < 1){const err15 = {instancePath:instancePath+"/basis",schemaPath:"#/properties/basis/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}else {const err16 = {instancePath:instancePath+"/basis",schemaPath:"#/properties/basis/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data.digest !== undefined){if(!(validate139(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate139.errors : vErrors.concat(validate139.errors);errors = vErrors.length;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate115.errors = vErrors;return errors === 0;}validate115.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.episode = validate141;const schema52 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/episode.schema.json","title":"Replica episode v1","description":"The unit of learning evidence: one review thread, chat session, scenario run, or similar. The digest covers the header, every field except digest and timeline, so appending events never changes it. Events carry their own digests. timeline appears only in exports.","type":"object","additionalProperties":false,"required":["schemaVersion","id","scope","source","actors","grants","provenance","startedAt","digest"],"properties":{"schemaVersion":{"const":"replica.episode/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"source":{"$ref":"common.schema.json#/$defs/source"},"task":{"type":"object","additionalProperties":false,"properties":{"prompt":{"type":"string","minLength":1,"maxLength":10000},"goal":{"type":"string","minLength":1,"maxLength":2000},"role":{"$ref":"common.schema.json#/$defs/slug"},"taskId":{"type":"string","minLength":1,"maxLength":200}}},"actors":{"type":"array","maxItems":500,"items":{"$ref":"common.schema.json#/$defs/actor"}},"versions":{"description":"What produced the experience under review, so outcomes can be tied to versions.","type":"object","additionalProperties":false,"properties":{"model":{"type":"string","minLength":1,"maxLength":200},"harness":{"type":"string","minLength":1,"maxLength":200},"designSystem":{"type":"string","minLength":1,"maxLength":200},"brandPack":{"type":"string","minLength":1,"maxLength":200},"memorySnapshot":{"$ref":"common.schema.json#/$defs/digest"}}},"grants":{"description":"The consent grants this episode was collected under, kept for provenance. Use for a purpose is decided at read time from the grants then active for the episode's scope and source.","type":"array","minItems":1,"maxItems":20,"items":{"$ref":"common.schema.json#/$defs/id"}},"contentTrust":{"type":"object","additionalProperties":false,"required":["untrusted","treatAs"],"properties":{"untrusted":{"type":"boolean"},"treatAs":{"const":"data"},"source":{"$ref":"common.schema.json#/$defs/sourceKind"}}},"provenance":{"$ref":"common.schema.json#/$defs/provenance"},"startedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"endedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"outcome":{"type":"object","additionalProperties":false,"required":["status"],"properties":{"status":{"enum":["success","failure","partial","unknown"]},"summary":{"type":"string","minLength":1,"maxLength":2000}}},"timeline":{"type":"array","maxItems":100000,"items":{"$ref":"event.schema.json"}},"digest":{"$ref":"common.schema.json#/$defs/digest"}}};function validate142(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate142.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate142.errors = vErrors;return errors === 0;}validate142.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate144(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate144.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate144.errors = vErrors;return errors === 0;}validate144.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate149(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate149.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(func1.call(schema32.properties, key0))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate80(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate80.errors : vErrors.concat(validate80.errors);errors = vErrors.length;}}if(data.hubOrigin !== undefined){if(!(validate82(data.hubOrigin, {instancePath:instancePath+"/hubOrigin",parentData:data,parentDataProperty:"hubOrigin",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate82.errors : vErrors.concat(validate82.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data2 = data.repository;if(typeof data2 === "string"){if(!pattern10.test(data2)){const err2 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.repositoryId !== undefined){if(!(validate84(data.repositoryId, {instancePath:instancePath+"/repositoryId",parentData:data,parentDataProperty:"repositoryId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeId !== undefined){if(!(validate84(data.prototypeId, {instancePath:instancePath+"/prototypeId",parentData:data,parentDataProperty:"prototypeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeName !== undefined){let data5 = data.prototypeName;if(typeof data5 === "string"){if(func2(data5) > 1024){const err4 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data5) < 1){const err5 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.branch !== undefined){let data6 = data.branch;if(typeof data6 === "string"){if(func2(data6) > 1024){const err7 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data6) < 1){const err8 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.buildNumber !== undefined){if(!(validate84(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.buildId !== undefined){if(!(validate84(data.buildId, {instancePath:instancePath+"/buildId",parentData:data,parentDataProperty:"buildId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.commitSha !== undefined){if(!(validate89(data.commitSha, {instancePath:instancePath+"/commitSha",parentData:data,parentDataProperty:"commitSha",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate89.errors : vErrors.concat(validate89.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate84(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.commentId !== undefined){if(!(validate84(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.sessionId !== undefined){let data12 = data.sessionId;if(typeof data12 === "string"){if(func2(data12) > 200){const err10 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data12) < 1){const err11 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate149.errors = vErrors;return errors === 0;}validate149.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate160(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate160.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate160.errors = vErrors;return errors === 0;}validate160.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate162(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate162.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate162.errors = vErrors;return errors === 0;}validate162.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate165(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate165.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate165.errors = vErrors;return errors === 0;}validate165.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate168(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate168.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern14.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9_]{1,63}$"},message:"must match pattern \""+"^[a-z][a-z0-9_]{1,63}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate168.errors = vErrors;return errors === 0;}validate168.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema60 = {"description":"Which code made a record, how, when, for whom, and from which inputs.","type":"object","additionalProperties":false,"required":["producer","method","createdAt","createdBy"],"properties":{"producer":{"$ref":"#/$defs/producer"},"method":{"type":"string","maxLength":128,"pattern":"^[a-z]+:[a-z0-9_.-]+$"},"createdAt":{"$ref":"#/$defs/timestamp"},"createdBy":{"$ref":"#/$defs/actor"},"inputs":{"type":"array","maxItems":1000,"items":{"$ref":"#/$defs/digest"}}}};const schema61 = {"type":"object","additionalProperties":false,"required":["name","version"],"properties":{"name":{"type":"string","minLength":1,"maxLength":200},"version":{"type":"string","minLength":1,"maxLength":64}}};function validate171(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate171.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.name === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.version === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "name") || (key0 === "version"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.name !== undefined){let data0 = data.name;if(typeof data0 === "string"){if(func2(data0) > 200){const err3 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(func2(data0) < 1){const err4 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.version !== undefined){let data1 = data.version;if(typeof data1 === "string"){if(func2(data1) > 64){const err6 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(func2(data1) < 1){const err7 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}else {const err8 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}}else {const err9 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}validate171.errors = vErrors;return errors === 0;}validate171.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate173(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate173.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate173.errors = vErrors;return errors === 0;}validate173.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate176(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate176.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate176.errors = vErrors;return errors === 0;}validate176.evaluated = {"dynamicProps":false,"dynamicItems":false};const pattern42 = new RegExp("^[a-z]+:[a-z0-9_.-]+$", "u");function validate170(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate170.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.producer === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "producer"},message:"must have required property '"+"producer"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.method === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "method"},message:"must have required property '"+"method"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.createdAt === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.createdBy === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdBy"},message:"must have required property '"+"createdBy"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!(((((key0 === "producer") || (key0 === "method")) || (key0 === "createdAt")) || (key0 === "createdBy")) || (key0 === "inputs"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.producer !== undefined){if(!(validate171(data.producer, {instancePath:instancePath+"/producer",parentData:data,parentDataProperty:"producer",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate171.errors : vErrors.concat(validate171.errors);errors = vErrors.length;}}if(data.method !== undefined){let data1 = data.method;if(typeof data1 === "string"){if(func2(data1) > 128){const err5 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern42.test(data1)){const err6 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/pattern",keyword:"pattern",params:{pattern: "^[a-z]+:[a-z0-9_.-]+$"},message:"must match pattern \""+"^[a-z]+:[a-z0-9_.-]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.createdAt !== undefined){if(!(validate173(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate173.errors : vErrors.concat(validate173.errors);errors = vErrors.length;}}if(data.createdBy !== undefined){if(!(validate130(data.createdBy, {instancePath:instancePath+"/createdBy",parentData:data,parentDataProperty:"createdBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate130.errors : vErrors.concat(validate130.errors);errors = vErrors.length;}}if(data.inputs !== undefined){let data4 = data.inputs;if(Array.isArray(data4)){if(data4.length > 1000){const err8 = {instancePath:instancePath+"/inputs",schemaPath:"#/properties/inputs/maxItems",keyword:"maxItems",params:{limit: 1000},message:"must NOT have more than 1000 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}const len0 = data4.length;for(let i0=0; i0 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 1 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate184.errors = vErrors;return errors === 0;}validate184.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate187(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate187.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate187.errors = vErrors;return errors === 0;}validate187.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema69 = {"description":"The compact saved target of a root comment: route and accessible element details.","type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"enum":["element","area"]},"route":{"type":"object","additionalProperties":false,"properties":{"pathname":{"type":"string","maxLength":2048},"search":{"type":"string","maxLength":2048},"hash":{"type":"string","maxLength":1024}}},"accessibleName":{"type":"string","maxLength":1000},"tagName":{"type":"string","maxLength":64},"selectedText":{"type":"string","maxLength":2000},"elements":{"type":"array","maxItems":8,"items":{"type":"object","additionalProperties":false,"properties":{"accessibleName":{"type":"string","maxLength":1000},"tagName":{"type":"string","maxLength":64},"role":{"type":"string","maxLength":64},"textExcerpt":{"type":"string","maxLength":500}}}}}};function validate192(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate192.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "route")) || (key0 === "accessibleName")) || (key0 === "tagName")) || (key0 === "selectedText")) || (key0 === "elements"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((data0 === "element") || (data0 === "area"))){const err2 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema69.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.route !== undefined){let data1 = data.route;if(data1 && typeof data1 == "object" && !Array.isArray(data1)){for(const key1 in data1){if(!(((key1 === "pathname") || (key1 === "search")) || (key1 === "hash"))){const err3 = {instancePath:instancePath+"/route",schemaPath:"#/properties/route/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data1.pathname !== undefined){let data2 = data1.pathname;if(typeof data2 === "string"){if(func2(data2) > 2048){const err4 = {instancePath:instancePath+"/route/pathname",schemaPath:"#/properties/route/properties/pathname/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/route/pathname",schemaPath:"#/properties/route/properties/pathname/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data1.search !== undefined){let data3 = data1.search;if(typeof data3 === "string"){if(func2(data3) > 2048){const err6 = {instancePath:instancePath+"/route/search",schemaPath:"#/properties/route/properties/search/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/route/search",schemaPath:"#/properties/route/properties/search/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data1.hash !== undefined){let data4 = data1.hash;if(typeof data4 === "string"){if(func2(data4) > 1024){const err8 = {instancePath:instancePath+"/route/hash",schemaPath:"#/properties/route/properties/hash/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/route/hash",schemaPath:"#/properties/route/properties/hash/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}}else {const err10 = {instancePath:instancePath+"/route",schemaPath:"#/properties/route/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.accessibleName !== undefined){let data5 = data.accessibleName;if(typeof data5 === "string"){if(func2(data5) > 1000){const err11 = {instancePath:instancePath+"/accessibleName",schemaPath:"#/properties/accessibleName/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/accessibleName",schemaPath:"#/properties/accessibleName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.tagName !== undefined){let data6 = data.tagName;if(typeof data6 === "string"){if(func2(data6) > 64){const err13 = {instancePath:instancePath+"/tagName",schemaPath:"#/properties/tagName/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}else {const err14 = {instancePath:instancePath+"/tagName",schemaPath:"#/properties/tagName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data.selectedText !== undefined){let data7 = data.selectedText;if(typeof data7 === "string"){if(func2(data7) > 2000){const err15 = {instancePath:instancePath+"/selectedText",schemaPath:"#/properties/selectedText/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}else {const err16 = {instancePath:instancePath+"/selectedText",schemaPath:"#/properties/selectedText/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data.elements !== undefined){let data8 = data.elements;if(Array.isArray(data8)){if(data8.length > 8){const err17 = {instancePath:instancePath+"/elements",schemaPath:"#/properties/elements/maxItems",keyword:"maxItems",params:{limit: 8},message:"must NOT have more than 8 items"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}const len0 = data8.length;for(let i0=0; i0 1000){const err19 = {instancePath:instancePath+"/elements/" + i0+"/accessibleName",schemaPath:"#/properties/elements/items/properties/accessibleName/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}else {const err20 = {instancePath:instancePath+"/elements/" + i0+"/accessibleName",schemaPath:"#/properties/elements/items/properties/accessibleName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}if(data9.tagName !== undefined){let data11 = data9.tagName;if(typeof data11 === "string"){if(func2(data11) > 64){const err21 = {instancePath:instancePath+"/elements/" + i0+"/tagName",schemaPath:"#/properties/elements/items/properties/tagName/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}else {const err22 = {instancePath:instancePath+"/elements/" + i0+"/tagName",schemaPath:"#/properties/elements/items/properties/tagName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}if(data9.role !== undefined){let data12 = data9.role;if(typeof data12 === "string"){if(func2(data12) > 64){const err23 = {instancePath:instancePath+"/elements/" + i0+"/role",schemaPath:"#/properties/elements/items/properties/role/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}else {const err24 = {instancePath:instancePath+"/elements/" + i0+"/role",schemaPath:"#/properties/elements/items/properties/role/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data9.textExcerpt !== undefined){let data13 = data9.textExcerpt;if(typeof data13 === "string"){if(func2(data13) > 500){const err25 = {instancePath:instancePath+"/elements/" + i0+"/textExcerpt",schemaPath:"#/properties/elements/items/properties/textExcerpt/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}else {const err26 = {instancePath:instancePath+"/elements/" + i0+"/textExcerpt",schemaPath:"#/properties/elements/items/properties/textExcerpt/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}}else {const err27 = {instancePath:instancePath+"/elements/" + i0,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}}else {const err28 = {instancePath:instancePath+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}}else {const err29 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}validate192.errors = vErrors;return errors === 0;}validate192.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate183(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate183.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.role !== undefined){if("root" !== data.role){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs5 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.buildNumber === undefined){const err1 = {instancePath,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty: "buildNumber"},message:"must have required property '"+"buildNumber"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var _valid0 = _errs5 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs6 = errors;const _errs7 = errors;const _errs8 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.buildNumber === undefined) && (missing0 = "buildNumber")){const err2 = {};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}var valid3 = _errs8 === errors;if(valid3){const err3 = {instancePath,schemaPath:"#/allOf/0/else/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}else {errors = _errs7;if(vErrors !== null){if(_errs7){vErrors.length = _errs7;}else {vErrors = null;}}}var _valid0 = _errs6 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}const _errs10 = errors;let valid4 = true;const _errs11 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.deletedAt !== undefined){if(typeof data.deletedAt !== "string"){const err5 = {};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}}var _valid1 = _errs11 === errors;errors = _errs10;if(vErrors !== null){if(_errs10){vErrors.length = _errs10;}else {vErrors = null;}}let ifClause1;if(_valid1){const _errs14 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.body !== undefined){if(data.body !== null){const err6 = {instancePath:instancePath+"/body",schemaPath:"#/allOf/1/then/properties/body/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}var _valid1 = _errs14 === errors;valid4 = _valid1;if(valid4){var props0 = {};props0.body = true;props0.deletedAt = true;}ifClause1 = "then";}else {const _errs17 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.body !== undefined){if(typeof data.body !== "string"){const err7 = {instancePath:instancePath+"/body",schemaPath:"#/allOf/1/else/properties/body/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}}var _valid1 = _errs17 === errors;valid4 = _valid1;if(valid4){if(props0 !== true){props0 = props0 || {};props0.body = true;}}ifClause1 = "else";}if(!valid4){const err8 = {instancePath,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword: ifClause1},message:"must match \""+ifClause1+"\" schema"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(props0 !== true){props0 = props0 || {};props0.role = true;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.source === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "source"},message:"must have required property '"+"source"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(data.commentId === undefined){const err10 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "commentId"},message:"must have required property '"+"commentId"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.threadId === undefined){const err11 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "threadId"},message:"must have required property '"+"threadId"+"'"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(data.role === undefined){const err12 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "role"},message:"must have required property '"+"role"+"'"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(data.body === undefined){const err13 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "body"},message:"must have required property '"+"body"+"'"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(data.createdAt === undefined){const err14 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data.editedAt === undefined){const err15 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "editedAt"},message:"must have required property '"+"editedAt"+"'"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}if(data.deletedAt === undefined){const err16 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "deletedAt"},message:"must have required property '"+"deletedAt"+"'"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}for(const key0 in data){if(!(func1.call(schema66.properties, key0))){const err17 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data.source !== undefined){if("hub_review_comment" !== data.source){const err18 = {instancePath:instancePath+"/source",schemaPath:"#/properties/source/const",keyword:"const",params:{allowedValue: "hub_review_comment"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data.commentId !== undefined){if(!(validate184(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate184.errors : vErrors.concat(validate184.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate184(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate184.errors : vErrors.concat(validate184.errors);errors = vErrors.length;}}if(data.role !== undefined){let data7 = data.role;if(!((data7 === "root") || (data7 === "reply"))){const err19 = {instancePath:instancePath+"/role",schemaPath:"#/properties/role/enum",keyword:"enum",params:{allowedValues: schema66.properties.role.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}if(data.body !== undefined){let data8 = data.body;const _errs26 = errors;let valid9 = false;const _errs27 = errors;if(typeof data8 === "string"){if(func2(data8) > 10000){const err20 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 10000},message:"must NOT have more than 10000 characters"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}if(func2(data8) < 1){const err21 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}else {const err22 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}var _valid2 = _errs27 === errors;valid9 = valid9 || _valid2;const _errs29 = errors;if(data8 !== null){const err23 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}var _valid2 = _errs29 === errors;valid9 = valid9 || _valid2;if(!valid9){const err24 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}else {errors = _errs26;if(vErrors !== null){if(_errs26){vErrors.length = _errs26;}else {vErrors = null;}}}}if(data.createdAt !== undefined){if(!(validate187(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate187.errors : vErrors.concat(validate187.errors);errors = vErrors.length;}}if(data.editedAt !== undefined){let data10 = data.editedAt;const _errs33 = errors;let valid10 = false;const _errs34 = errors;if(!(validate187(data10, {instancePath:instancePath+"/editedAt",parentData:data,parentDataProperty:"editedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate187.errors : vErrors.concat(validate187.errors);errors = vErrors.length;}var _valid3 = _errs34 === errors;valid10 = valid10 || _valid3;const _errs35 = errors;if(data10 !== null){const err25 = {instancePath:instancePath+"/editedAt",schemaPath:"#/properties/editedAt/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}var _valid3 = _errs35 === errors;valid10 = valid10 || _valid3;if(!valid10){const err26 = {instancePath:instancePath+"/editedAt",schemaPath:"#/properties/editedAt/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}}if(data.deletedAt !== undefined){let data11 = data.deletedAt;const _errs38 = errors;let valid11 = false;const _errs39 = errors;if(!(validate187(data11, {instancePath:instancePath+"/deletedAt",parentData:data,parentDataProperty:"deletedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate187.errors : vErrors.concat(validate187.errors);errors = vErrors.length;}var _valid4 = _errs39 === errors;valid11 = valid11 || _valid4;const _errs40 = errors;if(data11 !== null){const err27 = {instancePath:instancePath+"/deletedAt",schemaPath:"#/properties/deletedAt/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}var _valid4 = _errs40 === errors;valid11 = valid11 || _valid4;if(!valid11){const err28 = {instancePath:instancePath+"/deletedAt",schemaPath:"#/properties/deletedAt/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}else {errors = _errs38;if(vErrors !== null){if(_errs38){vErrors.length = _errs38;}else {vErrors = null;}}}}if(data.buildNumber !== undefined){if(!(validate184(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate184.errors : vErrors.concat(validate184.errors);errors = vErrors.length;}}if(data.context !== undefined){if(!(validate192(data.context, {instancePath:instancePath+"/context",parentData:data,parentDataProperty:"context",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate192.errors : vErrors.concat(validate192.errors);errors = vErrors.length;}}}else {const err29 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}validate183.errors = vErrors;return errors === 0;}validate183.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema70 = {"description":"A judgment about another event in the same episode: its theme, signal, and whether it is an observed problem.","type":"object","additionalProperties":false,"required":["target","theme","signal","observation","stance"],"properties":{"target":{"$ref":"#/$defs/eventTarget"},"theme":{"type":"object","additionalProperties":false,"required":["key","statement"],"properties":{"key":{"$ref":"common.schema.json#/$defs/slug"},"statement":{"type":"string","minLength":1,"maxLength":1000}}},"signal":{"enum":["visual_quality","accessibility","usability","content","interaction","performance","agreement","replica_workflow","other"]},"observation":{"enum":["observed","preference","question","praise","other"]},"stance":{"enum":["supports","contradicts"]},"proposedKind":{"$ref":"common.schema.json#/$defs/memoryKind"},"trace":{"$ref":"common.schema.json#/$defs/trace"},"note":{"type":"string","minLength":1,"maxLength":1000}}};const schema71 = {"type":"object","additionalProperties":false,"required":["eventId"],"properties":{"eventId":{"$ref":"common.schema.json#/$defs/id"}}};function validate197(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate197.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate197.errors = vErrors;return errors === 0;}validate197.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate196(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate196.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.eventId === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "eventId"},message:"must have required property '"+"eventId"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(key0 === "eventId")){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.eventId !== undefined){if(!(validate197(data.eventId, {instancePath:instancePath+"/eventId",parentData:data,parentDataProperty:"eventId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate197.errors : vErrors.concat(validate197.errors);errors = vErrors.length;}}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate196.errors = vErrors;return errors === 0;}validate196.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate200(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate200.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate200.errors = vErrors;return errors === 0;}validate200.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema74 = {"enum":["fact","preference","rule","procedure","example","anti_pattern","design_principle"]};function validate202(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate202.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((((((data === "fact") || (data === "preference")) || (data === "rule")) || (data === "procedure")) || (data === "example")) || (data === "anti_pattern")) || (data === "design_principle"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate202.errors = vErrors;return errors === 0;}validate202.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema75 = {"description":"The rule, skill, component, context, or token that should have prevented a problem.","type":"object","additionalProperties":false,"required":["kind","ref"],"properties":{"kind":{"enum":["rule","skill","component","context","token","other"]},"ref":{"type":"string","minLength":1,"maxLength":500}}};function validate204(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate204.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.ref === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "ref"},message:"must have required property '"+"ref"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "kind") || (key0 === "ref"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((((data0 === "rule") || (data0 === "skill")) || (data0 === "component")) || (data0 === "context")) || (data0 === "token")) || (data0 === "other"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema75.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.ref !== undefined){let data1 = data.ref;if(typeof data1 === "string"){if(func2(data1) > 500){const err4 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 1){const err5 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate204.errors = vErrors;return errors === 0;}validate204.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate195(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate195.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.target === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "target"},message:"must have required property '"+"target"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.theme === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "theme"},message:"must have required property '"+"theme"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.signal === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "signal"},message:"must have required property '"+"signal"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.observation === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "observation"},message:"must have required property '"+"observation"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.stance === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "stance"},message:"must have required property '"+"stance"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}for(const key0 in data){if(!((((((((key0 === "target") || (key0 === "theme")) || (key0 === "signal")) || (key0 === "observation")) || (key0 === "stance")) || (key0 === "proposedKind")) || (key0 === "trace")) || (key0 === "note"))){const err5 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.target !== undefined){if(!(validate196(data.target, {instancePath:instancePath+"/target",parentData:data,parentDataProperty:"target",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate196.errors : vErrors.concat(validate196.errors);errors = vErrors.length;}}if(data.theme !== undefined){let data1 = data.theme;if(data1 && typeof data1 == "object" && !Array.isArray(data1)){if(data1.key === undefined){const err6 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/required",keyword:"required",params:{missingProperty: "key"},message:"must have required property '"+"key"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data1.statement === undefined){const err7 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/required",keyword:"required",params:{missingProperty: "statement"},message:"must have required property '"+"statement"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}for(const key1 in data1){if(!((key1 === "key") || (key1 === "statement"))){const err8 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data1.key !== undefined){if(!(validate200(data1.key, {instancePath:instancePath+"/theme/key",parentData:data1,parentDataProperty:"key",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate200.errors : vErrors.concat(validate200.errors);errors = vErrors.length;}}if(data1.statement !== undefined){let data3 = data1.statement;if(typeof data3 === "string"){if(func2(data3) > 1000){const err9 = {instancePath:instancePath+"/theme/statement",schemaPath:"#/properties/theme/properties/statement/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(func2(data3) < 1){const err10 = {instancePath:instancePath+"/theme/statement",schemaPath:"#/properties/theme/properties/statement/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}else {const err11 = {instancePath:instancePath+"/theme/statement",schemaPath:"#/properties/theme/properties/statement/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}}else {const err12 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.signal !== undefined){let data4 = data.signal;if(!(((((((((data4 === "visual_quality") || (data4 === "accessibility")) || (data4 === "usability")) || (data4 === "content")) || (data4 === "interaction")) || (data4 === "performance")) || (data4 === "agreement")) || (data4 === "replica_workflow")) || (data4 === "other"))){const err13 = {instancePath:instancePath+"/signal",schemaPath:"#/properties/signal/enum",keyword:"enum",params:{allowedValues: schema70.properties.signal.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data.observation !== undefined){let data5 = data.observation;if(!(((((data5 === "observed") || (data5 === "preference")) || (data5 === "question")) || (data5 === "praise")) || (data5 === "other"))){const err14 = {instancePath:instancePath+"/observation",schemaPath:"#/properties/observation/enum",keyword:"enum",params:{allowedValues: schema70.properties.observation.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data.stance !== undefined){let data6 = data.stance;if(!((data6 === "supports") || (data6 === "contradicts"))){const err15 = {instancePath:instancePath+"/stance",schemaPath:"#/properties/stance/enum",keyword:"enum",params:{allowedValues: schema70.properties.stance.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data.proposedKind !== undefined){if(!(validate202(data.proposedKind, {instancePath:instancePath+"/proposedKind",parentData:data,parentDataProperty:"proposedKind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate202.errors : vErrors.concat(validate202.errors);errors = vErrors.length;}}if(data.trace !== undefined){if(!(validate204(data.trace, {instancePath:instancePath+"/trace",parentData:data,parentDataProperty:"trace",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate204.errors : vErrors.concat(validate204.errors);errors = vErrors.length;}}if(data.note !== undefined){let data9 = data.note;if(typeof data9 === "string"){if(func2(data9) > 1000){const err16 = {instancePath:instancePath+"/note",schemaPath:"#/properties/note/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}if(func2(data9) < 1){const err17 = {instancePath:instancePath+"/note",schemaPath:"#/properties/note/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}else {const err18 = {instancePath:instancePath+"/note",schemaPath:"#/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}}else {const err19 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}validate195.errors = vErrors;return errors === 0;}validate195.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema76 = {"description":"A labeler read another event in the same episode and found nothing to label, so it is not asked about that event again.","type":"object","additionalProperties":false,"required":["target"],"properties":{"target":{"$ref":"#/$defs/eventTarget"}}};function validate207(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate207.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.target === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "target"},message:"must have required property '"+"target"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(key0 === "target")){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.target !== undefined){if(!(validate196(data.target, {instancePath:instancePath+"/target",parentData:data,parentDataProperty:"target",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate196.errors : vErrors.concat(validate196.errors);errors = vErrors.length;}}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate207.errors = vErrors;return errors === 0;}validate207.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema77 = {"type":"object","additionalProperties":false,"required":["subject","status","at"],"properties":{"subject":{"type":"object","additionalProperties":false,"required":["kind","id"],"properties":{"kind":{"const":"thread"},"id":{"$ref":"common.schema.json#/$defs/positiveInteger"}}},"status":{"enum":["resolved","unresolved"]},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"by":{"$ref":"common.schema.json#/$defs/actor"}}};function validate213(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate213.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate213.errors = vErrors;return errors === 0;}validate213.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate210(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate210.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.subject === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "subject"},message:"must have required property '"+"subject"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.status === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "status"},message:"must have required property '"+"status"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.at === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!((((key0 === "subject") || (key0 === "status")) || (key0 === "at")) || (key0 === "by"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.subject !== undefined){let data0 = data.subject;if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.kind === undefined){const err4 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data0.id === undefined){const err5 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key1 in data0){if(!((key1 === "kind") || (key1 === "id"))){const err6 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.kind !== undefined){if("thread" !== data0.kind){const err7 = {instancePath:instancePath+"/subject/kind",schemaPath:"#/properties/subject/properties/kind/const",keyword:"const",params:{allowedValue: "thread"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data0.id !== undefined){if(!(validate184(data0.id, {instancePath:instancePath+"/subject/id",parentData:data0,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate184.errors : vErrors.concat(validate184.errors);errors = vErrors.length;}}}else {const err8 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.status !== undefined){let data3 = data.status;if(!((data3 === "resolved") || (data3 === "unresolved"))){const err9 = {instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema77.properties.status.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.at !== undefined){if(!(validate187(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate187.errors : vErrors.concat(validate187.errors);errors = vErrors.length;}}if(data.by !== undefined){if(!(validate213(data.by, {instancePath:instancePath+"/by",parentData:data,parentDataProperty:"by",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate213.errors : vErrors.concat(validate213.errors);errors = vErrors.length;}}}else {const err10 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}validate210.errors = vErrors;return errors === 0;}validate210.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema79 = {"description":"Withdraws an earlier event from every purpose. The earlier event stays in history for audit.","type":"object","additionalProperties":false,"required":["target","reason","at"],"properties":{"target":{"$ref":"#/$defs/eventTarget"},"reason":{"enum":["deleted_at_source","withdrawn_by_author","identity_corrected","other"]},"at":{"$ref":"common.schema.json#/$defs/timestamp"}}};function validate217(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate217.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.target === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "target"},message:"must have required property '"+"target"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.reason === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "reason"},message:"must have required property '"+"reason"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.at === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!(((key0 === "target") || (key0 === "reason")) || (key0 === "at"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.target !== undefined){if(!(validate196(data.target, {instancePath:instancePath+"/target",parentData:data,parentDataProperty:"target",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate196.errors : vErrors.concat(validate196.errors);errors = vErrors.length;}}if(data.reason !== undefined){let data1 = data.reason;if(!((((data1 === "deleted_at_source") || (data1 === "withdrawn_by_author")) || (data1 === "identity_corrected")) || (data1 === "other"))){const err4 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/enum",keyword:"enum",params:{allowedValues: schema79.properties.reason.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.at !== undefined){if(!(validate187(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate187.errors : vErrors.concat(validate187.errors);errors = vErrors.length;}}}else {const err5 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}validate217.errors = vErrors;return errors === 0;}validate217.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema80 = {"type":"object","additionalProperties":false,"required":["memories"],"properties":{"memories":{"type":"array","maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["id","contentDigest"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"contentDigest":{"$ref":"common.schema.json#/$defs/digest"}}}},"task":{"type":"string","minLength":1,"maxLength":2000}}};function validate223(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate223.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate223.errors = vErrors;return errors === 0;}validate223.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate221(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate221.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.memories === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "memories"},message:"must have required property '"+"memories"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((key0 === "memories") || (key0 === "task"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.memories !== undefined){let data0 = data.memories;if(Array.isArray(data0)){if(data0.length > 200){const err2 = {instancePath:instancePath+"/memories",schemaPath:"#/properties/memories/maxItems",keyword:"maxItems",params:{limit: 200},message:"must NOT have more than 200 items"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}const len0 = data0.length;for(let i0=0; i0 2000){const err8 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(func2(data4) < 1){const err9 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}else {const err10 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}}else {const err11 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}validate221.errors = vErrors;return errors === 0;}validate221.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate228(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate228.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate228.errors = vErrors;return errors === 0;}validate228.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema83 = {"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"$ref":"#/$defs/slug"},"uri":{"type":"string","minLength":1,"maxLength":2048},"digest":{"$ref":"#/$defs/digest"},"mediaType":{"type":"string","minLength":3,"maxLength":128}}};function validate238(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate238.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((((key0 === "kind") || (key0 === "uri")) || (key0 === "digest")) || (key0 === "mediaType"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate59(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.uri !== undefined){let data1 = data.uri;if(typeof data1 === "string"){if(func2(data1) > 2048){const err2 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(func2(data1) < 1){const err3 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.digest !== undefined){if(!(validate176(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate176.errors : vErrors.concat(validate176.errors);errors = vErrors.length;}}if(data.mediaType !== undefined){let data3 = data.mediaType;if(typeof data3 === "string"){if(func2(data3) > 128){const err5 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(func2(data3) < 3){const err6 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}}else {const err8 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}validate238.errors = vErrors;return errors === 0;}validate238.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema84 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/evidence-ref.schema.json","title":"Replica evidence reference v1","description":"Points from a learning back to the exact events that support it, and pins them to their source.","type":"object","additionalProperties":false,"required":["episodeId","eventIds"],"properties":{"episodeId":{"$ref":"common.schema.json#/$defs/id"},"eventIds":{"type":"array","minItems":1,"maxItems":100,"items":{"$ref":"common.schema.json#/$defs/id"}},"source":{"$ref":"common.schema.json#/$defs/source"},"observedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"author":{"$ref":"common.schema.json#/$defs/actor"},"artifacts":{"type":"array","maxItems":20,"items":{"$ref":"common.schema.json#/$defs/artifactRef"}}}};function validate243(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate243.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate243.errors = vErrors;return errors === 0;}validate243.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate246(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate246.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(func1.call(schema32.properties, key0))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate80(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate80.errors : vErrors.concat(validate80.errors);errors = vErrors.length;}}if(data.hubOrigin !== undefined){if(!(validate82(data.hubOrigin, {instancePath:instancePath+"/hubOrigin",parentData:data,parentDataProperty:"hubOrigin",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate82.errors : vErrors.concat(validate82.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data2 = data.repository;if(typeof data2 === "string"){if(!pattern10.test(data2)){const err2 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.repositoryId !== undefined){if(!(validate84(data.repositoryId, {instancePath:instancePath+"/repositoryId",parentData:data,parentDataProperty:"repositoryId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeId !== undefined){if(!(validate84(data.prototypeId, {instancePath:instancePath+"/prototypeId",parentData:data,parentDataProperty:"prototypeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeName !== undefined){let data5 = data.prototypeName;if(typeof data5 === "string"){if(func2(data5) > 1024){const err4 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data5) < 1){const err5 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.branch !== undefined){let data6 = data.branch;if(typeof data6 === "string"){if(func2(data6) > 1024){const err7 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data6) < 1){const err8 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.buildNumber !== undefined){if(!(validate84(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.buildId !== undefined){if(!(validate84(data.buildId, {instancePath:instancePath+"/buildId",parentData:data,parentDataProperty:"buildId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.commitSha !== undefined){if(!(validate89(data.commitSha, {instancePath:instancePath+"/commitSha",parentData:data,parentDataProperty:"commitSha",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate89.errors : vErrors.concat(validate89.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate84(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.commentId !== undefined){if(!(validate84(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.sessionId !== undefined){let data12 = data.sessionId;if(typeof data12 === "string"){if(func2(data12) > 200){const err10 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data12) < 1){const err11 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate246.errors = vErrors;return errors === 0;}validate246.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate257(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate257.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate257.errors = vErrors;return errors === 0;}validate257.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate259(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate259.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate259.errors = vErrors;return errors === 0;}validate259.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate262(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate262.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((((key0 === "kind") || (key0 === "uri")) || (key0 === "digest")) || (key0 === "mediaType"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate59(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.uri !== undefined){let data1 = data.uri;if(typeof data1 === "string"){if(func2(data1) > 2048){const err2 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(func2(data1) < 1){const err3 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.digest !== undefined){if(!(validate176(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate176.errors : vErrors.concat(validate176.errors);errors = vErrors.length;}}if(data.mediaType !== undefined){let data3 = data.mediaType;if(typeof data3 === "string"){if(func2(data3) > 128){const err5 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(func2(data3) < 3){const err6 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}}else {const err8 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}validate262.errors = vErrors;return errors === 0;}validate262.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate242(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/evidence-ref.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate242.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.episodeId === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "episodeId"},message:"must have required property '"+"episodeId"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.eventIds === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "eventIds"},message:"must have required property '"+"eventIds"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "episodeId") || (key0 === "eventIds")) || (key0 === "source")) || (key0 === "observedAt")) || (key0 === "author")) || (key0 === "artifacts"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.episodeId !== undefined){if(!(validate243(data.episodeId, {instancePath:instancePath+"/episodeId",parentData:data,parentDataProperty:"episodeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate243.errors : vErrors.concat(validate243.errors);errors = vErrors.length;}}if(data.eventIds !== undefined){let data1 = data.eventIds;if(Array.isArray(data1)){if(data1.length > 100){const err3 = {instancePath:instancePath+"/eventIds",schemaPath:"#/properties/eventIds/maxItems",keyword:"maxItems",params:{limit: 100},message:"must NOT have more than 100 items"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data1.length < 1){const err4 = {instancePath:instancePath+"/eventIds",schemaPath:"#/properties/eventIds/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}const len0 = data1.length;for(let i0=0; i0 20){const err6 = {instancePath:instancePath+"/artifacts",schemaPath:"#/properties/artifacts/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}const len1 = data6.length;for(let i1=0; i1 1000){const err4 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data2) < 1){const err5 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.commentId !== undefined){if(!(validate84(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate267.errors = vErrors;return errors === 0;}validate267.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const pattern54 = new RegExp("^x-[a-z0-9-]+\\.[a-z0-9_]+$", "u");function validate182(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/event.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate182.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.redaction === undefined) && (missing0 = "redaction")){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs4 = errors;const _errs5 = errors;const _errs6 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing1;if((data.payload === undefined) && (missing1 = "payload")){const err1 = {};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var valid2 = _errs6 === errors;if(valid2){const err2 = {instancePath,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs5;if(vErrors !== null){if(_errs5){vErrors.length = _errs5;}else {vErrors = null;}}}var _valid0 = _errs4 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs7 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload === undefined){const err3 = {instancePath,schemaPath:"#/allOf/0/else/required",keyword:"required",params:{missingProperty: "payload"},message:"must have required property '"+"payload"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var _valid0 = _errs7 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}const _errs9 = errors;let valid3 = true;const _errs10 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing2;if((data.type === undefined) && (missing2 = "type")){const err5 = {};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}else {if(data.type !== undefined){if("human_comment" !== data.type){const err6 = {};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}}var _valid1 = _errs10 === errors;errors = _errs9;if(vErrors !== null){if(_errs9){vErrors.length = _errs9;}else {vErrors = null;}}if(_valid1){const _errs12 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload !== undefined){if(!(validate183(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate183.errors : vErrors.concat(validate183.errors);errors = vErrors.length;}}}var _valid1 = _errs12 === errors;valid3 = _valid1;if(valid3){var props0 = {};props0.payload = true;props0.type = true;}}if(!valid3){const err7 = {instancePath,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}const _errs15 = errors;let valid6 = true;const _errs16 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing3;if((data.type === undefined) && (missing3 = "type")){const err8 = {};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}else {if(data.type !== undefined){if("annotation" !== data.type){const err9 = {};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}}}var _valid2 = _errs16 === errors;errors = _errs15;if(vErrors !== null){if(_errs15){vErrors.length = _errs15;}else {vErrors = null;}}if(_valid2){const _errs18 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.parentEventId === undefined){const err10 = {instancePath,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty: "parentEventId"},message:"must have required property '"+"parentEventId"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.payload !== undefined){if(!(validate195(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate195.errors : vErrors.concat(validate195.errors);errors = vErrors.length;}}}var _valid2 = _errs18 === errors;valid6 = _valid2;if(valid6){var props1 = {};props1.payload = true;props1.type = true;}}if(!valid6){const err11 = {instancePath,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(props0 !== true && props1 !== undefined){if(props1 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props1);}}const _errs21 = errors;let valid9 = true;const _errs22 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing4;if((data.type === undefined) && (missing4 = "type")){const err12 = {};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}else {if(data.type !== undefined){if("no_annotation" !== data.type){const err13 = {};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}}var _valid3 = _errs22 === errors;errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}if(_valid3){const _errs24 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.parentEventId === undefined){const err14 = {instancePath,schemaPath:"#/allOf/3/then/required",keyword:"required",params:{missingProperty: "parentEventId"},message:"must have required property '"+"parentEventId"+"'"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data.payload !== undefined){if(!(validate207(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate207.errors : vErrors.concat(validate207.errors);errors = vErrors.length;}}}var _valid3 = _errs24 === errors;valid9 = _valid3;if(valid9){var props2 = {};props2.payload = true;props2.type = true;}}if(!valid9){const err15 = {instancePath,schemaPath:"#/allOf/3/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}if(props0 !== true && props2 !== undefined){if(props2 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props2);}}const _errs27 = errors;let valid12 = true;const _errs28 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing5;if((data.type === undefined) && (missing5 = "type")){const err16 = {};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}else {if(data.type !== undefined){if("status_change" !== data.type){const err17 = {};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}}}var _valid4 = _errs28 === errors;errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}if(_valid4){const _errs30 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload !== undefined){if(!(validate210(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate210.errors : vErrors.concat(validate210.errors);errors = vErrors.length;}}}var _valid4 = _errs30 === errors;valid12 = _valid4;if(valid12){var props3 = {};props3.payload = true;props3.type = true;}}if(!valid12){const err18 = {instancePath,schemaPath:"#/allOf/4/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}if(props0 !== true && props3 !== undefined){if(props3 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props3);}}const _errs33 = errors;let valid15 = true;const _errs34 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing6;if((data.type === undefined) && (missing6 = "type")){const err19 = {};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}else {if(data.type !== undefined){if("retraction" !== data.type){const err20 = {};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}}}var _valid5 = _errs34 === errors;errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}if(_valid5){const _errs36 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.parentEventId === undefined){const err21 = {instancePath,schemaPath:"#/allOf/5/then/required",keyword:"required",params:{missingProperty: "parentEventId"},message:"must have required property '"+"parentEventId"+"'"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(data.payload !== undefined){if(!(validate217(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate217.errors : vErrors.concat(validate217.errors);errors = vErrors.length;}}}var _valid5 = _errs36 === errors;valid15 = _valid5;if(valid15){var props4 = {};props4.payload = true;props4.type = true;}}if(!valid15){const err22 = {instancePath,schemaPath:"#/allOf/5/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}if(props0 !== true && props4 !== undefined){if(props4 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props4);}}const _errs39 = errors;let valid18 = true;const _errs40 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing7;if((data.type === undefined) && (missing7 = "type")){const err23 = {};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}else {if(data.type !== undefined){if("memory_retrieved" !== data.type){const err24 = {};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}}}var _valid6 = _errs40 === errors;errors = _errs39;if(vErrors !== null){if(_errs39){vErrors.length = _errs39;}else {vErrors = null;}}if(_valid6){const _errs42 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload !== undefined){if(!(validate221(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate221.errors : vErrors.concat(validate221.errors);errors = vErrors.length;}}}var _valid6 = _errs42 === errors;valid18 = _valid6;if(valid18){var props5 = {};props5.payload = true;props5.type = true;}}if(!valid18){const err25 = {instancePath,schemaPath:"#/allOf/6/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}if(props0 !== true && props5 !== undefined){if(props5 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props5);}}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err26 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}if(data.id === undefined){const err27 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(data.episodeId === undefined){const err28 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "episodeId"},message:"must have required property '"+"episodeId"+"'"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}if(data.scope === undefined){const err29 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}if(data.type === undefined){const err30 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}if(data.at === undefined){const err31 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}if(data.actor === undefined){const err32 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "actor"},message:"must have required property '"+"actor"+"'"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}if(data.payloadDigest === undefined){const err33 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "payloadDigest"},message:"must have required property '"+"payloadDigest"+"'"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}if(data.digest === undefined){const err34 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}for(const key0 in data){if(!(func1.call(schema65.properties, key0))){const err35 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data.schemaVersion !== undefined){if("replica.event/v1" !== data.schemaVersion){const err36 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.event/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data.id !== undefined){if(!(validate197(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate197.errors : vErrors.concat(validate197.errors);errors = vErrors.length;}}if(data.episodeId !== undefined){if(!(validate197(data.episodeId, {instancePath:instancePath+"/episodeId",parentData:data,parentDataProperty:"episodeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate197.errors : vErrors.concat(validate197.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate228(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate228.errors : vErrors.concat(validate228.errors);errors = vErrors.length;}}if(data.type !== undefined){let data16 = data.type;const _errs50 = errors;let valid22 = false;const _errs51 = errors;if(!((((((((((((((((((((((((data16 === "user_message") || (data16 === "agent_message")) || (data16 === "human_comment")) || (data16 === "human_correction")) || (data16 === "human_approval")) || (data16 === "human_rejection")) || (data16 === "tool_call")) || (data16 === "tool_result")) || (data16 === "ui_snapshot")) || (data16 === "ui_interaction")) || (data16 === "build_created")) || (data16 === "audio_segment")) || (data16 === "voice_turn")) || (data16 === "agent_to_agent_message")) || (data16 === "evaluation_result")) || (data16 === "criterion_result")) || (data16 === "memory_retrieved")) || (data16 === "memory_proposed")) || (data16 === "handoff")) || (data16 === "error")) || (data16 === "annotation")) || (data16 === "no_annotation")) || (data16 === "status_change")) || (data16 === "retraction"))){const err37 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/0/enum",keyword:"enum",params:{allowedValues: schema65.properties.type.anyOf[0].enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}var _valid7 = _errs51 === errors;valid22 = valid22 || _valid7;const _errs52 = errors;if(typeof data16 === "string"){if(func2(data16) > 128){const err38 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/1/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}if(!pattern54.test(data16)){const err39 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^x-[a-z0-9-]+\\.[a-z0-9_]+$"},message:"must match pattern \""+"^x-[a-z0-9-]+\\.[a-z0-9_]+$"+"\""};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}else {const err40 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/1/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}var _valid7 = _errs52 === errors;valid22 = valid22 || _valid7;if(!valid22){const err41 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}else {errors = _errs50;if(vErrors !== null){if(_errs50){vErrors.length = _errs50;}else {vErrors = null;}}}}if(data.at !== undefined){if(!(validate187(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate187.errors : vErrors.concat(validate187.errors);errors = vErrors.length;}}if(data.actor !== undefined){if(!(validate213(data.actor, {instancePath:instancePath+"/actor",parentData:data,parentDataProperty:"actor",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate213.errors : vErrors.concat(validate213.errors);errors = vErrors.length;}}if(data.payload !== undefined){let data19 = data.payload;if(!(data19 && typeof data19 == "object" && !Array.isArray(data19))){const err42 = {instancePath:instancePath+"/payload",schemaPath:"#/properties/payload/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data.payloadDigest !== undefined){if(!(validate223(data.payloadDigest, {instancePath:instancePath+"/payloadDigest",parentData:data,parentDataProperty:"payloadDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate223.errors : vErrors.concat(validate223.errors);errors = vErrors.length;}}if(data.parentEventId !== undefined){if(!(validate197(data.parentEventId, {instancePath:instancePath+"/parentEventId",parentData:data,parentDataProperty:"parentEventId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate197.errors : vErrors.concat(validate197.errors);errors = vErrors.length;}}if(data.supersedes !== undefined){if(!(validate197(data.supersedes, {instancePath:instancePath+"/supersedes",parentData:data,parentDataProperty:"supersedes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate197.errors : vErrors.concat(validate197.errors);errors = vErrors.length;}}if(data.artifactRefs !== undefined){let data23 = data.artifactRefs;if(Array.isArray(data23)){if(data23.length > 20){const err43 = {instancePath:instancePath+"/artifactRefs",schemaPath:"#/properties/artifactRefs/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}const len0 = data23.length;for(let i0=0; i0 100){const err45 = {instancePath:instancePath+"/evidenceRefs",schemaPath:"#/properties/evidenceRefs/maxItems",keyword:"maxItems",params:{limit: 100},message:"must NOT have more than 100 items"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}const len1 = data25.length;for(let i1=0; i1 10000){const err12 = {instancePath:instancePath+"/task/prompt",schemaPath:"#/properties/task/properties/prompt/maxLength",keyword:"maxLength",params:{limit: 10000},message:"must NOT have more than 10000 characters"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(func2(data5) < 1){const err13 = {instancePath:instancePath+"/task/prompt",schemaPath:"#/properties/task/properties/prompt/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}else {const err14 = {instancePath:instancePath+"/task/prompt",schemaPath:"#/properties/task/properties/prompt/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data4.goal !== undefined){let data6 = data4.goal;if(typeof data6 === "string"){if(func2(data6) > 2000){const err15 = {instancePath:instancePath+"/task/goal",schemaPath:"#/properties/task/properties/goal/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}if(func2(data6) < 1){const err16 = {instancePath:instancePath+"/task/goal",schemaPath:"#/properties/task/properties/goal/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}else {const err17 = {instancePath:instancePath+"/task/goal",schemaPath:"#/properties/task/properties/goal/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data4.role !== undefined){if(!(validate160(data4.role, {instancePath:instancePath+"/task/role",parentData:data4,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate160.errors : vErrors.concat(validate160.errors);errors = vErrors.length;}}if(data4.taskId !== undefined){let data8 = data4.taskId;if(typeof data8 === "string"){if(func2(data8) > 200){const err18 = {instancePath:instancePath+"/task/taskId",schemaPath:"#/properties/task/properties/taskId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}if(func2(data8) < 1){const err19 = {instancePath:instancePath+"/task/taskId",schemaPath:"#/properties/task/properties/taskId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}else {const err20 = {instancePath:instancePath+"/task/taskId",schemaPath:"#/properties/task/properties/taskId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}}else {const err21 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data.actors !== undefined){let data9 = data.actors;if(Array.isArray(data9)){if(data9.length > 500){const err22 = {instancePath:instancePath+"/actors",schemaPath:"#/properties/actors/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}const len0 = data9.length;for(let i0=0; i0 200){const err25 = {instancePath:instancePath+"/versions/model",schemaPath:"#/properties/versions/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}if(func2(data12) < 1){const err26 = {instancePath:instancePath+"/versions/model",schemaPath:"#/properties/versions/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}else {const err27 = {instancePath:instancePath+"/versions/model",schemaPath:"#/properties/versions/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}if(data11.harness !== undefined){let data13 = data11.harness;if(typeof data13 === "string"){if(func2(data13) > 200){const err28 = {instancePath:instancePath+"/versions/harness",schemaPath:"#/properties/versions/properties/harness/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}if(func2(data13) < 1){const err29 = {instancePath:instancePath+"/versions/harness",schemaPath:"#/properties/versions/properties/harness/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}else {const err30 = {instancePath:instancePath+"/versions/harness",schemaPath:"#/properties/versions/properties/harness/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data11.designSystem !== undefined){let data14 = data11.designSystem;if(typeof data14 === "string"){if(func2(data14) > 200){const err31 = {instancePath:instancePath+"/versions/designSystem",schemaPath:"#/properties/versions/properties/designSystem/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}if(func2(data14) < 1){const err32 = {instancePath:instancePath+"/versions/designSystem",schemaPath:"#/properties/versions/properties/designSystem/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}else {const err33 = {instancePath:instancePath+"/versions/designSystem",schemaPath:"#/properties/versions/properties/designSystem/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data11.brandPack !== undefined){let data15 = data11.brandPack;if(typeof data15 === "string"){if(func2(data15) > 200){const err34 = {instancePath:instancePath+"/versions/brandPack",schemaPath:"#/properties/versions/properties/brandPack/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}if(func2(data15) < 1){const err35 = {instancePath:instancePath+"/versions/brandPack",schemaPath:"#/properties/versions/properties/brandPack/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}else {const err36 = {instancePath:instancePath+"/versions/brandPack",schemaPath:"#/properties/versions/properties/brandPack/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data11.memorySnapshot !== undefined){if(!(validate165(data11.memorySnapshot, {instancePath:instancePath+"/versions/memorySnapshot",parentData:data11,parentDataProperty:"memorySnapshot",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate165.errors : vErrors.concat(validate165.errors);errors = vErrors.length;}}}else {const err37 = {instancePath:instancePath+"/versions",schemaPath:"#/properties/versions/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}if(data.grants !== undefined){let data17 = data.grants;if(Array.isArray(data17)){if(data17.length > 20){const err38 = {instancePath:instancePath+"/grants",schemaPath:"#/properties/grants/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}if(data17.length < 1){const err39 = {instancePath:instancePath+"/grants",schemaPath:"#/properties/grants/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}const len1 = data17.length;for(let i1=0; i1 2000){const err50 = {instancePath:instancePath+"/outcome/summary",schemaPath:"#/properties/outcome/properties/summary/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}if(func2(data28) < 1){const err51 = {instancePath:instancePath+"/outcome/summary",schemaPath:"#/properties/outcome/properties/summary/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}else {const err52 = {instancePath:instancePath+"/outcome/summary",schemaPath:"#/properties/outcome/properties/summary/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}}else {const err53 = {instancePath:instancePath+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data.timeline !== undefined){let data29 = data.timeline;if(Array.isArray(data29)){if(data29.length > 100000){const err54 = {instancePath:instancePath+"/timeline",schemaPath:"#/properties/timeline/maxItems",keyword:"maxItems",params:{limit: 100000},message:"must NOT have more than 100000 items"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}const len2 = data29.length;for(let i2=0; i2 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate280.errors = vErrors;return errors === 0;}validate280.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate285(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate285.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate285.errors = vErrors;return errors === 0;}validate285.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate287(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate287.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(validate130(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate130.errors : vErrors.concat(validate130.errors);errors = vErrors.length;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind !== undefined){if("human" !== data.kind){const err0 = {instancePath:instancePath+"/kind",schemaPath:"#/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "human"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}else {const err1 = {instancePath,schemaPath:"#/allOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate287.errors = vErrors;return errors === 0;}validate287.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate290(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate290.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate290.errors = vErrors;return errors === 0;}validate290.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate292(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate292.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 0 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate292.errors = vErrors;return errors === 0;}validate292.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate300(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate300.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate300.errors = vErrors;return errors === 0;}validate300.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate275(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/export-manifest.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate275.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.purpose === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "purpose"},message:"must have required property '"+"purpose"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.scope === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.createdAt === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.createdBy === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdBy"},message:"must have required property '"+"createdBy"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.provider === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "provider"},message:"must have required property '"+"provider"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.destination === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "destination"},message:"must have required property '"+"destination"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.counts === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "counts"},message:"must have required property '"+"counts"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data.excluded === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "excluded"},message:"must have required property '"+"excluded"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(data.records === undefined){const err10 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "records"},message:"must have required property '"+"records"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.digest === undefined){const err11 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}for(const key0 in data){if(!(func1.call(schema91.properties, key0))){const err12 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.schemaVersion !== undefined){if("replica.export/v1" !== data.schemaVersion){const err13 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.export/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data.id !== undefined){if(!(validate276(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate276.errors : vErrors.concat(validate276.errors);errors = vErrors.length;}}if(data.purpose !== undefined){if(!(validate278(data.purpose, {instancePath:instancePath+"/purpose",parentData:data,parentDataProperty:"purpose",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate278.errors : vErrors.concat(validate278.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate280(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate280.errors : vErrors.concat(validate280.errors);errors = vErrors.length;}}if(data.createdAt !== undefined){if(!(validate285(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate285.errors : vErrors.concat(validate285.errors);errors = vErrors.length;}}if(data.createdBy !== undefined){if(!(validate287(data.createdBy, {instancePath:instancePath+"/createdBy",parentData:data,parentDataProperty:"createdBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate287.errors : vErrors.concat(validate287.errors);errors = vErrors.length;}}if(data.provider !== undefined){let data6 = data.provider;if(data6 && typeof data6 == "object" && !Array.isArray(data6)){if(data6.id === undefined){const err14 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data6.version === undefined){const err15 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}for(const key1 in data6){if(!((key1 === "id") || (key1 === "version"))){const err16 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data6.id !== undefined){if(!(validate290(data6.id, {instancePath:instancePath+"/provider/id",parentData:data6,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate290.errors : vErrors.concat(validate290.errors);errors = vErrors.length;}}if(data6.version !== undefined){let data8 = data6.version;if(typeof data8 === "string"){if(func2(data8) > 64){const err17 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}if(func2(data8) < 1){const err18 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}else {const err19 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}}else {const err20 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}if(data.destination !== undefined){let data9 = data.destination;if(typeof data9 === "string"){if(func2(data9) > 2048){const err21 = {instancePath:instancePath+"/destination",schemaPath:"#/properties/destination/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(func2(data9) < 1){const err22 = {instancePath:instancePath+"/destination",schemaPath:"#/properties/destination/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/destination",schemaPath:"#/properties/destination/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data.contents !== undefined){let data10 = data.contents;if(!((data10 === "all") || (data10 === "learnings"))){const err24 = {instancePath:instancePath+"/contents",schemaPath:"#/properties/contents/enum",keyword:"enum",params:{allowedValues: schema91.properties.contents.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data.counts !== undefined){let data11 = data.counts;if(data11 && typeof data11 == "object" && !Array.isArray(data11)){if(data11.episodes === undefined){const err25 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "episodes"},message:"must have required property '"+"episodes"+"'"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}if(data11.events === undefined){const err26 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "events"},message:"must have required property '"+"events"+"'"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}if(data11.memories === undefined){const err27 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "memories"},message:"must have required property '"+"memories"+"'"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(data11.grants === undefined){const err28 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "grants"},message:"must have required property '"+"grants"+"'"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}for(const key2 in data11){if(!((((key2 === "episodes") || (key2 === "events")) || (key2 === "memories")) || (key2 === "grants"))){const err29 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data11.episodes !== undefined){if(!(validate292(data11.episodes, {instancePath:instancePath+"/counts/episodes",parentData:data11,parentDataProperty:"episodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate292.errors : vErrors.concat(validate292.errors);errors = vErrors.length;}}if(data11.events !== undefined){if(!(validate292(data11.events, {instancePath:instancePath+"/counts/events",parentData:data11,parentDataProperty:"events",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate292.errors : vErrors.concat(validate292.errors);errors = vErrors.length;}}if(data11.memories !== undefined){if(!(validate292(data11.memories, {instancePath:instancePath+"/counts/memories",parentData:data11,parentDataProperty:"memories",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate292.errors : vErrors.concat(validate292.errors);errors = vErrors.length;}}if(data11.grants !== undefined){if(!(validate292(data11.grants, {instancePath:instancePath+"/counts/grants",parentData:data11,parentDataProperty:"grants",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate292.errors : vErrors.concat(validate292.errors);errors = vErrors.length;}}}else {const err30 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data.excluded !== undefined){let data16 = data.excluded;if(Array.isArray(data16)){if(data16.length > 50){const err31 = {instancePath:instancePath+"/excluded",schemaPath:"#/properties/excluded/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}const len0 = data16.length;for(let i0=0; i0 1000000){const err37 = {instancePath:instancePath+"/records",schemaPath:"#/properties/records/maxItems",keyword:"maxItems",params:{limit: 1000000},message:"must NOT have more than 1000000 items"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}const len1 = data20.length;for(let i1=0; i1 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate307.errors = vErrors;return errors === 0;}validate307.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate312(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate312.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 6){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 6},message:"must NOT have more than 6 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.length < 1){const err1 = {instancePath,schemaPath:"#/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}const len0 = data.length;for(let i0=0; i0 2000){const err10 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data7) < 1){const err11 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.digest !== undefined){if(!(validate320(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate320.errors : vErrors.concat(validate320.errors);errors = vErrors.length;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate303.errors = vErrors;return errors === 0;}validate303.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.memoryProposal = validate322;const schema107 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/memory-proposal.schema.json","title":"Replica memory proposal v1","description":"What a consolidator returns. It never sets an ID, a scope, or a state: the host assigns the ID, takes the scope from the caller, and stores every proposal as proposed until a person reviews it.","type":"object","additionalProperties":false,"required":["schemaVersion","kind","content","evidence","rationale","lifecycle","consolidator"],"properties":{"schemaVersion":{"const":"replica.memory-proposal/v1"},"kind":{"$ref":"common.schema.json#/$defs/memoryKind"},"content":{"type":"string","minLength":1,"maxLength":4000},"themeKey":{"$ref":"common.schema.json#/$defs/slug"},"appliesTo":{"type":"array","maxItems":20,"items":{"$ref":"common.schema.json#/$defs/trace"}},"evidence":{"type":"array","minItems":1,"maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"contradictions":{"type":"array","maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"support":{"$ref":"memory-record.schema.json#/$defs/support"},"confidence":{"type":"number","minimum":0,"maximum":1},"rationale":{"$ref":"#/$defs/rationale"},"lifecycle":{"$ref":"#/$defs/lifecycle"},"consolidator":{"$ref":"#/$defs/consolidator"},"validFrom":{"$ref":"common.schema.json#/$defs/timestamp"},"validUntil":{"$ref":"common.schema.json#/$defs/timestamp"},"expiresAt":{"$ref":"common.schema.json#/$defs/timestamp"}},"$defs":{"consolidator":{"type":"object","additionalProperties":false,"required":["id","version"],"properties":{"id":{"$ref":"common.schema.json#/$defs/slug"},"version":{"type":"string","minLength":1,"maxLength":64}}},"rationale":{"description":"Why the learning recurs, what contradicts it, what it should improve, and how we would know it is wrong.","type":"object","additionalProperties":false,"required":["recurrence","expectedBenefit","falsification"],"properties":{"recurrence":{"type":"string","minLength":1,"maxLength":2000},"contradictions":{"type":"string","minLength":1,"maxLength":2000},"expectedBenefit":{"type":"string","minLength":1,"maxLength":2000},"falsification":{"type":"string","minLength":1,"maxLength":2000}}},"lifecycle":{"type":"object","additionalProperties":false,"required":["action"],"properties":{"action":{"enum":["new","merge","supersede","retire"]},"targets":{"type":"array","minItems":1,"maxItems":50,"items":{"$ref":"common.schema.json#/$defs/id"}}},"allOf":[{"if":{"properties":{"action":{"const":"new"}}},"then":{"not":{"required":["targets"]}},"else":{"required":["targets"]}}]}}};function validate323(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate323.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((((((data === "fact") || (data === "preference")) || (data === "rule")) || (data === "procedure")) || (data === "example")) || (data === "anti_pattern")) || (data === "design_principle"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate323.errors = vErrors;return errors === 0;}validate323.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate325(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate325.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate325.errors = vErrors;return errors === 0;}validate325.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate327(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate327.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.ref === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "ref"},message:"must have required property '"+"ref"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "kind") || (key0 === "ref"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((((data0 === "rule") || (data0 === "skill")) || (data0 === "component")) || (data0 === "context")) || (data0 === "token")) || (data0 === "other"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema75.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.ref !== undefined){let data1 = data.ref;if(typeof data1 === "string"){if(func2(data1) > 500){const err4 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 1){const err5 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate327.errors = vErrors;return errors === 0;}validate327.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema118 = {"description":"Distinct sources behind a learning. Count distinct episodes, prototypes, Builds, and reviewers, never raw comments.","type":"object","additionalProperties":false,"required":["distinctEpisodes","distinctPrototypes","distinctReviewers","distinctBuilds"],"properties":{"distinctEpisodes":{"$ref":"common.schema.json#/$defs/count"},"distinctPrototypes":{"$ref":"common.schema.json#/$defs/count"},"distinctReviewers":{"$ref":"common.schema.json#/$defs/count"},"distinctBuilds":{"$ref":"common.schema.json#/$defs/count"}}};function validate350(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate350.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 0 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate350.errors = vErrors;return errors === 0;}validate350.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate397(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate397.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.distinctEpisodes === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctEpisodes"},message:"must have required property '"+"distinctEpisodes"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.distinctPrototypes === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctPrototypes"},message:"must have required property '"+"distinctPrototypes"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.distinctReviewers === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctReviewers"},message:"must have required property '"+"distinctReviewers"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.distinctBuilds === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctBuilds"},message:"must have required property '"+"distinctBuilds"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((key0 === "distinctEpisodes") || (key0 === "distinctPrototypes")) || (key0 === "distinctReviewers")) || (key0 === "distinctBuilds"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.distinctEpisodes !== undefined){if(!(validate350(data.distinctEpisodes, {instancePath:instancePath+"/distinctEpisodes",parentData:data,parentDataProperty:"distinctEpisodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}if(data.distinctPrototypes !== undefined){if(!(validate350(data.distinctPrototypes, {instancePath:instancePath+"/distinctPrototypes",parentData:data,parentDataProperty:"distinctPrototypes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}if(data.distinctReviewers !== undefined){if(!(validate350(data.distinctReviewers, {instancePath:instancePath+"/distinctReviewers",parentData:data,parentDataProperty:"distinctReviewers",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}if(data.distinctBuilds !== undefined){if(!(validate350(data.distinctBuilds, {instancePath:instancePath+"/distinctBuilds",parentData:data,parentDataProperty:"distinctBuilds",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}}else {const err5 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}validate397.errors = vErrors;return errors === 0;}validate397.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema122 = {"description":"Why the learning recurs, what contradicts it, what it should improve, and how we would know it is wrong.","type":"object","additionalProperties":false,"required":["recurrence","expectedBenefit","falsification"],"properties":{"recurrence":{"type":"string","minLength":1,"maxLength":2000},"contradictions":{"type":"string","minLength":1,"maxLength":2000},"expectedBenefit":{"type":"string","minLength":1,"maxLength":2000},"falsification":{"type":"string","minLength":1,"maxLength":2000}}};function validate403(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate403.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.recurrence === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "recurrence"},message:"must have required property '"+"recurrence"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.expectedBenefit === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "expectedBenefit"},message:"must have required property '"+"expectedBenefit"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.falsification === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "falsification"},message:"must have required property '"+"falsification"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!((((key0 === "recurrence") || (key0 === "contradictions")) || (key0 === "expectedBenefit")) || (key0 === "falsification"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.recurrence !== undefined){let data0 = data.recurrence;if(typeof data0 === "string"){if(func2(data0) > 2000){const err4 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data0) < 1){const err5 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.contradictions !== undefined){let data1 = data.contradictions;if(typeof data1 === "string"){if(func2(data1) > 2000){const err7 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data1) < 1){const err8 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.expectedBenefit !== undefined){let data2 = data.expectedBenefit;if(typeof data2 === "string"){if(func2(data2) > 2000){const err10 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data2) < 1){const err11 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.falsification !== undefined){let data3 = data.falsification;if(typeof data3 === "string"){if(func2(data3) > 2000){const err13 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(func2(data3) < 1){const err14 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}validate403.errors = vErrors;return errors === 0;}validate403.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema123 = {"type":"object","additionalProperties":false,"required":["action"],"properties":{"action":{"enum":["new","merge","supersede","retire"]},"targets":{"type":"array","minItems":1,"maxItems":50,"items":{"$ref":"common.schema.json#/$defs/id"}}},"allOf":[{"if":{"properties":{"action":{"const":"new"}}},"then":{"not":{"required":["targets"]}},"else":{"required":["targets"]}}]};function validate369(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate369.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate369.errors = vErrors;return errors === 0;}validate369.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate405(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate405.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.action !== undefined){if("new" !== data.action){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs5 = errors;const _errs6 = errors;const _errs7 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.targets === undefined) && (missing0 = "targets")){const err1 = {};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var valid3 = _errs7 === errors;if(valid3){const err2 = {instancePath,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs6;if(vErrors !== null){if(_errs6){vErrors.length = _errs6;}else {vErrors = null;}}}var _valid0 = _errs5 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs8 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.targets === undefined){const err3 = {instancePath,schemaPath:"#/allOf/0/else/required",keyword:"required",params:{missingProperty: "targets"},message:"must have required property '"+"targets"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var _valid0 = _errs8 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.action === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "action"},message:"must have required property '"+"action"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!((key0 === "action") || (key0 === "targets"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.action !== undefined){let data1 = data.action;if(!((((data1 === "new") || (data1 === "merge")) || (data1 === "supersede")) || (data1 === "retire"))){const err7 = {instancePath:instancePath+"/action",schemaPath:"#/properties/action/enum",keyword:"enum",params:{allowedValues: schema123.properties.action.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.targets !== undefined){let data2 = data.targets;if(Array.isArray(data2)){if(data2.length > 50){const err8 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data2.length < 1){const err9 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}const len0 = data2.length;for(let i0=0; i0 64){const err3 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(func2(data1) < 1){const err4 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}}else {const err6 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}validate408.errors = vErrors;return errors === 0;}validate408.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate411(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate411.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate411.errors = vErrors;return errors === 0;}validate411.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate322(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/memory-proposal.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate322.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.kind === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.content === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "content"},message:"must have required property '"+"content"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.evidence === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "evidence"},message:"must have required property '"+"evidence"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.rationale === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "rationale"},message:"must have required property '"+"rationale"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.lifecycle === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lifecycle"},message:"must have required property '"+"lifecycle"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.consolidator === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "consolidator"},message:"must have required property '"+"consolidator"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}for(const key0 in data){if(!(func1.call(schema107.properties, key0))){const err7 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.schemaVersion !== undefined){if("replica.memory-proposal/v1" !== data.schemaVersion){const err8 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.memory-proposal/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.kind !== undefined){if(!(validate323(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate323.errors : vErrors.concat(validate323.errors);errors = vErrors.length;}}if(data.content !== undefined){let data2 = data.content;if(typeof data2 === "string"){if(func2(data2) > 4000){const err9 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/maxLength",keyword:"maxLength",params:{limit: 4000},message:"must NOT have more than 4000 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(func2(data2) < 1){const err10 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}else {const err11 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data.themeKey !== undefined){if(!(validate325(data.themeKey, {instancePath:instancePath+"/themeKey",parentData:data,parentDataProperty:"themeKey",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate325.errors : vErrors.concat(validate325.errors);errors = vErrors.length;}}if(data.appliesTo !== undefined){let data4 = data.appliesTo;if(Array.isArray(data4)){if(data4.length > 20){const err12 = {instancePath:instancePath+"/appliesTo",schemaPath:"#/properties/appliesTo/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}const len0 = data4.length;for(let i0=0; i0 500){const err14 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data6.length < 1){const err15 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}const len1 = data6.length;for(let i1=0; i1 500){const err17 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}const len2 = data8.length;for(let i2=0; i2 1 || isNaN(data11)){const err19 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1},message:"must be <= 1"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data11 < 0 || isNaN(data11)){const err20 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}else {const err21 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data.rationale !== undefined){if(!(validate403(data.rationale, {instancePath:instancePath+"/rationale",parentData:data,parentDataProperty:"rationale",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate403.errors : vErrors.concat(validate403.errors);errors = vErrors.length;}}if(data.lifecycle !== undefined){if(!(validate405(data.lifecycle, {instancePath:instancePath+"/lifecycle",parentData:data,parentDataProperty:"lifecycle",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate405.errors : vErrors.concat(validate405.errors);errors = vErrors.length;}}if(data.consolidator !== undefined){if(!(validate408(data.consolidator, {instancePath:instancePath+"/consolidator",parentData:data,parentDataProperty:"consolidator",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate408.errors : vErrors.concat(validate408.errors);errors = vErrors.length;}}if(data.validFrom !== undefined){if(!(validate411(data.validFrom, {instancePath:instancePath+"/validFrom",parentData:data,parentDataProperty:"validFrom",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate411.errors : vErrors.concat(validate411.errors);errors = vErrors.length;}}if(data.validUntil !== undefined){if(!(validate411(data.validUntil, {instancePath:instancePath+"/validUntil",parentData:data,parentDataProperty:"validUntil",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate411.errors : vErrors.concat(validate411.errors);errors = vErrors.length;}}if(data.expiresAt !== undefined){if(!(validate411(data.expiresAt, {instancePath:instancePath+"/expiresAt",parentData:data,parentDataProperty:"expiresAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate411.errors : vErrors.concat(validate411.errors);errors = vErrors.length;}}}else {const err22 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}validate322.errors = vErrors;return errors === 0;}validate322.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.memoryRecord = validate331;const schema111 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/memory-record.schema.json","title":"Replica memory record v1","description":"One version of an explicit learning. Every lifecycle change appends a new version with the next version number and previousDigest. contentDigest identifies the learning itself: scope, kind, content, targets, lifecycle, evidence, and validity dates; an approval is valid only while accepted.contentDigest equals it. reviewDigest covers everything a reviewer is shown, adding contradictions, support, confidence, rationale, and the proposer; accepting or rejecting requires the reviewDigest the person reviewed.","type":"object","additionalProperties":false,"required":["schemaVersion","id","version","scope","kind","state","content","evidence","contentDigest","reviewDigest","proposal","provenance","createdAt","updatedAt","digest"],"properties":{"schemaVersion":{"const":"replica.memory/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"version":{"type":"integer","minimum":1,"maximum":1000000},"previousDigest":{"$ref":"common.schema.json#/$defs/digest"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"kind":{"$ref":"common.schema.json#/$defs/memoryKind"},"state":{"enum":["proposed","accepted","rejected","retired"]},"content":{"type":"string","minLength":1,"maxLength":4000},"themeKey":{"$ref":"common.schema.json#/$defs/slug"},"appliesTo":{"type":"array","maxItems":20,"items":{"$ref":"common.schema.json#/$defs/trace"}},"evidence":{"type":"array","minItems":1,"maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"contradictions":{"type":"array","maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"support":{"$ref":"#/$defs/support"},"confidence":{"description":"Optional metadata from the proposer. Never a measure of truth.","type":"number","minimum":0,"maximum":1},"validFrom":{"$ref":"common.schema.json#/$defs/timestamp"},"validUntil":{"$ref":"common.schema.json#/$defs/timestamp"},"expiresAt":{"$ref":"common.schema.json#/$defs/timestamp"},"supersedes":{"description":"Learnings this accepted learning replaces. Acceptance sets it from the reviewed lifecycle targets, and a later step may only add to it. No ID repeats. A proposed or rejected learning never carries it. Replaced learnings keep their own state; readers derive which replacement wins.","type":"array","minItems":1,"maxItems":50,"items":{"$ref":"common.schema.json#/$defs/id"}},"contentDigest":{"$ref":"common.schema.json#/$defs/digest"},"reviewDigest":{"$ref":"common.schema.json#/$defs/digest"},"proposal":{"type":"object","additionalProperties":false,"required":["consolidator","rationale","lifecycle","proposedAt","proposedBy","proposalDigest"],"properties":{"consolidator":{"$ref":"memory-proposal.schema.json#/$defs/consolidator"},"rationale":{"$ref":"memory-proposal.schema.json#/$defs/rationale"},"lifecycle":{"$ref":"memory-proposal.schema.json#/$defs/lifecycle"},"proposedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"proposedBy":{"$ref":"common.schema.json#/$defs/actor"},"proposalDigest":{"$ref":"common.schema.json#/$defs/digest"}}},"accepted":{"type":"object","additionalProperties":false,"required":["by","at","contentDigest","reviewedDigest","edited"],"properties":{"by":{"$ref":"common.schema.json#/$defs/humanActor"},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"contentDigest":{"$ref":"common.schema.json#/$defs/digest"},"reviewedDigest":{"$ref":"common.schema.json#/$defs/digest"},"edited":{"type":"boolean"},"note":{"type":"string","minLength":1,"maxLength":2000}}},"rejected":{"type":"object","additionalProperties":false,"required":["by","at","reviewedDigest","reason"],"properties":{"by":{"$ref":"common.schema.json#/$defs/humanActor"},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"reviewedDigest":{"$ref":"common.schema.json#/$defs/digest"},"reason":{"type":"string","minLength":1,"maxLength":2000}}},"retired":{"type":"object","additionalProperties":false,"required":["at","reason"],"properties":{"by":{"$ref":"common.schema.json#/$defs/humanActor"},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"reason":{"type":"string","minLength":1,"maxLength":2000}}},"provenance":{"$ref":"common.schema.json#/$defs/provenance"},"createdAt":{"$ref":"common.schema.json#/$defs/timestamp"},"updatedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"digest":{"$ref":"common.schema.json#/$defs/digest"}},"allOf":[{"if":{"properties":{"version":{"const":1}}},"then":{"not":{"required":["previousDigest"]}},"else":{"required":["previousDigest"]}},{"if":{"properties":{"state":{"const":"proposed"}}},"then":{"not":{"anyOf":[{"required":["accepted"]},{"required":["rejected"]},{"required":["retired"]},{"required":["supersedes"]}]}}},{"if":{"properties":{"state":{"const":"accepted"}}},"then":{"required":["accepted"],"not":{"anyOf":[{"required":["rejected"]},{"required":["retired"]}]}}},{"if":{"properties":{"state":{"const":"rejected"}}},"then":{"required":["rejected"],"not":{"anyOf":[{"required":["accepted"]},{"required":["retired"]},{"required":["supersedes"]}]}}},{"if":{"properties":{"state":{"const":"retired"}}},"then":{"required":["accepted","retired"],"not":{"required":["rejected"]}}}],"$defs":{"support":{"description":"Distinct sources behind a learning. Count distinct episodes, prototypes, Builds, and reviewers, never raw comments.","type":"object","additionalProperties":false,"required":["distinctEpisodes","distinctPrototypes","distinctReviewers","distinctBuilds"],"properties":{"distinctEpisodes":{"$ref":"common.schema.json#/$defs/count"},"distinctPrototypes":{"$ref":"common.schema.json#/$defs/count"},"distinctReviewers":{"$ref":"common.schema.json#/$defs/count"},"distinctBuilds":{"$ref":"common.schema.json#/$defs/count"}}}}};function validate332(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate332.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate332.errors = vErrors;return errors === 0;}validate332.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate334(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate334.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate334.errors = vErrors;return errors === 0;}validate334.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate336(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate336.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate336.errors = vErrors;return errors === 0;}validate336.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate341(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate341.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((((((data === "fact") || (data === "preference")) || (data === "rule")) || (data === "procedure")) || (data === "example")) || (data === "anti_pattern")) || (data === "design_principle"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate341.errors = vErrors;return errors === 0;}validate341.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate343(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate343.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate343.errors = vErrors;return errors === 0;}validate343.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate345(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate345.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.ref === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "ref"},message:"must have required property '"+"ref"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "kind") || (key0 === "ref"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((((data0 === "rule") || (data0 === "skill")) || (data0 === "component")) || (data0 === "context")) || (data0 === "token")) || (data0 === "other"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema75.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.ref !== undefined){let data1 = data.ref;if(typeof data1 === "string"){if(func2(data1) > 500){const err4 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 1){const err5 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate345.errors = vErrors;return errors === 0;}validate345.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate349(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate349.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.distinctEpisodes === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctEpisodes"},message:"must have required property '"+"distinctEpisodes"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.distinctPrototypes === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctPrototypes"},message:"must have required property '"+"distinctPrototypes"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.distinctReviewers === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctReviewers"},message:"must have required property '"+"distinctReviewers"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.distinctBuilds === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctBuilds"},message:"must have required property '"+"distinctBuilds"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((key0 === "distinctEpisodes") || (key0 === "distinctPrototypes")) || (key0 === "distinctReviewers")) || (key0 === "distinctBuilds"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.distinctEpisodes !== undefined){if(!(validate350(data.distinctEpisodes, {instancePath:instancePath+"/distinctEpisodes",parentData:data,parentDataProperty:"distinctEpisodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}if(data.distinctPrototypes !== undefined){if(!(validate350(data.distinctPrototypes, {instancePath:instancePath+"/distinctPrototypes",parentData:data,parentDataProperty:"distinctPrototypes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}if(data.distinctReviewers !== undefined){if(!(validate350(data.distinctReviewers, {instancePath:instancePath+"/distinctReviewers",parentData:data,parentDataProperty:"distinctReviewers",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}if(data.distinctBuilds !== undefined){if(!(validate350(data.distinctBuilds, {instancePath:instancePath+"/distinctBuilds",parentData:data,parentDataProperty:"distinctBuilds",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate350.errors : vErrors.concat(validate350.errors);errors = vErrors.length;}}}else {const err5 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}validate349.errors = vErrors;return errors === 0;}validate349.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate356(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate356.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate356.errors = vErrors;return errors === 0;}validate356.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate363(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate363.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.id === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.version === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "id") || (key0 === "version"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.id !== undefined){if(!(validate325(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate325.errors : vErrors.concat(validate325.errors);errors = vErrors.length;}}if(data.version !== undefined){let data1 = data.version;if(typeof data1 === "string"){if(func2(data1) > 64){const err3 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(func2(data1) < 1){const err4 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}}else {const err6 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}validate363.errors = vErrors;return errors === 0;}validate363.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate366(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate366.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.recurrence === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "recurrence"},message:"must have required property '"+"recurrence"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.expectedBenefit === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "expectedBenefit"},message:"must have required property '"+"expectedBenefit"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.falsification === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "falsification"},message:"must have required property '"+"falsification"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!((((key0 === "recurrence") || (key0 === "contradictions")) || (key0 === "expectedBenefit")) || (key0 === "falsification"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.recurrence !== undefined){let data0 = data.recurrence;if(typeof data0 === "string"){if(func2(data0) > 2000){const err4 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data0) < 1){const err5 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.contradictions !== undefined){let data1 = data.contradictions;if(typeof data1 === "string"){if(func2(data1) > 2000){const err7 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data1) < 1){const err8 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.expectedBenefit !== undefined){let data2 = data.expectedBenefit;if(typeof data2 === "string"){if(func2(data2) > 2000){const err10 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data2) < 1){const err11 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.falsification !== undefined){let data3 = data.falsification;if(typeof data3 === "string"){if(func2(data3) > 2000){const err13 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(func2(data3) < 1){const err14 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}validate366.errors = vErrors;return errors === 0;}validate366.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate368(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate368.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.action !== undefined){if("new" !== data.action){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs5 = errors;const _errs6 = errors;const _errs7 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.targets === undefined) && (missing0 = "targets")){const err1 = {};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var valid3 = _errs7 === errors;if(valid3){const err2 = {instancePath,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs6;if(vErrors !== null){if(_errs6){vErrors.length = _errs6;}else {vErrors = null;}}}var _valid0 = _errs5 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs8 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.targets === undefined){const err3 = {instancePath,schemaPath:"#/allOf/0/else/required",keyword:"required",params:{missingProperty: "targets"},message:"must have required property '"+"targets"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var _valid0 = _errs8 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.action === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "action"},message:"must have required property '"+"action"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!((key0 === "action") || (key0 === "targets"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.action !== undefined){let data1 = data.action;if(!((((data1 === "new") || (data1 === "merge")) || (data1 === "supersede")) || (data1 === "retire"))){const err7 = {instancePath:instancePath+"/action",schemaPath:"#/properties/action/enum",keyword:"enum",params:{allowedValues: schema123.properties.action.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.targets !== undefined){let data2 = data.targets;if(Array.isArray(data2)){if(data2.length > 50){const err8 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data2.length < 1){const err9 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}const len0 = data2.length;for(let i0=0; i0 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9_-]{1,256}$"},message:"must match pattern \""+"^[A-Za-z0-9_-]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate373.errors = vErrors;return errors === 0;}validate373.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate377(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate377.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(validate130(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate130.errors : vErrors.concat(validate130.errors);errors = vErrors.length;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind !== undefined){if("human" !== data.kind){const err0 = {instancePath:instancePath+"/kind",schemaPath:"#/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "human"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}else {const err1 = {instancePath,schemaPath:"#/allOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate377.errors = vErrors;return errors === 0;}validate377.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate388(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate388.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.producer === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "producer"},message:"must have required property '"+"producer"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.method === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "method"},message:"must have required property '"+"method"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.createdAt === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.createdBy === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdBy"},message:"must have required property '"+"createdBy"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!(((((key0 === "producer") || (key0 === "method")) || (key0 === "createdAt")) || (key0 === "createdBy")) || (key0 === "inputs"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.producer !== undefined){if(!(validate171(data.producer, {instancePath:instancePath+"/producer",parentData:data,parentDataProperty:"producer",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate171.errors : vErrors.concat(validate171.errors);errors = vErrors.length;}}if(data.method !== undefined){let data1 = data.method;if(typeof data1 === "string"){if(func2(data1) > 128){const err5 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern42.test(data1)){const err6 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/pattern",keyword:"pattern",params:{pattern: "^[a-z]+:[a-z0-9_.-]+$"},message:"must match pattern \""+"^[a-z]+:[a-z0-9_.-]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.createdAt !== undefined){if(!(validate173(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate173.errors : vErrors.concat(validate173.errors);errors = vErrors.length;}}if(data.createdBy !== undefined){if(!(validate130(data.createdBy, {instancePath:instancePath+"/createdBy",parentData:data,parentDataProperty:"createdBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate130.errors : vErrors.concat(validate130.errors);errors = vErrors.length;}}if(data.inputs !== undefined){let data4 = data.inputs;if(Array.isArray(data4)){if(data4.length > 1000){const err8 = {instancePath:instancePath+"/inputs",schemaPath:"#/properties/inputs/maxItems",keyword:"maxItems",params:{limit: 1000},message:"must NOT have more than 1000 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}const len0 = data4.length;for(let i0=0; i0 1000000 || isNaN(data7)){const err52 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1000000},message:"must be <= 1000000"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}if(data7 < 1 || isNaN(data7)){const err53 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}}if(data.previousDigest !== undefined){if(!(validate334(data.previousDigest, {instancePath:instancePath+"/previousDigest",parentData:data,parentDataProperty:"previousDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate334.errors : vErrors.concat(validate334.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate336(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate336.errors : vErrors.concat(validate336.errors);errors = vErrors.length;}}if(data.kind !== undefined){if(!(validate341(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate341.errors : vErrors.concat(validate341.errors);errors = vErrors.length;}}if(data.state !== undefined){let data11 = data.state;if(!((((data11 === "proposed") || (data11 === "accepted")) || (data11 === "rejected")) || (data11 === "retired"))){const err54 = {instancePath:instancePath+"/state",schemaPath:"#/properties/state/enum",keyword:"enum",params:{allowedValues: schema111.properties.state.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data.content !== undefined){let data12 = data.content;if(typeof data12 === "string"){if(func2(data12) > 4000){const err55 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/maxLength",keyword:"maxLength",params:{limit: 4000},message:"must NOT have more than 4000 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}if(func2(data12) < 1){const err56 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}else {const err57 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data.themeKey !== undefined){if(!(validate343(data.themeKey, {instancePath:instancePath+"/themeKey",parentData:data,parentDataProperty:"themeKey",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate343.errors : vErrors.concat(validate343.errors);errors = vErrors.length;}}if(data.appliesTo !== undefined){let data14 = data.appliesTo;if(Array.isArray(data14)){if(data14.length > 20){const err58 = {instancePath:instancePath+"/appliesTo",schemaPath:"#/properties/appliesTo/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}const len0 = data14.length;for(let i0=0; i0 500){const err60 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}if(data16.length < 1){const err61 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}const len1 = data16.length;for(let i1=0; i1 500){const err63 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}const len2 = data18.length;for(let i2=0; i2 1 || isNaN(data21)){const err65 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1},message:"must be <= 1"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}if(data21 < 0 || isNaN(data21)){const err66 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}else {const err67 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data.validFrom !== undefined){if(!(validate356(data.validFrom, {instancePath:instancePath+"/validFrom",parentData:data,parentDataProperty:"validFrom",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data.validUntil !== undefined){if(!(validate356(data.validUntil, {instancePath:instancePath+"/validUntil",parentData:data,parentDataProperty:"validUntil",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data.expiresAt !== undefined){if(!(validate356(data.expiresAt, {instancePath:instancePath+"/expiresAt",parentData:data,parentDataProperty:"expiresAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data.supersedes !== undefined){let data25 = data.supersedes;if(Array.isArray(data25)){if(data25.length > 50){const err68 = {instancePath:instancePath+"/supersedes",schemaPath:"#/properties/supersedes/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}if(data25.length < 1){const err69 = {instancePath:instancePath+"/supersedes",schemaPath:"#/properties/supersedes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}const len3 = data25.length;for(let i3=0; i3 2000){const err86 = {instancePath:instancePath+"/accepted/note",schemaPath:"#/properties/accepted/properties/note/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}if(func2(data42) < 1){const err87 = {instancePath:instancePath+"/accepted/note",schemaPath:"#/properties/accepted/properties/note/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}else {const err88 = {instancePath:instancePath+"/accepted/note",schemaPath:"#/properties/accepted/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}}else {const err89 = {instancePath:instancePath+"/accepted",schemaPath:"#/properties/accepted/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}if(data.rejected !== undefined){let data43 = data.rejected;if(data43 && typeof data43 == "object" && !Array.isArray(data43)){if(data43.by === undefined){const err90 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "by"},message:"must have required property '"+"by"+"'"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}if(data43.at === undefined){const err91 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}if(data43.reviewedDigest === undefined){const err92 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "reviewedDigest"},message:"must have required property '"+"reviewedDigest"+"'"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}if(data43.reason === undefined){const err93 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "reason"},message:"must have required property '"+"reason"+"'"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}for(const key3 in data43){if(!((((key3 === "by") || (key3 === "at")) || (key3 === "reviewedDigest")) || (key3 === "reason"))){const err94 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}if(data43.by !== undefined){if(!(validate377(data43.by, {instancePath:instancePath+"/rejected/by",parentData:data43,parentDataProperty:"by",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate377.errors : vErrors.concat(validate377.errors);errors = vErrors.length;}}if(data43.at !== undefined){if(!(validate356(data43.at, {instancePath:instancePath+"/rejected/at",parentData:data43,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data43.reviewedDigest !== undefined){if(!(validate334(data43.reviewedDigest, {instancePath:instancePath+"/rejected/reviewedDigest",parentData:data43,parentDataProperty:"reviewedDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate334.errors : vErrors.concat(validate334.errors);errors = vErrors.length;}}if(data43.reason !== undefined){let data47 = data43.reason;if(typeof data47 === "string"){if(func2(data47) > 2000){const err95 = {instancePath:instancePath+"/rejected/reason",schemaPath:"#/properties/rejected/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}if(func2(data47) < 1){const err96 = {instancePath:instancePath+"/rejected/reason",schemaPath:"#/properties/rejected/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}else {const err97 = {instancePath:instancePath+"/rejected/reason",schemaPath:"#/properties/rejected/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}}else {const err98 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}if(data.retired !== undefined){let data48 = data.retired;if(data48 && typeof data48 == "object" && !Array.isArray(data48)){if(data48.at === undefined){const err99 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}if(data48.reason === undefined){const err100 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/required",keyword:"required",params:{missingProperty: "reason"},message:"must have required property '"+"reason"+"'"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}for(const key4 in data48){if(!(((key4 === "by") || (key4 === "at")) || (key4 === "reason"))){const err101 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}if(data48.by !== undefined){if(!(validate377(data48.by, {instancePath:instancePath+"/retired/by",parentData:data48,parentDataProperty:"by",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate377.errors : vErrors.concat(validate377.errors);errors = vErrors.length;}}if(data48.at !== undefined){if(!(validate356(data48.at, {instancePath:instancePath+"/retired/at",parentData:data48,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data48.reason !== undefined){let data51 = data48.reason;if(typeof data51 === "string"){if(func2(data51) > 2000){const err102 = {instancePath:instancePath+"/retired/reason",schemaPath:"#/properties/retired/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}if(func2(data51) < 1){const err103 = {instancePath:instancePath+"/retired/reason",schemaPath:"#/properties/retired/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}else {const err104 = {instancePath:instancePath+"/retired/reason",schemaPath:"#/properties/retired/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}}else {const err105 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}if(data.provenance !== undefined){if(!(validate388(data.provenance, {instancePath:instancePath+"/provenance",parentData:data,parentDataProperty:"provenance",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate388.errors : vErrors.concat(validate388.errors);errors = vErrors.length;}}if(data.createdAt !== undefined){if(!(validate356(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data.updatedAt !== undefined){if(!(validate356(data.updatedAt, {instancePath:instancePath+"/updatedAt",parentData:data,parentDataProperty:"updatedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate356.errors : vErrors.concat(validate356.errors);errors = vErrors.length;}}if(data.digest !== undefined){if(!(validate334(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate334.errors : vErrors.concat(validate334.errors);errors = vErrors.length;}}}else {const err106 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}validate331.errors = vErrors;return errors === 0;}validate331.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.providerManifest = validate415;const schema133 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/provider-manifest.schema.json","title":"Replica memory provider manifest v1","description":"What a memory provider is, which contract versions it supports, which capabilities it offers, and where its data goes. A host checks this before use and refuses a provider that lacks a required capability.","type":"object","additionalProperties":false,"required":["schemaVersion","id","name","version","contract","capabilities","storage","externalCalls"],"properties":{"schemaVersion":{"const":"replica.provider/v1"},"id":{"$ref":"common.schema.json#/$defs/slug"},"name":{"type":"string","minLength":1,"maxLength":200},"version":{"type":"string","minLength":1,"maxLength":64},"contract":{"type":"object","additionalProperties":false,"required":["name","versions"],"properties":{"name":{"const":"replica.memory-provider"},"versions":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"integer","minimum":1,"maximum":1000}}}},"capabilities":{"description":"Required by v1 hosts: observation.append, observation.query, memory.store, memory.query, memory.lifecycle, grant.store, audit.store. Optional examples: memory.semantic_search, memory.graph_query, memory.temporal_query, memory.compaction, memory.consolidate.","type":"array","minItems":1,"maxItems":64,"items":{"type":"string","maxLength":64,"pattern":"^[a-z]+(?:\\.[a-z_]+)+$"}},"storage":{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"enum":["local","memory","remote"]},"location":{"description":"A non-secret description such as a directory or service name. Never a credential.","type":"string","minLength":1,"maxLength":2048}}},"externalCalls":{"description":"Hosts this provider sends data to. Empty for a provider that stays on the machine.","type":"array","maxItems":50,"items":{"type":"string","minLength":1,"maxLength":255,"pattern":"^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"}},"dataRetention":{"type":"string","minLength":1,"maxLength":2000}}};function validate416(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate416.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate416.errors = vErrors;return errors === 0;}validate416.evaluated = {"dynamicProps":false,"dynamicItems":false};const pattern84 = new RegExp("^[a-z]+(?:\\.[a-z_]+)+$", "u");const pattern85 = new RegExp("^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$", "u");function validate415(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/provider-manifest.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate415.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.name === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.version === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.contract === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "contract"},message:"must have required property '"+"contract"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.capabilities === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "capabilities"},message:"must have required property '"+"capabilities"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.storage === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "storage"},message:"must have required property '"+"storage"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.externalCalls === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "externalCalls"},message:"must have required property '"+"externalCalls"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}for(const key0 in data){if(!(func1.call(schema133.properties, key0))){const err8 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.schemaVersion !== undefined){if("replica.provider/v1" !== data.schemaVersion){const err9 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.provider/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.id !== undefined){if(!(validate416(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate416.errors : vErrors.concat(validate416.errors);errors = vErrors.length;}}if(data.name !== undefined){let data2 = data.name;if(typeof data2 === "string"){if(func2(data2) > 200){const err10 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data2) < 1){const err11 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.version !== undefined){let data3 = data.version;if(typeof data3 === "string"){if(func2(data3) > 64){const err13 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(func2(data3) < 1){const err14 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data.contract !== undefined){let data4 = data.contract;if(data4 && typeof data4 == "object" && !Array.isArray(data4)){if(data4.name === undefined){const err16 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}if(data4.versions === undefined){const err17 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/required",keyword:"required",params:{missingProperty: "versions"},message:"must have required property '"+"versions"+"'"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}for(const key1 in data4){if(!((key1 === "name") || (key1 === "versions"))){const err18 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data4.name !== undefined){if("replica.memory-provider" !== data4.name){const err19 = {instancePath:instancePath+"/contract/name",schemaPath:"#/properties/contract/properties/name/const",keyword:"const",params:{allowedValue: "replica.memory-provider"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}if(data4.versions !== undefined){let data6 = data4.versions;if(Array.isArray(data6)){if(data6.length > 20){const err20 = {instancePath:instancePath+"/contract/versions",schemaPath:"#/properties/contract/properties/versions/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}if(data6.length < 1){const err21 = {instancePath:instancePath+"/contract/versions",schemaPath:"#/properties/contract/properties/versions/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}const len0 = data6.length;for(let i0=0; i0 1000 || isNaN(data7)){const err23 = {instancePath:instancePath+"/contract/versions/" + i0,schemaPath:"#/properties/contract/properties/versions/items/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1000},message:"must be <= 1000"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}if(data7 < 1 || isNaN(data7)){const err24 = {instancePath:instancePath+"/contract/versions/" + i0,schemaPath:"#/properties/contract/properties/versions/items/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}}}else {const err25 = {instancePath:instancePath+"/contract/versions",schemaPath:"#/properties/contract/properties/versions/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}}else {const err26 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}if(data.capabilities !== undefined){let data8 = data.capabilities;if(Array.isArray(data8)){if(data8.length > 64){const err27 = {instancePath:instancePath+"/capabilities",schemaPath:"#/properties/capabilities/maxItems",keyword:"maxItems",params:{limit: 64},message:"must NOT have more than 64 items"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(data8.length < 1){const err28 = {instancePath:instancePath+"/capabilities",schemaPath:"#/properties/capabilities/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}const len1 = data8.length;for(let i1=0; i1 64){const err29 = {instancePath:instancePath+"/capabilities/" + i1,schemaPath:"#/properties/capabilities/items/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}if(!pattern84.test(data9)){const err30 = {instancePath:instancePath+"/capabilities/" + i1,schemaPath:"#/properties/capabilities/items/pattern",keyword:"pattern",params:{pattern: "^[a-z]+(?:\\.[a-z_]+)+$"},message:"must match pattern \""+"^[a-z]+(?:\\.[a-z_]+)+$"+"\""};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}else {const err31 = {instancePath:instancePath+"/capabilities/" + i1,schemaPath:"#/properties/capabilities/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}}else {const err32 = {instancePath:instancePath+"/capabilities",schemaPath:"#/properties/capabilities/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data.storage !== undefined){let data10 = data.storage;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.kind === undefined){const err33 = {instancePath:instancePath+"/storage",schemaPath:"#/properties/storage/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}for(const key2 in data10){if(!((key2 === "kind") || (key2 === "location"))){const err34 = {instancePath:instancePath+"/storage",schemaPath:"#/properties/storage/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data10.kind !== undefined){let data11 = data10.kind;if(!(((data11 === "local") || (data11 === "memory")) || (data11 === "remote"))){const err35 = {instancePath:instancePath+"/storage/kind",schemaPath:"#/properties/storage/properties/kind/enum",keyword:"enum",params:{allowedValues: schema133.properties.storage.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data10.location !== undefined){let data12 = data10.location;if(typeof data12 === "string"){if(func2(data12) > 2048){const err36 = {instancePath:instancePath+"/storage/location",schemaPath:"#/properties/storage/properties/location/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}if(func2(data12) < 1){const err37 = {instancePath:instancePath+"/storage/location",schemaPath:"#/properties/storage/properties/location/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}else {const err38 = {instancePath:instancePath+"/storage/location",schemaPath:"#/properties/storage/properties/location/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}}else {const err39 = {instancePath:instancePath+"/storage",schemaPath:"#/properties/storage/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}if(data.externalCalls !== undefined){let data13 = data.externalCalls;if(Array.isArray(data13)){if(data13.length > 50){const err40 = {instancePath:instancePath+"/externalCalls",schemaPath:"#/properties/externalCalls/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}const len2 = data13.length;for(let i2=0; i2 255){const err41 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/maxLength",keyword:"maxLength",params:{limit: 255},message:"must NOT have more than 255 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}if(func2(data14) < 1){const err42 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}if(!pattern85.test(data14)){const err43 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}else {const err44 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/externalCalls",schemaPath:"#/properties/externalCalls/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data.dataRetention !== undefined){let data15 = data.dataRetention;if(typeof data15 === "string"){if(func2(data15) > 2000){const err46 = {instancePath:instancePath+"/dataRetention",schemaPath:"#/properties/dataRetention/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}if(func2(data15) < 1){const err47 = {instancePath:instancePath+"/dataRetention",schemaPath:"#/properties/dataRetention/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}else {const err48 = {instancePath:instancePath+"/dataRetention",schemaPath:"#/properties/dataRetention/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}}else {const err49 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}validate415.errors = vErrors;return errors === 0;}validate415.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; +} })["date-time"];const pattern4 = new RegExp("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$", "u");function validate56(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate56.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate56.errors = vErrors;return errors === 0;}validate56.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema23 = {"description":"A person, agent, or system. asserted marks an identity the host could not authenticate.","type":"object","additionalProperties":false,"required":["kind","id"],"properties":{"kind":{"enum":["human","agent","system","service"]},"id":{"description":"A prefix such as github: and a name. The name has no whitespace, control characters, Unicode format characters, or code points from the tag block, U+E0000 to U+E007F, because each can make an ID read as another.","type":"string","minLength":3,"maxLength":300,"pattern":"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},"role":{"$ref":"#/$defs/slug"},"login":{"description":"The login shown at import time, for display only. Stable actor IDs, not this mutable login, identify reviewers.","type":"string","pattern":"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},"model":{"type":"string","minLength":1,"maxLength":200},"asserted":{"type":"boolean"}}};const pattern5 = new RegExp("^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$", "u");const pattern7 = new RegExp("^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$", "u");const schema24 = {"type":"string","minLength":1,"maxLength":128,"pattern":"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"};const pattern6 = new RegExp("^[a-z0-9]+(?:[._-][a-z0-9]+)*$", "u");function validate59(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate59.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate59.errors = vErrors;return errors === 0;}validate59.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate58(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate58.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate58.errors = vErrors;return errors === 0;}validate58.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema25 = {"description":"Who a record belongs to. Hosts derive it from the caller's access, never from agent input.","type":"object","additionalProperties":false,"minProperties":1,"properties":{"host":{"description":"The Git or Hub host, such as github.com, when the scope comes from a repository URL. The same owner/name on two hosts never shares records.","type":"string","maxLength":261,"pattern":"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},"organization":{"$ref":"#/$defs/scopeName"},"team":{"$ref":"#/$defs/scopeName"},"repository":{"description":"owner/name in lowercase.","type":"string","pattern":"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},"product":{"$ref":"#/$defs/scopeName"}}};const pattern8 = new RegExp("^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$", "u");const pattern10 = new RegExp("^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$", "u");const schema26 = {"type":"string","minLength":1,"maxLength":100,"pattern":"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"};function validate63(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate63.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 100){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 100},message:"must NOT have more than 100 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate63.errors = vErrors;return errors === 0;}validate63.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate62(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate62.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate62.errors = vErrors;return errors === 0;}validate62.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema27 = {"description":"What a record may be used for. Permission for one purpose never implies another.","enum":["review","instruction","evaluation","analytics","training","publication"]};function validate68(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate68.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!((((((data === "review") || (data === "instruction")) || (data === "evaluation")) || (data === "analytics")) || (data === "training")) || (data === "publication"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema27.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate68.errors = vErrors;return errors === 0;}validate68.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema28 = {"description":"SHA-256 of the RFC 8785 canonical JSON of a value.","type":"string","pattern":"^sha256:[0-9a-f]{64}$"};const pattern11 = new RegExp("^sha256:[0-9a-f]{64}$", "u");function validate71(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate71.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate71.errors = vErrors;return errors === 0;}validate71.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate73(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate73.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate73.errors = vErrors;return errors === 0;}validate73.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate52(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/audit-entry.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate52.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.at === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.actor === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "actor"},message:"must have required property '"+"actor"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.operation === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "operation"},message:"must have required property '"+"operation"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.scope === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.subjects === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "subjects"},message:"must have required property '"+"subjects"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.outcome === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "outcome"},message:"must have required property '"+"outcome"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.provider === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "provider"},message:"must have required property '"+"provider"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data.digest === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key0 in data){if(!(func1.call(schema19.properties, key0))){const err10 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.schemaVersion !== undefined){if("replica.audit/v1" !== data.schemaVersion){const err11 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.audit/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data.id !== undefined){if(!(validate54(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate54.errors : vErrors.concat(validate54.errors);errors = vErrors.length;}}if(data.at !== undefined){if(!(validate56(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate56.errors : vErrors.concat(validate56.errors);errors = vErrors.length;}}if(data.actor !== undefined){if(!(validate58(data.actor, {instancePath:instancePath+"/actor",parentData:data,parentDataProperty:"actor",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate58.errors : vErrors.concat(validate58.errors);errors = vErrors.length;}}if(data.operation !== undefined){let data4 = data.operation;if(!((((((((((((((data4 === "grant.add") || (data4 === "grant.withdraw")) || (data4 === "collection.import")) || (data4 === "observation.append")) || (data4 === "evidence.redact")) || (data4 === "annotation.add")) || (data4 === "consolidation.run")) || (data4 === "memory.propose")) || (data4 === "memory.accept")) || (data4 === "memory.reject")) || (data4 === "memory.retire")) || (data4 === "memory.supersede")) || (data4 === "memory.recall")) || (data4 === "export.create"))){const err12 = {instancePath:instancePath+"/operation",schemaPath:"#/properties/operation/enum",keyword:"enum",params:{allowedValues: schema19.properties.operation.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.scope !== undefined){if(!(validate62(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate62.errors : vErrors.concat(validate62.errors);errors = vErrors.length;}}if(data.purpose !== undefined){if(!(validate68(data.purpose, {instancePath:instancePath+"/purpose",parentData:data,parentDataProperty:"purpose",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate68.errors : vErrors.concat(validate68.errors);errors = vErrors.length;}}if(data.subjects !== undefined){let data7 = data.subjects;if(Array.isArray(data7)){if(data7.length > 10000){const err13 = {instancePath:instancePath+"/subjects",schemaPath:"#/properties/subjects/maxItems",keyword:"maxItems",params:{limit: 10000},message:"must NOT have more than 10000 items"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}const len0 = data7.length;for(let i0=0; i0 2000){const err21 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(func2(data13) < 1){const err22 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data.provider !== undefined){let data14 = data.provider;if(data14 && typeof data14 == "object" && !Array.isArray(data14)){if(data14.id === undefined){const err24 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}if(data14.version === undefined){const err25 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}for(const key2 in data14){if(!((key2 === "id") || (key2 === "version"))){const err26 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}if(data14.id !== undefined){if(!(validate73(data14.id, {instancePath:instancePath+"/provider/id",parentData:data14,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate73.errors : vErrors.concat(validate73.errors);errors = vErrors.length;}}if(data14.version !== undefined){let data16 = data14.version;if(typeof data16 === "string"){if(func2(data16) > 64){const err27 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(func2(data16) < 1){const err28 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}else {const err29 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}}else {const err30 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data.digest !== undefined){if(!(validate71(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate71.errors : vErrors.concat(validate71.errors);errors = vErrors.length;}}}else {const err31 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}validate52.errors = vErrors;return errors === 0;}validate52.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.collection = validate76;const schema30 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/collection.schema.json","title":"Replica evidence collection v1","description":"One import of source evidence for a time window. complete is true only when every page and reply continuation was present. A window that no complete collection covers is reported as incomplete, never as empty.","type":"object","additionalProperties":false,"required":["schemaVersion","id","source","scope","snapshotId","snapshotDigest","capturedAt","filters","complete","problems","counts","importedAt","importedBy","digest"],"properties":{"schemaVersion":{"const":"replica.collection/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"source":{"$ref":"common.schema.json#/$defs/source"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"snapshotId":{"type":"string","pattern":"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"},"snapshotDigest":{"description":"The digest of the snapshot's normalized contents. Each scope stores one collection per snapshotId, and importing the snapshot again matches this digest.","$ref":"common.schema.json#/$defs/digest"},"reviewerIdentity":{"description":"Once a Hub source opts into stable identities, login-only evidence from that source serves review only.","const":"stable-user-id"},"capturedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"filters":{"type":"object","additionalProperties":false,"required":["resolution","read","from","to"],"properties":{"resolution":{"enum":["all","unresolved","resolved"]},"read":{"enum":["all","unread","read"]},"from":{"anyOf":[{"$ref":"common.schema.json#/$defs/timestamp"},{"type":"null"}]},"to":{"anyOf":[{"$ref":"common.schema.json#/$defs/timestamp"},{"type":"null"}]}}},"complete":{"type":"boolean"},"problems":{"type":"array","maxItems":1000,"items":{"type":"string","minLength":1,"maxLength":2000}},"counts":{"type":"object","additionalProperties":false,"required":["threads","messages","episodes","events"],"properties":{"threads":{"$ref":"common.schema.json#/$defs/count"},"messages":{"$ref":"common.schema.json#/$defs/count"},"episodes":{"$ref":"common.schema.json#/$defs/count"},"events":{"$ref":"common.schema.json#/$defs/count"}}},"importedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"importedBy":{"$ref":"common.schema.json#/$defs/actor"},"digest":{"$ref":"common.schema.json#/$defs/digest"}}};function validate77(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate77.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate77.errors = vErrors;return errors === 0;}validate77.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema32 = {"description":"Where an episode or a piece of evidence came from, pinned to the exact Build when there is one.","type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"$ref":"#/$defs/sourceKind"},"hubOrigin":{"$ref":"#/$defs/origin"},"repository":{"type":"string","pattern":"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},"repositoryId":{"$ref":"#/$defs/sourceIdentifier"},"prototypeId":{"$ref":"#/$defs/sourceIdentifier"},"prototypeName":{"type":"string","minLength":1,"maxLength":1024},"branch":{"type":"string","minLength":1,"maxLength":1024},"buildNumber":{"$ref":"#/$defs/positiveInteger"},"buildId":{"$ref":"#/$defs/positiveInteger"},"commitSha":{"$ref":"#/$defs/commitSha"},"threadId":{"$ref":"#/$defs/positiveInteger"},"commentId":{"$ref":"#/$defs/positiveInteger"},"sessionId":{"type":"string","minLength":1,"maxLength":200}}};const schema33 = {"description":"Where evidence came from, such as hub_review_comments.","type":"string","pattern":"^[a-z][a-z0-9_]{1,63}$"};const pattern14 = new RegExp("^[a-z][a-z0-9_]{1,63}$", "u");function validate80(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate80.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern14.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9_]{1,63}$"},message:"must match pattern \""+"^[a-z][a-z0-9_]{1,63}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate80.errors = vErrors;return errors === 0;}validate80.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema34 = {"description":"An HTTP or HTTPS origin without credentials, path, query, or fragment.","type":"string","maxLength":2048,"pattern":"^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"};const pattern15 = new RegExp("^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$", "u");function validate82(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate82.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 2048){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!pattern15.test(data)){const err1 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^https?://[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate82.errors = vErrors;return errors === 0;}validate82.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema35 = {"description":"A stable source-system identifier, either a legacy positive integer or a UUID.","oneOf":[{"$ref":"#/$defs/positiveInteger"},{"type":"string","pattern":"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"}]};const schema36 = {"type":"integer","minimum":1,"maximum":9007199254740991};function validate85(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate85.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 1 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate85.errors = vErrors;return errors === 0;}validate85.evaluated = {"dynamicProps":false,"dynamicItems":false};const pattern17 = new RegExp("^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$", "u");function validate84(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate84.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs0 = errors;let valid0 = false;let passing0 = null;const _errs1 = errors;if(!(validate85(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}var _valid0 = _errs1 === errors;if(_valid0){valid0 = true;passing0 = 0;}const _errs2 = errors;if(typeof data === "string"){if(!pattern17.test(data)){const err0 = {instancePath,schemaPath:"#/oneOf/1/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"},message:"must match pattern \""+"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/oneOf/1/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}var _valid0 = _errs2 === errors;if(_valid0 && valid0){valid0 = false;passing0 = [passing0, 1];}else {if(_valid0){valid0 = true;passing0 = 1;}}if(!valid0){const err2 = {instancePath,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs0;if(vErrors !== null){if(_errs0){vErrors.length = _errs0;}else {vErrors = null;}}}validate84.errors = vErrors;return errors === 0;}validate84.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema37 = {"type":"string","pattern":"^[0-9a-f]{40}$"};const pattern18 = new RegExp("^[0-9a-f]{40}$", "u");function validate91(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate91.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern18.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{40}$"},message:"must match pattern \""+"^[0-9a-f]{40}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate91.errors = vErrors;return errors === 0;}validate91.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate79(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate79.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(func1.call(schema32.properties, key0))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate80(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate80.errors : vErrors.concat(validate80.errors);errors = vErrors.length;}}if(data.hubOrigin !== undefined){if(!(validate82(data.hubOrigin, {instancePath:instancePath+"/hubOrigin",parentData:data,parentDataProperty:"hubOrigin",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate82.errors : vErrors.concat(validate82.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data2 = data.repository;if(typeof data2 === "string"){if(!pattern10.test(data2)){const err2 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.repositoryId !== undefined){if(!(validate84(data.repositoryId, {instancePath:instancePath+"/repositoryId",parentData:data,parentDataProperty:"repositoryId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeId !== undefined){if(!(validate84(data.prototypeId, {instancePath:instancePath+"/prototypeId",parentData:data,parentDataProperty:"prototypeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeName !== undefined){let data5 = data.prototypeName;if(typeof data5 === "string"){if(func2(data5) > 1024){const err4 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data5) < 1){const err5 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.branch !== undefined){let data6 = data.branch;if(typeof data6 === "string"){if(func2(data6) > 1024){const err7 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data6) < 1){const err8 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.buildNumber !== undefined){if(!(validate85(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.buildId !== undefined){if(!(validate85(data.buildId, {instancePath:instancePath+"/buildId",parentData:data,parentDataProperty:"buildId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.commitSha !== undefined){if(!(validate91(data.commitSha, {instancePath:instancePath+"/commitSha",parentData:data,parentDataProperty:"commitSha",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate91.errors : vErrors.concat(validate91.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate85(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.commentId !== undefined){if(!(validate85(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.sessionId !== undefined){let data12 = data.sessionId;if(typeof data12 === "string"){if(func2(data12) > 200){const err10 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data12) < 1){const err11 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate79.errors = vErrors;return errors === 0;}validate79.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate96(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate96.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate96.errors = vErrors;return errors === 0;}validate96.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate101(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate101.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate101.errors = vErrors;return errors === 0;}validate101.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate103(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate103.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate103.errors = vErrors;return errors === 0;}validate103.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema41 = {"type":"integer","minimum":0,"maximum":9007199254740991};function validate107(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate107.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 0 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate107.errors = vErrors;return errors === 0;}validate107.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate113(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate113.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate113.errors = vErrors;return errors === 0;}validate113.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const pattern21 = new RegExp("^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", "u");function validate76(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/collection.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate76.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.source === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "source"},message:"must have required property '"+"source"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.scope === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.snapshotId === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "snapshotId"},message:"must have required property '"+"snapshotId"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.snapshotDigest === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "snapshotDigest"},message:"must have required property '"+"snapshotDigest"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.capturedAt === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "capturedAt"},message:"must have required property '"+"capturedAt"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.filters === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "filters"},message:"must have required property '"+"filters"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.complete === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "complete"},message:"must have required property '"+"complete"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data.problems === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "problems"},message:"must have required property '"+"problems"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(data.counts === undefined){const err10 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "counts"},message:"must have required property '"+"counts"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.importedAt === undefined){const err11 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "importedAt"},message:"must have required property '"+"importedAt"+"'"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(data.importedBy === undefined){const err12 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "importedBy"},message:"must have required property '"+"importedBy"+"'"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(data.digest === undefined){const err13 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}for(const key0 in data){if(!(func1.call(schema30.properties, key0))){const err14 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data.schemaVersion !== undefined){if("replica.collection/v1" !== data.schemaVersion){const err15 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.collection/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data.id !== undefined){if(!(validate77(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate77.errors : vErrors.concat(validate77.errors);errors = vErrors.length;}}if(data.source !== undefined){if(!(validate79(data.source, {instancePath:instancePath+"/source",parentData:data,parentDataProperty:"source",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate79.errors : vErrors.concat(validate79.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate96(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate96.errors : vErrors.concat(validate96.errors);errors = vErrors.length;}}if(data.snapshotId !== undefined){let data4 = data.snapshotId;if(typeof data4 === "string"){if(!pattern21.test(data4)){const err16 = {instancePath:instancePath+"/snapshotId",schemaPath:"#/properties/snapshotId/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"},message:"must match pattern \""+"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"+"\""};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}else {const err17 = {instancePath:instancePath+"/snapshotId",schemaPath:"#/properties/snapshotId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data.snapshotDigest !== undefined){if(!(validate101(data.snapshotDigest, {instancePath:instancePath+"/snapshotDigest",parentData:data,parentDataProperty:"snapshotDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate101.errors : vErrors.concat(validate101.errors);errors = vErrors.length;}}if(data.reviewerIdentity !== undefined){if("stable-user-id" !== data.reviewerIdentity){const err18 = {instancePath:instancePath+"/reviewerIdentity",schemaPath:"#/properties/reviewerIdentity/const",keyword:"const",params:{allowedValue: "stable-user-id"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data.capturedAt !== undefined){if(!(validate103(data.capturedAt, {instancePath:instancePath+"/capturedAt",parentData:data,parentDataProperty:"capturedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate103.errors : vErrors.concat(validate103.errors);errors = vErrors.length;}}if(data.filters !== undefined){let data8 = data.filters;if(data8 && typeof data8 == "object" && !Array.isArray(data8)){if(data8.resolution === undefined){const err19 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "resolution"},message:"must have required property '"+"resolution"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data8.read === undefined){const err20 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "read"},message:"must have required property '"+"read"+"'"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}if(data8.from === undefined){const err21 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(data8.to === undefined){const err22 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}for(const key1 in data8){if(!((((key1 === "resolution") || (key1 === "read")) || (key1 === "from")) || (key1 === "to"))){const err23 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data8.resolution !== undefined){let data9 = data8.resolution;if(!(((data9 === "all") || (data9 === "unresolved")) || (data9 === "resolved"))){const err24 = {instancePath:instancePath+"/filters/resolution",schemaPath:"#/properties/filters/properties/resolution/enum",keyword:"enum",params:{allowedValues: schema30.properties.filters.properties.resolution.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data8.read !== undefined){let data10 = data8.read;if(!(((data10 === "all") || (data10 === "unread")) || (data10 === "read"))){const err25 = {instancePath:instancePath+"/filters/read",schemaPath:"#/properties/filters/properties/read/enum",keyword:"enum",params:{allowedValues: schema30.properties.filters.properties.read.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}if(data8.from !== undefined){let data11 = data8.from;const _errs17 = errors;let valid2 = false;const _errs18 = errors;if(!(validate103(data11, {instancePath:instancePath+"/filters/from",parentData:data8,parentDataProperty:"from",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate103.errors : vErrors.concat(validate103.errors);errors = vErrors.length;}var _valid0 = _errs18 === errors;valid2 = valid2 || _valid0;const _errs19 = errors;if(data11 !== null){const err26 = {instancePath:instancePath+"/filters/from",schemaPath:"#/properties/filters/properties/from/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}var _valid0 = _errs19 === errors;valid2 = valid2 || _valid0;if(!valid2){const err27 = {instancePath:instancePath+"/filters/from",schemaPath:"#/properties/filters/properties/from/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}else {errors = _errs17;if(vErrors !== null){if(_errs17){vErrors.length = _errs17;}else {vErrors = null;}}}}if(data8.to !== undefined){let data12 = data8.to;const _errs22 = errors;let valid3 = false;const _errs23 = errors;if(!(validate103(data12, {instancePath:instancePath+"/filters/to",parentData:data8,parentDataProperty:"to",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate103.errors : vErrors.concat(validate103.errors);errors = vErrors.length;}var _valid1 = _errs23 === errors;valid3 = valid3 || _valid1;const _errs24 = errors;if(data12 !== null){const err28 = {instancePath:instancePath+"/filters/to",schemaPath:"#/properties/filters/properties/to/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}var _valid1 = _errs24 === errors;valid3 = valid3 || _valid1;if(!valid3){const err29 = {instancePath:instancePath+"/filters/to",schemaPath:"#/properties/filters/properties/to/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}else {errors = _errs22;if(vErrors !== null){if(_errs22){vErrors.length = _errs22;}else {vErrors = null;}}}}}else {const err30 = {instancePath:instancePath+"/filters",schemaPath:"#/properties/filters/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data.complete !== undefined){if(typeof data.complete !== "boolean"){const err31 = {instancePath:instancePath+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data.problems !== undefined){let data14 = data.problems;if(Array.isArray(data14)){if(data14.length > 1000){const err32 = {instancePath:instancePath+"/problems",schemaPath:"#/properties/problems/maxItems",keyword:"maxItems",params:{limit: 1000},message:"must NOT have more than 1000 items"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}const len0 = data14.length;for(let i0=0; i0 2000){const err33 = {instancePath:instancePath+"/problems/" + i0,schemaPath:"#/properties/problems/items/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}if(func2(data15) < 1){const err34 = {instancePath:instancePath+"/problems/" + i0,schemaPath:"#/properties/problems/items/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}else {const err35 = {instancePath:instancePath+"/problems/" + i0,schemaPath:"#/properties/problems/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}}else {const err36 = {instancePath:instancePath+"/problems",schemaPath:"#/properties/problems/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data.counts !== undefined){let data16 = data.counts;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){if(data16.threads === undefined){const err37 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "threads"},message:"must have required property '"+"threads"+"'"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}if(data16.messages === undefined){const err38 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "messages"},message:"must have required property '"+"messages"+"'"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}if(data16.episodes === undefined){const err39 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "episodes"},message:"must have required property '"+"episodes"+"'"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}if(data16.events === undefined){const err40 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "events"},message:"must have required property '"+"events"+"'"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}for(const key2 in data16){if(!((((key2 === "threads") || (key2 === "messages")) || (key2 === "episodes")) || (key2 === "events"))){const err41 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data16.threads !== undefined){if(!(validate107(data16.threads, {instancePath:instancePath+"/counts/threads",parentData:data16,parentDataProperty:"threads",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate107.errors : vErrors.concat(validate107.errors);errors = vErrors.length;}}if(data16.messages !== undefined){if(!(validate107(data16.messages, {instancePath:instancePath+"/counts/messages",parentData:data16,parentDataProperty:"messages",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate107.errors : vErrors.concat(validate107.errors);errors = vErrors.length;}}if(data16.episodes !== undefined){if(!(validate107(data16.episodes, {instancePath:instancePath+"/counts/episodes",parentData:data16,parentDataProperty:"episodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate107.errors : vErrors.concat(validate107.errors);errors = vErrors.length;}}if(data16.events !== undefined){if(!(validate107(data16.events, {instancePath:instancePath+"/counts/events",parentData:data16,parentDataProperty:"events",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate107.errors : vErrors.concat(validate107.errors);errors = vErrors.length;}}}else {const err42 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data.importedAt !== undefined){if(!(validate103(data.importedAt, {instancePath:instancePath+"/importedAt",parentData:data,parentDataProperty:"importedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate103.errors : vErrors.concat(validate103.errors);errors = vErrors.length;}}if(data.importedBy !== undefined){if(!(validate113(data.importedBy, {instancePath:instancePath+"/importedBy",parentData:data,parentDataProperty:"importedBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate113.errors : vErrors.concat(validate113.errors);errors = vErrors.length;}}if(data.digest !== undefined){if(!(validate101(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate101.errors : vErrors.concat(validate101.errors);errors = vErrors.length;}}}else {const err43 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}validate76.errors = vErrors;return errors === 0;}validate76.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.consentGrant = validate117;const schema43 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/consent-grant.schema.json","title":"Replica consent grant v1","description":"Permission to use evidence from named sources, in one scope, for named purposes. A host decides at read time whether a record may be used for a purpose: some active grant in the record's scope must name the purpose and the record's source, and cover the evidence's original time. Reading feedback, publishing it, and training on it are separate purposes. A grant is never edited; a withdrawal record ends a purpose.","type":"object","additionalProperties":false,"required":["schemaVersion","id","scope","purposes","sources","grantedBy","grantedAt","basis","digest"],"properties":{"schemaVersion":{"const":"replica.consent-grant/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"purposes":{"$ref":"common.schema.json#/$defs/purposes"},"sources":{"type":"array","minItems":1,"maxItems":20,"items":{"$ref":"common.schema.json#/$defs/sourceKind"}},"grantedBy":{"$ref":"common.schema.json#/$defs/humanActor"},"grantedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"expiresAt":{"$ref":"common.schema.json#/$defs/timestamp"},"evidenceFrom":{"description":"Covers only evidence whose original time is at or after this time. Omit to cover earlier evidence too.","$ref":"common.schema.json#/$defs/timestamp"},"evidenceUntil":{"description":"Covers only evidence whose original time is before this time. Omit for no upper bound.","$ref":"common.schema.json#/$defs/timestamp"},"basis":{"description":"Why this use is allowed, such as a team agreement or a study consent form.","type":"string","minLength":1,"maxLength":2000},"digest":{"$ref":"common.schema.json#/$defs/digest"}}};function validate118(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate118.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate118.errors = vErrors;return errors === 0;}validate118.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate120(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate120.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate120.errors = vErrors;return errors === 0;}validate120.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema46 = {"type":"array","minItems":1,"maxItems":6,"items":{"$ref":"#/$defs/purpose"}};function validate126(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate126.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!((((((data === "review") || (data === "instruction")) || (data === "evaluation")) || (data === "analytics")) || (data === "training")) || (data === "publication"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema27.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate126.errors = vErrors;return errors === 0;}validate126.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate125(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate125.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 6){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 6},message:"must NOT have more than 6 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.length < 1){const err1 = {instancePath,schemaPath:"#/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}const len0 = data.length;for(let i0=0; i0 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate132.errors = vErrors;return errors === 0;}validate132.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate131(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate131.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(validate132(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate132.errors : vErrors.concat(validate132.errors);errors = vErrors.length;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind !== undefined){if("human" !== data.kind){const err0 = {instancePath:instancePath+"/kind",schemaPath:"#/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "human"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}else {const err1 = {instancePath,schemaPath:"#/allOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate131.errors = vErrors;return errors === 0;}validate131.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate136(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate136.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate136.errors = vErrors;return errors === 0;}validate136.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate141(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate141.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate141.errors = vErrors;return errors === 0;}validate141.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate117(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/consent-grant.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate117.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.scope === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.purposes === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "purposes"},message:"must have required property '"+"purposes"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.sources === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "sources"},message:"must have required property '"+"sources"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.grantedBy === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "grantedBy"},message:"must have required property '"+"grantedBy"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.grantedAt === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "grantedAt"},message:"must have required property '"+"grantedAt"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.basis === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "basis"},message:"must have required property '"+"basis"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.digest === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}for(const key0 in data){if(!(func1.call(schema43.properties, key0))){const err9 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.schemaVersion !== undefined){if("replica.consent-grant/v1" !== data.schemaVersion){const err10 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.consent-grant/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.id !== undefined){if(!(validate118(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate118.errors : vErrors.concat(validate118.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate120(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate120.errors : vErrors.concat(validate120.errors);errors = vErrors.length;}}if(data.purposes !== undefined){if(!(validate125(data.purposes, {instancePath:instancePath+"/purposes",parentData:data,parentDataProperty:"purposes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate125.errors : vErrors.concat(validate125.errors);errors = vErrors.length;}}if(data.sources !== undefined){let data4 = data.sources;if(Array.isArray(data4)){if(data4.length > 20){const err11 = {instancePath:instancePath+"/sources",schemaPath:"#/properties/sources/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(data4.length < 1){const err12 = {instancePath:instancePath+"/sources",schemaPath:"#/properties/sources/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}const len0 = data4.length;for(let i0=0; i0 2000){const err14 = {instancePath:instancePath+"/basis",schemaPath:"#/properties/basis/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(func2(data11) < 1){const err15 = {instancePath:instancePath+"/basis",schemaPath:"#/properties/basis/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}else {const err16 = {instancePath:instancePath+"/basis",schemaPath:"#/properties/basis/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data.digest !== undefined){if(!(validate141(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate141.errors : vErrors.concat(validate141.errors);errors = vErrors.length;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate117.errors = vErrors;return errors === 0;}validate117.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.episode = validate143;const schema53 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/episode.schema.json","title":"Replica episode v1","description":"The unit of learning evidence: one review thread, chat session, scenario run, or similar. The digest covers the header, every field except digest and timeline, so appending events never changes it. Events carry their own digests. timeline appears only in exports.","type":"object","additionalProperties":false,"required":["schemaVersion","id","scope","source","actors","grants","provenance","startedAt","digest"],"properties":{"schemaVersion":{"const":"replica.episode/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"source":{"$ref":"common.schema.json#/$defs/source"},"task":{"type":"object","additionalProperties":false,"properties":{"prompt":{"type":"string","minLength":1,"maxLength":10000},"goal":{"type":"string","minLength":1,"maxLength":2000},"role":{"$ref":"common.schema.json#/$defs/slug"},"taskId":{"type":"string","minLength":1,"maxLength":200}}},"actors":{"type":"array","maxItems":500,"items":{"$ref":"common.schema.json#/$defs/actor"}},"versions":{"description":"What produced the experience under review, so outcomes can be tied to versions.","type":"object","additionalProperties":false,"properties":{"model":{"type":"string","minLength":1,"maxLength":200},"harness":{"type":"string","minLength":1,"maxLength":200},"designSystem":{"type":"string","minLength":1,"maxLength":200},"brandPack":{"type":"string","minLength":1,"maxLength":200},"memorySnapshot":{"$ref":"common.schema.json#/$defs/digest"}}},"grants":{"description":"The consent grants this episode was collected under, kept for provenance. Use for a purpose is decided at read time from the grants then active for the episode's scope and source.","type":"array","minItems":1,"maxItems":20,"items":{"$ref":"common.schema.json#/$defs/id"}},"contentTrust":{"type":"object","additionalProperties":false,"required":["untrusted","treatAs"],"properties":{"untrusted":{"type":"boolean"},"treatAs":{"const":"data"},"source":{"$ref":"common.schema.json#/$defs/sourceKind"}}},"provenance":{"$ref":"common.schema.json#/$defs/provenance"},"startedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"endedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"outcome":{"type":"object","additionalProperties":false,"required":["status"],"properties":{"status":{"enum":["success","failure","partial","unknown"]},"summary":{"type":"string","minLength":1,"maxLength":2000}}},"timeline":{"type":"array","maxItems":100000,"items":{"$ref":"event.schema.json"}},"digest":{"$ref":"common.schema.json#/$defs/digest"}}};function validate144(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate144.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate144.errors = vErrors;return errors === 0;}validate144.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate146(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate146.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate146.errors = vErrors;return errors === 0;}validate146.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate151(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate151.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(func1.call(schema32.properties, key0))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate80(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate80.errors : vErrors.concat(validate80.errors);errors = vErrors.length;}}if(data.hubOrigin !== undefined){if(!(validate82(data.hubOrigin, {instancePath:instancePath+"/hubOrigin",parentData:data,parentDataProperty:"hubOrigin",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate82.errors : vErrors.concat(validate82.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data2 = data.repository;if(typeof data2 === "string"){if(!pattern10.test(data2)){const err2 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.repositoryId !== undefined){if(!(validate84(data.repositoryId, {instancePath:instancePath+"/repositoryId",parentData:data,parentDataProperty:"repositoryId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeId !== undefined){if(!(validate84(data.prototypeId, {instancePath:instancePath+"/prototypeId",parentData:data,parentDataProperty:"prototypeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeName !== undefined){let data5 = data.prototypeName;if(typeof data5 === "string"){if(func2(data5) > 1024){const err4 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data5) < 1){const err5 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.branch !== undefined){let data6 = data.branch;if(typeof data6 === "string"){if(func2(data6) > 1024){const err7 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data6) < 1){const err8 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.buildNumber !== undefined){if(!(validate85(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.buildId !== undefined){if(!(validate85(data.buildId, {instancePath:instancePath+"/buildId",parentData:data,parentDataProperty:"buildId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.commitSha !== undefined){if(!(validate91(data.commitSha, {instancePath:instancePath+"/commitSha",parentData:data,parentDataProperty:"commitSha",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate91.errors : vErrors.concat(validate91.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate85(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.commentId !== undefined){if(!(validate85(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.sessionId !== undefined){let data12 = data.sessionId;if(typeof data12 === "string"){if(func2(data12) > 200){const err10 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data12) < 1){const err11 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate151.errors = vErrors;return errors === 0;}validate151.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate162(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate162.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate162.errors = vErrors;return errors === 0;}validate162.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate164(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate164.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate164.errors = vErrors;return errors === 0;}validate164.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate167(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate167.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate167.errors = vErrors;return errors === 0;}validate167.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate170(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate170.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern14.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9_]{1,63}$"},message:"must match pattern \""+"^[a-z][a-z0-9_]{1,63}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate170.errors = vErrors;return errors === 0;}validate170.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema61 = {"description":"Which code made a record, how, when, for whom, and from which inputs.","type":"object","additionalProperties":false,"required":["producer","method","createdAt","createdBy"],"properties":{"producer":{"$ref":"#/$defs/producer"},"method":{"type":"string","maxLength":128,"pattern":"^[a-z]+:[a-z0-9_.-]+$"},"createdAt":{"$ref":"#/$defs/timestamp"},"createdBy":{"$ref":"#/$defs/actor"},"inputs":{"type":"array","maxItems":1000,"items":{"$ref":"#/$defs/digest"}}}};const schema62 = {"type":"object","additionalProperties":false,"required":["name","version"],"properties":{"name":{"type":"string","minLength":1,"maxLength":200},"version":{"type":"string","minLength":1,"maxLength":64}}};function validate173(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate173.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.name === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.version === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "name") || (key0 === "version"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.name !== undefined){let data0 = data.name;if(typeof data0 === "string"){if(func2(data0) > 200){const err3 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(func2(data0) < 1){const err4 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.version !== undefined){let data1 = data.version;if(typeof data1 === "string"){if(func2(data1) > 64){const err6 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(func2(data1) < 1){const err7 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}else {const err8 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}}else {const err9 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}validate173.errors = vErrors;return errors === 0;}validate173.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate175(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate175.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate175.errors = vErrors;return errors === 0;}validate175.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate178(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate178.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate178.errors = vErrors;return errors === 0;}validate178.evaluated = {"dynamicProps":false,"dynamicItems":false};const pattern43 = new RegExp("^[a-z]+:[a-z0-9_.-]+$", "u");function validate172(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate172.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.producer === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "producer"},message:"must have required property '"+"producer"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.method === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "method"},message:"must have required property '"+"method"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.createdAt === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.createdBy === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdBy"},message:"must have required property '"+"createdBy"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!(((((key0 === "producer") || (key0 === "method")) || (key0 === "createdAt")) || (key0 === "createdBy")) || (key0 === "inputs"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.producer !== undefined){if(!(validate173(data.producer, {instancePath:instancePath+"/producer",parentData:data,parentDataProperty:"producer",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate173.errors : vErrors.concat(validate173.errors);errors = vErrors.length;}}if(data.method !== undefined){let data1 = data.method;if(typeof data1 === "string"){if(func2(data1) > 128){const err5 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern43.test(data1)){const err6 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/pattern",keyword:"pattern",params:{pattern: "^[a-z]+:[a-z0-9_.-]+$"},message:"must match pattern \""+"^[a-z]+:[a-z0-9_.-]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.createdAt !== undefined){if(!(validate175(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate175.errors : vErrors.concat(validate175.errors);errors = vErrors.length;}}if(data.createdBy !== undefined){if(!(validate132(data.createdBy, {instancePath:instancePath+"/createdBy",parentData:data,parentDataProperty:"createdBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate132.errors : vErrors.concat(validate132.errors);errors = vErrors.length;}}if(data.inputs !== undefined){let data4 = data.inputs;if(Array.isArray(data4)){if(data4.length > 1000){const err8 = {instancePath:instancePath+"/inputs",schemaPath:"#/properties/inputs/maxItems",keyword:"maxItems",params:{limit: 1000},message:"must NOT have more than 1000 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}const len0 = data4.length;for(let i0=0; i0 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 1 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate186.errors = vErrors;return errors === 0;}validate186.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate189(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate189.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate189.errors = vErrors;return errors === 0;}validate189.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema70 = {"description":"The compact saved target of a root comment: route and accessible element details.","type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"enum":["element","area"]},"route":{"type":"object","additionalProperties":false,"properties":{"pathname":{"type":"string","maxLength":2048},"search":{"type":"string","maxLength":2048},"hash":{"type":"string","maxLength":1024}}},"accessibleName":{"type":"string","maxLength":1000},"tagName":{"type":"string","maxLength":64},"selectedText":{"type":"string","maxLength":2000},"elements":{"type":"array","maxItems":8,"items":{"type":"object","additionalProperties":false,"properties":{"accessibleName":{"type":"string","maxLength":1000},"tagName":{"type":"string","maxLength":64},"role":{"type":"string","maxLength":64},"textExcerpt":{"type":"string","maxLength":500}}}}}};function validate194(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate194.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "route")) || (key0 === "accessibleName")) || (key0 === "tagName")) || (key0 === "selectedText")) || (key0 === "elements"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((data0 === "element") || (data0 === "area"))){const err2 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema70.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.route !== undefined){let data1 = data.route;if(data1 && typeof data1 == "object" && !Array.isArray(data1)){for(const key1 in data1){if(!(((key1 === "pathname") || (key1 === "search")) || (key1 === "hash"))){const err3 = {instancePath:instancePath+"/route",schemaPath:"#/properties/route/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data1.pathname !== undefined){let data2 = data1.pathname;if(typeof data2 === "string"){if(func2(data2) > 2048){const err4 = {instancePath:instancePath+"/route/pathname",schemaPath:"#/properties/route/properties/pathname/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/route/pathname",schemaPath:"#/properties/route/properties/pathname/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data1.search !== undefined){let data3 = data1.search;if(typeof data3 === "string"){if(func2(data3) > 2048){const err6 = {instancePath:instancePath+"/route/search",schemaPath:"#/properties/route/properties/search/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/route/search",schemaPath:"#/properties/route/properties/search/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data1.hash !== undefined){let data4 = data1.hash;if(typeof data4 === "string"){if(func2(data4) > 1024){const err8 = {instancePath:instancePath+"/route/hash",schemaPath:"#/properties/route/properties/hash/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/route/hash",schemaPath:"#/properties/route/properties/hash/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}}else {const err10 = {instancePath:instancePath+"/route",schemaPath:"#/properties/route/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data.accessibleName !== undefined){let data5 = data.accessibleName;if(typeof data5 === "string"){if(func2(data5) > 1000){const err11 = {instancePath:instancePath+"/accessibleName",schemaPath:"#/properties/accessibleName/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/accessibleName",schemaPath:"#/properties/accessibleName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.tagName !== undefined){let data6 = data.tagName;if(typeof data6 === "string"){if(func2(data6) > 64){const err13 = {instancePath:instancePath+"/tagName",schemaPath:"#/properties/tagName/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}else {const err14 = {instancePath:instancePath+"/tagName",schemaPath:"#/properties/tagName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data.selectedText !== undefined){let data7 = data.selectedText;if(typeof data7 === "string"){if(func2(data7) > 2000){const err15 = {instancePath:instancePath+"/selectedText",schemaPath:"#/properties/selectedText/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}else {const err16 = {instancePath:instancePath+"/selectedText",schemaPath:"#/properties/selectedText/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data.elements !== undefined){let data8 = data.elements;if(Array.isArray(data8)){if(data8.length > 8){const err17 = {instancePath:instancePath+"/elements",schemaPath:"#/properties/elements/maxItems",keyword:"maxItems",params:{limit: 8},message:"must NOT have more than 8 items"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}const len0 = data8.length;for(let i0=0; i0 1000){const err19 = {instancePath:instancePath+"/elements/" + i0+"/accessibleName",schemaPath:"#/properties/elements/items/properties/accessibleName/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}else {const err20 = {instancePath:instancePath+"/elements/" + i0+"/accessibleName",schemaPath:"#/properties/elements/items/properties/accessibleName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}if(data9.tagName !== undefined){let data11 = data9.tagName;if(typeof data11 === "string"){if(func2(data11) > 64){const err21 = {instancePath:instancePath+"/elements/" + i0+"/tagName",schemaPath:"#/properties/elements/items/properties/tagName/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}else {const err22 = {instancePath:instancePath+"/elements/" + i0+"/tagName",schemaPath:"#/properties/elements/items/properties/tagName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}if(data9.role !== undefined){let data12 = data9.role;if(typeof data12 === "string"){if(func2(data12) > 64){const err23 = {instancePath:instancePath+"/elements/" + i0+"/role",schemaPath:"#/properties/elements/items/properties/role/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}else {const err24 = {instancePath:instancePath+"/elements/" + i0+"/role",schemaPath:"#/properties/elements/items/properties/role/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data9.textExcerpt !== undefined){let data13 = data9.textExcerpt;if(typeof data13 === "string"){if(func2(data13) > 500){const err25 = {instancePath:instancePath+"/elements/" + i0+"/textExcerpt",schemaPath:"#/properties/elements/items/properties/textExcerpt/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}else {const err26 = {instancePath:instancePath+"/elements/" + i0+"/textExcerpt",schemaPath:"#/properties/elements/items/properties/textExcerpt/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}}else {const err27 = {instancePath:instancePath+"/elements/" + i0,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}}else {const err28 = {instancePath:instancePath+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}}else {const err29 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}validate194.errors = vErrors;return errors === 0;}validate194.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate185(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate185.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.role !== undefined){if("root" !== data.role){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs5 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.buildNumber === undefined){const err1 = {instancePath,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty: "buildNumber"},message:"must have required property '"+"buildNumber"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var _valid0 = _errs5 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs6 = errors;const _errs7 = errors;const _errs8 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.buildNumber === undefined) && (missing0 = "buildNumber")){const err2 = {};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}var valid3 = _errs8 === errors;if(valid3){const err3 = {instancePath,schemaPath:"#/allOf/0/else/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}else {errors = _errs7;if(vErrors !== null){if(_errs7){vErrors.length = _errs7;}else {vErrors = null;}}}var _valid0 = _errs6 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}const _errs10 = errors;let valid4 = true;const _errs11 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.deletedAt !== undefined){if(typeof data.deletedAt !== "string"){const err5 = {};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}}var _valid1 = _errs11 === errors;errors = _errs10;if(vErrors !== null){if(_errs10){vErrors.length = _errs10;}else {vErrors = null;}}let ifClause1;if(_valid1){const _errs14 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.body !== undefined){if(data.body !== null){const err6 = {instancePath:instancePath+"/body",schemaPath:"#/allOf/1/then/properties/body/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}var _valid1 = _errs14 === errors;valid4 = _valid1;if(valid4){var props0 = {};props0.body = true;props0.deletedAt = true;}ifClause1 = "then";}else {const _errs17 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.body !== undefined){if(typeof data.body !== "string"){const err7 = {instancePath:instancePath+"/body",schemaPath:"#/allOf/1/else/properties/body/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}}var _valid1 = _errs17 === errors;valid4 = _valid1;if(valid4){if(props0 !== true){props0 = props0 || {};props0.body = true;}}ifClause1 = "else";}if(!valid4){const err8 = {instancePath,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword: ifClause1},message:"must match \""+ifClause1+"\" schema"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(props0 !== true){props0 = props0 || {};props0.role = true;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.source === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "source"},message:"must have required property '"+"source"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(data.commentId === undefined){const err10 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "commentId"},message:"must have required property '"+"commentId"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.threadId === undefined){const err11 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "threadId"},message:"must have required property '"+"threadId"+"'"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(data.role === undefined){const err12 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "role"},message:"must have required property '"+"role"+"'"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(data.body === undefined){const err13 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "body"},message:"must have required property '"+"body"+"'"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(data.createdAt === undefined){const err14 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data.editedAt === undefined){const err15 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "editedAt"},message:"must have required property '"+"editedAt"+"'"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}if(data.deletedAt === undefined){const err16 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "deletedAt"},message:"must have required property '"+"deletedAt"+"'"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}for(const key0 in data){if(!(func1.call(schema67.properties, key0))){const err17 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data.source !== undefined){if("hub_review_comment" !== data.source){const err18 = {instancePath:instancePath+"/source",schemaPath:"#/properties/source/const",keyword:"const",params:{allowedValue: "hub_review_comment"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data.commentId !== undefined){if(!(validate186(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate186.errors : vErrors.concat(validate186.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate186(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate186.errors : vErrors.concat(validate186.errors);errors = vErrors.length;}}if(data.role !== undefined){let data7 = data.role;if(!((data7 === "root") || (data7 === "reply"))){const err19 = {instancePath:instancePath+"/role",schemaPath:"#/properties/role/enum",keyword:"enum",params:{allowedValues: schema67.properties.role.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}if(data.body !== undefined){let data8 = data.body;const _errs26 = errors;let valid9 = false;const _errs27 = errors;if(typeof data8 === "string"){if(func2(data8) > 10000){const err20 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 10000},message:"must NOT have more than 10000 characters"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}if(func2(data8) < 1){const err21 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}else {const err22 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}var _valid2 = _errs27 === errors;valid9 = valid9 || _valid2;const _errs29 = errors;if(data8 !== null){const err23 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}var _valid2 = _errs29 === errors;valid9 = valid9 || _valid2;if(!valid9){const err24 = {instancePath:instancePath+"/body",schemaPath:"#/properties/body/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}else {errors = _errs26;if(vErrors !== null){if(_errs26){vErrors.length = _errs26;}else {vErrors = null;}}}}if(data.createdAt !== undefined){if(!(validate189(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate189.errors : vErrors.concat(validate189.errors);errors = vErrors.length;}}if(data.editedAt !== undefined){let data10 = data.editedAt;const _errs33 = errors;let valid10 = false;const _errs34 = errors;if(!(validate189(data10, {instancePath:instancePath+"/editedAt",parentData:data,parentDataProperty:"editedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate189.errors : vErrors.concat(validate189.errors);errors = vErrors.length;}var _valid3 = _errs34 === errors;valid10 = valid10 || _valid3;const _errs35 = errors;if(data10 !== null){const err25 = {instancePath:instancePath+"/editedAt",schemaPath:"#/properties/editedAt/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}var _valid3 = _errs35 === errors;valid10 = valid10 || _valid3;if(!valid10){const err26 = {instancePath:instancePath+"/editedAt",schemaPath:"#/properties/editedAt/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}}if(data.deletedAt !== undefined){let data11 = data.deletedAt;const _errs38 = errors;let valid11 = false;const _errs39 = errors;if(!(validate189(data11, {instancePath:instancePath+"/deletedAt",parentData:data,parentDataProperty:"deletedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate189.errors : vErrors.concat(validate189.errors);errors = vErrors.length;}var _valid4 = _errs39 === errors;valid11 = valid11 || _valid4;const _errs40 = errors;if(data11 !== null){const err27 = {instancePath:instancePath+"/deletedAt",schemaPath:"#/properties/deletedAt/anyOf/1/type",keyword:"type",params:{type: "null"},message:"must be null"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}var _valid4 = _errs40 === errors;valid11 = valid11 || _valid4;if(!valid11){const err28 = {instancePath:instancePath+"/deletedAt",schemaPath:"#/properties/deletedAt/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}else {errors = _errs38;if(vErrors !== null){if(_errs38){vErrors.length = _errs38;}else {vErrors = null;}}}}if(data.buildNumber !== undefined){if(!(validate186(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate186.errors : vErrors.concat(validate186.errors);errors = vErrors.length;}}if(data.context !== undefined){if(!(validate194(data.context, {instancePath:instancePath+"/context",parentData:data,parentDataProperty:"context",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate194.errors : vErrors.concat(validate194.errors);errors = vErrors.length;}}}else {const err29 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}validate185.errors = vErrors;return errors === 0;}validate185.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema71 = {"description":"A judgment about another event in the same episode: its theme, signal, and whether it is an observed problem.","type":"object","additionalProperties":false,"required":["target","theme","signal","observation","stance"],"properties":{"target":{"$ref":"#/$defs/eventTarget"},"theme":{"type":"object","additionalProperties":false,"required":["key","statement"],"properties":{"key":{"$ref":"common.schema.json#/$defs/slug"},"statement":{"type":"string","minLength":1,"maxLength":1000}}},"signal":{"enum":["visual_quality","accessibility","usability","content","interaction","performance","agreement","replica_workflow","other"]},"observation":{"enum":["observed","preference","question","praise","other"]},"stance":{"enum":["supports","contradicts"]},"proposedKind":{"$ref":"common.schema.json#/$defs/memoryKind"},"trace":{"$ref":"common.schema.json#/$defs/trace"},"note":{"type":"string","minLength":1,"maxLength":1000}}};const schema72 = {"type":"object","additionalProperties":false,"required":["eventId"],"properties":{"eventId":{"$ref":"common.schema.json#/$defs/id"}}};function validate199(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate199.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate199.errors = vErrors;return errors === 0;}validate199.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate198(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate198.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.eventId === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "eventId"},message:"must have required property '"+"eventId"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(key0 === "eventId")){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.eventId !== undefined){if(!(validate199(data.eventId, {instancePath:instancePath+"/eventId",parentData:data,parentDataProperty:"eventId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate199.errors : vErrors.concat(validate199.errors);errors = vErrors.length;}}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate198.errors = vErrors;return errors === 0;}validate198.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate202(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate202.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate202.errors = vErrors;return errors === 0;}validate202.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema75 = {"enum":["fact","preference","rule","procedure","example","anti_pattern","design_principle"]};function validate204(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate204.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((((((data === "fact") || (data === "preference")) || (data === "rule")) || (data === "procedure")) || (data === "example")) || (data === "anti_pattern")) || (data === "design_principle"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate204.errors = vErrors;return errors === 0;}validate204.evaluated = {"dynamicProps":false,"dynamicItems":false};const schema76 = {"description":"The rule, skill, component, context, or token that should have prevented a problem.","type":"object","additionalProperties":false,"required":["kind","ref"],"properties":{"kind":{"enum":["rule","skill","component","context","token","other"]},"ref":{"type":"string","minLength":1,"maxLength":500}}};function validate206(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate206.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.ref === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "ref"},message:"must have required property '"+"ref"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "kind") || (key0 === "ref"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((((data0 === "rule") || (data0 === "skill")) || (data0 === "component")) || (data0 === "context")) || (data0 === "token")) || (data0 === "other"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema76.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.ref !== undefined){let data1 = data.ref;if(typeof data1 === "string"){if(func2(data1) > 500){const err4 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 1){const err5 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate206.errors = vErrors;return errors === 0;}validate206.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate197(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate197.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.target === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "target"},message:"must have required property '"+"target"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.theme === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "theme"},message:"must have required property '"+"theme"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.signal === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "signal"},message:"must have required property '"+"signal"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.observation === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "observation"},message:"must have required property '"+"observation"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.stance === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "stance"},message:"must have required property '"+"stance"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}for(const key0 in data){if(!((((((((key0 === "target") || (key0 === "theme")) || (key0 === "signal")) || (key0 === "observation")) || (key0 === "stance")) || (key0 === "proposedKind")) || (key0 === "trace")) || (key0 === "note"))){const err5 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.target !== undefined){if(!(validate198(data.target, {instancePath:instancePath+"/target",parentData:data,parentDataProperty:"target",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate198.errors : vErrors.concat(validate198.errors);errors = vErrors.length;}}if(data.theme !== undefined){let data1 = data.theme;if(data1 && typeof data1 == "object" && !Array.isArray(data1)){if(data1.key === undefined){const err6 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/required",keyword:"required",params:{missingProperty: "key"},message:"must have required property '"+"key"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data1.statement === undefined){const err7 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/required",keyword:"required",params:{missingProperty: "statement"},message:"must have required property '"+"statement"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}for(const key1 in data1){if(!((key1 === "key") || (key1 === "statement"))){const err8 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data1.key !== undefined){if(!(validate202(data1.key, {instancePath:instancePath+"/theme/key",parentData:data1,parentDataProperty:"key",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate202.errors : vErrors.concat(validate202.errors);errors = vErrors.length;}}if(data1.statement !== undefined){let data3 = data1.statement;if(typeof data3 === "string"){if(func2(data3) > 1000){const err9 = {instancePath:instancePath+"/theme/statement",schemaPath:"#/properties/theme/properties/statement/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(func2(data3) < 1){const err10 = {instancePath:instancePath+"/theme/statement",schemaPath:"#/properties/theme/properties/statement/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}else {const err11 = {instancePath:instancePath+"/theme/statement",schemaPath:"#/properties/theme/properties/statement/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}}else {const err12 = {instancePath:instancePath+"/theme",schemaPath:"#/properties/theme/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.signal !== undefined){let data4 = data.signal;if(!(((((((((data4 === "visual_quality") || (data4 === "accessibility")) || (data4 === "usability")) || (data4 === "content")) || (data4 === "interaction")) || (data4 === "performance")) || (data4 === "agreement")) || (data4 === "replica_workflow")) || (data4 === "other"))){const err13 = {instancePath:instancePath+"/signal",schemaPath:"#/properties/signal/enum",keyword:"enum",params:{allowedValues: schema71.properties.signal.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data.observation !== undefined){let data5 = data.observation;if(!(((((data5 === "observed") || (data5 === "preference")) || (data5 === "question")) || (data5 === "praise")) || (data5 === "other"))){const err14 = {instancePath:instancePath+"/observation",schemaPath:"#/properties/observation/enum",keyword:"enum",params:{allowedValues: schema71.properties.observation.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data.stance !== undefined){let data6 = data.stance;if(!((data6 === "supports") || (data6 === "contradicts"))){const err15 = {instancePath:instancePath+"/stance",schemaPath:"#/properties/stance/enum",keyword:"enum",params:{allowedValues: schema71.properties.stance.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data.proposedKind !== undefined){if(!(validate204(data.proposedKind, {instancePath:instancePath+"/proposedKind",parentData:data,parentDataProperty:"proposedKind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate204.errors : vErrors.concat(validate204.errors);errors = vErrors.length;}}if(data.trace !== undefined){if(!(validate206(data.trace, {instancePath:instancePath+"/trace",parentData:data,parentDataProperty:"trace",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate206.errors : vErrors.concat(validate206.errors);errors = vErrors.length;}}if(data.note !== undefined){let data9 = data.note;if(typeof data9 === "string"){if(func2(data9) > 1000){const err16 = {instancePath:instancePath+"/note",schemaPath:"#/properties/note/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}if(func2(data9) < 1){const err17 = {instancePath:instancePath+"/note",schemaPath:"#/properties/note/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}else {const err18 = {instancePath:instancePath+"/note",schemaPath:"#/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}}else {const err19 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}validate197.errors = vErrors;return errors === 0;}validate197.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema77 = {"description":"A labeler read another event in the same episode and found nothing to label, so it is not asked about that event again.","type":"object","additionalProperties":false,"required":["target"],"properties":{"target":{"$ref":"#/$defs/eventTarget"}}};function validate209(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate209.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.target === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "target"},message:"must have required property '"+"target"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(key0 === "target")){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.target !== undefined){if(!(validate198(data.target, {instancePath:instancePath+"/target",parentData:data,parentDataProperty:"target",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate198.errors : vErrors.concat(validate198.errors);errors = vErrors.length;}}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate209.errors = vErrors;return errors === 0;}validate209.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema78 = {"type":"object","additionalProperties":false,"required":["subject","status","at"],"properties":{"subject":{"type":"object","additionalProperties":false,"required":["kind","id"],"properties":{"kind":{"const":"thread"},"id":{"$ref":"common.schema.json#/$defs/positiveInteger"}}},"status":{"enum":["resolved","unresolved"]},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"by":{"$ref":"common.schema.json#/$defs/actor"}}};function validate215(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate215.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate215.errors = vErrors;return errors === 0;}validate215.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate212(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate212.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.subject === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "subject"},message:"must have required property '"+"subject"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.status === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "status"},message:"must have required property '"+"status"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.at === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!((((key0 === "subject") || (key0 === "status")) || (key0 === "at")) || (key0 === "by"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.subject !== undefined){let data0 = data.subject;if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.kind === undefined){const err4 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data0.id === undefined){const err5 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key1 in data0){if(!((key1 === "kind") || (key1 === "id"))){const err6 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.kind !== undefined){if("thread" !== data0.kind){const err7 = {instancePath:instancePath+"/subject/kind",schemaPath:"#/properties/subject/properties/kind/const",keyword:"const",params:{allowedValue: "thread"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data0.id !== undefined){if(!(validate186(data0.id, {instancePath:instancePath+"/subject/id",parentData:data0,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate186.errors : vErrors.concat(validate186.errors);errors = vErrors.length;}}}else {const err8 = {instancePath:instancePath+"/subject",schemaPath:"#/properties/subject/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.status !== undefined){let data3 = data.status;if(!((data3 === "resolved") || (data3 === "unresolved"))){const err9 = {instancePath:instancePath+"/status",schemaPath:"#/properties/status/enum",keyword:"enum",params:{allowedValues: schema78.properties.status.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.at !== undefined){if(!(validate189(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate189.errors : vErrors.concat(validate189.errors);errors = vErrors.length;}}if(data.by !== undefined){if(!(validate215(data.by, {instancePath:instancePath+"/by",parentData:data,parentDataProperty:"by",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate215.errors : vErrors.concat(validate215.errors);errors = vErrors.length;}}}else {const err10 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}validate212.errors = vErrors;return errors === 0;}validate212.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema80 = {"description":"Withdraws an earlier event from every purpose. The earlier event stays in history for audit.","type":"object","additionalProperties":false,"required":["target","reason","at"],"properties":{"target":{"$ref":"#/$defs/eventTarget"},"reason":{"enum":["deleted_at_source","withdrawn_by_author","identity_corrected","other"]},"at":{"$ref":"common.schema.json#/$defs/timestamp"}}};function validate219(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate219.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.target === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "target"},message:"must have required property '"+"target"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.reason === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "reason"},message:"must have required property '"+"reason"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.at === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!(((key0 === "target") || (key0 === "reason")) || (key0 === "at"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.target !== undefined){if(!(validate198(data.target, {instancePath:instancePath+"/target",parentData:data,parentDataProperty:"target",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate198.errors : vErrors.concat(validate198.errors);errors = vErrors.length;}}if(data.reason !== undefined){let data1 = data.reason;if(!((((data1 === "deleted_at_source") || (data1 === "withdrawn_by_author")) || (data1 === "identity_corrected")) || (data1 === "other"))){const err4 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/enum",keyword:"enum",params:{allowedValues: schema80.properties.reason.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.at !== undefined){if(!(validate189(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate189.errors : vErrors.concat(validate189.errors);errors = vErrors.length;}}}else {const err5 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}validate219.errors = vErrors;return errors === 0;}validate219.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema81 = {"type":"object","additionalProperties":false,"required":["memories"],"properties":{"memories":{"type":"array","maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["id","contentDigest"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"contentDigest":{"$ref":"common.schema.json#/$defs/digest"}}}},"task":{"type":"string","minLength":1,"maxLength":2000}}};function validate225(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate225.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate225.errors = vErrors;return errors === 0;}validate225.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate223(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate223.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.memories === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "memories"},message:"must have required property '"+"memories"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((key0 === "memories") || (key0 === "task"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.memories !== undefined){let data0 = data.memories;if(Array.isArray(data0)){if(data0.length > 200){const err2 = {instancePath:instancePath+"/memories",schemaPath:"#/properties/memories/maxItems",keyword:"maxItems",params:{limit: 200},message:"must NOT have more than 200 items"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}const len0 = data0.length;for(let i0=0; i0 2000){const err8 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(func2(data4) < 1){const err9 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}else {const err10 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}}else {const err11 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}validate223.errors = vErrors;return errors === 0;}validate223.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate230(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate230.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate230.errors = vErrors;return errors === 0;}validate230.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema84 = {"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"$ref":"#/$defs/slug"},"uri":{"type":"string","minLength":1,"maxLength":2048},"digest":{"$ref":"#/$defs/digest"},"mediaType":{"type":"string","minLength":3,"maxLength":128}}};function validate240(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate240.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((((key0 === "kind") || (key0 === "uri")) || (key0 === "digest")) || (key0 === "mediaType"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate59(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.uri !== undefined){let data1 = data.uri;if(typeof data1 === "string"){if(func2(data1) > 2048){const err2 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(func2(data1) < 1){const err3 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.digest !== undefined){if(!(validate178(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate178.errors : vErrors.concat(validate178.errors);errors = vErrors.length;}}if(data.mediaType !== undefined){let data3 = data.mediaType;if(typeof data3 === "string"){if(func2(data3) > 128){const err5 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(func2(data3) < 3){const err6 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}}else {const err8 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}validate240.errors = vErrors;return errors === 0;}validate240.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema85 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/evidence-ref.schema.json","title":"Replica evidence reference v1","description":"Points from a learning back to the exact events that support it, and pins them to their source.","type":"object","additionalProperties":false,"required":["episodeId","eventIds"],"properties":{"episodeId":{"$ref":"common.schema.json#/$defs/id"},"eventIds":{"type":"array","minItems":1,"maxItems":100,"items":{"$ref":"common.schema.json#/$defs/id"}},"source":{"$ref":"common.schema.json#/$defs/source"},"observedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"author":{"$ref":"common.schema.json#/$defs/actor"},"artifacts":{"type":"array","maxItems":20,"items":{"$ref":"common.schema.json#/$defs/artifactRef"}}}};function validate245(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate245.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate245.errors = vErrors;return errors === 0;}validate245.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate248(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate248.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(func1.call(schema32.properties, key0))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate80(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate80.errors : vErrors.concat(validate80.errors);errors = vErrors.length;}}if(data.hubOrigin !== undefined){if(!(validate82(data.hubOrigin, {instancePath:instancePath+"/hubOrigin",parentData:data,parentDataProperty:"hubOrigin",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate82.errors : vErrors.concat(validate82.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data2 = data.repository;if(typeof data2 === "string"){if(!pattern10.test(data2)){const err2 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.repositoryId !== undefined){if(!(validate84(data.repositoryId, {instancePath:instancePath+"/repositoryId",parentData:data,parentDataProperty:"repositoryId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeId !== undefined){if(!(validate84(data.prototypeId, {instancePath:instancePath+"/prototypeId",parentData:data,parentDataProperty:"prototypeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate84.errors : vErrors.concat(validate84.errors);errors = vErrors.length;}}if(data.prototypeName !== undefined){let data5 = data.prototypeName;if(typeof data5 === "string"){if(func2(data5) > 1024){const err4 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data5) < 1){const err5 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/prototypeName",schemaPath:"#/properties/prototypeName/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.branch !== undefined){let data6 = data.branch;if(typeof data6 === "string"){if(func2(data6) > 1024){const err7 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/maxLength",keyword:"maxLength",params:{limit: 1024},message:"must NOT have more than 1024 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data6) < 1){const err8 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/branch",schemaPath:"#/properties/branch/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.buildNumber !== undefined){if(!(validate85(data.buildNumber, {instancePath:instancePath+"/buildNumber",parentData:data,parentDataProperty:"buildNumber",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.buildId !== undefined){if(!(validate85(data.buildId, {instancePath:instancePath+"/buildId",parentData:data,parentDataProperty:"buildId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.commitSha !== undefined){if(!(validate91(data.commitSha, {instancePath:instancePath+"/commitSha",parentData:data,parentDataProperty:"commitSha",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate91.errors : vErrors.concat(validate91.errors);errors = vErrors.length;}}if(data.threadId !== undefined){if(!(validate85(data.threadId, {instancePath:instancePath+"/threadId",parentData:data,parentDataProperty:"threadId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.commentId !== undefined){if(!(validate85(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}if(data.sessionId !== undefined){let data12 = data.sessionId;if(typeof data12 === "string"){if(func2(data12) > 200){const err10 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data12) < 1){const err11 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/sessionId",schemaPath:"#/properties/sessionId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate248.errors = vErrors;return errors === 0;}validate248.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate259(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate259.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate259.errors = vErrors;return errors === 0;}validate259.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate261(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate261.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "kind") || (key0 === "id")) || (key0 === "role")) || (key0 === "login")) || (key0 === "model")) || (key0 === "asserted"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((data0 === "human") || (data0 === "agent")) || (data0 === "system")) || (data0 === "service"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema23.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.id !== undefined){let data1 = data.id;if(typeof data1 === "string"){if(func2(data1) > 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate261.errors = vErrors;return errors === 0;}validate261.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate264(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate264.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!((((key0 === "kind") || (key0 === "uri")) || (key0 === "digest")) || (key0 === "mediaType"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.kind !== undefined){if(!(validate59(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.uri !== undefined){let data1 = data.uri;if(typeof data1 === "string"){if(func2(data1) > 2048){const err2 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(func2(data1) < 1){const err3 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/uri",schemaPath:"#/properties/uri/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.digest !== undefined){if(!(validate178(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate178.errors : vErrors.concat(validate178.errors);errors = vErrors.length;}}if(data.mediaType !== undefined){let data3 = data.mediaType;if(typeof data3 === "string"){if(func2(data3) > 128){const err5 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(func2(data3) < 3){const err6 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/mediaType",schemaPath:"#/properties/mediaType/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}}else {const err8 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}validate264.errors = vErrors;return errors === 0;}validate264.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate244(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/evidence-ref.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate244.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.episodeId === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "episodeId"},message:"must have required property '"+"episodeId"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.eventIds === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "eventIds"},message:"must have required property '"+"eventIds"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((((((key0 === "episodeId") || (key0 === "eventIds")) || (key0 === "source")) || (key0 === "observedAt")) || (key0 === "author")) || (key0 === "artifacts"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.episodeId !== undefined){if(!(validate245(data.episodeId, {instancePath:instancePath+"/episodeId",parentData:data,parentDataProperty:"episodeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate245.errors : vErrors.concat(validate245.errors);errors = vErrors.length;}}if(data.eventIds !== undefined){let data1 = data.eventIds;if(Array.isArray(data1)){if(data1.length > 100){const err3 = {instancePath:instancePath+"/eventIds",schemaPath:"#/properties/eventIds/maxItems",keyword:"maxItems",params:{limit: 100},message:"must NOT have more than 100 items"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data1.length < 1){const err4 = {instancePath:instancePath+"/eventIds",schemaPath:"#/properties/eventIds/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}const len0 = data1.length;for(let i0=0; i0 20){const err6 = {instancePath:instancePath+"/artifacts",schemaPath:"#/properties/artifacts/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}const len1 = data6.length;for(let i1=0; i1 1000){const err4 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/maxLength",keyword:"maxLength",params:{limit: 1000},message:"must NOT have more than 1000 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data2) < 1){const err5 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.commentId !== undefined){if(!(validate85(data.commentId, {instancePath:instancePath+"/commentId",parentData:data,parentDataProperty:"commentId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate85.errors : vErrors.concat(validate85.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate269.errors = vErrors;return errors === 0;}validate269.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const pattern55 = new RegExp("^x-[a-z0-9-]+\\.[a-z0-9_]+$", "u");function validate184(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/event.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate184.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.redaction === undefined) && (missing0 = "redaction")){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs4 = errors;const _errs5 = errors;const _errs6 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing1;if((data.payload === undefined) && (missing1 = "payload")){const err1 = {};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var valid2 = _errs6 === errors;if(valid2){const err2 = {instancePath,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs5;if(vErrors !== null){if(_errs5){vErrors.length = _errs5;}else {vErrors = null;}}}var _valid0 = _errs4 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs7 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload === undefined){const err3 = {instancePath,schemaPath:"#/allOf/0/else/required",keyword:"required",params:{missingProperty: "payload"},message:"must have required property '"+"payload"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var _valid0 = _errs7 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}const _errs9 = errors;let valid3 = true;const _errs10 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing2;if((data.type === undefined) && (missing2 = "type")){const err5 = {};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}else {if(data.type !== undefined){if("human_comment" !== data.type){const err6 = {};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}}var _valid1 = _errs10 === errors;errors = _errs9;if(vErrors !== null){if(_errs9){vErrors.length = _errs9;}else {vErrors = null;}}if(_valid1){const _errs12 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload !== undefined){if(!(validate185(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate185.errors : vErrors.concat(validate185.errors);errors = vErrors.length;}}}var _valid1 = _errs12 === errors;valid3 = _valid1;if(valid3){var props0 = {};props0.payload = true;props0.type = true;}}if(!valid3){const err7 = {instancePath,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}const _errs15 = errors;let valid6 = true;const _errs16 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing3;if((data.type === undefined) && (missing3 = "type")){const err8 = {};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}else {if(data.type !== undefined){if("annotation" !== data.type){const err9 = {};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}}}var _valid2 = _errs16 === errors;errors = _errs15;if(vErrors !== null){if(_errs15){vErrors.length = _errs15;}else {vErrors = null;}}if(_valid2){const _errs18 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.parentEventId === undefined){const err10 = {instancePath,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty: "parentEventId"},message:"must have required property '"+"parentEventId"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.payload !== undefined){if(!(validate197(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate197.errors : vErrors.concat(validate197.errors);errors = vErrors.length;}}}var _valid2 = _errs18 === errors;valid6 = _valid2;if(valid6){var props1 = {};props1.payload = true;props1.type = true;}}if(!valid6){const err11 = {instancePath,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}if(props0 !== true && props1 !== undefined){if(props1 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props1);}}const _errs21 = errors;let valid9 = true;const _errs22 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing4;if((data.type === undefined) && (missing4 = "type")){const err12 = {};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}else {if(data.type !== undefined){if("no_annotation" !== data.type){const err13 = {};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}}var _valid3 = _errs22 === errors;errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}if(_valid3){const _errs24 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.parentEventId === undefined){const err14 = {instancePath,schemaPath:"#/allOf/3/then/required",keyword:"required",params:{missingProperty: "parentEventId"},message:"must have required property '"+"parentEventId"+"'"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data.payload !== undefined){if(!(validate209(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate209.errors : vErrors.concat(validate209.errors);errors = vErrors.length;}}}var _valid3 = _errs24 === errors;valid9 = _valid3;if(valid9){var props2 = {};props2.payload = true;props2.type = true;}}if(!valid9){const err15 = {instancePath,schemaPath:"#/allOf/3/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}if(props0 !== true && props2 !== undefined){if(props2 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props2);}}const _errs27 = errors;let valid12 = true;const _errs28 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing5;if((data.type === undefined) && (missing5 = "type")){const err16 = {};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}else {if(data.type !== undefined){if("status_change" !== data.type){const err17 = {};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}}}var _valid4 = _errs28 === errors;errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}if(_valid4){const _errs30 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload !== undefined){if(!(validate212(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate212.errors : vErrors.concat(validate212.errors);errors = vErrors.length;}}}var _valid4 = _errs30 === errors;valid12 = _valid4;if(valid12){var props3 = {};props3.payload = true;props3.type = true;}}if(!valid12){const err18 = {instancePath,schemaPath:"#/allOf/4/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}if(props0 !== true && props3 !== undefined){if(props3 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props3);}}const _errs33 = errors;let valid15 = true;const _errs34 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing6;if((data.type === undefined) && (missing6 = "type")){const err19 = {};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}else {if(data.type !== undefined){if("retraction" !== data.type){const err20 = {};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}}}var _valid5 = _errs34 === errors;errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}if(_valid5){const _errs36 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.parentEventId === undefined){const err21 = {instancePath,schemaPath:"#/allOf/5/then/required",keyword:"required",params:{missingProperty: "parentEventId"},message:"must have required property '"+"parentEventId"+"'"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(data.payload !== undefined){if(!(validate219(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate219.errors : vErrors.concat(validate219.errors);errors = vErrors.length;}}}var _valid5 = _errs36 === errors;valid15 = _valid5;if(valid15){var props4 = {};props4.payload = true;props4.type = true;}}if(!valid15){const err22 = {instancePath,schemaPath:"#/allOf/5/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}if(props0 !== true && props4 !== undefined){if(props4 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props4);}}const _errs39 = errors;let valid18 = true;const _errs40 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing7;if((data.type === undefined) && (missing7 = "type")){const err23 = {};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}else {if(data.type !== undefined){if("memory_retrieved" !== data.type){const err24 = {};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}}}var _valid6 = _errs40 === errors;errors = _errs39;if(vErrors !== null){if(_errs39){vErrors.length = _errs39;}else {vErrors = null;}}if(_valid6){const _errs42 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.payload !== undefined){if(!(validate223(data.payload, {instancePath:instancePath+"/payload",parentData:data,parentDataProperty:"payload",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate223.errors : vErrors.concat(validate223.errors);errors = vErrors.length;}}}var _valid6 = _errs42 === errors;valid18 = _valid6;if(valid18){var props5 = {};props5.payload = true;props5.type = true;}}if(!valid18){const err25 = {instancePath,schemaPath:"#/allOf/6/if",keyword:"if",params:{failingKeyword: "then"},message:"must match \"then\" schema"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}if(props0 !== true && props5 !== undefined){if(props5 === true){props0 = true;}else {props0 = props0 || {};Object.assign(props0, props5);}}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err26 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}if(data.id === undefined){const err27 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(data.episodeId === undefined){const err28 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "episodeId"},message:"must have required property '"+"episodeId"+"'"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}if(data.scope === undefined){const err29 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}if(data.type === undefined){const err30 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}if(data.at === undefined){const err31 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}if(data.actor === undefined){const err32 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "actor"},message:"must have required property '"+"actor"+"'"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}if(data.payloadDigest === undefined){const err33 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "payloadDigest"},message:"must have required property '"+"payloadDigest"+"'"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}if(data.digest === undefined){const err34 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}for(const key0 in data){if(!(func1.call(schema66.properties, key0))){const err35 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data.schemaVersion !== undefined){if("replica.event/v1" !== data.schemaVersion){const err36 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.event/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data.id !== undefined){if(!(validate199(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate199.errors : vErrors.concat(validate199.errors);errors = vErrors.length;}}if(data.episodeId !== undefined){if(!(validate199(data.episodeId, {instancePath:instancePath+"/episodeId",parentData:data,parentDataProperty:"episodeId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate199.errors : vErrors.concat(validate199.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate230(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate230.errors : vErrors.concat(validate230.errors);errors = vErrors.length;}}if(data.type !== undefined){let data16 = data.type;const _errs50 = errors;let valid22 = false;const _errs51 = errors;if(!((((((((((((((((((((((((data16 === "user_message") || (data16 === "agent_message")) || (data16 === "human_comment")) || (data16 === "human_correction")) || (data16 === "human_approval")) || (data16 === "human_rejection")) || (data16 === "tool_call")) || (data16 === "tool_result")) || (data16 === "ui_snapshot")) || (data16 === "ui_interaction")) || (data16 === "build_created")) || (data16 === "audio_segment")) || (data16 === "voice_turn")) || (data16 === "agent_to_agent_message")) || (data16 === "evaluation_result")) || (data16 === "criterion_result")) || (data16 === "memory_retrieved")) || (data16 === "memory_proposed")) || (data16 === "handoff")) || (data16 === "error")) || (data16 === "annotation")) || (data16 === "no_annotation")) || (data16 === "status_change")) || (data16 === "retraction"))){const err37 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/0/enum",keyword:"enum",params:{allowedValues: schema66.properties.type.anyOf[0].enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}var _valid7 = _errs51 === errors;valid22 = valid22 || _valid7;const _errs52 = errors;if(typeof data16 === "string"){if(func2(data16) > 128){const err38 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/1/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}if(!pattern55.test(data16)){const err39 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^x-[a-z0-9-]+\\.[a-z0-9_]+$"},message:"must match pattern \""+"^x-[a-z0-9-]+\\.[a-z0-9_]+$"+"\""};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}else {const err40 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf/1/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}var _valid7 = _errs52 === errors;valid22 = valid22 || _valid7;if(!valid22){const err41 = {instancePath:instancePath+"/type",schemaPath:"#/properties/type/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}else {errors = _errs50;if(vErrors !== null){if(_errs50){vErrors.length = _errs50;}else {vErrors = null;}}}}if(data.at !== undefined){if(!(validate189(data.at, {instancePath:instancePath+"/at",parentData:data,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate189.errors : vErrors.concat(validate189.errors);errors = vErrors.length;}}if(data.actor !== undefined){if(!(validate215(data.actor, {instancePath:instancePath+"/actor",parentData:data,parentDataProperty:"actor",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate215.errors : vErrors.concat(validate215.errors);errors = vErrors.length;}}if(data.payload !== undefined){let data19 = data.payload;if(!(data19 && typeof data19 == "object" && !Array.isArray(data19))){const err42 = {instancePath:instancePath+"/payload",schemaPath:"#/properties/payload/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data.payloadDigest !== undefined){if(!(validate225(data.payloadDigest, {instancePath:instancePath+"/payloadDigest",parentData:data,parentDataProperty:"payloadDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate225.errors : vErrors.concat(validate225.errors);errors = vErrors.length;}}if(data.parentEventId !== undefined){if(!(validate199(data.parentEventId, {instancePath:instancePath+"/parentEventId",parentData:data,parentDataProperty:"parentEventId",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate199.errors : vErrors.concat(validate199.errors);errors = vErrors.length;}}if(data.supersedes !== undefined){if(!(validate199(data.supersedes, {instancePath:instancePath+"/supersedes",parentData:data,parentDataProperty:"supersedes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate199.errors : vErrors.concat(validate199.errors);errors = vErrors.length;}}if(data.artifactRefs !== undefined){let data23 = data.artifactRefs;if(Array.isArray(data23)){if(data23.length > 20){const err43 = {instancePath:instancePath+"/artifactRefs",schemaPath:"#/properties/artifactRefs/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}const len0 = data23.length;for(let i0=0; i0 100){const err45 = {instancePath:instancePath+"/evidenceRefs",schemaPath:"#/properties/evidenceRefs/maxItems",keyword:"maxItems",params:{limit: 100},message:"must NOT have more than 100 items"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}const len1 = data25.length;for(let i1=0; i1 10000){const err12 = {instancePath:instancePath+"/task/prompt",schemaPath:"#/properties/task/properties/prompt/maxLength",keyword:"maxLength",params:{limit: 10000},message:"must NOT have more than 10000 characters"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(func2(data5) < 1){const err13 = {instancePath:instancePath+"/task/prompt",schemaPath:"#/properties/task/properties/prompt/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}else {const err14 = {instancePath:instancePath+"/task/prompt",schemaPath:"#/properties/task/properties/prompt/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data4.goal !== undefined){let data6 = data4.goal;if(typeof data6 === "string"){if(func2(data6) > 2000){const err15 = {instancePath:instancePath+"/task/goal",schemaPath:"#/properties/task/properties/goal/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}if(func2(data6) < 1){const err16 = {instancePath:instancePath+"/task/goal",schemaPath:"#/properties/task/properties/goal/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}else {const err17 = {instancePath:instancePath+"/task/goal",schemaPath:"#/properties/task/properties/goal/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data4.role !== undefined){if(!(validate162(data4.role, {instancePath:instancePath+"/task/role",parentData:data4,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate162.errors : vErrors.concat(validate162.errors);errors = vErrors.length;}}if(data4.taskId !== undefined){let data8 = data4.taskId;if(typeof data8 === "string"){if(func2(data8) > 200){const err18 = {instancePath:instancePath+"/task/taskId",schemaPath:"#/properties/task/properties/taskId/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}if(func2(data8) < 1){const err19 = {instancePath:instancePath+"/task/taskId",schemaPath:"#/properties/task/properties/taskId/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}else {const err20 = {instancePath:instancePath+"/task/taskId",schemaPath:"#/properties/task/properties/taskId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}}else {const err21 = {instancePath:instancePath+"/task",schemaPath:"#/properties/task/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data.actors !== undefined){let data9 = data.actors;if(Array.isArray(data9)){if(data9.length > 500){const err22 = {instancePath:instancePath+"/actors",schemaPath:"#/properties/actors/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}const len0 = data9.length;for(let i0=0; i0 200){const err25 = {instancePath:instancePath+"/versions/model",schemaPath:"#/properties/versions/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}if(func2(data12) < 1){const err26 = {instancePath:instancePath+"/versions/model",schemaPath:"#/properties/versions/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}else {const err27 = {instancePath:instancePath+"/versions/model",schemaPath:"#/properties/versions/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}if(data11.harness !== undefined){let data13 = data11.harness;if(typeof data13 === "string"){if(func2(data13) > 200){const err28 = {instancePath:instancePath+"/versions/harness",schemaPath:"#/properties/versions/properties/harness/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}if(func2(data13) < 1){const err29 = {instancePath:instancePath+"/versions/harness",schemaPath:"#/properties/versions/properties/harness/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}else {const err30 = {instancePath:instancePath+"/versions/harness",schemaPath:"#/properties/versions/properties/harness/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data11.designSystem !== undefined){let data14 = data11.designSystem;if(typeof data14 === "string"){if(func2(data14) > 200){const err31 = {instancePath:instancePath+"/versions/designSystem",schemaPath:"#/properties/versions/properties/designSystem/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}if(func2(data14) < 1){const err32 = {instancePath:instancePath+"/versions/designSystem",schemaPath:"#/properties/versions/properties/designSystem/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}else {const err33 = {instancePath:instancePath+"/versions/designSystem",schemaPath:"#/properties/versions/properties/designSystem/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data11.brandPack !== undefined){let data15 = data11.brandPack;if(typeof data15 === "string"){if(func2(data15) > 200){const err34 = {instancePath:instancePath+"/versions/brandPack",schemaPath:"#/properties/versions/properties/brandPack/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}if(func2(data15) < 1){const err35 = {instancePath:instancePath+"/versions/brandPack",schemaPath:"#/properties/versions/properties/brandPack/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}else {const err36 = {instancePath:instancePath+"/versions/brandPack",schemaPath:"#/properties/versions/properties/brandPack/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data11.memorySnapshot !== undefined){if(!(validate167(data11.memorySnapshot, {instancePath:instancePath+"/versions/memorySnapshot",parentData:data11,parentDataProperty:"memorySnapshot",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate167.errors : vErrors.concat(validate167.errors);errors = vErrors.length;}}}else {const err37 = {instancePath:instancePath+"/versions",schemaPath:"#/properties/versions/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}if(data.grants !== undefined){let data17 = data.grants;if(Array.isArray(data17)){if(data17.length > 20){const err38 = {instancePath:instancePath+"/grants",schemaPath:"#/properties/grants/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}if(data17.length < 1){const err39 = {instancePath:instancePath+"/grants",schemaPath:"#/properties/grants/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}const len1 = data17.length;for(let i1=0; i1 2000){const err50 = {instancePath:instancePath+"/outcome/summary",schemaPath:"#/properties/outcome/properties/summary/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}if(func2(data28) < 1){const err51 = {instancePath:instancePath+"/outcome/summary",schemaPath:"#/properties/outcome/properties/summary/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}else {const err52 = {instancePath:instancePath+"/outcome/summary",schemaPath:"#/properties/outcome/properties/summary/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}}else {const err53 = {instancePath:instancePath+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data.timeline !== undefined){let data29 = data.timeline;if(Array.isArray(data29)){if(data29.length > 100000){const err54 = {instancePath:instancePath+"/timeline",schemaPath:"#/properties/timeline/maxItems",keyword:"maxItems",params:{limit: 100000},message:"must NOT have more than 100000 items"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}const len2 = data29.length;for(let i2=0; i2 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate282.errors = vErrors;return errors === 0;}validate282.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate287(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate287.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate287.errors = vErrors;return errors === 0;}validate287.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate289(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate289.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(validate132(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate132.errors : vErrors.concat(validate132.errors);errors = vErrors.length;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind !== undefined){if("human" !== data.kind){const err0 = {instancePath:instancePath+"/kind",schemaPath:"#/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "human"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}else {const err1 = {instancePath,schemaPath:"#/allOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate289.errors = vErrors;return errors === 0;}validate289.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate292(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate292.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate292.errors = vErrors;return errors === 0;}validate292.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate294(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate294.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 0 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate294.errors = vErrors;return errors === 0;}validate294.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate302(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate302.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate302.errors = vErrors;return errors === 0;}validate302.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate277(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/export-manifest.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate277.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.purpose === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "purpose"},message:"must have required property '"+"purpose"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.scope === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "scope"},message:"must have required property '"+"scope"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.createdAt === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.createdBy === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdBy"},message:"must have required property '"+"createdBy"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.provider === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "provider"},message:"must have required property '"+"provider"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.destination === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "destination"},message:"must have required property '"+"destination"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(data.counts === undefined){const err8 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "counts"},message:"must have required property '"+"counts"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data.excluded === undefined){const err9 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "excluded"},message:"must have required property '"+"excluded"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(data.records === undefined){const err10 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "records"},message:"must have required property '"+"records"+"'"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(data.digest === undefined){const err11 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "digest"},message:"must have required property '"+"digest"+"'"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}for(const key0 in data){if(!(func1.call(schema92.properties, key0))){const err12 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.schemaVersion !== undefined){if("replica.export/v1" !== data.schemaVersion){const err13 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.export/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data.id !== undefined){if(!(validate278(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate278.errors : vErrors.concat(validate278.errors);errors = vErrors.length;}}if(data.purpose !== undefined){if(!(validate280(data.purpose, {instancePath:instancePath+"/purpose",parentData:data,parentDataProperty:"purpose",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate280.errors : vErrors.concat(validate280.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate282(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate282.errors : vErrors.concat(validate282.errors);errors = vErrors.length;}}if(data.createdAt !== undefined){if(!(validate287(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate287.errors : vErrors.concat(validate287.errors);errors = vErrors.length;}}if(data.createdBy !== undefined){if(!(validate289(data.createdBy, {instancePath:instancePath+"/createdBy",parentData:data,parentDataProperty:"createdBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate289.errors : vErrors.concat(validate289.errors);errors = vErrors.length;}}if(data.provider !== undefined){let data6 = data.provider;if(data6 && typeof data6 == "object" && !Array.isArray(data6)){if(data6.id === undefined){const err14 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data6.version === undefined){const err15 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}for(const key1 in data6){if(!((key1 === "id") || (key1 === "version"))){const err16 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data6.id !== undefined){if(!(validate292(data6.id, {instancePath:instancePath+"/provider/id",parentData:data6,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate292.errors : vErrors.concat(validate292.errors);errors = vErrors.length;}}if(data6.version !== undefined){let data8 = data6.version;if(typeof data8 === "string"){if(func2(data8) > 64){const err17 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}if(func2(data8) < 1){const err18 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}else {const err19 = {instancePath:instancePath+"/provider/version",schemaPath:"#/properties/provider/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}}else {const err20 = {instancePath:instancePath+"/provider",schemaPath:"#/properties/provider/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}if(data.destination !== undefined){let data9 = data.destination;if(typeof data9 === "string"){if(func2(data9) > 2048){const err21 = {instancePath:instancePath+"/destination",schemaPath:"#/properties/destination/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}if(func2(data9) < 1){const err22 = {instancePath:instancePath+"/destination",schemaPath:"#/properties/destination/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/destination",schemaPath:"#/properties/destination/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data.contents !== undefined){let data10 = data.contents;if(!((data10 === "all") || (data10 === "learnings"))){const err24 = {instancePath:instancePath+"/contents",schemaPath:"#/properties/contents/enum",keyword:"enum",params:{allowedValues: schema92.properties.contents.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data.counts !== undefined){let data11 = data.counts;if(data11 && typeof data11 == "object" && !Array.isArray(data11)){if(data11.episodes === undefined){const err25 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "episodes"},message:"must have required property '"+"episodes"+"'"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}if(data11.events === undefined){const err26 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "events"},message:"must have required property '"+"events"+"'"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}if(data11.memories === undefined){const err27 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "memories"},message:"must have required property '"+"memories"+"'"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(data11.grants === undefined){const err28 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/required",keyword:"required",params:{missingProperty: "grants"},message:"must have required property '"+"grants"+"'"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}for(const key2 in data11){if(!((((key2 === "episodes") || (key2 === "events")) || (key2 === "memories")) || (key2 === "grants"))){const err29 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data11.episodes !== undefined){if(!(validate294(data11.episodes, {instancePath:instancePath+"/counts/episodes",parentData:data11,parentDataProperty:"episodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate294.errors : vErrors.concat(validate294.errors);errors = vErrors.length;}}if(data11.events !== undefined){if(!(validate294(data11.events, {instancePath:instancePath+"/counts/events",parentData:data11,parentDataProperty:"events",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate294.errors : vErrors.concat(validate294.errors);errors = vErrors.length;}}if(data11.memories !== undefined){if(!(validate294(data11.memories, {instancePath:instancePath+"/counts/memories",parentData:data11,parentDataProperty:"memories",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate294.errors : vErrors.concat(validate294.errors);errors = vErrors.length;}}if(data11.grants !== undefined){if(!(validate294(data11.grants, {instancePath:instancePath+"/counts/grants",parentData:data11,parentDataProperty:"grants",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate294.errors : vErrors.concat(validate294.errors);errors = vErrors.length;}}}else {const err30 = {instancePath:instancePath+"/counts",schemaPath:"#/properties/counts/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data.excluded !== undefined){let data16 = data.excluded;if(Array.isArray(data16)){if(data16.length > 50){const err31 = {instancePath:instancePath+"/excluded",schemaPath:"#/properties/excluded/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}const len0 = data16.length;for(let i0=0; i0 1000000){const err37 = {instancePath:instancePath+"/records",schemaPath:"#/properties/records/maxItems",keyword:"maxItems",params:{limit: 1000000},message:"must NOT have more than 1000000 items"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}const len1 = data20.length;for(let i1=0; i1 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate309.errors = vErrors;return errors === 0;}validate309.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate314(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate314.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 6){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 6},message:"must NOT have more than 6 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.length < 1){const err1 = {instancePath,schemaPath:"#/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}const len0 = data.length;for(let i0=0; i0 2000){const err10 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data7) < 1){const err11 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.digest !== undefined){if(!(validate322(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate322.errors : vErrors.concat(validate322.errors);errors = vErrors.length;}}}else {const err13 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}validate305.errors = vErrors;return errors === 0;}validate305.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.memoryProposal = validate324;const schema108 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/memory-proposal.schema.json","title":"Replica memory proposal v1","description":"What a consolidator returns. It never sets an ID, a scope, or a state: the host assigns the ID, takes the scope from the caller, and stores every proposal as proposed until a person reviews it.","type":"object","additionalProperties":false,"required":["schemaVersion","kind","content","evidence","rationale","lifecycle","consolidator"],"properties":{"schemaVersion":{"const":"replica.memory-proposal/v1"},"kind":{"$ref":"common.schema.json#/$defs/memoryKind"},"content":{"type":"string","minLength":1,"maxLength":4000},"themeKey":{"$ref":"common.schema.json#/$defs/slug"},"appliesTo":{"type":"array","maxItems":20,"items":{"$ref":"common.schema.json#/$defs/trace"}},"evidence":{"type":"array","minItems":1,"maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"contradictions":{"type":"array","maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"support":{"$ref":"memory-record.schema.json#/$defs/support"},"confidence":{"type":"number","minimum":0,"maximum":1},"rationale":{"$ref":"#/$defs/rationale"},"lifecycle":{"$ref":"#/$defs/lifecycle"},"consolidator":{"$ref":"#/$defs/consolidator"},"validFrom":{"$ref":"common.schema.json#/$defs/timestamp"},"validUntil":{"$ref":"common.schema.json#/$defs/timestamp"},"expiresAt":{"$ref":"common.schema.json#/$defs/timestamp"}},"$defs":{"consolidator":{"type":"object","additionalProperties":false,"required":["id","version"],"properties":{"id":{"$ref":"common.schema.json#/$defs/slug"},"version":{"type":"string","minLength":1,"maxLength":64}}},"rationale":{"description":"Why the learning recurs, what contradicts it, what it should improve, and how we would know it is wrong.","type":"object","additionalProperties":false,"required":["recurrence","expectedBenefit","falsification"],"properties":{"recurrence":{"type":"string","minLength":1,"maxLength":2000},"contradictions":{"type":"string","minLength":1,"maxLength":2000},"expectedBenefit":{"type":"string","minLength":1,"maxLength":2000},"falsification":{"type":"string","minLength":1,"maxLength":2000}}},"lifecycle":{"type":"object","additionalProperties":false,"required":["action"],"properties":{"action":{"enum":["new","merge","supersede","retire"]},"targets":{"type":"array","minItems":1,"maxItems":50,"items":{"$ref":"common.schema.json#/$defs/id"}}},"allOf":[{"if":{"properties":{"action":{"const":"new"}}},"then":{"not":{"required":["targets"]}},"else":{"required":["targets"]}}]}}};function validate325(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate325.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((((((data === "fact") || (data === "preference")) || (data === "rule")) || (data === "procedure")) || (data === "example")) || (data === "anti_pattern")) || (data === "design_principle"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate325.errors = vErrors;return errors === 0;}validate325.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate327(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate327.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate327.errors = vErrors;return errors === 0;}validate327.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate329(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate329.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.ref === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "ref"},message:"must have required property '"+"ref"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "kind") || (key0 === "ref"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((((data0 === "rule") || (data0 === "skill")) || (data0 === "component")) || (data0 === "context")) || (data0 === "token")) || (data0 === "other"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema76.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.ref !== undefined){let data1 = data.ref;if(typeof data1 === "string"){if(func2(data1) > 500){const err4 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 1){const err5 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate329.errors = vErrors;return errors === 0;}validate329.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema119 = {"description":"Distinct sources behind a learning. Count distinct episodes, prototypes, Builds, and reviewers, never raw comments.","type":"object","additionalProperties":false,"required":["distinctEpisodes","distinctPrototypes","distinctReviewers","distinctBuilds"],"properties":{"distinctEpisodes":{"$ref":"common.schema.json#/$defs/count"},"distinctPrototypes":{"$ref":"common.schema.json#/$defs/count"},"distinctReviewers":{"$ref":"common.schema.json#/$defs/count"},"distinctBuilds":{"$ref":"common.schema.json#/$defs/count"}}};function validate352(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate352.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((typeof data == "number") && (!(data % 1) && !isNaN(data))) && (isFinite(data)))){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if((typeof data == "number") && (isFinite(data))){if(data > 9007199254740991 || isNaN(data)){const err1 = {instancePath,schemaPath:"#/maximum",keyword:"maximum",params:{comparison: "<=", limit: 9007199254740991},message:"must be <= 9007199254740991"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data < 0 || isNaN(data)){const err2 = {instancePath,schemaPath:"#/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}validate352.errors = vErrors;return errors === 0;}validate352.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate399(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate399.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.distinctEpisodes === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctEpisodes"},message:"must have required property '"+"distinctEpisodes"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.distinctPrototypes === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctPrototypes"},message:"must have required property '"+"distinctPrototypes"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.distinctReviewers === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctReviewers"},message:"must have required property '"+"distinctReviewers"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.distinctBuilds === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctBuilds"},message:"must have required property '"+"distinctBuilds"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((key0 === "distinctEpisodes") || (key0 === "distinctPrototypes")) || (key0 === "distinctReviewers")) || (key0 === "distinctBuilds"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.distinctEpisodes !== undefined){if(!(validate352(data.distinctEpisodes, {instancePath:instancePath+"/distinctEpisodes",parentData:data,parentDataProperty:"distinctEpisodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}if(data.distinctPrototypes !== undefined){if(!(validate352(data.distinctPrototypes, {instancePath:instancePath+"/distinctPrototypes",parentData:data,parentDataProperty:"distinctPrototypes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}if(data.distinctReviewers !== undefined){if(!(validate352(data.distinctReviewers, {instancePath:instancePath+"/distinctReviewers",parentData:data,parentDataProperty:"distinctReviewers",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}if(data.distinctBuilds !== undefined){if(!(validate352(data.distinctBuilds, {instancePath:instancePath+"/distinctBuilds",parentData:data,parentDataProperty:"distinctBuilds",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}}else {const err5 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}validate399.errors = vErrors;return errors === 0;}validate399.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema123 = {"description":"Why the learning recurs, what contradicts it, what it should improve, and how we would know it is wrong.","type":"object","additionalProperties":false,"required":["recurrence","expectedBenefit","falsification"],"properties":{"recurrence":{"type":"string","minLength":1,"maxLength":2000},"contradictions":{"type":"string","minLength":1,"maxLength":2000},"expectedBenefit":{"type":"string","minLength":1,"maxLength":2000},"falsification":{"type":"string","minLength":1,"maxLength":2000}}};function validate405(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate405.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.recurrence === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "recurrence"},message:"must have required property '"+"recurrence"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.expectedBenefit === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "expectedBenefit"},message:"must have required property '"+"expectedBenefit"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.falsification === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "falsification"},message:"must have required property '"+"falsification"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!((((key0 === "recurrence") || (key0 === "contradictions")) || (key0 === "expectedBenefit")) || (key0 === "falsification"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.recurrence !== undefined){let data0 = data.recurrence;if(typeof data0 === "string"){if(func2(data0) > 2000){const err4 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data0) < 1){const err5 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.contradictions !== undefined){let data1 = data.contradictions;if(typeof data1 === "string"){if(func2(data1) > 2000){const err7 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data1) < 1){const err8 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.expectedBenefit !== undefined){let data2 = data.expectedBenefit;if(typeof data2 === "string"){if(func2(data2) > 2000){const err10 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data2) < 1){const err11 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.falsification !== undefined){let data3 = data.falsification;if(typeof data3 === "string"){if(func2(data3) > 2000){const err13 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(func2(data3) < 1){const err14 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}validate405.errors = vErrors;return errors === 0;}validate405.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const schema124 = {"type":"object","additionalProperties":false,"required":["action"],"properties":{"action":{"enum":["new","merge","supersede","retire"]},"targets":{"type":"array","minItems":1,"maxItems":50,"items":{"$ref":"common.schema.json#/$defs/id"}}},"allOf":[{"if":{"properties":{"action":{"const":"new"}}},"then":{"not":{"required":["targets"]}},"else":{"required":["targets"]}}]};function validate371(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate371.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate371.errors = vErrors;return errors === 0;}validate371.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate407(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate407.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.action !== undefined){if("new" !== data.action){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs5 = errors;const _errs6 = errors;const _errs7 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.targets === undefined) && (missing0 = "targets")){const err1 = {};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var valid3 = _errs7 === errors;if(valid3){const err2 = {instancePath,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs6;if(vErrors !== null){if(_errs6){vErrors.length = _errs6;}else {vErrors = null;}}}var _valid0 = _errs5 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs8 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.targets === undefined){const err3 = {instancePath,schemaPath:"#/allOf/0/else/required",keyword:"required",params:{missingProperty: "targets"},message:"must have required property '"+"targets"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var _valid0 = _errs8 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.action === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "action"},message:"must have required property '"+"action"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!((key0 === "action") || (key0 === "targets"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.action !== undefined){let data1 = data.action;if(!((((data1 === "new") || (data1 === "merge")) || (data1 === "supersede")) || (data1 === "retire"))){const err7 = {instancePath:instancePath+"/action",schemaPath:"#/properties/action/enum",keyword:"enum",params:{allowedValues: schema124.properties.action.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.targets !== undefined){let data2 = data.targets;if(Array.isArray(data2)){if(data2.length > 50){const err8 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data2.length < 1){const err9 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}const len0 = data2.length;for(let i0=0; i0 64){const err3 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(func2(data1) < 1){const err4 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}}else {const err6 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}validate410.errors = vErrors;return errors === 0;}validate410.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate413(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate413.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate413.errors = vErrors;return errors === 0;}validate413.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate324(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/memory-proposal.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate324.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.kind === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.content === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "content"},message:"must have required property '"+"content"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.evidence === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "evidence"},message:"must have required property '"+"evidence"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.rationale === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "rationale"},message:"must have required property '"+"rationale"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.lifecycle === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lifecycle"},message:"must have required property '"+"lifecycle"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.consolidator === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "consolidator"},message:"must have required property '"+"consolidator"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}for(const key0 in data){if(!(func1.call(schema108.properties, key0))){const err7 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.schemaVersion !== undefined){if("replica.memory-proposal/v1" !== data.schemaVersion){const err8 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.memory-proposal/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.kind !== undefined){if(!(validate325(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate325.errors : vErrors.concat(validate325.errors);errors = vErrors.length;}}if(data.content !== undefined){let data2 = data.content;if(typeof data2 === "string"){if(func2(data2) > 4000){const err9 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/maxLength",keyword:"maxLength",params:{limit: 4000},message:"must NOT have more than 4000 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}if(func2(data2) < 1){const err10 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}else {const err11 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data.themeKey !== undefined){if(!(validate327(data.themeKey, {instancePath:instancePath+"/themeKey",parentData:data,parentDataProperty:"themeKey",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate327.errors : vErrors.concat(validate327.errors);errors = vErrors.length;}}if(data.appliesTo !== undefined){let data4 = data.appliesTo;if(Array.isArray(data4)){if(data4.length > 20){const err12 = {instancePath:instancePath+"/appliesTo",schemaPath:"#/properties/appliesTo/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}const len0 = data4.length;for(let i0=0; i0 500){const err14 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}if(data6.length < 1){const err15 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}const len1 = data6.length;for(let i1=0; i1 500){const err17 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}const len2 = data8.length;for(let i2=0; i2 1 || isNaN(data11)){const err19 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1},message:"must be <= 1"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data11 < 0 || isNaN(data11)){const err20 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}else {const err21 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data.rationale !== undefined){if(!(validate405(data.rationale, {instancePath:instancePath+"/rationale",parentData:data,parentDataProperty:"rationale",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate405.errors : vErrors.concat(validate405.errors);errors = vErrors.length;}}if(data.lifecycle !== undefined){if(!(validate407(data.lifecycle, {instancePath:instancePath+"/lifecycle",parentData:data,parentDataProperty:"lifecycle",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate407.errors : vErrors.concat(validate407.errors);errors = vErrors.length;}}if(data.consolidator !== undefined){if(!(validate410(data.consolidator, {instancePath:instancePath+"/consolidator",parentData:data,parentDataProperty:"consolidator",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate410.errors : vErrors.concat(validate410.errors);errors = vErrors.length;}}if(data.validFrom !== undefined){if(!(validate413(data.validFrom, {instancePath:instancePath+"/validFrom",parentData:data,parentDataProperty:"validFrom",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate413.errors : vErrors.concat(validate413.errors);errors = vErrors.length;}}if(data.validUntil !== undefined){if(!(validate413(data.validUntil, {instancePath:instancePath+"/validUntil",parentData:data,parentDataProperty:"validUntil",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate413.errors : vErrors.concat(validate413.errors);errors = vErrors.length;}}if(data.expiresAt !== undefined){if(!(validate413(data.expiresAt, {instancePath:instancePath+"/expiresAt",parentData:data,parentDataProperty:"expiresAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate413.errors : vErrors.concat(validate413.errors);errors = vErrors.length;}}}else {const err22 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}validate324.errors = vErrors;return errors === 0;}validate324.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.memoryRecord = validate333;const schema112 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/memory-record.schema.json","title":"Replica memory record v1","description":"One version of an explicit learning. Every lifecycle change appends a new version with the next version number and previousDigest. contentDigest identifies the learning itself: scope, kind, content, targets, lifecycle, evidence, and validity dates; an approval is valid only while accepted.contentDigest equals it. reviewDigest covers everything a reviewer is shown, adding contradictions, support, confidence, rationale, and the proposer; accepting or rejecting requires the reviewDigest the person reviewed.","type":"object","additionalProperties":false,"required":["schemaVersion","id","version","scope","kind","state","content","evidence","contentDigest","reviewDigest","proposal","provenance","createdAt","updatedAt","digest"],"properties":{"schemaVersion":{"const":"replica.memory/v1"},"id":{"$ref":"common.schema.json#/$defs/id"},"version":{"type":"integer","minimum":1,"maximum":1000000},"previousDigest":{"$ref":"common.schema.json#/$defs/digest"},"scope":{"$ref":"common.schema.json#/$defs/scope"},"kind":{"$ref":"common.schema.json#/$defs/memoryKind"},"state":{"enum":["proposed","accepted","rejected","retired"]},"content":{"type":"string","minLength":1,"maxLength":4000},"themeKey":{"$ref":"common.schema.json#/$defs/slug"},"appliesTo":{"type":"array","maxItems":20,"items":{"$ref":"common.schema.json#/$defs/trace"}},"evidence":{"type":"array","minItems":1,"maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"contradictions":{"type":"array","maxItems":500,"items":{"$ref":"evidence-ref.schema.json"}},"support":{"$ref":"#/$defs/support"},"confidence":{"description":"Optional metadata from the proposer. Never a measure of truth.","type":"number","minimum":0,"maximum":1},"validFrom":{"$ref":"common.schema.json#/$defs/timestamp"},"validUntil":{"$ref":"common.schema.json#/$defs/timestamp"},"expiresAt":{"$ref":"common.schema.json#/$defs/timestamp"},"supersedes":{"description":"Learnings this accepted learning replaces. Acceptance sets it from the reviewed lifecycle targets, and a later step may only add to it. No ID repeats. A proposed or rejected learning never carries it. Replaced learnings keep their own state; readers derive which replacement wins.","type":"array","minItems":1,"maxItems":50,"items":{"$ref":"common.schema.json#/$defs/id"}},"contentDigest":{"$ref":"common.schema.json#/$defs/digest"},"reviewDigest":{"$ref":"common.schema.json#/$defs/digest"},"proposal":{"type":"object","additionalProperties":false,"required":["consolidator","rationale","lifecycle","proposedAt","proposedBy","proposalDigest"],"properties":{"consolidator":{"$ref":"memory-proposal.schema.json#/$defs/consolidator"},"rationale":{"$ref":"memory-proposal.schema.json#/$defs/rationale"},"lifecycle":{"$ref":"memory-proposal.schema.json#/$defs/lifecycle"},"proposedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"proposedBy":{"$ref":"common.schema.json#/$defs/actor"},"proposalDigest":{"$ref":"common.schema.json#/$defs/digest"}}},"accepted":{"type":"object","additionalProperties":false,"required":["by","at","contentDigest","reviewedDigest","edited"],"properties":{"by":{"$ref":"common.schema.json#/$defs/humanActor"},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"contentDigest":{"$ref":"common.schema.json#/$defs/digest"},"reviewedDigest":{"$ref":"common.schema.json#/$defs/digest"},"edited":{"type":"boolean"},"operationId":{"type":"string","pattern":"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"},"note":{"type":"string","minLength":1,"maxLength":2000}}},"rejected":{"type":"object","additionalProperties":false,"required":["by","at","reviewedDigest","reason"],"properties":{"by":{"$ref":"common.schema.json#/$defs/humanActor"},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"reviewedDigest":{"$ref":"common.schema.json#/$defs/digest"},"reason":{"type":"string","minLength":1,"maxLength":2000},"operationId":{"type":"string","pattern":"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"}}},"retired":{"type":"object","additionalProperties":false,"required":["at","reason"],"properties":{"by":{"$ref":"common.schema.json#/$defs/humanActor"},"at":{"$ref":"common.schema.json#/$defs/timestamp"},"reason":{"type":"string","minLength":1,"maxLength":2000},"operationId":{"type":"string","pattern":"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"}}},"provenance":{"$ref":"common.schema.json#/$defs/provenance"},"createdAt":{"$ref":"common.schema.json#/$defs/timestamp"},"updatedAt":{"$ref":"common.schema.json#/$defs/timestamp"},"digest":{"$ref":"common.schema.json#/$defs/digest"}},"allOf":[{"if":{"properties":{"version":{"const":1}}},"then":{"not":{"required":["previousDigest"]}},"else":{"required":["previousDigest"]}},{"if":{"properties":{"state":{"const":"proposed"}}},"then":{"not":{"anyOf":[{"required":["accepted"]},{"required":["rejected"]},{"required":["retired"]},{"required":["supersedes"]}]}}},{"if":{"properties":{"state":{"const":"accepted"}}},"then":{"required":["accepted"],"not":{"anyOf":[{"required":["rejected"]},{"required":["retired"]}]}}},{"if":{"properties":{"state":{"const":"rejected"}}},"then":{"required":["rejected"],"not":{"anyOf":[{"required":["accepted"]},{"required":["retired"]},{"required":["supersedes"]}]}}},{"if":{"properties":{"state":{"const":"retired"}}},"then":{"required":["accepted","retired"],"not":{"required":["rejected"]}}}],"$defs":{"support":{"description":"Distinct sources behind a learning. Count distinct episodes, prototypes, Builds, and reviewers, never raw comments.","type":"object","additionalProperties":false,"required":["distinctEpisodes","distinctPrototypes","distinctReviewers","distinctBuilds"],"properties":{"distinctEpisodes":{"$ref":"common.schema.json#/$defs/count"},"distinctPrototypes":{"$ref":"common.schema.json#/$defs/count"},"distinctReviewers":{"$ref":"common.schema.json#/$defs/count"},"distinctBuilds":{"$ref":"common.schema.json#/$defs/count"}}}}};function validate334(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate334.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern3.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"},message:"must match pattern \""+"^[a-z][a-z0-9]{1,15}_[A-Za-z0-9_-]{8,128}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate334.errors = vErrors;return errors === 0;}validate334.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate336(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate336.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern11.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^sha256:[0-9a-f]{64}$"},message:"must match pattern \""+"^sha256:[0-9a-f]{64}$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}else {const err1 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate336.errors = vErrors;return errors === 0;}validate336.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate338(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate338.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(Object.keys(data).length < 1){const err0 = {instancePath,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}for(const key0 in data){if(!(((((key0 === "host") || (key0 === "organization")) || (key0 === "team")) || (key0 === "repository")) || (key0 === "product"))){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.host !== undefined){let data0 = data.host;if(typeof data0 === "string"){if(func2(data0) > 261){const err2 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/maxLength",keyword:"maxLength",params:{limit: 261},message:"must NOT have more than 261 characters"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(!pattern8.test(data0)){const err3 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/host",schemaPath:"#/properties/host/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.organization !== undefined){if(!(validate63(data.organization, {instancePath:instancePath+"/organization",parentData:data,parentDataProperty:"organization",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.team !== undefined){if(!(validate63(data.team, {instancePath:instancePath+"/team",parentData:data,parentDataProperty:"team",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}if(data.repository !== undefined){let data3 = data.repository;if(typeof data3 === "string"){if(!pattern10.test(data3)){const err5 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"},message:"must match pattern \""+"^[a-z0-9_.-]{1,100}/[a-z0-9_.-]{1,100}$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.product !== undefined){if(!(validate63(data.product, {instancePath:instancePath+"/product",parentData:data,parentDataProperty:"product",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate63.errors : vErrors.concat(validate63.errors);errors = vErrors.length;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate338.errors = vErrors;return errors === 0;}validate338.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate343(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate343.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(((((((data === "fact") || (data === "preference")) || (data === "rule")) || (data === "procedure")) || (data === "example")) || (data === "anti_pattern")) || (data === "design_principle"))){const err0 = {instancePath,schemaPath:"#/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}validate343.errors = vErrors;return errors === 0;}validate343.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate345(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate345.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate345.errors = vErrors;return errors === 0;}validate345.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate347(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate347.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.ref === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "ref"},message:"must have required property '"+"ref"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "kind") || (key0 === "ref"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.kind !== undefined){let data0 = data.kind;if(!((((((data0 === "rule") || (data0 === "skill")) || (data0 === "component")) || (data0 === "context")) || (data0 === "token")) || (data0 === "other"))){const err3 = {instancePath:instancePath+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues: schema76.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.ref !== undefined){let data1 = data.ref;if(typeof data1 === "string"){if(func2(data1) > 500){const err4 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/maxLength",keyword:"maxLength",params:{limit: 500},message:"must NOT have more than 500 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 1){const err5 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/ref",schemaPath:"#/properties/ref/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate347.errors = vErrors;return errors === 0;}validate347.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate351(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate351.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.distinctEpisodes === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctEpisodes"},message:"must have required property '"+"distinctEpisodes"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.distinctPrototypes === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctPrototypes"},message:"must have required property '"+"distinctPrototypes"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.distinctReviewers === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctReviewers"},message:"must have required property '"+"distinctReviewers"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.distinctBuilds === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "distinctBuilds"},message:"must have required property '"+"distinctBuilds"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((key0 === "distinctEpisodes") || (key0 === "distinctPrototypes")) || (key0 === "distinctReviewers")) || (key0 === "distinctBuilds"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.distinctEpisodes !== undefined){if(!(validate352(data.distinctEpisodes, {instancePath:instancePath+"/distinctEpisodes",parentData:data,parentDataProperty:"distinctEpisodes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}if(data.distinctPrototypes !== undefined){if(!(validate352(data.distinctPrototypes, {instancePath:instancePath+"/distinctPrototypes",parentData:data,parentDataProperty:"distinctPrototypes",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}if(data.distinctReviewers !== undefined){if(!(validate352(data.distinctReviewers, {instancePath:instancePath+"/distinctReviewers",parentData:data,parentDataProperty:"distinctReviewers",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}if(data.distinctBuilds !== undefined){if(!(validate352(data.distinctBuilds, {instancePath:instancePath+"/distinctBuilds",parentData:data,parentDataProperty:"distinctBuilds",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate352.errors : vErrors.concat(validate352.errors);errors = vErrors.length;}}}else {const err5 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}validate351.errors = vErrors;return errors === 0;}validate351.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate358(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate358.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(!pattern4.test(data)){const err0 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"},message:"must match pattern \""+"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"+"\""};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(!(formats0(data))){const err1 = {instancePath,schemaPath:"#/format",keyword:"format",params:{format: "date-time"},message:"must match format \""+"date-time"+"\""};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}else {const err2 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}validate358.errors = vErrors;return errors === 0;}validate358.evaluated = {"dynamicProps":false,"dynamicItems":false};function validate365(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate365.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.id === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.version === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "id") || (key0 === "version"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.id !== undefined){if(!(validate327(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate327.errors : vErrors.concat(validate327.errors);errors = vErrors.length;}}if(data.version !== undefined){let data1 = data.version;if(typeof data1 === "string"){if(func2(data1) > 64){const err3 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(func2(data1) < 1){const err4 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}else {const err5 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}}else {const err6 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}validate365.errors = vErrors;return errors === 0;}validate365.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate368(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate368.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.recurrence === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "recurrence"},message:"must have required property '"+"recurrence"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.expectedBenefit === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "expectedBenefit"},message:"must have required property '"+"expectedBenefit"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.falsification === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "falsification"},message:"must have required property '"+"falsification"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}for(const key0 in data){if(!((((key0 === "recurrence") || (key0 === "contradictions")) || (key0 === "expectedBenefit")) || (key0 === "falsification"))){const err3 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}if(data.recurrence !== undefined){let data0 = data.recurrence;if(typeof data0 === "string"){if(func2(data0) > 2000){const err4 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data0) < 1){const err5 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/recurrence",schemaPath:"#/properties/recurrence/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.contradictions !== undefined){let data1 = data.contradictions;if(typeof data1 === "string"){if(func2(data1) > 2000){const err7 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func2(data1) < 1){const err8 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.expectedBenefit !== undefined){let data2 = data.expectedBenefit;if(typeof data2 === "string"){if(func2(data2) > 2000){const err10 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data2) < 1){const err11 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/expectedBenefit",schemaPath:"#/properties/expectedBenefit/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.falsification !== undefined){let data3 = data.falsification;if(typeof data3 === "string"){if(func2(data3) > 2000){const err13 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(func2(data3) < 1){const err14 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/falsification",schemaPath:"#/properties/falsification/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}validate368.errors = vErrors;return errors === 0;}validate368.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate370(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate370.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}const _errs2 = errors;let valid1 = true;const _errs3 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.action !== undefined){if("new" !== data.action){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}var _valid0 = _errs3 === errors;errors = _errs2;if(vErrors !== null){if(_errs2){vErrors.length = _errs2;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs5 = errors;const _errs6 = errors;const _errs7 = errors;if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.targets === undefined) && (missing0 = "targets")){const err1 = {};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}var valid3 = _errs7 === errors;if(valid3){const err2 = {instancePath,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}else {errors = _errs6;if(vErrors !== null){if(_errs6){vErrors.length = _errs6;}else {vErrors = null;}}}var _valid0 = _errs5 === errors;valid1 = _valid0;ifClause0 = "then";}else {const _errs8 = errors;if(data && typeof data == "object" && !Array.isArray(data)){if(data.targets === undefined){const err3 = {instancePath,schemaPath:"#/allOf/0/else/required",keyword:"required",params:{missingProperty: "targets"},message:"must have required property '"+"targets"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}var _valid0 = _errs8 === errors;valid1 = _valid0;ifClause0 = "else";}if(!valid1){const err4 = {instancePath,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.action === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "action"},message:"must have required property '"+"action"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!((key0 === "action") || (key0 === "targets"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.action !== undefined){let data1 = data.action;if(!((((data1 === "new") || (data1 === "merge")) || (data1 === "supersede")) || (data1 === "retire"))){const err7 = {instancePath:instancePath+"/action",schemaPath:"#/properties/action/enum",keyword:"enum",params:{allowedValues: schema124.properties.action.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.targets !== undefined){let data2 = data.targets;if(Array.isArray(data2)){if(data2.length > 50){const err8 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}if(data2.length < 1){const err9 = {instancePath:instancePath+"/targets",schemaPath:"#/properties/targets/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}const len0 = data2.length;for(let i0=0; i0 300){const err4 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/maxLength",keyword:"maxLength",params:{limit: 300},message:"must NOT have more than 300 characters"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(func2(data1) < 3){const err5 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit: 3},message:"must NOT have fewer than 3 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern5.test(data1)){const err6 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/pattern",keyword:"pattern",params:{pattern: "^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"},message:"must match pattern \""+"^[a-z][a-z0-9-]*:[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.role !== undefined){if(!(validate59(data.role, {instancePath:instancePath+"/role",parentData:data,parentDataProperty:"role",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate59.errors : vErrors.concat(validate59.errors);errors = vErrors.length;}}if(data.login !== undefined){let data3 = data.login;if(typeof data3 === "string"){if(!pattern7.test(data3)){const err8 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/pattern",keyword:"pattern",params:{pattern: "^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"},message:"must match pattern \""+"^[^\\s\\p{Cc}\\p{Cf}\\u{E0000}-\\u{E007F}]{1,256}$"+"\""};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/login",schemaPath:"#/properties/login/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.model !== undefined){let data4 = data.model;if(typeof data4 === "string"){if(func2(data4) > 200){const err10 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data4) < 1){const err11 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/model",schemaPath:"#/properties/model/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.asserted !== undefined){if(typeof data.asserted !== "boolean"){const err13 = {instancePath:instancePath+"/asserted",schemaPath:"#/properties/asserted/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}}else {const err14 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}validate375.errors = vErrors;return errors === 0;}validate375.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate379(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate379.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(!(validate132(data, {instancePath,parentData,parentDataProperty,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate132.errors : vErrors.concat(validate132.errors);errors = vErrors.length;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.kind !== undefined){if("human" !== data.kind){const err0 = {instancePath:instancePath+"/kind",schemaPath:"#/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue: "human"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}}}else {const err1 = {instancePath,schemaPath:"#/allOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}validate379.errors = vErrors;return errors === 0;}validate379.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate390(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate390.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.producer === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "producer"},message:"must have required property '"+"producer"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.method === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "method"},message:"must have required property '"+"method"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.createdAt === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdAt"},message:"must have required property '"+"createdAt"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.createdBy === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "createdBy"},message:"must have required property '"+"createdBy"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!(((((key0 === "producer") || (key0 === "method")) || (key0 === "createdAt")) || (key0 === "createdBy")) || (key0 === "inputs"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.producer !== undefined){if(!(validate173(data.producer, {instancePath:instancePath+"/producer",parentData:data,parentDataProperty:"producer",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate173.errors : vErrors.concat(validate173.errors);errors = vErrors.length;}}if(data.method !== undefined){let data1 = data.method;if(typeof data1 === "string"){if(func2(data1) > 128){const err5 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(!pattern43.test(data1)){const err6 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/pattern",keyword:"pattern",params:{pattern: "^[a-z]+:[a-z0-9_.-]+$"},message:"must match pattern \""+"^[a-z]+:[a-z0-9_.-]+$"+"\""};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}else {const err7 = {instancePath:instancePath+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.createdAt !== undefined){if(!(validate175(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate175.errors : vErrors.concat(validate175.errors);errors = vErrors.length;}}if(data.createdBy !== undefined){if(!(validate132(data.createdBy, {instancePath:instancePath+"/createdBy",parentData:data,parentDataProperty:"createdBy",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate132.errors : vErrors.concat(validate132.errors);errors = vErrors.length;}}if(data.inputs !== undefined){let data4 = data.inputs;if(Array.isArray(data4)){if(data4.length > 1000){const err8 = {instancePath:instancePath+"/inputs",schemaPath:"#/properties/inputs/maxItems",keyword:"maxItems",params:{limit: 1000},message:"must NOT have more than 1000 items"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}const len0 = data4.length;for(let i0=0; i0 1000000 || isNaN(data7)){const err52 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1000000},message:"must be <= 1000000"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}if(data7 < 1 || isNaN(data7)){const err53 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}}if(data.previousDigest !== undefined){if(!(validate336(data.previousDigest, {instancePath:instancePath+"/previousDigest",parentData:data,parentDataProperty:"previousDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate336.errors : vErrors.concat(validate336.errors);errors = vErrors.length;}}if(data.scope !== undefined){if(!(validate338(data.scope, {instancePath:instancePath+"/scope",parentData:data,parentDataProperty:"scope",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate338.errors : vErrors.concat(validate338.errors);errors = vErrors.length;}}if(data.kind !== undefined){if(!(validate343(data.kind, {instancePath:instancePath+"/kind",parentData:data,parentDataProperty:"kind",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate343.errors : vErrors.concat(validate343.errors);errors = vErrors.length;}}if(data.state !== undefined){let data11 = data.state;if(!((((data11 === "proposed") || (data11 === "accepted")) || (data11 === "rejected")) || (data11 === "retired"))){const err54 = {instancePath:instancePath+"/state",schemaPath:"#/properties/state/enum",keyword:"enum",params:{allowedValues: schema112.properties.state.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data.content !== undefined){let data12 = data.content;if(typeof data12 === "string"){if(func2(data12) > 4000){const err55 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/maxLength",keyword:"maxLength",params:{limit: 4000},message:"must NOT have more than 4000 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}if(func2(data12) < 1){const err56 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}else {const err57 = {instancePath:instancePath+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data.themeKey !== undefined){if(!(validate345(data.themeKey, {instancePath:instancePath+"/themeKey",parentData:data,parentDataProperty:"themeKey",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate345.errors : vErrors.concat(validate345.errors);errors = vErrors.length;}}if(data.appliesTo !== undefined){let data14 = data.appliesTo;if(Array.isArray(data14)){if(data14.length > 20){const err58 = {instancePath:instancePath+"/appliesTo",schemaPath:"#/properties/appliesTo/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}const len0 = data14.length;for(let i0=0; i0 500){const err60 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}if(data16.length < 1){const err61 = {instancePath:instancePath+"/evidence",schemaPath:"#/properties/evidence/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}const len1 = data16.length;for(let i1=0; i1 500){const err63 = {instancePath:instancePath+"/contradictions",schemaPath:"#/properties/contradictions/maxItems",keyword:"maxItems",params:{limit: 500},message:"must NOT have more than 500 items"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}const len2 = data18.length;for(let i2=0; i2 1 || isNaN(data21)){const err65 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1},message:"must be <= 1"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}if(data21 < 0 || isNaN(data21)){const err66 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}else {const err67 = {instancePath:instancePath+"/confidence",schemaPath:"#/properties/confidence/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data.validFrom !== undefined){if(!(validate358(data.validFrom, {instancePath:instancePath+"/validFrom",parentData:data,parentDataProperty:"validFrom",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data.validUntil !== undefined){if(!(validate358(data.validUntil, {instancePath:instancePath+"/validUntil",parentData:data,parentDataProperty:"validUntil",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data.expiresAt !== undefined){if(!(validate358(data.expiresAt, {instancePath:instancePath+"/expiresAt",parentData:data,parentDataProperty:"expiresAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data.supersedes !== undefined){let data25 = data.supersedes;if(Array.isArray(data25)){if(data25.length > 50){const err68 = {instancePath:instancePath+"/supersedes",schemaPath:"#/properties/supersedes/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}if(data25.length < 1){const err69 = {instancePath:instancePath+"/supersedes",schemaPath:"#/properties/supersedes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}const len3 = data25.length;for(let i3=0; i3 2000){const err88 = {instancePath:instancePath+"/accepted/note",schemaPath:"#/properties/accepted/properties/note/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}if(func2(data43) < 1){const err89 = {instancePath:instancePath+"/accepted/note",schemaPath:"#/properties/accepted/properties/note/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}else {const err90 = {instancePath:instancePath+"/accepted/note",schemaPath:"#/properties/accepted/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}}else {const err91 = {instancePath:instancePath+"/accepted",schemaPath:"#/properties/accepted/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}}if(data.rejected !== undefined){let data44 = data.rejected;if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.by === undefined){const err92 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "by"},message:"must have required property '"+"by"+"'"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}if(data44.at === undefined){const err93 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}if(data44.reviewedDigest === undefined){const err94 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "reviewedDigest"},message:"must have required property '"+"reviewedDigest"+"'"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}if(data44.reason === undefined){const err95 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/required",keyword:"required",params:{missingProperty: "reason"},message:"must have required property '"+"reason"+"'"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}for(const key3 in data44){if(!(((((key3 === "by") || (key3 === "at")) || (key3 === "reviewedDigest")) || (key3 === "reason")) || (key3 === "operationId"))){const err96 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}if(data44.by !== undefined){if(!(validate379(data44.by, {instancePath:instancePath+"/rejected/by",parentData:data44,parentDataProperty:"by",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate379.errors : vErrors.concat(validate379.errors);errors = vErrors.length;}}if(data44.at !== undefined){if(!(validate358(data44.at, {instancePath:instancePath+"/rejected/at",parentData:data44,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data44.reviewedDigest !== undefined){if(!(validate336(data44.reviewedDigest, {instancePath:instancePath+"/rejected/reviewedDigest",parentData:data44,parentDataProperty:"reviewedDigest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate336.errors : vErrors.concat(validate336.errors);errors = vErrors.length;}}if(data44.reason !== undefined){let data48 = data44.reason;if(typeof data48 === "string"){if(func2(data48) > 2000){const err97 = {instancePath:instancePath+"/rejected/reason",schemaPath:"#/properties/rejected/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}if(func2(data48) < 1){const err98 = {instancePath:instancePath+"/rejected/reason",schemaPath:"#/properties/rejected/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}else {const err99 = {instancePath:instancePath+"/rejected/reason",schemaPath:"#/properties/rejected/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data44.operationId !== undefined){let data49 = data44.operationId;if(typeof data49 === "string"){if(!pattern17.test(data49)){const err100 = {instancePath:instancePath+"/rejected/operationId",schemaPath:"#/properties/rejected/properties/operationId/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"},message:"must match pattern \""+"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"+"\""};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}}else {const err101 = {instancePath:instancePath+"/rejected/operationId",schemaPath:"#/properties/rejected/properties/operationId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}}else {const err102 = {instancePath:instancePath+"/rejected",schemaPath:"#/properties/rejected/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(data.retired !== undefined){let data50 = data.retired;if(data50 && typeof data50 == "object" && !Array.isArray(data50)){if(data50.at === undefined){const err103 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/required",keyword:"required",params:{missingProperty: "at"},message:"must have required property '"+"at"+"'"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}if(data50.reason === undefined){const err104 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/required",keyword:"required",params:{missingProperty: "reason"},message:"must have required property '"+"reason"+"'"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}for(const key4 in data50){if(!((((key4 === "by") || (key4 === "at")) || (key4 === "reason")) || (key4 === "operationId"))){const err105 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}if(data50.by !== undefined){if(!(validate379(data50.by, {instancePath:instancePath+"/retired/by",parentData:data50,parentDataProperty:"by",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate379.errors : vErrors.concat(validate379.errors);errors = vErrors.length;}}if(data50.at !== undefined){if(!(validate358(data50.at, {instancePath:instancePath+"/retired/at",parentData:data50,parentDataProperty:"at",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data50.reason !== undefined){let data53 = data50.reason;if(typeof data53 === "string"){if(func2(data53) > 2000){const err106 = {instancePath:instancePath+"/retired/reason",schemaPath:"#/properties/retired/properties/reason/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}if(func2(data53) < 1){const err107 = {instancePath:instancePath+"/retired/reason",schemaPath:"#/properties/retired/properties/reason/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}else {const err108 = {instancePath:instancePath+"/retired/reason",schemaPath:"#/properties/retired/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}}if(data50.operationId !== undefined){let data54 = data50.operationId;if(typeof data54 === "string"){if(!pattern17.test(data54)){const err109 = {instancePath:instancePath+"/retired/operationId",schemaPath:"#/properties/retired/properties/operationId/pattern",keyword:"pattern",params:{pattern: "^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"},message:"must match pattern \""+"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"+"\""};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}else {const err110 = {instancePath:instancePath+"/retired/operationId",schemaPath:"#/properties/retired/properties/operationId/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}}else {const err111 = {instancePath:instancePath+"/retired",schemaPath:"#/properties/retired/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}}if(data.provenance !== undefined){if(!(validate390(data.provenance, {instancePath:instancePath+"/provenance",parentData:data,parentDataProperty:"provenance",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate390.errors : vErrors.concat(validate390.errors);errors = vErrors.length;}}if(data.createdAt !== undefined){if(!(validate358(data.createdAt, {instancePath:instancePath+"/createdAt",parentData:data,parentDataProperty:"createdAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data.updatedAt !== undefined){if(!(validate358(data.updatedAt, {instancePath:instancePath+"/updatedAt",parentData:data,parentDataProperty:"updatedAt",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate358.errors : vErrors.concat(validate358.errors);errors = vErrors.length;}}if(data.digest !== undefined){if(!(validate336(data.digest, {instancePath:instancePath+"/digest",parentData:data,parentDataProperty:"digest",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate336.errors : vErrors.concat(validate336.errors);errors = vErrors.length;}}}else {const err112 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}validate333.errors = vErrors;return errors === 0;}validate333.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};exports.providerManifest = validate417;const schema134 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/github/replica/learning/v1/provider-manifest.schema.json","title":"Replica memory provider manifest v1","description":"What a memory provider is, which contract versions it supports, which capabilities it offers, and where its data goes. A host checks this before use and refuses a provider that lacks a required capability.","type":"object","additionalProperties":false,"required":["schemaVersion","id","name","version","contract","capabilities","storage","externalCalls"],"properties":{"schemaVersion":{"const":"replica.provider/v1"},"id":{"$ref":"common.schema.json#/$defs/slug"},"name":{"type":"string","minLength":1,"maxLength":200},"version":{"type":"string","minLength":1,"maxLength":64},"contract":{"type":"object","additionalProperties":false,"required":["name","versions"],"properties":{"name":{"const":"replica.memory-provider"},"versions":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"integer","minimum":1,"maximum":1000}}}},"capabilities":{"description":"Required by v1 hosts: observation.append, observation.query, memory.store, memory.query, memory.lifecycle, grant.store, audit.store. Optional examples: memory.semantic_search, memory.graph_query, memory.temporal_query, memory.compaction, memory.consolidate.","type":"array","minItems":1,"maxItems":64,"items":{"type":"string","maxLength":64,"pattern":"^[a-z]+(?:\\.[a-z_]+)+$"}},"storage":{"type":"object","additionalProperties":false,"required":["kind"],"properties":{"kind":{"enum":["local","memory","remote"]},"location":{"description":"A non-secret description such as a directory or service name. Never a credential.","type":"string","minLength":1,"maxLength":2048}}},"externalCalls":{"description":"Hosts this provider sends data to. Empty for a provider that stays on the machine.","type":"array","maxItems":50,"items":{"type":"string","minLength":1,"maxLength":255,"pattern":"^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"}},"dataRetention":{"type":"string","minLength":1,"maxLength":2000}}};function validate418(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate418.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(typeof data === "string"){if(func2(data) > 128){const err0 = {instancePath,schemaPath:"#/maxLength",keyword:"maxLength",params:{limit: 128},message:"must NOT have more than 128 characters"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(func2(data) < 1){const err1 = {instancePath,schemaPath:"#/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(!pattern6.test(data)){const err2 = {instancePath,schemaPath:"#/pattern",keyword:"pattern",params:{pattern: "^[a-z0-9]+(?:[._-][a-z0-9]+)*$"},message:"must match pattern \""+"^[a-z0-9]+(?:[._-][a-z0-9]+)*$"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}validate418.errors = vErrors;return errors === 0;}validate418.evaluated = {"dynamicProps":false,"dynamicItems":false};const pattern88 = new RegExp("^[a-z]+(?:\\.[a-z_]+)+$", "u");const pattern89 = new RegExp("^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$", "u");function validate417(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/github/replica/learning/v1/provider-manifest.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate417.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schemaVersion === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schemaVersion"},message:"must have required property '"+"schemaVersion"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.id === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.name === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.version === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "version"},message:"must have required property '"+"version"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.contract === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "contract"},message:"must have required property '"+"contract"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.capabilities === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "capabilities"},message:"must have required property '"+"capabilities"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}if(data.storage === undefined){const err6 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "storage"},message:"must have required property '"+"storage"+"'"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}if(data.externalCalls === undefined){const err7 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "externalCalls"},message:"must have required property '"+"externalCalls"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}for(const key0 in data){if(!(func1.call(schema134.properties, key0))){const err8 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.schemaVersion !== undefined){if("replica.provider/v1" !== data.schemaVersion){const err9 = {instancePath:instancePath+"/schemaVersion",schemaPath:"#/properties/schemaVersion/const",keyword:"const",params:{allowedValue: "replica.provider/v1"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data.id !== undefined){if(!(validate418(data.id, {instancePath:instancePath+"/id",parentData:data,parentDataProperty:"id",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate418.errors : vErrors.concat(validate418.errors);errors = vErrors.length;}}if(data.name !== undefined){let data2 = data.name;if(typeof data2 === "string"){if(func2(data2) > 200){const err10 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/maxLength",keyword:"maxLength",params:{limit: 200},message:"must NOT have more than 200 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}if(func2(data2) < 1){const err11 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data.version !== undefined){let data3 = data.version;if(typeof data3 === "string"){if(func2(data3) > 64){const err13 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}if(func2(data3) < 1){const err14 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data.contract !== undefined){let data4 = data.contract;if(data4 && typeof data4 == "object" && !Array.isArray(data4)){if(data4.name === undefined){const err16 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/required",keyword:"required",params:{missingProperty: "name"},message:"must have required property '"+"name"+"'"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}if(data4.versions === undefined){const err17 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/required",keyword:"required",params:{missingProperty: "versions"},message:"must have required property '"+"versions"+"'"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}for(const key1 in data4){if(!((key1 === "name") || (key1 === "versions"))){const err18 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data4.name !== undefined){if("replica.memory-provider" !== data4.name){const err19 = {instancePath:instancePath+"/contract/name",schemaPath:"#/properties/contract/properties/name/const",keyword:"const",params:{allowedValue: "replica.memory-provider"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}if(data4.versions !== undefined){let data6 = data4.versions;if(Array.isArray(data6)){if(data6.length > 20){const err20 = {instancePath:instancePath+"/contract/versions",schemaPath:"#/properties/contract/properties/versions/maxItems",keyword:"maxItems",params:{limit: 20},message:"must NOT have more than 20 items"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}if(data6.length < 1){const err21 = {instancePath:instancePath+"/contract/versions",schemaPath:"#/properties/contract/properties/versions/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}const len0 = data6.length;for(let i0=0; i0 1000 || isNaN(data7)){const err23 = {instancePath:instancePath+"/contract/versions/" + i0,schemaPath:"#/properties/contract/properties/versions/items/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1000},message:"must be <= 1000"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}if(data7 < 1 || isNaN(data7)){const err24 = {instancePath:instancePath+"/contract/versions/" + i0,schemaPath:"#/properties/contract/properties/versions/items/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}}}else {const err25 = {instancePath:instancePath+"/contract/versions",schemaPath:"#/properties/contract/properties/versions/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}}else {const err26 = {instancePath:instancePath+"/contract",schemaPath:"#/properties/contract/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}if(data.capabilities !== undefined){let data8 = data.capabilities;if(Array.isArray(data8)){if(data8.length > 64){const err27 = {instancePath:instancePath+"/capabilities",schemaPath:"#/properties/capabilities/maxItems",keyword:"maxItems",params:{limit: 64},message:"must NOT have more than 64 items"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}if(data8.length < 1){const err28 = {instancePath:instancePath+"/capabilities",schemaPath:"#/properties/capabilities/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}const len1 = data8.length;for(let i1=0; i1 64){const err29 = {instancePath:instancePath+"/capabilities/" + i1,schemaPath:"#/properties/capabilities/items/maxLength",keyword:"maxLength",params:{limit: 64},message:"must NOT have more than 64 characters"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}if(!pattern88.test(data9)){const err30 = {instancePath:instancePath+"/capabilities/" + i1,schemaPath:"#/properties/capabilities/items/pattern",keyword:"pattern",params:{pattern: "^[a-z]+(?:\\.[a-z_]+)+$"},message:"must match pattern \""+"^[a-z]+(?:\\.[a-z_]+)+$"+"\""};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}else {const err31 = {instancePath:instancePath+"/capabilities/" + i1,schemaPath:"#/properties/capabilities/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}}else {const err32 = {instancePath:instancePath+"/capabilities",schemaPath:"#/properties/capabilities/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data.storage !== undefined){let data10 = data.storage;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.kind === undefined){const err33 = {instancePath:instancePath+"/storage",schemaPath:"#/properties/storage/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}for(const key2 in data10){if(!((key2 === "kind") || (key2 === "location"))){const err34 = {instancePath:instancePath+"/storage",schemaPath:"#/properties/storage/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data10.kind !== undefined){let data11 = data10.kind;if(!(((data11 === "local") || (data11 === "memory")) || (data11 === "remote"))){const err35 = {instancePath:instancePath+"/storage/kind",schemaPath:"#/properties/storage/properties/kind/enum",keyword:"enum",params:{allowedValues: schema134.properties.storage.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data10.location !== undefined){let data12 = data10.location;if(typeof data12 === "string"){if(func2(data12) > 2048){const err36 = {instancePath:instancePath+"/storage/location",schemaPath:"#/properties/storage/properties/location/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}if(func2(data12) < 1){const err37 = {instancePath:instancePath+"/storage/location",schemaPath:"#/properties/storage/properties/location/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}else {const err38 = {instancePath:instancePath+"/storage/location",schemaPath:"#/properties/storage/properties/location/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}}else {const err39 = {instancePath:instancePath+"/storage",schemaPath:"#/properties/storage/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}if(data.externalCalls !== undefined){let data13 = data.externalCalls;if(Array.isArray(data13)){if(data13.length > 50){const err40 = {instancePath:instancePath+"/externalCalls",schemaPath:"#/properties/externalCalls/maxItems",keyword:"maxItems",params:{limit: 50},message:"must NOT have more than 50 items"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}const len2 = data13.length;for(let i2=0; i2 255){const err41 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/maxLength",keyword:"maxLength",params:{limit: 255},message:"must NOT have more than 255 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}if(func2(data14) < 1){const err42 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}if(!pattern89.test(data14)){const err43 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/pattern",keyword:"pattern",params:{pattern: "^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"},message:"must match pattern \""+"^[A-Za-z0-9.-]+(?::[0-9]{1,5})?$"+"\""};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}else {const err44 = {instancePath:instancePath+"/externalCalls/" + i2,schemaPath:"#/properties/externalCalls/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/externalCalls",schemaPath:"#/properties/externalCalls/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data.dataRetention !== undefined){let data15 = data.dataRetention;if(typeof data15 === "string"){if(func2(data15) > 2000){const err46 = {instancePath:instancePath+"/dataRetention",schemaPath:"#/properties/dataRetention/maxLength",keyword:"maxLength",params:{limit: 2000},message:"must NOT have more than 2000 characters"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}if(func2(data15) < 1){const err47 = {instancePath:instancePath+"/dataRetention",schemaPath:"#/properties/dataRetention/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}else {const err48 = {instancePath:instancePath+"/dataRetention",schemaPath:"#/properties/dataRetention/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}}else {const err49 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}validate417.errors = vErrors;return errors === 0;}validate417.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false}; diff --git a/packages/learning/src/sources/hub-review-comments.mjs b/packages/learning/src/sources/hub-review-comments.mjs index eea79dfc3..e3bf56be8 100644 --- a/packages/learning/src/sources/hub-review-comments.mjs +++ b/packages/learning/src/sources/hub-review-comments.mjs @@ -21,7 +21,7 @@ const LIST = "list_repository_comments" const THREAD = "get_repository_comment_thread" const UUID = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i const ORIGIN = /^https?:\/\/[A-Za-z0-9.-]+(?::[0-9]{1,5})?$/ -const LOGIN = /^[A-Za-z0-9_-]{1,256}$/ +const LOGIN = /^[^\s\p{Cc}\p{Cf}\u{E0000}-\u{E007F}]{1,256}$/u /** * Read a log of Replica canvas comment calls and decide whether it is a complete collection. @@ -197,11 +197,10 @@ export function readHubReviewCollection(log, { repository }) { ) const identified = [...threads.values()].some( (thread) => - [thread.root, ...thread.replies].some( - (message) => message.authorGithubId !== undefined || message.authorLocalId !== undefined, - ) || + [thread.root, ...thread.replies].some((message) => stableIdentity(message)) || thread.root.resolvedByGithubId !== undefined || - thread.root.resolvedByLocalId !== undefined, + thread.root.resolvedByLocalId !== undefined || + thread.root.resolvedByHubUserId !== undefined, ) return { meta: { @@ -243,7 +242,16 @@ export function hubThreadEpisode({ meta, thread, scope, grantIds, principal, imp buildNumber: root.buildNumber, threadId: root.id, }, - actors: [reviewer(root.authorLogin, root.authorGithubId, root.authorLocalId, scope, meta)], + actors: [ + reviewer( + root.authorLogin, + root.authorGithubId, + root.authorLocalId, + root.authorHubUserId, + scope, + meta, + ), + ], grants: [...grantIds], contentTrust: { untrusted: true, treatAs: "data", source: HUB_SOURCE }, provenance: { @@ -297,10 +305,11 @@ export function hubThreadEvents({ meta, thread, scope, episodeId, existing }) { message.authorLogin, message.authorGithubId, message.authorLocalId, + message.authorHubUserId, scope, meta, ) - const stable = message.authorGithubId !== undefined || message.authorLocalId !== undefined + const stable = stableIdentity(message) const versionIds = new Set(versions.map((event) => event.id)) const existingStable = [ ...versions, @@ -422,48 +431,73 @@ export function hubThreadEvents({ meta, thread, scope, episodeId, existing }) { } const statuses = known.filter((event) => event.type === "status_change") - const recorded = statuses.at(-1)?.payload?.status ?? "unresolved" - const current = thread.root.resolvedAt ? "resolved" : "unresolved" - if (current !== recorded) { - const at = thread.root.resolvedAt ?? meta.capturedAt + let recorded = statuses.at(-1)?.payload?.status ?? "unresolved" + const history = + thread.root.resolutionHistory.length > 0 + ? thread.root.resolutionHistory + : [ + { + state: thread.root.resolvedAt ? "resolved" : "unresolved", + at: thread.root.resolvedAt ?? meta.capturedAt, + actorLogin: thread.root.resolvedByLogin, + actorGithubId: thread.root.resolvedByGithubId, + actorLocalId: thread.root.resolvedByLocalId, + actorHubUserId: thread.root.resolvedByHubUserId, + }, + ] + for (const change of history) { + if (change.state === recorded) continue + const at = change.at + const actor = change.actorLogin + ? reviewer( + change.actorLogin, + change.actorGithubId, + change.actorLocalId, + change.actorHubUserId, + scope, + meta, + ) + : { kind: "system", id: `system:${HUB_SOURCE}` } + const id = derivedId("ev", { + episodeId, + status: change.state, + ...(change.id ? { resolutionEventId: change.id } : { at }), + ...(change.sequence ? { sequence: change.sequence } : {}), + }) + if (ids.has(id)) { + recorded = change.state + continue + } + ids.add(id) add({ schemaVersion: SCHEMA_VERSIONS.event, - id: derivedId("ev", { episodeId, status: current, at }), + id, episodeId, scope, type: "status_change", at, - actor: thread.root.resolvedByLogin - ? reviewer( - thread.root.resolvedByLogin, - thread.root.resolvedByGithubId, - thread.root.resolvedByLocalId, - scope, - meta, - ) - : { kind: "system", id: `system:${HUB_SOURCE}` }, + actor, payload: { subject: { kind: "thread", id: thread.root.id }, - status: current, + status: change.state, at, - ...(thread.root.resolvedByLogin - ? { - by: reviewer( - thread.root.resolvedByLogin, - thread.root.resolvedByGithubId, - thread.root.resolvedByLocalId, - scope, - meta, - ), - } - : {}), + ...(change.actorLogin ? { by: actor } : {}), }, }) + recorded = change.state } return added } -function reviewer(login, githubId, localId, scope, meta) { +function stableIdentity(message) { + return ( + message.authorGithubId !== undefined || + message.authorLocalId !== undefined || + message.authorHubUserId !== undefined + ) +} + +function reviewer(login, githubId, localId, hubUserId, scope, meta) { if (githubId !== undefined) { if (!scope.host || scope.host === "local") invalid("A GitHub reviewer ID needs an explicit GitHub host in the scope.") @@ -478,21 +512,32 @@ function reviewer(login, githubId, localId, scope, meta) { role: "reviewer", } } + if (hubUserId !== undefined) { + return { + kind: "human", + id: `hub-user:${new URL(meta.hubOrigin).origin}/${hubUserId}`, + login, + role: "reviewer", + } + } return { kind: "human", id: `github:${login}`, role: "reviewer", asserted: true } } export function stableReviewer(actor, scope, source) { - const prefix = + const prefixes = [ + source.hubOrigin ? `hub-user:${new URL(source.hubOrigin).origin}/` : null, scope.host === "local" ? source.hubOrigin ? `hub-user:${new URL(source.hubOrigin).origin}/` : null : scope.host ? `github-user:${scope.host}/` - : null - if (!prefix || !actor?.id?.startsWith(prefix)) return false + : null, + ].filter(Boolean) + const prefix = prefixes.find((candidate) => actor?.id?.startsWith(candidate)) + if (!prefix) return false const id = actor.id.slice(prefix.length) - return /^[1-9]\d*$/.test(id) && Number.isSafeInteger(Number(id)) + return (/^[1-9]\d*$/.test(id) && Number.isSafeInteger(Number(id))) || UUID.test(id) } /** Check the pagination fields of a list page; a missing or contradictory flag is malformed. */ @@ -550,7 +595,7 @@ function readTarget(value) { !ORIGIN.test(value.hubOrigin) || typeof value.repository !== "string" || !/^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/.test(value.repository) || - !positive(value.repositoryId) + !sourceIdentifier(value.repositoryId) ) invalid( "Results need a repository target from list_repository_comments. Prototype-scoped list_comments logs are not supported.", @@ -606,7 +651,7 @@ function readMessage(value, kind) { : readIdentity(value.resolvedBy, `Comment ${value.id} resolver`) if ( !isObject(value.prototype) || - !positive(value.prototype.id) || + !sourceIdentifier(value.prototype.id) || !text(value.prototype.branch, 1024) ) invalid(`Comment ${value.id} needs its prototype ID and branch.`) @@ -617,6 +662,9 @@ function readMessage(value, kind) { authorLogin: value.author.login, ...(authorIdentity.githubId !== undefined ? { authorGithubId: authorIdentity.githubId } : {}), ...(authorIdentity.localId !== undefined ? { authorLocalId: authorIdentity.localId } : {}), + ...(authorIdentity.hubUserId !== undefined + ? { authorHubUserId: authorIdentity.hubUserId } + : {}), createdAt: timestamp(value.createdAt, "createdAt"), editedAt: value.editedAt === null || value.editedAt === undefined @@ -638,14 +686,22 @@ function readMessage(value, kind) { } if (!positive(value.buildNumber)) invalid(`Thread ${value.id} needs the Build number the reviewer saw.`) + const resolvedAt = + value.resolvedAt === null || value.resolvedAt === undefined + ? null + : timestamp(value.resolvedAt, "resolvedAt") + const resolutionHistory = readResolutionHistory(value.resolutionHistory) + if ( + resolutionHistory.length > 0 && + resolutionHistory.at(-1).state !== (resolvedAt ? "resolved" : "unresolved") + ) { + invalid(`Thread ${value.id} resolution history does not match its current state.`) + } return { ...message, buildNumber: value.buildNumber, context: compactContext(value.anchor), - resolvedAt: - value.resolvedAt === null || value.resolvedAt === undefined - ? null - : timestamp(value.resolvedAt, "resolvedAt"), + resolvedAt, resolvedByLogin: isObject(value.resolvedBy) && LOGIN.test(value.resolvedBy.login ?? "") ? value.resolvedBy.login @@ -656,13 +712,19 @@ function readMessage(value, kind) { ...(resolverIdentity.localId !== undefined ? { resolvedByLocalId: resolverIdentity.localId } : {}), + ...(resolverIdentity.hubUserId !== undefined + ? { resolvedByHubUserId: resolverIdentity.hubUserId } + : {}), + resolutionHistory, } function readIdentity(value, label) { if (!isObject(value)) invalid(`${label} must be an actor.`) if (Object.hasOwn(value, "local")) invalid(`${label} uses localId, not a local flag.`) - if (Object.hasOwn(value, "githubId") && Object.hasOwn(value, "localId")) - invalid(`${label} cannot name both githubId and localId.`) + const identityKeys = ["githubId", "localId", "hubUserId"].filter((key) => + Object.hasOwn(value, key), + ) + if (identityKeys.length > 1) invalid(`${label} cannot name more than one stable identity.`) const identity = {} for (const key of ["githubId", "localId"]) if (Object.hasOwn(value, key)) { @@ -670,8 +732,47 @@ function readMessage(value, kind) { if (!LOGIN.test(value.login ?? "")) invalid(`${label} needs a login for display.`) identity[key] = value[key] } + if (Object.hasOwn(value, "hubUserId")) { + if (typeof value.hubUserId !== "string" || !UUID.test(value.hubUserId)) + invalid(`${label}.hubUserId must be a UUID.`) + if (!LOGIN.test(value.login ?? "")) invalid(`${label} needs a login for display.`) + identity.hubUserId = value.hubUserId.toLowerCase() + } return identity } + + function readResolutionHistory(history) { + if (history === undefined) return [] + if (!Array.isArray(history)) invalid(`Thread ${value.id} resolutionHistory must be an array.`) + let lastSequence = 0 + return history.map((change, index) => { + if (!isObject(change) || !["resolved", "unresolved"].includes(change.state)) + invalid(`Resolution change ${index + 1} is invalid.`) + const at = timestamp(change.at, "resolutionHistory.at") + if (typeof change.id !== "string" || !UUID.test(change.id)) + invalid(`Resolution change ${index + 1} needs its durable event ID.`) + if (!positive(change.sequence) || change.sequence <= lastSequence) + invalid("Resolution history sequence must increase.") + lastSequence = change.sequence + if (!isObject(change.actor) || !LOGIN.test(change.actor.login ?? "")) + invalid(`Resolution change ${index + 1} needs an actor.`) + const identity = readIdentity(change.actor, `Resolution change ${index + 1} actor`) + return { + id: change.id.toLowerCase(), + sequence: change.sequence, + state: change.state, + at, + actorLogin: change.actor.login, + ...(identity.githubId !== undefined ? { actorGithubId: identity.githubId } : {}), + ...(identity.localId !== undefined ? { actorLocalId: identity.localId } : {}), + ...(identity.hubUserId !== undefined ? { actorHubUserId: identity.hubUserId } : {}), + } + }) + } +} + +function sourceIdentifier(value) { + return positive(value) || (typeof value === "string" && UUID.test(value)) } /** Keep only the saved target fields Hub itself shows: route and accessible element details. */ diff --git a/packages/learning/src/store.mjs b/packages/learning/src/store.mjs index 6e4a54824..22f1cd9d6 100644 --- a/packages/learning/src/store.mjs +++ b/packages/learning/src/store.mjs @@ -1807,6 +1807,20 @@ class LearningStore { } } + /** Find one host decision marker in intact history without returning learning content. */ + async findMemoryOperation(context, id, operationId) { + assertContext(context) + const entry = (await this.#memories(context, [id])).get(id) + if (!entry) throw new LearningError("not_found", `No memory ${id} in this scope.`) + const version = entry.intact.find( + (record) => + record.accepted?.operationId === operationId || + record.rejected?.operationId === operationId || + record.retired?.operationId === operationId, + ) + return { state: version?.state ?? null } + } + /** Memories in scope, newest version of each, with their recall status, read for a purpose. */ async queryMemory(context, { states, kinds, purpose = "review" } = {}) { assertContext(context) @@ -1839,7 +1853,7 @@ class LearningStore { * supersedes, and recall follows that; the replaced memories keep their state. Such a * proposal must apply now, so an expired one, or one not valid yet, is refused. */ - async acceptMemory(context, id, { expectedDigest, content, note } = {}) { + async acceptMemory(context, id, { expectedDigest, content, note, operationId } = {}) { assertContext(context) requireHuman(context, "accept a learning") const { items, eligible, now } = await this.#statuses(context) @@ -1879,6 +1893,7 @@ class LearningStore { contentDigest: memoryContentDigest(draft), reviewedDigest: expectedDigest, edited, + ...(operationId ? { operationId } : {}), ...(note ? { note } : {}), } const record = sealMemory(draft) @@ -1901,7 +1916,7 @@ class LearningStore { } /** Reject a proposed memory, keeping the reason so later proposals can see the disagreement. */ - async rejectMemory(context, id, { expectedDigest, reason } = {}) { + async rejectMemory(context, id, { expectedDigest, reason, operationId } = {}) { assertContext(context) requireHuman(context, "reject a learning") const now = this.#now() @@ -1912,7 +1927,13 @@ class LearningStore { previousDigest: latest.digest, state: "rejected", updatedAt: now, - rejected: { by: context.principal, at: now, reviewedDigest: expectedDigest, reason }, + rejected: { + by: context.principal, + at: now, + reviewedDigest: expectedDigest, + reason, + ...(operationId ? { operationId } : {}), + }, }) assertValid("memoryRecord", record) await this.#appendVersion( @@ -1927,7 +1948,7 @@ class LearningStore { } /** Stop recalling an accepted memory. Its history stays inspectable. */ - async retireMemory(context, id, { reason } = {}) { + async retireMemory(context, id, { reason, operationId } = {}) { assertContext(context) requireHuman(context, "retire a learning") const entry = (await this.#memories(context, [id])).get(id) @@ -1939,7 +1960,7 @@ class LearningStore { "invalid_transition", `Only accepted memories can be retired; ${id} is ${entry.record.state}.`, ) - return this.#retire(entry.record, context, reason, this.#now()) + return this.#retire(entry.record, context, reason, this.#now(), operationId) } /** @@ -2027,14 +2048,14 @@ class LearningStore { return entry.record } - async #retire(latest, context, reason, now) { + async #retire(latest, context, reason, now, operationId) { const record = sealMemory({ ...without(latest, "digest", "contentDigest"), version: latest.version + 1, previousDigest: latest.digest, state: "retired", updatedAt: now, - retired: { by: context.principal, at: now, reason }, + retired: { by: context.principal, at: now, reason, ...(operationId ? { operationId } : {}) }, }) assertValid("memoryRecord", record) await this.#appendVersion( diff --git a/packages/learning/test/cli.test.mjs b/packages/learning/test/cli.test.mjs index 9fb2a0cd3..39d1eca7f 100644 --- a/packages/learning/test/cli.test.mjs +++ b/packages/learning/test/cli.test.mjs @@ -158,11 +158,26 @@ describe("replica-learning CLI: the first learning milestone", () => { "github:ana-designer", "--content-file", "edited.txt", + "--operation-id", + "11111111-2222-4333-8444-555555555555", "--json", ]) ).json() assert.equal(accepted.state, "accepted") assert.equal(accepted.accepted.edited, true) + assert.equal(accepted.accepted.operationId, "11111111-2222-4333-8444-555555555555") + assert.deepEqual( + ( + await ok(repo, [ + "operation-status", + proposal.id, + "--operation-id", + "11111111-2222-4333-8444-555555555555", + "--json", + ]) + ).json(), + { state: "accepted" }, + ) assert.equal( accepted.content, "Put a visible label above every form field. Placeholder text never replaces the label.", @@ -999,6 +1014,24 @@ describe("replica-learning CLI: guard rails", () => { assert.equal((await cli(repo, ["--help"])).code, 0) }) + it("reads a dash-leading decision reason from a file", async () => { + const repo = checkout("decision-reason-file") + writeFileSync(path.join(repo, "reason.txt"), "-private repository context\n") + + const result = await cli(repo, [ + "retire", + "mem_missing01", + "--by", + "github:ana-designer", + "--reason-file", + "reason.txt", + ]) + + assert.equal(result.code, 1) + assert.match(result.stderr, /not_found/) + assert.doesNotMatch(result.stderr, /Run replica-learning --help/) + }) + it("refuses an identity with control or invisible formatting characters", async () => { const repo = checkout("hidden-identity") const grant = ["grants", "add", "--purpose", "review", "--basis", "Test."] diff --git a/packages/learning/test/hub-source.test.mjs b/packages/learning/test/hub-source.test.mjs index 457f86e67..aac21a76b 100644 --- a/packages/learning/test/hub-source.test.mjs +++ b/packages/learning/test/hub-source.test.mjs @@ -1,7 +1,11 @@ import assert from "node:assert/strict" import { describe, it } from "node:test" import { REPOSITORY, collectionLog, weekOneLog } from "../conformance/fixtures.mjs" -import { hubThreadEvents, readHubReviewCollection } from "../src/sources/hub-review-comments.mjs" +import { + hubThreadEpisode, + hubThreadEvents, + readHubReviewCollection, +} from "../src/sources/hub-review-comments.mjs" const expected = { repository: REPOSITORY } function read(log) { @@ -34,13 +38,169 @@ describe("Hub review collections", () => { ) }) + it("accepts UUID repository and prototype identifiers in source evidence", () => { + const log = weekOneLog() + const repositoryId = "11111111-2222-4333-8444-555555555555" + const prototypeIds = new Map([ + [11, "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"], + [12, "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"], + [13, "cccccccc-cccc-4ccc-8ccc-cccccccccccc"], + ]) + for (const call of log.calls) { + if (call.result.target) call.result.target.repositoryId = repositoryId + for (const thread of call.result.threads ?? + (call.result.thread ? [call.result.thread] : [])) { + thread.prototype = { + ...thread.prototype, + id: prototypeIds.get(thread.prototype.id), + } + for (const reply of thread.replies ?? []) + reply.prototype = { ...reply.prototype, id: thread.prototype.id } + } + } + + const collection = read(log) + const thread = collection.threads[0] + assert.equal(collection.meta.repositoryId, repositoryId) + assert.match(thread.root.prototype.id, /^[0-9a-f-]{36}$/) + const episode = hubThreadEpisode({ + meta: collection.meta, + thread, + scope: expected, + grantIds: [], + principal: { kind: "agent", id: "agent:test" }, + importedAt: "2026-10-05T18:00:00.000000Z", + }) + assert.equal(episode.source.repositoryId, repositoryId) + assert.equal(episode.source.prototypeId, thread.root.prototype.id) + }) + + it("uses Hub UUID identities for roots, replies, and resolution actors", () => { + const log = weekOneLog() + const root = log.calls[1].result.threads[0] + root.author.hubUserId = "11111111-2222-4333-8444-555555555555" + root.replies[0].author.hubUserId = "66666666-7777-4888-8999-000000000000" + root.resolvedAt = "2026-10-04T12:00:00.000000Z" + root.resolvedBy = { + login: "resolver", + hubUserId: "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee", + } + root.resolutionHistory = [ + { + id: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb", + sequence: 1, + state: "resolved", + at: root.resolvedAt, + actor: root.resolvedBy, + }, + ] + const collection = read(log) + const thread = collection.threads.find((item) => item.root.id === root.id) + const events = hubThreadEvents({ + meta: collection.meta, + thread, + scope: { ...expected, host: "local" }, + episodeId: "ep_uuuuuuuuuuuuuuuu", + existing: [], + }) + + assert.deepEqual( + events.map((event) => event.actor.id), + [ + "hub-user:https://replica.example.com/11111111-2222-4333-8444-555555555555", + "hub-user:https://replica.example.com/66666666-7777-4888-8999-000000000000", + "hub-user:https://replica.example.com/aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee", + ], + ) + }) + + it("imports ordered resolution and reopening history from one complete snapshot", () => { + const log = weekOneLog() + const root = log.calls[1].result.threads[0] + root.resolvedAt = null + root.resolvedBy = null + root.resolutionHistory = [ + { + id: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb", + sequence: 1, + state: "resolved", + at: "2026-10-04T12:00:00.000000Z", + actor: { login: "resolver", hubUserId: "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee" }, + }, + { + id: "cccccccc-cccc-4ccc-8ccc-cccccccccccc", + sequence: 2, + state: "unresolved", + at: "2026-10-04T11:00:00.000000Z", + actor: { login: "reopener", hubUserId: "ffffffff-eeee-4ddd-8ccc-bbbbbbbbbbbb" }, + }, + ] + const collection = read(log) + const thread = collection.threads.find((item) => item.root.id === root.id) + const events = hubThreadEvents({ + meta: collection.meta, + thread, + scope: expected, + episodeId: "ep_resolutionhistory", + existing: [], + }) + + assert.deepEqual( + events + .filter((event) => event.type === "status_change") + .map((event) => [event.payload.status, event.at]), + [ + ["resolved", "2026-10-04T12:00:00.000000Z"], + ["unresolved", "2026-10-04T11:00:00.000000Z"], + ], + ) + assert.deepEqual( + hubThreadEvents({ + meta: collection.meta, + thread, + scope: expected, + episodeId: "ep_resolutionhistory", + existing: events, + }), + [], + ) + }) + + it("accepts provider-neutral display logins when a Hub UUID identifies the reviewer", () => { + const log = weekOneLog() + const root = log.calls[1].result.threads[0] + root.author.login = "mona@example.com" + root.author.hubUserId = "11111111-2222-4333-8444-555555555555" + + const collection = read(log) + const thread = collection.threads.find((item) => item.root.id === root.id) + const [event] = hubThreadEvents({ + meta: collection.meta, + thread, + scope: expected, + episodeId: "ep_entrareviewer1", + existing: [], + }) + + assert.equal(event.actor.login, "mona@example.com") + assert.equal( + event.actor.id, + "hub-user:https://replica.example.com/11111111-2222-4333-8444-555555555555", + ) + }) + it("reads a complete log and joins reply pages", () => { const result = read(weekOneLog()) assert.equal(result.complete, true) assert.deepEqual(result.problems, []) assert.deepEqual(result.counts, { threads: 9, messages: 12 }) assert.equal(result.meta.repository, REPOSITORY) - assert.deepEqual(result.filters, { resolution: "all", read: "all", from: null, to: null }) + assert.deepEqual(result.filters, { + resolution: "all", + read: "all", + from: null, + to: null, + }) const thread = result.threads.find((item) => item.root.id === 109) assert.deepEqual( thread.replies.map((item) => item.id), @@ -145,7 +305,10 @@ describe("Hub review collections", () => { snapshotId: "11111111-2222-4333-8444-555555555555", capturedAt: "2026-10-05T18:00:00.000000Z", threads: [], - filters: { from: "2026-09-29T00:00:00Z", to: "2026-10-05T00:00:00+00:00" }, + filters: { + from: "2026-09-29T00:00:00Z", + to: "2026-10-05T00:00:00+00:00", + }, }) assert.deepEqual(read(log).filters, { resolution: "all", @@ -164,16 +327,26 @@ describe("Hub review collections", () => { }) const prototypeScoped = weekOneLog() for (const call of prototypeScoped.calls) { - call.result.target = { ...call.result.target, scope: undefined, prototypeId: 11 } + call.result.target = { + ...call.result.target, + scope: undefined, + prototypeId: 11, + } } assert.throws( () => read(prototypeScoped), /Prototype-scoped list_comments logs are not supported/, ) const foreign = weekOneLog() - foreign.calls[0].result.contentTrust = { source: "web", untrusted: true, treatAs: "data" } + foreign.calls[0].result.contentTrust = { + source: "web", + untrusted: true, + treatAs: "data", + } assert.throws(() => read(foreign), /not a Hub review comment result/) - assert.throws(() => read({ kind: "other", calls: [] }), { code: "invalid_input" }) + assert.throws(() => read({ kind: "other", calls: [] }), { + code: "invalid_input", + }) }) it("adds an edit, a deletion, and a resolution as new events without touching old ones", () => {