@brainervirus/workit-pi 6.0.1 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,10 @@ pi install ./packages/workit-pi -l --approve # local checkout
15
15
  ```
16
16
 
17
17
  Pi discovers the extension and skills from the package's `pi` manifest
18
- (`./dist/workit.js`, `./skills`). Pi project trust still gates mutations;
19
- shell writes are agent-guided, since an extension is not an OS sandbox.
18
+ (`./dist/workit.js`, `./skills`). Pi project trust still gates mutations.
19
+ The `tool_call` boundary applies branch policy and the
20
+ [before-write gate](https://github.com/BrainerVirus/workit/blob/main/docs/guides/verification.md) to write, edit and recognizable bash
21
+ writes (unrecognized shell writes stay agent-guided; an extension is not an OS
22
+ sandbox). Tools take flat fields.
20
23
  Delivery limits come from Pi's permissions plus the workspace
21
24
  [grants](https://github.com/BrainerVirus/workit/blob/main/docs/guides/grants.md).
package/dist/worker.js CHANGED
@@ -7206,6 +7206,14 @@ function object(shape, params) {
7206
7206
  };
7207
7207
  return new ZodObject(def);
7208
7208
  }
7209
+ function looseObject(shape, params) {
7210
+ return new ZodObject({
7211
+ type: "object",
7212
+ shape,
7213
+ catchall: unknown(),
7214
+ ...normalizeParams(params)
7215
+ });
7216
+ }
7209
7217
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
7210
7218
  $ZodUnion.init(inst, def);
7211
7219
  ZodType.init(inst, def);
@@ -7607,76 +7615,16 @@ var provenanceSchema = object({
7607
7615
  workerId: nullableId
7608
7616
  }).strict();
7609
7617
  var entrySchema = (data) => object({ id, recordedAt: utc, provenance: provenanceSchema, data }).strict();
7610
- var factSchema = object({
7611
- statement: text,
7612
- basis: _enum(["observed", "inferred", "unknown"]),
7613
- refs: array(refSchema)
7614
- }).strict().check((ctx) => {
7615
- if (ctx.value.basis === "observed" && ctx.value.refs.length === 0)
7616
- ctx.issues.push({
7617
- code: "custom",
7618
- input: ctx.value,
7619
- message: "observed facts require supporting references",
7620
- path: ["refs"]
7621
- });
7622
- });
7623
- var signalSchema = object({
7624
- value: union([boolean2(), literal("unknown")]),
7625
- basis: _enum(["observed", "inferred", "unknown"]),
7626
- reason: text,
7618
+ var RISK_TIERS = ["trivial", "normal", "high"];
7619
+ var judgmentSchema = object({
7620
+ riskTier: _enum(RISK_TIERS),
7621
+ behaviorChange: boolean2(),
7622
+ productChoiceOpen: boolean2(),
7623
+ needsPlan: boolean2(),
7624
+ note: text.nullable(),
7627
7625
  refs: array(refSchema)
7628
- }).strict().check((ctx) => {
7629
- const signal = ctx.value;
7630
- const valid = signal.value === "unknown" ? signal.basis === "unknown" : signal.basis === "observed" || signal.basis === "inferred";
7631
- if (!valid)
7632
- ctx.issues.push({
7633
- code: "custom",
7634
- input: signal,
7635
- message: "signal value and basis disagree",
7636
- path: []
7637
- });
7638
- if (signal.basis === "observed" && signal.refs.length === 0)
7639
- ctx.issues.push({
7640
- code: "custom",
7641
- input: signal,
7642
- message: "observed signals require supporting references",
7643
- path: ["refs"]
7644
- });
7645
- });
7646
- var signalSet = object({
7647
- approachUnknown: signalSchema,
7648
- productChoiceOpen: signalSchema,
7649
- behaviorChange: signalSchema,
7650
- mechanicalLowRisk: signalSchema,
7651
- durableAgreementNeeded: signalSchema,
7652
- coordinationPlanNeeded: signalSchema,
7653
- helperUseful: signalSchema,
7654
- testFirstPractical: signalSchema
7655
- }).strict();
7656
- var consequenceSchema = object({
7657
- area: _enum([
7658
- "behavior",
7659
- "public_contract",
7660
- "data",
7661
- "security",
7662
- "operations",
7663
- "reversibility",
7664
- "consumers"
7665
- ]),
7666
- fact: factSchema
7667
- }).strict();
7668
- var verificationSchema = object({
7669
- claim: text,
7670
- scope: scopeSchema,
7671
- availableChecks: array(refSchema),
7672
- gaps: array(text)
7673
- }).strict();
7674
- var assessmentSchema = object({
7675
- facts: array(factSchema),
7676
- signals: signalSet,
7677
- consequences: array(consequenceSchema),
7678
- verification: array(verificationSchema)
7679
7626
  }).strict();
7627
+ var legacyAssessmentSchema = looseObject({});
7680
7628
  var constraintSchema = object({
7681
7629
  id: nonEmpty,
7682
7630
  kind: _enum(["host", "project", "user"]),
@@ -7912,7 +7860,8 @@ var taskRecordSchema = object({
7912
7860
  progress: progressSchema,
7913
7861
  pauseReason: text.nullable().optional(),
7914
7862
  runtime: runtimeSchema.optional(),
7915
- assessments: array(entrySchema(assessmentSchema)),
7863
+ assessments: array(entrySchema(legacyAssessmentSchema)),
7864
+ judgments: array(entrySchema(judgmentSchema)).optional(),
7916
7865
  policy: policySchema.nullable(),
7917
7866
  policyChanges: array(policyChangeSchema),
7918
7867
  candidates: array(candidateSchema),
@@ -8035,14 +7984,15 @@ var taskOperations = {
8035
7984
  decisionIds: array(id).optional()
8036
7985
  })
8037
7986
  };
7987
+ var rawJudgment = record(string2(), unknown());
8038
7988
  var policyOperations = {
8039
7989
  assess: operation({
8040
7990
  action: literal("assess"),
8041
7991
  ...taskId,
8042
7992
  expectedRevision: revision.optional(),
8043
- assessment: assessmentSchema
7993
+ judgment: rawJudgment
8044
7994
  }),
8045
- preview: operation({ action: literal("preview"), ...taskId, assessment: assessmentSchema }),
7995
+ preview: operation({ action: literal("preview"), ...taskId, judgment: rawJudgment }),
8046
7996
  explain: operation({ action: literal("explain"), ...taskId })
8047
7997
  };
8048
7998
  var evidenceOperations = {
@@ -8081,7 +8031,10 @@ var decisionOperations = {
8081
8031
  ...taskId,
8082
8032
  expectedRevision: revision.optional(),
8083
8033
  purpose: decisionSchema.shape.purpose,
8084
- binding: decisionSchema.shape.binding,
8034
+ binding: decisionSchema.shape.binding.extend({
8035
+ taskId: id.optional(),
8036
+ workspaceId: id.optional()
8037
+ }),
8085
8038
  response: decisionSchema.shape.response,
8086
8039
  requirementIds: array(digest)
8087
8040
  }),
@@ -8135,6 +8088,15 @@ var operationSchemas = {
8135
8088
  worker: discriminatedUnion("action", Object.values(workerOperations)),
8136
8089
  state: discriminatedUnion("action", Object.values(stateOperations))
8137
8090
  };
8091
+ var OPERATION_ACTIONS = {
8092
+ task: Object.keys(taskOperations),
8093
+ policy: Object.keys(policyOperations),
8094
+ evidence: Object.keys(evidenceOperations),
8095
+ finding: Object.keys(findingOperations),
8096
+ decision: Object.keys(decisionOperations),
8097
+ worker: Object.keys(workerOperations),
8098
+ state: Object.keys(stateOperations)
8099
+ };
8138
8100
  var withImplicitTask = (options) => Object.values(options).map((option) => ("taskId" in option.shape) ? option.extend({ taskId: id.optional() }) : option);
8139
8101
  var advertised = (options) => discriminatedUnion("action", withImplicitTask(options));
8140
8102
  var advertisedOperationSchemas = {
@@ -8223,6 +8185,126 @@ function candidateDigest(input) {
8223
8185
  head: input.head
8224
8186
  });
8225
8187
  }
8188
+ // packages/workit-core/src/core/operation-input.ts
8189
+ var str = (d, values) => ({
8190
+ type: "string",
8191
+ ...values ? { enum: values } : {},
8192
+ ...d ? { d } : {}
8193
+ });
8194
+ var list = (d) => ({ type: "array", ...d ? { d } : {} });
8195
+ var bool = (d) => ({ type: "boolean", ...d ? { d } : {} });
8196
+ var int2 = (d) => ({ type: "integer", ...d ? { d } : {} });
8197
+ var scopeFields = {
8198
+ paths: list("Scope paths (default: whole checkout)."),
8199
+ exclusions: list(),
8200
+ scope: str("Scope description.")
8201
+ };
8202
+ var refs = list("Paths or URLs.");
8203
+ var FLAT = {
8204
+ task: {
8205
+ fields: {
8206
+ objective: str(),
8207
+ ...scopeFields,
8208
+ refs,
8209
+ reason: str(),
8210
+ summary: str(),
8211
+ nextAction: str(),
8212
+ blockers: list(),
8213
+ outcome: str(undefined, ["verified", "accepted_limitations", "stopped"]),
8214
+ decisionIds: list(),
8215
+ status: str(undefined, ["open", "closed", "all"]),
8216
+ query: str(),
8217
+ limit: int2(),
8218
+ view: str(undefined, ["summary", "full"])
8219
+ }
8220
+ },
8221
+ policy: {
8222
+ fields: {
8223
+ riskTier: str("low=trivial, medium=normal.", ["trivial", "normal", "high", "low", "medium"]),
8224
+ behaviorChange: bool("Observable behavior changes."),
8225
+ productChoiceOpen: bool("A product/preference choice is still open."),
8226
+ needsPlan: bool("Needs a written plan or spec first."),
8227
+ note: str(),
8228
+ refs: list("Plan/spec paths or URLs.")
8229
+ }
8230
+ },
8231
+ evidence: {
8232
+ fields: {
8233
+ kind: str(undefined, ["check", "review", "investigation", "artifact"]),
8234
+ claim: str(),
8235
+ result: str(undefined, ["passed", "failed", "missing", "skipped"]),
8236
+ summary: str(),
8237
+ exitCode: int2(),
8238
+ refs,
8239
+ requirementIds: list(),
8240
+ candidateId: str(),
8241
+ beforeCandidateId: str(),
8242
+ reviewSession: str("Reviewer session handle (review evidence).")
8243
+ }
8244
+ },
8245
+ finding: {
8246
+ fields: {
8247
+ claim: str(),
8248
+ consequence: str(),
8249
+ ...scopeFields,
8250
+ candidateId: str(),
8251
+ refs,
8252
+ findingId: str(),
8253
+ disposition: str(undefined, ["open", "fixed", "dismissed", "deferred"]),
8254
+ reason: str(),
8255
+ evidenceIds: list(),
8256
+ decisionIds: list()
8257
+ }
8258
+ },
8259
+ decision: {
8260
+ fields: {
8261
+ purpose: str(undefined, ["design", "action", "limitation", "preference"]),
8262
+ response: str(undefined, ["approved", "rejected", "stated"]),
8263
+ presented: str("What the user was asked."),
8264
+ choice: str("The user's stated choice (response=stated)."),
8265
+ ...scopeFields,
8266
+ refs,
8267
+ requirementIds: list(),
8268
+ decisionId: str(),
8269
+ reason: str()
8270
+ }
8271
+ },
8272
+ worker: {
8273
+ fields: {
8274
+ role: str(undefined, ["investigator", "reviewer", "implementer"]),
8275
+ objective: str(),
8276
+ ...scopeFields,
8277
+ decisionIds: list(),
8278
+ requirementIds: list(),
8279
+ candidateId: str(),
8280
+ stoppingCondition: str(),
8281
+ workerId: str(),
8282
+ outcome: str(undefined, ["completed", "failed", "cancelled"]),
8283
+ summary: str(),
8284
+ evidenceIds: list(),
8285
+ findingIds: list(),
8286
+ reason: str()
8287
+ }
8288
+ },
8289
+ state: {
8290
+ fields: { bundle: { type: "object", d: "An export bundle (object or JSON string)." } }
8291
+ }
8292
+ };
8293
+ var COMMON = {
8294
+ taskId: str("Omit for this branch's task."),
8295
+ expectedRevision: str(),
8296
+ expectedWorkspaceRevision: str()
8297
+ };
8298
+ var READ_TASK_FIELDS = new Set(["status", "query", "limit", "view"]);
8299
+ var READ_ONLY_ACTIONS = new Set(["list", "inspect", "preview", "explain", "export"]);
8300
+ var ENVELOPE = new Set([
8301
+ "schemaVersion",
8302
+ "action",
8303
+ "taskId",
8304
+ "expectedRevision",
8305
+ "expectedWorkspaceRevision",
8306
+ "judgment"
8307
+ ]);
8226
8308
  // packages/workit-core/src/core/package-root.ts
8227
8309
  import { existsSync } from "node:fs";
8228
8310
  import path from "node:path";
@@ -8292,6 +8374,25 @@ var heldInProcess = new Map;
8292
8374
  // packages/workit-core/src/git/rev.ts
8293
8375
  var MAX_BUFFER = 256 * 1024 * 1024;
8294
8376
  var MAX_UNTRACKED_BYTES = 5 * 1024 * 1024;
8377
+
8378
+ // packages/workit-core/src/ledger.ts
8379
+ var PASSING = new Set(["verified", "tests-verified", "type-check-only"]);
8380
+ var FAILING = new Set(["failed", "blocked"]);
8381
+ var STRONG_RESULTS = new Set(["verified", "tests-verified"]);
8382
+ var PR_ROW_TYPES = new Set(["pr.created", "pr.status", "pr.merged"]);
8383
+ var NETWORK_FS_TYPES = new Set([
8384
+ 26985,
8385
+ 20859,
8386
+ 4266872130,
8387
+ 4283649346,
8388
+ 1702057286,
8389
+ 1397113167,
8390
+ 12805120,
8391
+ 16914839,
8392
+ 1196443219,
8393
+ 198183888
8394
+ ]);
8395
+ var OBSERVED_ONLY = new Set(["check", ...PR_ROW_TYPES]);
8295
8396
  // packages/workit-core/src/core/config.ts
8296
8397
  var PRESETS = {
8297
8398
  gitflow: {
@@ -8356,26 +8457,31 @@ var versionSourceSchema = discriminatedUnion("kind", [
8356
8457
  object({ kind: literal("manual") }).strict()
8357
8458
  ]);
8358
8459
  var releaseTrackSchema = object({
8359
- strategy: branchPreset,
8460
+ strategy: branchPreset.optional(),
8360
8461
  productionBranch: nonBlank,
8361
8462
  integrationBranch: nonBlank,
8362
- naming: object({ feature: nonBlank, release: nonBlank, hotfix: nonBlank }).strict(),
8363
- baseBranch: nonBlank,
8364
- mergeBackBranches: array(nonBlank),
8365
- pullRequestTarget: nonBlank,
8366
- tagNamespace: string2(),
8367
- versionSource: versionSourceSchema,
8368
- requiredChecks: array(nonBlank)
8369
- }).strict().superRefine((track, context) => {
8463
+ naming: object({
8464
+ feature: nonBlank.optional(),
8465
+ release: nonBlank.optional(),
8466
+ hotfix: nonBlank.optional()
8467
+ }).passthrough().optional(),
8468
+ baseBranch: nonBlank.optional(),
8469
+ mergeBackBranches: array(nonBlank).optional(),
8470
+ pullRequestTarget: nonBlank.optional(),
8471
+ tagNamespace: string2().optional(),
8472
+ versionSource: versionSourceSchema.optional(),
8473
+ requiredChecks: array(nonBlank).optional(),
8474
+ critical: array(nonBlank).optional()
8475
+ }).passthrough().superRefine((track, context) => {
8370
8476
  for (const [field, values] of [
8371
- ["mergeBackBranches", track.mergeBackBranches],
8372
- ["requiredChecks", track.requiredChecks]
8477
+ ["mergeBackBranches", track.mergeBackBranches ?? []],
8478
+ ["requiredChecks", track.requiredChecks ?? []]
8373
8479
  ]) {
8374
8480
  if (new Set(values).size !== values.length) {
8375
8481
  context.addIssue({ code: "custom", path: [field], message: "entries must be unique" });
8376
8482
  }
8377
8483
  }
8378
- if (track.versionSource.kind === "package-json" && (path2.posix.isAbsolute(track.versionSource.path.replaceAll("\\", "/")) || /^[A-Za-z]:\//u.test(track.versionSource.path.replaceAll("\\", "/")) || track.versionSource.path.replaceAll("\\", "/").split("/").includes(".."))) {
8484
+ if (track.versionSource?.kind === "package-json" && (path2.posix.isAbsolute(track.versionSource.path.replaceAll("\\", "/")) || /^[A-Za-z]:\//u.test(track.versionSource.path.replaceAll("\\", "/")) || track.versionSource.path.replaceAll("\\", "/").split("/").includes(".."))) {
8379
8485
  context.addIssue({
8380
8486
  code: "custom",
8381
8487
  path: ["versionSource", "path"],
@@ -8394,6 +8500,7 @@ var workspaceConfigSchema = object({
8394
8500
  }).passthrough().optional(),
8395
8501
  autoApprove: union([boolean2(), array(nonBlank)]).optional(),
8396
8502
  defaultEndpoint: _enum(["commit", "pr"]).optional(),
8503
+ verification: _enum(["self", "independent"]).optional(),
8397
8504
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
8398
8505
  kind,
8399
8506
  union([boolean2(), literal("verified")]).optional()
@@ -8437,18 +8544,35 @@ var workspacesFileSchema = object({ workspaces: array(workspaceConfigSchema).opt
8437
8544
  var runtimeWorkspaceIndexSchema = object({
8438
8545
  workspaces: array(object({ name: nonBlank, glob: nonBlank }).passthrough()).optional()
8439
8546
  }).passthrough();
8440
- // packages/workit-core/src/core/policy-resolver.ts
8441
- var resolverInputSchema = object({
8442
- intent: intentSchema,
8443
- assessment: assessmentSchema,
8444
- constraints: array(constraintSchema),
8445
- prior: object({
8446
- decisions: array(decisionSchema),
8447
- findings: array(findingSchema),
8448
- requirements: array(requirementSchema)
8449
- }).strict(),
8450
- preferences: object({ fast: boolean2().optional(), thorough: boolean2().optional() }).strict().optional()
8451
- }).strict();
8547
+
8548
+ // packages/workit-core/src/core/release-tracks.ts
8549
+ var KNOWN_FIELDS = new Set([
8550
+ "strategy",
8551
+ "productionBranch",
8552
+ "integrationBranch",
8553
+ "naming",
8554
+ "baseBranch",
8555
+ "mergeBackBranches",
8556
+ "pullRequestTarget",
8557
+ "tagNamespace",
8558
+ "versionSource",
8559
+ "requiredChecks",
8560
+ "critical"
8561
+ ]);
8562
+ var memo2 = new Map;
8563
+ // packages/workit-core/src/core/policy/judgment.ts
8564
+ var LEGACY_KEYS = new Set(["assessment", "facts", "signals", "consequences", "verification"]);
8565
+ var YES = new Set(["true", "yes", "y", "1", "on"]);
8566
+ var NO = new Set(["false", "no", "n", "0", "off", "none"]);
8567
+
8568
+ // packages/workit-core/src/autonomy.ts
8569
+ var DEFAULT_GRANTS = Object.freeze({
8570
+ push: true,
8571
+ pr: true,
8572
+ merge: false,
8573
+ release: false,
8574
+ rerun: true
8575
+ });
8452
8576
 
8453
8577
  // packages/workit-core/src/core/task-engine.ts
8454
8578
  var verifiedWorkers = new WeakMap;