wabachi 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.codex-plugin/plugin.json +6 -0
  2. package/LICENSE +1 -1
  3. package/README.md +17 -21
  4. package/dist/architecture/cli.js +51 -36
  5. package/dist/architecture/cli.js.map +1 -1
  6. package/dist/architecture/documentation/react-flow.d.ts +23 -0
  7. package/dist/architecture/documentation/react-flow.js +436 -0
  8. package/dist/architecture/documentation/react-flow.js.map +1 -0
  9. package/dist/architecture/documentation/site.d.ts +10 -13
  10. package/dist/architecture/documentation/site.js +58 -24
  11. package/dist/architecture/documentation/site.js.map +1 -1
  12. package/dist/architecture/projection/react-flow.d.ts +96 -0
  13. package/dist/architecture/projection/react-flow.js +388 -0
  14. package/dist/architecture/projection/react-flow.js.map +1 -0
  15. package/dist/cli.js +53 -14
  16. package/dist/cli.js.map +1 -1
  17. package/dist/command-contract.d.ts +78 -0
  18. package/dist/command-contract.js +194 -0
  19. package/dist/command-contract.js.map +1 -0
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/runtime/repository.d.ts +3 -0
  24. package/dist/runtime/repository.js +140 -16
  25. package/dist/runtime/repository.js.map +1 -1
  26. package/dist/runtime/run.js +3 -1
  27. package/dist/runtime/run.js.map +1 -1
  28. package/dist/skill.d.ts +47 -0
  29. package/dist/skill.js +160 -0
  30. package/dist/skill.js.map +1 -0
  31. package/dist/working-set/codec.d.ts +7 -0
  32. package/dist/working-set/codec.js +53 -0
  33. package/dist/working-set/codec.js.map +1 -0
  34. package/dist/working-set/conflicts.d.ts +46 -0
  35. package/dist/working-set/conflicts.js +97 -0
  36. package/dist/working-set/conflicts.js.map +1 -0
  37. package/dist/working-set/derive.d.ts +34 -0
  38. package/dist/working-set/derive.js +634 -0
  39. package/dist/working-set/derive.js.map +1 -0
  40. package/dist/working-set/index.d.ts +3 -0
  41. package/dist/working-set/index.js +3 -0
  42. package/dist/working-set/index.js.map +1 -0
  43. package/dist/working-set/model.d.ts +93 -0
  44. package/dist/working-set/model.js +204 -0
  45. package/dist/working-set/model.js.map +1 -0
  46. package/dist/working-set/quality.d.ts +201 -0
  47. package/dist/working-set/quality.js +447 -0
  48. package/dist/working-set/quality.js.map +1 -0
  49. package/dist/working-set/seeds.d.ts +135 -0
  50. package/dist/working-set/seeds.js +433 -0
  51. package/dist/working-set/seeds.js.map +1 -0
  52. package/docs/USAGE.md +118 -0
  53. package/docs/examples/minimal-canon.json +24 -0
  54. package/package.json +14 -4
  55. package/skills/wabachi/SKILL.md +39 -0
@@ -0,0 +1,97 @@
1
+ import { CANDIDATE_WORKING_SET_LIMITS, } from "./model.js";
2
+ /** V1 diagnostics that must remain visible instead of being resolved implicitly. */
3
+ export const WORKING_SET_CONFLICT_KINDS = [
4
+ "ambiguity",
5
+ "disagreement",
6
+ "stale-evidence",
7
+ "mapping-gap",
8
+ "required-but-unauthorized",
9
+ "insufficient-evidence",
10
+ ];
11
+ const CONFLICT_SUMMARIES = Object.freeze({
12
+ ambiguity: "candidate evidence has multiple possible interpretations",
13
+ disagreement: "provider evidence disagrees about the candidate context",
14
+ "stale-evidence": "evidence is not pinned to the current repository revision",
15
+ "mapping-gap": "required evidence has no unique Canon repository mapping",
16
+ "required-but-unauthorized": "required context is outside the supplied authorization comparison",
17
+ "insufficient-evidence": "available evidence is insufficient for a current derivation",
18
+ });
19
+ function compareText(left, right) {
20
+ if (left < right)
21
+ return -1;
22
+ if (left > right)
23
+ return 1;
24
+ return 0;
25
+ }
26
+ function evidenceKey(reference) {
27
+ return `${reference.artifact}\u0000${reference.reference}`;
28
+ }
29
+ function boundedEvidence(references) {
30
+ const unique = new Map();
31
+ for (const reference of references)
32
+ unique.set(evidenceKey(reference), reference);
33
+ return [...unique.values()]
34
+ .sort((left, right) => compareText(left.artifact, right.artifact) || compareText(left.reference, right.reference))
35
+ .slice(0, CANDIDATE_WORKING_SET_LIMITS.maxEvidenceReferencesPerEntry);
36
+ }
37
+ function boundedLocator(value) {
38
+ const normalized = value.normalize("NFC");
39
+ return normalized.length === 0 ? "unknown" : normalized.slice(0, CANDIDATE_WORKING_SET_LIMITS.maxTargetLocatorLength);
40
+ }
41
+ /** Creates one deterministic, unresolved conflict record from bounded evidence. */
42
+ export function createWorkingSetConflict(input) {
43
+ const locator = boundedLocator(input.locator);
44
+ const kind = input.kind;
45
+ return Object.freeze({
46
+ kind,
47
+ target: Object.freeze({ kind: "unresolved", locator: boundedLocator(`conflict:${kind}:${locator}`) }),
48
+ reason: Object.freeze({ id: `conflict:${kind}`, summary: CONFLICT_SUMMARIES[kind] }),
49
+ evidence: Object.freeze(boundedEvidence(input.evidence ?? [])),
50
+ });
51
+ }
52
+ /** Converts the semantic conflict record into the existing artifact entry shape. */
53
+ export function conflictToWorkingSetEntry(conflict) {
54
+ return {
55
+ state: "unresolved",
56
+ target: conflict.target,
57
+ reason: conflict.reason,
58
+ evidence: conflict.evidence,
59
+ };
60
+ }
61
+ /** Returns the machine-readable conflict class carried by an unresolved entry. */
62
+ export function getWorkingSetConflictKind(entry) {
63
+ if (entry.state !== "unresolved" || entry.target.kind !== "unresolved")
64
+ return undefined;
65
+ const kind = entry.reason.id.startsWith("conflict:") ? entry.reason.id.slice("conflict:".length) : undefined;
66
+ return WORKING_SET_CONFLICT_KINDS.includes(kind)
67
+ ? kind
68
+ : undefined;
69
+ }
70
+ function isAuthorizationEntry(value) {
71
+ return "target" in value;
72
+ }
73
+ /** Canonicalizes the supported authorization comparison shapes without issuing authority. */
74
+ export function authorizationEntries(input) {
75
+ const values = [...(input.targets ?? []), ...(input.entries ?? []), ...(input.authorizedTargets ?? [])].map((value) => (isAuthorizationEntry(value) ? value : { target: value }));
76
+ const unique = new Map();
77
+ for (const value of values) {
78
+ const key = `${value.target.kind}\u0000${value.target.locator}`;
79
+ const existing = unique.get(key);
80
+ if (existing === undefined) {
81
+ unique.set(key, value);
82
+ continue;
83
+ }
84
+ unique.set(key, {
85
+ target: existing.target,
86
+ evidence: boundedEvidence([...(existing.evidence ?? []), ...(value.evidence ?? [])]),
87
+ });
88
+ }
89
+ return [...unique.values()].sort((left, right) => compareText(left.target.kind, right.target.kind) || compareText(left.target.locator, right.target.locator));
90
+ }
91
+ export function workingSetTargetKey(target) {
92
+ return `${target.kind}\u0000${target.locator}`;
93
+ }
94
+ export function conflictSummary(kind) {
95
+ return CONFLICT_SUMMARIES[kind];
96
+ }
97
+ //# sourceMappingURL=conflicts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflicts.js","sourceRoot":"","sources":["../../src/working-set/conflicts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,GAK7B,MAAM,YAAY,CAAC;AAEpB,oFAAoF;AACpF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,2BAA2B;IAC3B,uBAAuB;CACf,CAAC;AAGX,MAAM,kBAAkB,GAAqD,MAAM,CAAC,MAAM,CAAC;IACzF,SAAS,EAAE,0DAA0D;IACrE,YAAY,EAAE,yDAAyD;IACvE,gBAAgB,EAAE,2DAA2D;IAC7E,aAAa,EAAE,0DAA0D;IACzE,2BAA2B,EAAE,mEAAmE;IAChG,uBAAuB,EAAE,6DAA6D;CACvF,CAAC,CAAC;AAsCH,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,SAAsC;IACzD,OAAO,GAAG,SAAS,CAAC,QAAQ,SAAS,SAAS,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,eAAe,CAAC,UAAkD;IACzE,MAAM,MAAM,GAAG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UAAU,eAAe,CAAC,IAA4B;IAC1D,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type FactNormalizationResult } from "../runtime/facts.js";
2
+ import type { ArchitectureDocumentV1 } from "../architecture/canon/document.js";
3
+ import { type CandidateWorkingSet } from "./model.js";
4
+ import { type WorkingSetAuthorizationInput } from "./conflicts.js";
5
+ import type { WorkingSetSeedResolutionResult } from "./seeds.js";
6
+ /** Canon relationship classes admitted by the V1 derivation boundary. */
7
+ export declare const CANON_V1_RELATIONSHIP_CLASSES: readonly ["depends-on", "calls", "uses", "data", "control"];
8
+ export type CanonV1RelationshipClass = (typeof CANON_V1_RELATIONSHIP_CLASSES)[number];
9
+ /** Provider predicates admitted by the V1 derivation boundary. */
10
+ export declare const PROVIDER_V1_RELATIONSHIP_CLASSES: readonly ["depends-on", "imports", "calls", "references"];
11
+ export type ProviderV1RelationshipClass = (typeof PROVIDER_V1_RELATIONSHIP_CLASSES)[number];
12
+ export interface CandidateWorkingSetDerivationInput {
13
+ /** Seed resolutions are already bound to the task repository and revision. */
14
+ readonly seeds: WorkingSetSeedResolutionResult;
15
+ /** Existing normalized provider evidence and its correlation projection. */
16
+ readonly providerEvidence: FactNormalizationResult;
17
+ /** Existing read-only Architecture Canon. */
18
+ readonly canon: ArchitectureDocumentV1;
19
+ /** Optional artifact identity; the task identity is used when omitted. */
20
+ readonly workingSetId?: string;
21
+ /** Optional external authorization boundary used only as comparison evidence. */
22
+ readonly authorization?: WorkingSetAuthorizationInput;
23
+ }
24
+ /**
25
+ * Derives one authorization-neutral Candidate Working Set from bounded seed
26
+ * resolutions, normalized provider evidence, and the read-only Canon.
27
+ *
28
+ * The algorithm has two deliberate traversal boundaries: Canon `depends-on`
29
+ * may recurse only while the source and target retain the same non-empty
30
+ * boundary membership, and provider relationships are consumed only as a
31
+ * single evidence hop. Other admitted relationship classes add context but
32
+ * never create a transitive provider/repository graph.
33
+ */
34
+ export declare function deriveCandidateWorkingSet(input: CandidateWorkingSetDerivationInput): CandidateWorkingSet;