@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -5
- package/README.md +385 -305
- package/dist/acp-package.d.ts +28 -0
- package/dist/acp-package.js +23 -0
- package/dist/adapter-facts.d.ts +8 -1
- package/dist/adapter-facts.js +9 -1
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +36 -3
- package/dist/agent-delete.d.ts +50 -0
- package/dist/agent-delete.js +125 -0
- package/dist/agents-store.d.ts +9 -3
- package/dist/agents-store.js +22 -8
- package/dist/agents.d.ts +5 -1
- package/dist/agents.js +8 -4
- package/dist/api-only.d.ts +8 -3
- package/dist/api-only.js +10 -4
- package/dist/archil-routes.d.ts +5 -1
- package/dist/archil-routes.js +57 -2
- package/dist/browser-wait-ended.d.ts +2 -0
- package/dist/browser-wait-ended.js +2 -0
- package/dist/calendar/ics-faux.d.ts +3 -1
- package/dist/calendar/ics-faux.js +12 -2
- package/dist/calendar/tools.js +5 -2
- package/dist/chatgpt-plan.js +3 -1
- package/dist/claude-login.d.ts +135 -0
- package/dist/claude-login.js +244 -0
- package/dist/cli.js +62 -19
- package/dist/composio-preset.js +69 -7
- package/dist/composio-triggers.d.ts +14 -0
- package/dist/composio-triggers.js +79 -15
- package/dist/computer-attach.d.ts +40 -5
- package/dist/computer-attach.js +130 -15
- package/dist/computer-keys.d.ts +3 -0
- package/dist/computer-keys.js +7 -1
- package/dist/computer-live.js +3 -2
- package/dist/computers.d.ts +21 -10
- package/dist/computers.js +39 -28
- package/dist/console/assets/index-C2MYaUBa.css +1 -0
- package/dist/console/assets/index-CZZeCReB.js +701 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/dial-relay.d.ts +29 -0
- package/dist/dial-relay.js +94 -0
- package/dist/email/tools.js +10 -5
- package/dist/env-proxy.d.ts +2 -0
- package/dist/env-proxy.js +35 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +7 -4
- package/dist/faux-computers.d.ts +8 -2
- package/dist/faux-computers.js +83 -6
- package/dist/harness-archive.d.ts +67 -0
- package/dist/harness-archive.js +177 -0
- package/dist/harness-goose.d.ts +34 -0
- package/dist/harness-goose.js +87 -0
- package/dist/harness-install.d.ts +21 -0
- package/dist/harness-install.js +24 -11
- package/dist/harness-opencode/adapter.js +1 -1
- package/dist/harness-table.d.ts +9 -1
- package/dist/harness-table.js +20 -3
- package/dist/harness.d.ts +1 -2
- package/dist/harness.js +3 -4
- package/dist/host.js +2 -1
- package/dist/import.d.ts +10 -0
- package/dist/import.js +28 -8
- package/dist/key-check.js +3 -0
- package/dist/learn/audit.d.ts +6 -6
- package/dist/learn/audit.js +3 -7
- package/dist/learn/check.d.ts +23 -89
- package/dist/learn/check.js +57 -335
- package/dist/learn/commit.d.ts +63 -90
- package/dist/learn/commit.js +124 -316
- package/dist/learn/compile.d.ts +53 -50
- package/dist/learn/compile.js +89 -104
- package/dist/learn/corrections.d.ts +13 -0
- package/dist/learn/corrections.js +23 -0
- package/dist/learn/delete.d.ts +5 -5
- package/dist/learn/delete.js +8 -10
- package/dist/learn/folder.d.ts +35 -47
- package/dist/learn/folder.js +118 -134
- package/dist/learn/index.d.ts +3 -5
- package/dist/learn/index.js +6 -9
- package/dist/learn/learning.sh +45 -15
- package/dist/learn/promote.d.ts +23 -5
- package/dist/learn/promote.js +40 -2
- package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
- package/dist/learn/{skills.js → workflow-draft.js} +48 -58
- package/dist/learn/workflow-nodes.js +1 -1
- package/dist/learned-workflow.js +2 -2
- package/dist/learning-cost.d.ts +38 -24
- package/dist/learning-cost.js +41 -24
- package/dist/learning-routes.d.ts +91 -170
- package/dist/learning-routes.js +183 -421
- package/dist/learning-run.d.ts +19 -40
- package/dist/learning-run.js +23 -93
- package/dist/learning-setting.d.ts +21 -10
- package/dist/learning-setting.js +47 -11
- package/dist/learning-words.d.ts +28 -74
- package/dist/learning-words.js +64 -162
- package/dist/learning.d.ts +61 -392
- package/dist/learning.js +101 -651
- package/dist/live-reach.d.ts +25 -2
- package/dist/live-reach.js +46 -4
- package/dist/llms.txt +1 -1
- package/dist/local-models.d.ts +3 -11
- package/dist/local-models.js +5 -6
- package/dist/mcp-servers-store.d.ts +4 -4
- package/dist/model-form.js +6 -5
- package/dist/model.d.ts +4 -0
- package/dist/model.js +26 -9
- package/dist/native/binding.js +1 -1
- package/dist/native/connection.js +1 -1
- package/dist/native/discovery.js +1 -1
- package/dist/native/instructions.d.ts +3 -0
- package/dist/native/instructions.js +5 -3
- package/dist/native/remote-worker-bridge.js +9 -43
- package/dist/native/remote.d.ts +8 -15
- package/dist/native/remote.js +3 -3
- package/dist/native/schema.js +1 -1
- package/dist/native/types.d.ts +2 -2
- package/dist/openapi.js +273 -319
- package/dist/paid-calls.d.ts +8 -0
- package/dist/paid-calls.js +20 -0
- package/dist/particle-provider.d.ts +11 -0
- package/dist/particle-provider.js +135 -0
- package/dist/port-models.d.ts +12 -4
- package/dist/port-models.js +28 -11
- package/dist/print.d.ts +27 -0
- package/dist/print.js +21 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +15 -1
- package/dist/reflect-range.js +2 -3
- package/dist/run-launch.d.ts +14 -28
- package/dist/run-launch.js +9 -12
- package/dist/run-learning-served.d.ts +15 -89
- package/dist/run-listing.d.ts +34 -0
- package/dist/run-listing.js +128 -0
- package/dist/run-model-key.js +1 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-trace.d.ts +97 -0
- package/dist/run-trace.js +253 -0
- package/dist/run-view.d.ts +15 -0
- package/dist/run-view.js +9 -0
- package/dist/runnable.js +2 -1
- package/dist/runner/adapter-loop.d.ts +8 -6
- package/dist/runner/adapter-loop.js +16 -12
- package/dist/runner/adapter-run-spec.d.ts +16 -4
- package/dist/runner/adapter-run-spec.js +64 -58
- package/dist/runner/adapters/index.js +22 -0
- package/dist/runner/adapters/pi.d.ts +4 -12
- package/dist/runner/adapters/pi.js +2 -2
- package/dist/runner/audit.d.ts +1 -1
- package/dist/runner/audit.js +30 -13
- package/dist/runner/beside.d.ts +6 -2
- package/dist/runner/beside.js +38 -9
- package/dist/runner/claim-secrets.d.ts +18 -2
- package/dist/runner/claim-secrets.js +42 -18
- package/dist/runner/cli-run-spec.js +55 -51
- package/dist/runner/conformance/harness.d.ts +6 -0
- package/dist/runner/conformance/harness.js +35 -13
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/dispatch.d.ts +2 -2
- package/dist/runner/end-of-run.d.ts +6 -14
- package/dist/runner/end-of-run.js +8 -33
- package/dist/runner/feedback-round.d.ts +2 -2
- package/dist/runner/feedback-round.js +7 -7
- package/dist/runner/github-app.js +3 -1
- package/dist/runner/harness-loops.d.ts +0 -8
- package/dist/runner/harness-loops.js +11 -59
- package/dist/runner/held.d.ts +170 -0
- package/dist/runner/held.js +57 -0
- package/dist/runner/journal-kinds.d.ts +2 -3
- package/dist/runner/journal-kinds.js +2 -3
- package/dist/runner/learned-first.d.ts +40 -0
- package/dist/runner/learned-first.js +32 -0
- package/dist/runner/learning-end.d.ts +77 -69
- package/dist/runner/learning-end.js +250 -303
- package/dist/runner/learning-seed.d.ts +15 -33
- package/dist/runner/learning-seed.js +24 -45
- package/dist/runner/loop-contract.d.ts +2 -3
- package/dist/runner/main.d.ts +17 -9
- package/dist/runner/main.js +82 -20
- package/dist/runner/mcp-run.d.ts +11 -0
- package/dist/runner/mcp-run.js +67 -0
- package/dist/runner/memory-claim.d.ts +10 -5
- package/dist/runner/memory-claim.js +12 -6
- package/dist/runner/model-route.d.ts +7 -4
- package/dist/runner/model-route.js +22 -10
- package/dist/runner/native-loop.d.ts +0 -7
- package/dist/runner/native-loop.js +9 -101
- package/dist/runner/promotion.d.ts +12 -8
- package/dist/runner/promotion.js +37 -28
- package/dist/runner/reflect-hook.d.ts +64 -95
- package/dist/runner/reflect-hook.js +112 -225
- package/dist/runner/run-channel.d.ts +43 -0
- package/dist/runner/run-channel.js +467 -0
- package/dist/runner/run-child-host.d.ts +169 -0
- package/dist/runner/run-child-host.js +1230 -0
- package/dist/runner/run-child.d.ts +1 -0
- package/dist/runner/run-child.js +254 -0
- package/dist/runner/run-errors.d.ts +2 -0
- package/dist/runner/run-errors.js +20 -0
- package/dist/runner/runner.js +1 -5
- package/dist/runner/sdk-ask.d.ts +78 -0
- package/dist/runner/sdk-ask.js +158 -0
- package/dist/runner/sdk-loop.d.ts +2 -4
- package/dist/runner/sdk-loop.js +29 -49
- package/dist/runner/store-secrets.d.ts +5 -3
- package/dist/runner/store-secrets.js +5 -1
- package/dist/runner/workflow-first.d.ts +5 -0
- package/dist/runner/workflow-first.js +4 -0
- package/dist/runner/workflow-spec.js +7 -2
- package/dist/runs-over-store.d.ts +16 -28
- package/dist/runs-over-store.js +31 -38
- package/dist/sdk/runs.d.ts +6 -11
- package/dist/sdk/runs.js +20 -41
- package/dist/sdk/schema.js +3 -4
- package/dist/seal-key.d.ts +5 -0
- package/dist/seal-key.js +7 -0
- package/dist/secrets.d.ts +3 -0
- package/dist/secrets.js +16 -3
- package/dist/server.d.ts +55 -33
- package/dist/server.js +689 -322
- package/dist/sign-ins-store.d.ts +8 -0
- package/dist/sign-ins-store.js +36 -1
- package/dist/skills.js +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +3 -0
- package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
- package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
- package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
- package/dist/store/schema.d.ts +53 -4
- package/dist/store/schema.js +137 -6
- package/dist/store/sqlite/connection.d.ts +2 -0
- package/dist/store/sqlite/connection.js +3 -1
- package/dist/store/sqlite/run-patch.d.ts +0 -17
- package/dist/store/sqlite/run-patch.js +4 -33
- package/dist/store/sqlite/store.js +246 -63
- package/dist/store/sqlite/worker.js +25 -0
- package/dist/store/store.d.ts +193 -36
- package/dist/store/store.js +25 -3
- package/dist/store-reads/learning.d.ts +102 -204
- package/dist/store-reads/learning.js +159 -321
- package/dist/store-reads/loop.d.ts +0 -1
- package/dist/store-reads/loop.js +1 -1
- package/dist/store-view.d.ts +29 -1
- package/dist/store-view.js +97 -31
- package/dist/template-eval.d.ts +3 -6
- package/dist/template-eval.js +22 -36
- package/dist/templates.d.ts +8 -4
- package/dist/templates.js +44 -6
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -1
- package/dist/timeline/timeline.js +16 -0
- package/dist/tool-gate.d.ts +0 -7
- package/dist/tool-gate.js +1 -15
- package/dist/tool-keys-store.d.ts +1 -1
- package/dist/tool-keys.d.ts +6 -4
- package/dist/tool-keys.js +12 -6
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +11 -4
- package/dist/triggers.d.ts +65 -6
- package/dist/triggers.js +125 -19
- package/dist/validate.js +1 -1
- package/dist/webhooks.d.ts +7 -2
- package/dist/webhooks.js +12 -5
- package/dist/workspace/agent-computer.d.ts +2 -0
- package/dist/workspace/agent-computer.js +2 -0
- package/dist/workspace/archil-claim.d.ts +7 -0
- package/dist/workspace/archil-claim.js +29 -0
- package/dist/workspace/archil.d.ts +9 -1
- package/dist/workspace/archil.js +165 -3
- package/dist/workspace/attach.d.ts +3 -1
- package/dist/workspace/attach.js +2 -0
- package/dist/workspace/attached-computers.d.ts +16 -5
- package/dist/workspace/attached-computers.js +25 -9
- package/dist/workspace/computer-deps.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +7 -3
- package/dist/workspace/computer-for-claim.js +119 -22
- package/dist/workspace/computer-hold.js +2 -1
- package/dist/workspace/computer-kept.d.ts +11 -1
- package/dist/workspace/computer-kept.js +24 -3
- package/dist/workspace/resolve-computer.d.ts +33 -19
- package/dist/workspace/resolve-computer.js +172 -64
- package/dist/workspace/revision-skills.d.ts +1 -2
- package/dist/workspace/revision-skills.js +3 -4
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +5 -0
- package/dist/workspace/synced-folder.d.ts +85 -0
- package/dist/workspace/synced-folder.js +230 -0
- package/dist/workspace/workspace.d.ts +4 -0
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/templates/README.md +8 -8
- package/templates/inbound-lead/agent.md +5 -4
- package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
- package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
- package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
- package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
- package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
- package/templates/inbound-lead/lead.schema.json +6 -5
- package/templates/inbound-lead/rules/RUBRIC.md +4 -4
- package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
- package/templates/kyb/agent.md +2 -1
- package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
- package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
- package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
- package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
- package/templates/release-notes/evals/learned-style/case.yaml +4 -4
- package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
- package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
- package/templates/release-notes/evals/learned-style/prompt.md +1 -1
- package/dist/console/assets/index-BUktRvS-.css +0 -1
- package/dist/console/assets/index-nB9kTfIN.js +0 -711
- package/dist/learn/grade.d.ts +0 -138
- package/dist/learn/grade.js +0 -682
- package/dist/learn/notes.d.ts +0 -81
- package/dist/learn/notes.js +0 -178
- package/dist/learn/reflect.d.ts +0 -77
- package/dist/learn/reflect.js +0 -228
- package/dist/learn/relevance.d.ts +0 -24
- package/dist/learn/relevance.js +0 -91
- package/dist/learn/seed-check.d.ts +0 -74
- package/dist/learn/seed-check.js +0 -103
- package/dist/learning-batch.d.ts +0 -291
- package/dist/learning-batch.js +0 -600
- package/dist/learning-evals.d.ts +0 -35
- package/dist/learning-evals.js +0 -99
- package/dist/native/context.d.ts +0 -6
- package/dist/native/context.js +0 -22
- package/dist/propose.d.ts +0 -52
- package/dist/propose.js +0 -224
- package/dist/runner/learning-ask.d.ts +0 -47
- package/dist/runner/learning-ask.js +0 -128
- package/dist/runner/learning-dispatch.d.ts +0 -45
- package/dist/runner/learning-dispatch.js +0 -99
- package/dist/runner/learning-factory.d.ts +0 -16
- package/dist/runner/learning-factory.js +0 -50
- package/dist/runner/learning-loop.d.ts +0 -273
- package/dist/runner/learning-loop.js +0 -521
- package/dist/usage.d.ts +0 -11
- package/dist/usage.js +0 -11
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
- package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
- package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
- package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
- package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
- package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/dist/learn/check.js
CHANGED
|
@@ -1,49 +1,23 @@
|
|
|
1
|
-
// The checker of
|
|
2
|
-
// each a change against
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// path and detail are cut of the host's secrets and of text shaped like one, and a field over PRINT_MAX is redacted whole.
|
|
1
|
+
// The checker of a workflow draft a run's compile turn gives its agent's learning folder (SPEC.md): its workflow.json and
|
|
2
|
+
// README.md, each a change against what the folder holds. Structure only, and what must never be stored; nothing the
|
|
3
|
+
// checker refuses is ever written to git. Every problem it reports is printable: its path and detail are cut of the
|
|
4
|
+
// host's secrets and of text shaped like one, and a field over PRINT_MAX is redacted whole.
|
|
6
5
|
import { placeholdersOf, placeholderValue } from "@parcha/agentrun-dsl";
|
|
7
6
|
import { hiddenCharacter } from "./invisible.js";
|
|
8
|
-
import { compiledLineBytes, INDEX_FILE, INDEX_LINES, NOTE_FILE, parseNoteFile, ruleOf } from "./notes.js";
|
|
9
7
|
import { learnedSecretShapes, redactLearned, valueMatcher } from "./secrets.js";
|
|
10
|
-
import { childNodes, draftProblems, decodedStrings, DECODED_DEPTH, DRY_RUN_FAILED, frontKeys, frontValues, LEARNED_KEYS,
|
|
11
|
-
/**
|
|
12
|
-
* each (notes.ts mergedNote). */
|
|
13
|
-
const HOST_LINES = Buffer.byteLength("origin: you\nstatus: pending\n");
|
|
14
|
-
/** A note's bytes as the note cap counts them: all of `text` but the `compiled_into` line the host adds when a learned
|
|
15
|
-
* workflow is compiled from it (notes.ts compiledLineBytes). A note at the cap stays one once marked: it retires,
|
|
16
|
-
* restores, and a later note supersedes it through the grader, each checked against `note`. A run never sets the line
|
|
17
|
-
* (checkProposal refuses it), so a run's note is counted whole. */
|
|
18
|
-
export const noteBytes = (text) => Buffer.byteLength(text) - compiledLineBytes(text);
|
|
19
|
-
/** Byte caps (UTF-8) and counts. Over a cap is refused, never cut. */
|
|
8
|
+
import { childNodes, draftProblems, decodedStrings, DECODED_DEPTH, DRY_RUN_FAILED, frontKeys, frontValues, LEARNED_KEYS, learnedPlace, readmeProblems, WORKFLOW_NAME, WORKFLOWS_DIR } from "./workflow-draft.js";
|
|
9
|
+
/** Byte caps (UTF-8). Over a cap is refused, never cut. */
|
|
20
10
|
export const CAPS = Object.freeze({
|
|
21
|
-
/** One
|
|
22
|
-
note: 4096,
|
|
23
|
-
/** One note a run proposes: the note cap less HOST_LINES, so a run's note stays within `note` once the host merges
|
|
24
|
-
* it, and a person can still retire it and a later run supersede it, each read and checked against `note`. */
|
|
25
|
-
runNote: 4096 - HOST_LINES,
|
|
26
|
-
/** New notes in one run. */
|
|
27
|
-
newNotes: 8,
|
|
28
|
-
/** Notes one run's new notes supersede, together. */
|
|
29
|
-
supersedes: 8,
|
|
30
|
-
/** Changed paths in one run; over it nothing else is read. */
|
|
31
|
-
changes: 64,
|
|
32
|
-
/** One skill's SKILL.md, or one workflow draft's workflow.json: one grader reads each whole beside the notes, so the
|
|
33
|
-
* most a run proposes stays within its prompt (grade.ts GRADE_CAPS.prompt). */
|
|
11
|
+
/** One draft's workflow.json. */
|
|
34
12
|
file: 16_384,
|
|
35
13
|
/** One draft's README.md, which the host writes from the one-line description its block gives. */
|
|
36
14
|
readme: 1_024,
|
|
37
|
-
/** Skills one run adds or changes. */
|
|
38
|
-
skills: 1,
|
|
39
|
-
/** Workflow drafts one run adds or changes. */
|
|
40
|
-
workflows: 1,
|
|
41
15
|
});
|
|
42
16
|
const MODES = { "120000": "a link: never followed", "040000": "a folder: nothing in it was read" };
|
|
43
|
-
/** Why a
|
|
44
|
-
const
|
|
45
|
-
/** Why a
|
|
46
|
-
const
|
|
17
|
+
/** Why a path is none of what a draft may write. */
|
|
18
|
+
const OUTSIDE = "a draft writes workflows/<name>/ with its workflow.json and README.md";
|
|
19
|
+
/** Why a workflow.json checked with no workflow DSL is refused. */
|
|
20
|
+
const NO_DSL = "no workflow DSL to read it with: it was not checked";
|
|
47
21
|
/** `problem` as it may be printed: its path and detail cut of `values` and of every shape learning refuses, a bank's
|
|
48
22
|
* numbers too (redactLearned: a name refused for one never prints it), whole when over PRINT_MAX. */
|
|
49
23
|
export const printable = (problem, values) => ({
|
|
@@ -60,33 +34,6 @@ function nameScanned(path, refused, add) {
|
|
|
60
34
|
if (refused(path))
|
|
61
35
|
add("secret_value", "its name holds a value the host named as secret", path);
|
|
62
36
|
}
|
|
63
|
-
/** A note's file name, whoever writes it: nameScanned, and a note's own (a `.md` file at the folder's top). False when
|
|
64
|
-
* it is not a note's name, and nothing else is read. */
|
|
65
|
-
function nameChecked(path, refused, add, outside = "only a .md file at the folder's top is a note") {
|
|
66
|
-
nameScanned(path, refused, add);
|
|
67
|
-
if (path.includes("/") || !path.endsWith(".md"))
|
|
68
|
-
return add("outside", outside, path), false;
|
|
69
|
-
if (!NOTE_FILE.test(path))
|
|
70
|
-
return add("file_name", "a note's name is letters, digits, dots, dashes and underscores, starting with a letter or digit, and ends .md", path), false;
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
/** A note's text by itself, whoever writes it: within the cap, UTF-8, no hidden character, no secret's shape or the host's
|
|
74
|
-
* values, its front matter in shape. The note when it is. */
|
|
75
|
-
function textChecked(path, size, bytes, refused, add, run = false) {
|
|
76
|
-
const cap = run ? CAPS.runNote : CAPS.note;
|
|
77
|
-
// A person's note (or one main holds) is counted without the host's compiled_into line; a run's whole (it may not set it).
|
|
78
|
-
if (!run && bytes)
|
|
79
|
-
size -= compiledLineBytes(Buffer.from(bytes).toString("utf8"));
|
|
80
|
-
if (size > cap)
|
|
81
|
-
return void add("too_large", `${size} bytes; the cap is ${cap}${run ? " for a run's note" : ""}`, path);
|
|
82
|
-
const text = textOf(path, bytes, refused, add);
|
|
83
|
-
if (text === undefined)
|
|
84
|
-
return undefined;
|
|
85
|
-
const note = parseNoteFile(path, text);
|
|
86
|
-
if (Array.isArray(note))
|
|
87
|
-
return void note.forEach((reason) => add("note", reason, path));
|
|
88
|
-
return { ...note, text };
|
|
89
|
-
}
|
|
90
37
|
/** A file's text, whatever it holds: UTF-8, no hidden character, no secret's shape or the host's values. Undefined,
|
|
91
38
|
* with why, when it is not. */
|
|
92
39
|
function textOf(path, bytes, refused, add) {
|
|
@@ -109,9 +56,9 @@ function textOf(path, bytes, refused, add) {
|
|
|
109
56
|
found = (add("secret_value", "it holds a value the host named as secret", path), true);
|
|
110
57
|
return found ? undefined : text;
|
|
111
58
|
}
|
|
112
|
-
/** A learned file at `path` as it is read later, its escapes decoded: a
|
|
113
|
-
*
|
|
114
|
-
*
|
|
59
|
+
/** A learned file at `path` as it is read later, its escapes decoded: a draft's README.md, its front matter read as YAML
|
|
60
|
+
* reads it (workflow-draft.ts frontValues, the value a harness is served); a draft's workflow.json, every string it
|
|
61
|
+
* decodes to, keys too, as JSON.parse reads it (workflow-draft.ts decodedStrings, what draftProblems and a learned
|
|
115
62
|
* call's run read). A hidden character, a secret's shape or the host's value there is refused as one in its text is,
|
|
116
63
|
* though the text as stored spells it in escapes. True when it found one. */
|
|
117
64
|
function decodedScanned(path, text, refused, add, deep = true) {
|
|
@@ -686,38 +633,34 @@ function quoteRule(workflow, schemasAround, depth = 0) {
|
|
|
686
633
|
return { applies: true, checked: [], problems: child.problems.map((problem) => `the composed workflow step ${JSON.stringify(String(writer.label ?? "(no label)").slice(0, 64))} writes the answer: ${problem}`) };
|
|
687
634
|
return problems.length ? { applies: true, problems, checked: [] } : passed;
|
|
688
635
|
}
|
|
689
|
-
/** What a
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
* (quoteCheckProblems); a README that names its folder and says what
|
|
695
|
-
* the draft is for. */
|
|
636
|
+
/** What a draft may write of a workflow (`place`), by itself: a good folder name, never a deletion, a regular file
|
|
637
|
+
* within CAPS.file (a README within CAPS.readme), its text as textOf takes it, and in shape: a draft the DSL validates
|
|
638
|
+
* against `tools` with no node that runs code (draftProblems), whose answering step runs on the agent's model
|
|
639
|
+
* (answerTierProblems), whose steps there read no page (compactStateProblems), whose quotes of the pages it fetched are
|
|
640
|
+
* checked in code (quoteCheckProblems); a README that names its folder and says what the draft is for. */
|
|
696
641
|
function learnedChecked(change, place, refused, input, add) {
|
|
697
642
|
const { path } = change;
|
|
698
643
|
nameScanned(path, refused, add);
|
|
699
|
-
if (!
|
|
700
|
-
return add("file_name",
|
|
644
|
+
if (!WORKFLOW_NAME.test(place.name))
|
|
645
|
+
return add("file_name", "a workflow's name is lowercase letters, digits, dashes and underscores, at most 64, starting with a letter or digit", path);
|
|
701
646
|
if (change.status === "deleted")
|
|
702
|
-
return add("deleted", "a run never deletes a
|
|
703
|
-
if (place.kind === "workflow" && input.workflows === false)
|
|
704
|
-
return add("workflow", NOTES_ONLY, path);
|
|
647
|
+
return add("deleted", "a run never deletes a workflow", path);
|
|
705
648
|
if (change.mode !== undefined && change.mode !== "100644")
|
|
706
649
|
return add("file_mode", MODES[change.mode] ?? "not a regular file: never read", path);
|
|
707
650
|
const size = change.size ?? change.bytes?.length ?? 0;
|
|
708
651
|
const cap = place.kind === "readme" ? CAPS.readme : CAPS.file;
|
|
709
652
|
if (size > cap)
|
|
710
653
|
return add("too_large", `${size} bytes; the cap is ${cap}`, path);
|
|
711
|
-
// A person's call stands: a
|
|
654
|
+
// A person's call stands: a draft whose text on main has a status (retired, or waiting for its owner's OK).
|
|
712
655
|
const readmeOf = `${path.slice(0, path.lastIndexOf("/"))}/README.md`;
|
|
713
656
|
if (input.kept?.includes(path) || (place.kind === "workflow" && input.kept?.includes(readmeOf)))
|
|
714
|
-
return add("
|
|
657
|
+
return add("kept", "a person retired it, or it waits for its owner's OK: a run never changes it", path);
|
|
715
658
|
const text = textOf(path, change.bytes, refused, add);
|
|
716
659
|
if (text === undefined || decodedScanned(path, text, refused, add))
|
|
717
660
|
return;
|
|
718
661
|
if (place.kind === "workflow") {
|
|
719
662
|
if (!input.dsl)
|
|
720
|
-
|
|
663
|
+
return add("workflow", NO_DSL, path);
|
|
721
664
|
const problems = draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy, input.decisions, input.workflowAdapters);
|
|
722
665
|
// A draft the DSL reads parses: its answering step is held to the agent's model, its steps there to compact state
|
|
723
666
|
// (the SDK bridge's runNode picks every model itself: it names no tier), and its quote check to code.
|
|
@@ -734,41 +677,23 @@ function learnedChecked(change, place, refused, input, add) {
|
|
|
734
677
|
add("workflow", dry.detail ?? DRY_RUN_FAILED, path);
|
|
735
678
|
return;
|
|
736
679
|
}
|
|
737
|
-
for (const reason of
|
|
738
|
-
add(
|
|
739
|
-
// Its front matter says what it is and nothing more:
|
|
740
|
-
//
|
|
680
|
+
for (const reason of readmeProblems(text, place.name))
|
|
681
|
+
add("workflow", reason, path);
|
|
682
|
+
// Its front matter says what it is and nothing more: a reader takes directives from any other key. `status` is the
|
|
683
|
+
// host's (`kept`).
|
|
741
684
|
const extra = (frontKeys(text) ?? []).filter((key) => !LEARNED_KEYS.includes(key) && key !== "status");
|
|
742
685
|
if (extra.length)
|
|
743
|
-
add("
|
|
744
|
-
if (place.kind === "skill" && setsStatus(text))
|
|
745
|
-
add("status", "a run never sets a skill's status: the host does, when it holds one for its owner's OK", path);
|
|
746
|
-
}
|
|
747
|
-
/** The checks one note's file passes by itself (SPEC.md), as a person writes it through the host: its name, the note cap,
|
|
748
|
-
* UTF-8, hidden characters, secret shapes and the host's values in its name and text, and its front matter. A person
|
|
749
|
-
* may set `status` and `superseded_by`; what a run may not do (edit, delete, set status) is checkProposal's. Every
|
|
750
|
-
* problem is printable. */
|
|
751
|
-
export function checkNote(path, bytes, refuseValues = []) {
|
|
752
|
-
const problems = [];
|
|
753
|
-
const add = (rule, detail, at) => void problems.push(printable(at === undefined ? { rule, detail } : { rule, path: at, detail }, refuseValues));
|
|
754
|
-
const refused = valueMatcher(refuseValues);
|
|
755
|
-
const note = nameChecked(path, refused, add) ? textChecked(path, bytes.length, bytes, refused, add) : undefined;
|
|
756
|
-
return problems.length || !note ? { problems } : { problems, note };
|
|
686
|
+
add("front_matter", `its front matter sets ${extra.join(", ")}: a learned workflow sets name and description alone`, path);
|
|
757
687
|
}
|
|
758
|
-
/** Checks what a run proposes against SPEC.md: its notes, and a skill or workflow drafts beside them (learnedChecked).
|
|
759
|
-
* `MEMORY.md` is the host's: a change to it is ignored, never refused. */
|
|
760
688
|
/** What must never be stored, in every change's name and text, whatever the checks would refuse it for first: the
|
|
761
|
-
* name and text scans (nameScanned, textOf) of each change, its text read whole (
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
* refuse (propose.ts): an item refused before its text was read hides nothing. */
|
|
689
|
+
* name and text scans (nameScanned, textOf) of each change, its text read whole (a file over its cap, one not a regular
|
|
690
|
+
* file included), printable as checkDraft's are. A text that is not UTF-8 is `encoding`: unread, so never trusted.
|
|
691
|
+
* Empty when nothing in them must be refused. */
|
|
765
692
|
export function unstorable(changes, refuseValues = []) {
|
|
766
693
|
const problems = [];
|
|
767
694
|
const add = (rule, detail, path) => void problems.push(printable(path === undefined ? { rule, detail } : { rule, path, detail }, refuseValues));
|
|
768
695
|
const refused = valueMatcher(refuseValues);
|
|
769
696
|
for (const change of changes) {
|
|
770
|
-
if (change.path === INDEX_FILE)
|
|
771
|
-
continue;
|
|
772
697
|
nameScanned(change.path, refused, add);
|
|
773
698
|
const text = change.bytes ? textOf(change.path, change.bytes, refused, add) : undefined;
|
|
774
699
|
if (text !== undefined)
|
|
@@ -776,242 +701,39 @@ export function unstorable(changes, refuseValues = []) {
|
|
|
776
701
|
}
|
|
777
702
|
return problems;
|
|
778
703
|
}
|
|
779
|
-
|
|
704
|
+
/** Checks one workflow draft (its workflow.json and README.md, given together by draftFiles) against SPEC.md: each file
|
|
705
|
+
* under workflows/<name>/ (learnedChecked), nothing else, and the two together (a workflow whose files are otherwise in
|
|
706
|
+
* shape with one of them missing names it: restore reads the README). Never throws: a draft it could not read (no
|
|
707
|
+
* workflow DSL, a check that threw) is a problem in words. Every problem printable; none when it passes. */
|
|
708
|
+
export function checkDraft(input) {
|
|
780
709
|
const values = input.refuseValues ?? [];
|
|
781
710
|
const problems = [];
|
|
782
711
|
const add = (rule, detail, path) => void problems.push(printable(path === undefined ? { rule, detail } : { rule, path, detail }, values));
|
|
783
|
-
const given = input.changes.filter((change) => change.path !== INDEX_FILE);
|
|
784
712
|
const refused = valueMatcher(values);
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
if (!learnedPlace(change.path) && (change.path.includes("/") || !change.path.endsWith(".md")))
|
|
713
|
+
/** Each workflow's files given, by its name. */
|
|
714
|
+
const given = new Map();
|
|
715
|
+
for (const change of input.changes) {
|
|
716
|
+
const place = learnedPlace(change.path);
|
|
717
|
+
if (!place) {
|
|
718
|
+
nameScanned(change.path, refused, add);
|
|
792
719
|
add("outside", OUTSIDE, change.path);
|
|
793
|
-
else if (change.status === "deleted")
|
|
794
|
-
add("deleted", "a run never deletes a note, a skill or a workflow", change.path);
|
|
795
|
-
add("too_many_files", `${given.length} changed paths; the cap is ${CAPS.changes} a run, and this one, past it, was not read`, change.path);
|
|
796
|
-
}
|
|
797
|
-
const changes = given.slice(0, CAPS.changes);
|
|
798
|
-
const base = new Set(input.base.files);
|
|
799
|
-
// The new notes that pass their own checks, in the answer's order. Which of them is a duplicate is settled after,
|
|
800
|
-
// with the merge's checks (settled below).
|
|
801
|
-
const candidates = [];
|
|
802
|
-
const skills = [];
|
|
803
|
-
const workflows = new Set();
|
|
804
|
-
const added = [];
|
|
805
|
-
const one = (change) => {
|
|
806
|
-
const { path } = change;
|
|
807
|
-
const place = learnedPlace(path);
|
|
808
|
-
if (place) {
|
|
809
|
-
// What the run writes, under a good name, is counted: a skill against the run's, a draft's file against its pair.
|
|
810
|
-
if (change.status !== "deleted" && learnedName(place.kind, place.name)) {
|
|
811
|
-
if (place.kind === "skill")
|
|
812
|
-
skills.push(path);
|
|
813
|
-
else
|
|
814
|
-
workflows.add(place.name);
|
|
815
|
-
}
|
|
816
|
-
return learnedChecked(change, place, refused, input, add);
|
|
817
|
-
}
|
|
818
|
-
if (change.status === "added")
|
|
819
|
-
added.push(path);
|
|
820
|
-
if (!nameChecked(path, refused, add, OUTSIDE))
|
|
821
|
-
return;
|
|
822
|
-
if (change.status === "deleted")
|
|
823
|
-
return add("deleted", "a run never deletes a note", path);
|
|
824
|
-
if (change.mode !== undefined && change.mode !== "100644")
|
|
825
|
-
return add("file_mode", MODES[change.mode] ?? "not a regular file: never read", path);
|
|
826
|
-
if (change.status === "modified")
|
|
827
|
-
return add("edited", "a run never edits a note: to replace one, it adds a new note that supersedes it", path);
|
|
828
|
-
if (base.has(path))
|
|
829
|
-
return add("exists", "the folder has a note by this name", path);
|
|
830
|
-
const note = textChecked(path, change.size ?? change.bytes?.length ?? 0, change.bytes, refused, add, true);
|
|
831
|
-
if (!note)
|
|
832
|
-
return;
|
|
833
|
-
if (["status", "superseded_by", "retired_from", "origin", "compiled_into"].some((key) => note.keys.includes(key)))
|
|
834
|
-
return add("status", "a run never sets status, superseded_by, retired_from, origin or compiled_into: the host does, when it merges the note, a later one supersedes it, a learned workflow is compiled from it or a person retires it", path);
|
|
835
|
-
candidates.push(note);
|
|
836
|
-
};
|
|
837
|
-
for (const change of changes)
|
|
838
|
-
one(change);
|
|
839
|
-
for (const path of added.slice(CAPS.newNotes))
|
|
840
|
-
add("too_many_notes", `${added.length} new notes; the cap is ${CAPS.newNotes} a run, and this one is past it`, path);
|
|
841
|
-
for (const path of skills.slice(CAPS.skills))
|
|
842
|
-
add("too_many_skills", `${skills.length} skills added or changed; a run adds or changes at most ${CAPS.skills}, and this one is past it`, path);
|
|
843
|
-
for (const name of [...workflows].slice(CAPS.workflows))
|
|
844
|
-
add("too_many_workflows", `${workflows.size} workflow drafts added or changed; a run adds or changes at most ${CAPS.workflows}, and this one is past it`, `${WORKFLOWS_DIR}/${name}/workflow.json`);
|
|
845
|
-
// A skill is what every later run reads as how to do the job: only a run that did it writes one.
|
|
846
|
-
if (input.outcome !== "completed")
|
|
847
|
-
for (const path of skills)
|
|
848
|
-
add("skill_outcome", `the run's outcome is ${input.outcome ?? "not known"}: only a completed run adds or changes a skill`, path);
|
|
849
|
-
// A draft is its workflow.json and its README.md, together, as the folder will hold them.
|
|
850
|
-
const gone = new Set(changes.filter((change) => change.status === "deleted").map((change) => change.path));
|
|
851
|
-
const after = new Set([...base, ...changes.filter((change) => change.status !== "deleted").map((change) => change.path)].filter((path) => !gone.has(path)));
|
|
852
|
-
for (const name of workflows) {
|
|
853
|
-
const [json, readme] = ["workflow.json", "README.md"].map((file) => `${WORKFLOWS_DIR}/${name}/${file}`);
|
|
854
|
-
if (after.has(json) !== after.has(readme))
|
|
855
|
-
add("workflow", `the folder holds ${after.has(json) ? "workflow.json" : "README.md"} without the other file`, after.has(json) ? readme : json);
|
|
856
|
-
}
|
|
857
|
-
const notes = problems.length ? [] : settled(candidates);
|
|
858
|
-
return { ok: problems.length === 0, problems, notes: problems.length ? [] : notes };
|
|
859
|
-
/** `candidates` once nothing else is wrong, settled in one order, so no note is ever lost to another's failure:
|
|
860
|
-
* 1. Each note alone against the base (ownProblems): what it supersedes, active there, and how many. One that fails
|
|
861
|
-
* is left out with its own reason.
|
|
862
|
-
* 2. The survivors by rule: the first of a rule holds it, the rest are its alternates. A rule the seed's active
|
|
863
|
-
* notes hold is held already (an alternate that supersedes its holder is an update, and holds it).
|
|
864
|
-
* 3. The holders' shared checks (sharedProblems): two notes superseding one note, the supersedes cap over the run,
|
|
865
|
-
* the index's lines, each counted in order, after the duplicates are out. A holder they refuse is left out with
|
|
866
|
-
* that reason, and its next alternate holds the rule in its place; then 3 again, until nothing changes (each
|
|
867
|
-
* round leaves one note out or more: bounded by the count).
|
|
868
|
-
* 4. Only then the alternates no rule needed are left out, each as the duplicate of its rule's holder.
|
|
869
|
-
* The notes that pass, in the answer's order. */
|
|
870
|
-
function settled(all) {
|
|
871
|
-
const survivors = all.filter((note) => {
|
|
872
|
-
const own = ownProblems(input.base, note);
|
|
873
|
-
for (const problem of own)
|
|
874
|
-
add(problem.rule, problem.detail, problem.path);
|
|
875
|
-
return own.length === 0;
|
|
876
|
-
});
|
|
877
|
-
const out = new Set();
|
|
878
|
-
for (;;) {
|
|
879
|
-
const { holders } = byRule(survivors.filter((note) => !out.has(note.file)));
|
|
880
|
-
const shared = sharedProblems(input.base, holders);
|
|
881
|
-
if (!shared.length) {
|
|
882
|
-
const { holders: kept, alternates } = byRule(survivors.filter((note) => !out.has(note.file)));
|
|
883
|
-
for (const [note, holder] of alternates)
|
|
884
|
-
add("duplicate", `it says what ${holder} says`, note.file);
|
|
885
|
-
return kept;
|
|
886
|
-
}
|
|
887
|
-
for (const problem of shared) {
|
|
888
|
-
add(problem.rule, problem.detail, problem.path);
|
|
889
|
-
out.add(problem.path);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
/** `notes` by rule, in order: the first of a rule holds it, the rest are its alternates (each with its holder). A
|
|
894
|
-
* rule the seed's active notes hold is held by that note, unless the new note supersedes it (an update), or any of
|
|
895
|
-
* `notes` does: a note this proposal supersedes keeps no rule after it, so a copy of its rule under another name is
|
|
896
|
-
* no duplicate, and the rule is never left with no active note. */
|
|
897
|
-
function byRule(notes) {
|
|
898
|
-
const going = new Set(notes.flatMap((note) => note.supersedes));
|
|
899
|
-
const rules = new Map([...(input.base.rules ?? [])].filter(([, holder]) => !going.has(holder)));
|
|
900
|
-
const holders = [];
|
|
901
|
-
const alternates = [];
|
|
902
|
-
for (const note of notes) {
|
|
903
|
-
const rule = ruleOf(note.body);
|
|
904
|
-
const holder = rules.get(rule);
|
|
905
|
-
if (holder !== undefined && !note.supersedes.includes(holder)) {
|
|
906
|
-
// An update of the holder the seed has, after a copy of its rule: the update holds the rule, the copy is its
|
|
907
|
-
// alternate (else the update is dropped as the copy's duplicate, and the copy as the seed's, on the next pass).
|
|
908
|
-
const original = input.base.rules?.get(rule);
|
|
909
|
-
const at = holders.findIndex((one) => one.file === holder);
|
|
910
|
-
if (original !== undefined && holder !== original && at >= 0 && note.supersedes.includes(original)) {
|
|
911
|
-
// At its own place in the answer (the end of the holders so far), not the copy's: the shared checks name notes
|
|
912
|
-
// in answer order, so an update must not jump ahead of a note between the two.
|
|
913
|
-
alternates.push([holders.splice(at, 1)[0], note.file]);
|
|
914
|
-
holders.push(note);
|
|
915
|
-
rules.set(rule, note.file);
|
|
916
|
-
continue;
|
|
917
|
-
}
|
|
918
|
-
alternates.push([note, holder]);
|
|
919
|
-
continue;
|
|
920
|
-
}
|
|
921
|
-
rules.set(rule, note.file);
|
|
922
|
-
holders.push(note);
|
|
923
|
-
}
|
|
924
|
-
return { holders, alternates };
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
/** What `note` alone cannot join `base` with, needing no other note: a `supersedes` that names no active note of `base`,
|
|
928
|
-
* or more of them than CAPS.supersedes. */
|
|
929
|
-
function ownProblems(base, note) {
|
|
930
|
-
const active = new Set(base.active.map((one) => one.file));
|
|
931
|
-
const out = note.supersedes.filter((old) => !active.has(old)).map((old) => ({ rule: "supersedes", path: note.file, detail: `it supersedes ${old}, which is not an active note` }));
|
|
932
|
-
if (note.supersedes.length > CAPS.supersedes)
|
|
933
|
-
out.push({ rule: "supersedes", path: note.file, detail: `it supersedes ${note.supersedes.length} notes; the cap is ${CAPS.supersedes} a run` });
|
|
934
|
-
return out;
|
|
935
|
-
}
|
|
936
|
-
/** What stops the holders `notes` (one a rule, each passing ownProblems) from joining `base` together, each named by the
|
|
937
|
-
* note it falls on. In the answer's order: a note that supersedes one an earlier note supersedes, or that takes the
|
|
938
|
-
* notes superseded past CAPS.supersedes (a note named counts toward neither, so a later one that fits is kept). Then
|
|
939
|
-
* the index over the rest, whole (each active new note a line, each note it supersedes one fewer), so a note that frees
|
|
940
|
-
* lines counts wherever it stands: past INDEX_LINES, the notes that add lines are named from the answer's end until
|
|
941
|
-
* it fits. */
|
|
942
|
-
function sharedProblems(base, notes) {
|
|
943
|
-
const out = [];
|
|
944
|
-
const replaced = new Set();
|
|
945
|
-
const fits = [];
|
|
946
|
-
for (const note of notes) {
|
|
947
|
-
const twice = note.supersedes.find((old) => replaced.has(old));
|
|
948
|
-
if (twice) {
|
|
949
|
-
out.push({ rule: "supersedes", path: note.file, detail: `${twice} is superseded by another new note too` });
|
|
950
720
|
continue;
|
|
951
721
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
722
|
+
if (change.status !== "deleted")
|
|
723
|
+
given.set(place.name, (given.get(place.name) ?? new Set()).add(place.kind));
|
|
724
|
+
try {
|
|
725
|
+
learnedChecked(change, place, refused, input, add);
|
|
726
|
+
}
|
|
727
|
+
catch (error) {
|
|
728
|
+
add("workflow", `it could not be checked: ${String(error?.message ?? error).slice(0, 200)}`, change.path);
|
|
956
729
|
}
|
|
957
|
-
for (const old of note.supersedes)
|
|
958
|
-
replaced.add(old);
|
|
959
|
-
fits.push(note);
|
|
960
730
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
if (lines <= INDEX_LINES)
|
|
965
|
-
break;
|
|
966
|
-
if (net(note) <= 0)
|
|
731
|
+
for (const [name, kinds] of given) {
|
|
732
|
+
const dir = `${WORKFLOWS_DIR}/${name}/`;
|
|
733
|
+
if (kinds.size === 2 || problems.some((problem) => problem.path?.startsWith(dir)))
|
|
967
734
|
continue;
|
|
968
|
-
|
|
969
|
-
|
|
735
|
+
const missing = kinds.has("workflow") ? "README.md" : "workflow.json";
|
|
736
|
+
add("workflow", `${OUTSIDE}: its ${missing} is missing`, `${dir}${missing}`);
|
|
970
737
|
}
|
|
971
|
-
return
|
|
972
|
-
}
|
|
973
|
-
/** The notes the active ones of `notes` supersede, each by the note that supersedes it. A note that waits for its
|
|
974
|
-
* owner's OK (`status: pending`) supersedes nothing until it is approved: what it names stays active. The one rule the
|
|
975
|
-
* merge writes by (runner/learning-loop.ts mergeChangeOf) and its index is counted by (mergeProblems). */
|
|
976
|
-
export function supersededBy(notes) {
|
|
977
|
-
return new Map(notes.filter((note) => note.status === "active").flatMap((note) => note.supersedes.map((old) => [old, note.file])));
|
|
978
|
-
}
|
|
979
|
-
/** What stops `notes` from joining `base` as they are: a name `base` holds (`exists`), a `supersedes` that names no
|
|
980
|
-
* active note of `base` or one another new note supersedes too, or more than CAPS.supersedes notes superseded, and an
|
|
981
|
-
* index past INDEX_LINES, counted as the merge makes it (supersededBy: a pending note adds no line and replaces none).
|
|
982
|
-
* The checker asks it of the run's seed, where every new note is active; the host asks it again of main at merge time,
|
|
983
|
-
* with each note as it merges it, since other runs may have merged meanwhile. */
|
|
984
|
-
export function mergeProblems(base, notes, refuseValues = []) {
|
|
985
|
-
const files = new Set(base.files);
|
|
986
|
-
const active = new Set(base.active.map((note) => note.file));
|
|
987
|
-
const out = [];
|
|
988
|
-
const replaced = new Set();
|
|
989
|
-
// The grader reads each note superseded in full (grade.ts): their count is capped, as the new notes' is. Counted in
|
|
990
|
-
// the order the notes come: a note that would take the count past the cap is named (and left out), and what it
|
|
991
|
-
// supersedes is neither counted nor held as superseded for the notes after it, so a later one that fits is kept.
|
|
992
|
-
const counted = new Set();
|
|
993
|
-
for (const note of notes) {
|
|
994
|
-
if (files.has(note.file))
|
|
995
|
-
out.push({ rule: "exists", path: note.file, detail: "the folder has a note by this name" });
|
|
996
|
-
const would = new Set([...counted, ...note.supersedes]);
|
|
997
|
-
const over = would.size > CAPS.supersedes;
|
|
998
|
-
for (const old of note.supersedes) {
|
|
999
|
-
if (!active.has(old))
|
|
1000
|
-
out.push({ rule: "supersedes", path: note.file, detail: `it supersedes ${old}, which is not an active note` });
|
|
1001
|
-
else if (replaced.has(old))
|
|
1002
|
-
out.push({ rule: "supersedes", path: note.file, detail: `${old} is superseded by another new note too` });
|
|
1003
|
-
if (!over)
|
|
1004
|
-
replaced.add(old);
|
|
1005
|
-
}
|
|
1006
|
-
if (over)
|
|
1007
|
-
out.push({ rule: "supersedes", path: note.file, detail: `with it the new notes supersede ${would.size} notes; the cap is ${CAPS.supersedes} a run` });
|
|
1008
|
-
else
|
|
1009
|
-
for (const old of note.supersedes)
|
|
1010
|
-
counted.add(old);
|
|
1011
|
-
}
|
|
1012
|
-
const gone = supersededBy(notes);
|
|
1013
|
-
const lines = [...active].filter((file) => !gone.has(file)).length + notes.filter((note) => note.status === "active").length;
|
|
1014
|
-
if (lines > INDEX_LINES)
|
|
1015
|
-
out.push({ rule: "index_full", detail: `the index would hold ${lines} lines; it holds at most ${INDEX_LINES}, so supersede a note rather than add one` });
|
|
1016
|
-
return out.map((problem) => printable(problem, refuseValues));
|
|
738
|
+
return problems;
|
|
1017
739
|
}
|