@plurnk/plurnk-contracts 1.10.0 → 1.11.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 (66) hide show
  1. package/README.md +2 -3
  2. package/SPEC.md +149 -75
  3. package/dist/plurnk.gemma.gbnf +4 -3
  4. package/dist/plurnk.qwen.gbnf +4 -3
  5. package/dist/schema/CapabilityDescriptor.json +23 -0
  6. package/dist/schema/CapabilityPolicy.json +18 -0
  7. package/dist/schema/CapabilityProjection.json +16 -0
  8. package/dist/schema/CapabilitySelector.json +24 -0
  9. package/dist/schema/ClientStatement.json +10 -2
  10. package/dist/schema/LoopPolicy.json +13 -0
  11. package/dist/schema/MatcherBody.json +8 -8
  12. package/dist/schema/ParsedPath.json +1 -11
  13. package/dist/schema/PlurnkStatement.json +76 -34
  14. package/dist/schema/ProblemProjection.json +38 -0
  15. package/dist/schema/ProposalProjection.json +2 -2
  16. package/dist/schema/ResourceSelection.json +12 -2
  17. package/dist/src/ApplicationPort.d.ts +9 -40
  18. package/dist/src/ApplicationPort.d.ts.map +1 -1
  19. package/dist/src/AstBuilder.d.ts +1 -7
  20. package/dist/src/AstBuilder.d.ts.map +1 -1
  21. package/dist/src/AstBuilder.js +127 -102
  22. package/dist/src/AstBuilder.js.map +1 -1
  23. package/dist/src/CapabilityAdmission.d.ts +9 -0
  24. package/dist/src/CapabilityAdmission.d.ts.map +1 -0
  25. package/dist/src/CapabilityAdmission.js +96 -0
  26. package/dist/src/CapabilityAdmission.js.map +1 -0
  27. package/dist/src/PlurnkErrorStrategy.d.ts.map +1 -1
  28. package/dist/src/PlurnkErrorStrategy.js +51 -1
  29. package/dist/src/PlurnkErrorStrategy.js.map +1 -1
  30. package/dist/src/PlurnkParser.d.ts +4 -1
  31. package/dist/src/PlurnkParser.d.ts.map +1 -1
  32. package/dist/src/PlurnkParser.js +86 -21
  33. package/dist/src/PlurnkParser.js.map +1 -1
  34. package/dist/src/Problems.d.ts +6 -1
  35. package/dist/src/Problems.d.ts.map +1 -1
  36. package/dist/src/Problems.js +34 -0
  37. package/dist/src/Problems.js.map +1 -1
  38. package/dist/src/Validator.d.ts +17 -4
  39. package/dist/src/Validator.d.ts.map +1 -1
  40. package/dist/src/Validator.js +65 -10
  41. package/dist/src/Validator.js.map +1 -1
  42. package/dist/src/generated/plurnkLexer.d.ts +52 -40
  43. package/dist/src/generated/plurnkLexer.d.ts.map +1 -1
  44. package/dist/src/generated/plurnkLexer.js +519 -431
  45. package/dist/src/generated/plurnkLexer.js.map +1 -1
  46. package/dist/src/generated/plurnkParser.d.ts +166 -92
  47. package/dist/src/generated/plurnkParser.d.ts.map +1 -1
  48. package/dist/src/generated/plurnkParser.js +1318 -705
  49. package/dist/src/generated/plurnkParser.js.map +1 -1
  50. package/dist/src/generated/plurnkParserVisitor.d.ts +49 -0
  51. package/dist/src/generated/plurnkParserVisitor.d.ts.map +1 -1
  52. package/dist/src/generated/plurnkParserVisitor.js +42 -0
  53. package/dist/src/generated/plurnkParserVisitor.js.map +1 -1
  54. package/dist/src/index.d.ts +4 -4
  55. package/dist/src/index.d.ts.map +1 -1
  56. package/dist/src/index.js +3 -3
  57. package/dist/src/index.js.map +1 -1
  58. package/dist/src/types.d.ts +3 -2
  59. package/dist/src/types.d.ts.map +1 -1
  60. package/dist/src/types.generated.d.ts +140 -34
  61. package/dist/src/types.generated.d.ts.map +1 -1
  62. package/dist/src/types.js +4 -6
  63. package/dist/src/types.js.map +1 -1
  64. package/package.json +2 -2
  65. package/plurnk.md +58 -44
  66. package/dist/schema/LoopFlags.json +0 -16
package/plurnk.md CHANGED
@@ -1,10 +1,7 @@
1
1
  # Plurnk Service
2
2
 
3
3
  YOU MUST ONLY use the Plurnk OPs (PLAN|FIND|READ|EDIT|COPY|MOVE|FOLD|OPEN|EXEC|BARE|WORK|FORK|KILL|SEND).
4
- YOU MUST begin every turn with a `# PLAN0`, adding and updating determinations, decisions, and docket.
5
- YOU MUST use the same delimiter, such as `0`, for every OP.
6
4
  YOU MUST perform Plurnk OPs to resolve your pending and in_progress docket until the Active User Prompt is resolved.
7
- YOU MUST end every turn with `## SEND0 [submit code]`, as in `## SEND0 [102]`.
8
5
 
9
6
  ### Syntax
10
7
 
@@ -16,23 +13,19 @@ YOU MUST end every turn with `## SEND0 [submit code]`, as in `## SEND0 [102]`.
16
13
  body?
17
14
  ```
18
15
 
19
- * Every non-PLAN OP goes on a new line starting with `## `, as in `## FIND0`, and shares PLAN's delimiter.
20
- * Every OP's `[signal]`, `(path)`, and `<scope>` goes only on the same line as the OP.
16
+ * Every non-PLAN OP starts with `## `, as in `## FIND0`, and shares PLAN's delimiter.
17
+ * Every OP's `[signal]`, `(path)`, `<scope>`, and `<!-- annotation -->` go only on the OP heading line.
21
18
  * `body` content must be immediately beneath the OP heading line and character-perfect, including whitespace.
22
19
 
23
- ### Standard Workflow
24
-
25
- * The results of OPs are observable after submitting a continuing `## SEND0 [102]` or waiting `## SEND0 [202]`.
26
- * The concluding `## SEND0 [200]` response contains no references to internal operations unless directly requested.
27
-
28
20
  ### OPs
29
21
 
30
- * Do not include code fence in turn.
31
- * Plurnk is highly polymorphic, with `[signal]`, `(path)`, `<scope>`, and `body` components depending on the OP in use.
22
+ * Plurnk grammar is overloaded and polymorphic, with `[signal]`, `(path)`, `<scope>`, and `body` components depending on the OP.
32
23
  * `[signal]`, `(path)`, `<scope>`, `<!-- annotations -->` and `body` are optional, but at least one must be present.
24
+ * To delete a text region, omit the EDIT `body`.
25
+ * Code fences are not part of the OP syntax. Do not add them around OPs.
33
26
 
34
27
  ```plurnk-syntax
35
- # PLAN0 <!-- strategy and orientation -->
28
+ # PLAN0 <!-- determinations, decisions, and docket items -->
36
29
  [{"content": string, "status": "pending" | "in_progress" | "completed" | "memory"}]
37
30
 
38
31
  ## FIND0 [+tag] (target or glob) <result page> <!-- list matching targets -->
@@ -40,14 +33,12 @@ filter pattern
40
33
 
41
34
  ## READ0 [+tag] (target) <text region> <!-- retrieve target content -->
42
35
 
43
- ## EDIT0 [+tag] (file or entry) <text region> <!-- create or edit scoped content -->
44
- literal text
36
+ ## EDIT0 [+tag] (target) <text region> <!-- edit/replace/delete text -->
37
+ literal replacement text
45
38
 
46
- ## COPY0 [+tag] (source target) <source region> <!-- copy from a target -->
47
- destination <region>
39
+ ## COPY0 [+tag] (source) <source text region> (destination) <destination text region> <!-- copy between targets -->
48
40
 
49
- ## MOVE0 [+tag] (source target) <source region> <!-- move from a target -->
50
- destination <region>
41
+ ## MOVE0 [+tag] (source) <source text region> (destination) <destination text region> <!-- move between targets -->
51
42
 
52
43
  ## FOLD0 [tag] (log items) <log body lines> <!-- hide matching log bodies -->
53
44
  filter pattern
@@ -55,29 +46,62 @@ filter pattern
55
46
  ## OPEN0 [tag] (log items) <log body lines> <!-- reveal matching log bodies -->
56
47
  filter pattern
57
48
 
58
- ## EXEC0 [executor] (cwd, script, or tool name) <timeout, poll> <!-- execute a registered tool -->
59
- tool input
49
+ ## EXEC0 <!-- run a command, script, or tool -->
50
+ command, script, or tool input
60
51
 
61
52
  ## BARE0 [+tag] <!-- retrieve one model response -->
62
53
  prompt
63
54
 
64
- ## WORK0 [branch] (worker://name) <!-- spawn a child worker -->
55
+ ## WORK0 (worker://name) <!-- spawn a child worker -->
65
56
  prompt
66
57
 
67
- ## FORK0 [branch] (worker://name) <!-- fork current worker -->
58
+ ## FORK0 (worker://name) <!-- fork current worker -->
68
59
  prompt
69
60
 
70
61
  ## KILL0 [code] (target, including log item) <!-- delete or terminate -->
71
62
 
72
- ## SEND0 [code] (recipient) <timeout, poll> <!-- message a recipient, or close the turn with a submit code -->
63
+ ## SEND0 [code] (recipient) <!-- message a worker://name, a resource, or the user (default) -->
73
64
  message
74
65
  ```
75
66
 
67
+ ### Standard Workflow
68
+
69
+ YOU MUST begin every turn with a `# PLAN0`, including determinations, decisions, and docket items.
70
+ YOU MUST use the same delimiter, such as `0`, for every OP.
71
+ YOU MUST end every turn with `## SEND0 [submit code]`, as in `## SEND0 [102]`.
72
+
73
+ | submit code | meaning | body message |
74
+ |------------------|----------------------------------|---------------------------------------------|
75
+ | `## SEND0 [102]` | Continue to results in next turn | Describe expected or intended next steps |
76
+ | `## SEND0 [202]` | Wait for workers or streams | Describe expected or intended next steps |
77
+ | `## SEND0 [200]` | Successful conclusion | Response to the Active User Prompt |
78
+ | `## SEND0 [499]` | Abort and fail prompt | Describe error or issue |
79
+
80
+ YOU SHOULD continue with `[102]` or wait with `[202]` rather than conclude with `[200]` when the turn includes OPs with side effects.
81
+
82
+ * The results of OPs are observable after submitting a continuing `## SEND0 [102]` or waiting `## SEND0 [202]`.
83
+ * The concluding `## SEND0 [200]` response contains no references to internal operations unless directly requested.
84
+
85
+ ```plurnk-example
86
+ # PLAN0
87
+ [{"content":"report.md is very large, requiring chunking.","status":"memory"},
88
+ {"content":"Update the existing private summary entry with relevant findings from report.md.","status":"in_progress"}]
89
+ ## EDIT0 [+quarterly] (worker://~/report-summary.md) <@wCf7x>
90
+ * Q3 results: 42%
91
+
92
+ ## EDIT0 [+quarterly] (worker://~/report-summary.md) <-1>
93
+ * Q4 results exceeded Q3
94
+
95
+ ## READ0 [+quarterly] (report.md) <501,700>
96
+ ## SEND0 [102]
97
+ Next: Distill relevant findings from this chunk, then continue reading.
98
+ ```
99
+
76
100
  ### The PLAN
77
101
 
78
- * Determinations: Add and update all "memory" entries recording findings, learnings, or open questions.
79
- * Decisions: Add and update all "memory" entries recording conclusions, decisions, or policies.
80
- * Docket: Add and update all "pending", "in_progress", or "completed" work.
102
+ * Determinations: "memory" entries recording findings or learnings.
103
+ * Decisions: "memory" entries recording conclusions, decisions, or policies.
104
+ * Docket: "pending", "in_progress", or "completed" work.
81
105
 
82
106
  ### Pattern Filtering
83
107
 
@@ -89,7 +113,7 @@ message
89
113
  | `//` | xpath | `//selector` | XPath 1.0 |
90
114
  | `$` | jsonpath | `$.field`, `$.items[*].name` | RFC 9535 |
91
115
  | `~` | semantic | `~phrase` | embedding cosine |
92
- | `@` | graph | `@<symbol`, `@>symbol`, `@symbol` | symbol index |
116
+ | `&` | graph | `&<symbol`, `&>symbol`, `&symbol` | symbol index |
93
117
  | none | glob | `pattern` | glob / literal |
94
118
 
95
119
  * The leading symbol commits its dialect.
@@ -123,11 +147,12 @@ message
123
147
  * Unscoped FIND returns items 1-16; unscoped READ returns lines 1–16. `<1,-1>` returns all.
124
148
  * Rendered exact READ lines begin with a per-line `@hash` anchor and `L:` line number; neither is content.
125
149
 
126
- YOU SHOULD prefer `@hash` anchors for EDIT line coordinates; they reject stale targets.
150
+ YOU SHOULD prefer `<@hash>` or `<@start,@end>` for EDIT line coordinates; they reject stale targets.
127
151
 
128
152
  ### The Log
129
153
 
130
- * `[+tag]` adds, `[-tag]` removes; FOLD/OPEN select by unsigned `[tag]`.
154
+ * `[+tag]` adds, `[-tag]` removes; FOLD/OPEN apply signed tags or select by unsigned `[tag]` for folksonomic log curation.
155
+ * `## KILL0 (log:///1/[1-7]/*/{PLAN,READ})` removes irrelevant log items.
131
156
  * `## FOLD0 [+trimmed] (log:///**/READ) <17,-1>` tags every READ and folds each body after line 16.
132
157
  * `## OPEN0 (log:///1/2/3/READ) <@aB3dE>` restores one anchored line.
133
158
  * Log item paths contain their loop, turn, and item: `log:///{loop}/{turn}/{item}/{OP}`.
@@ -138,23 +163,12 @@ YOU SHOULD FOLD, KILL, or trim superseded, stale, or irrelevant log content.
138
163
 
139
164
  | OP | inherits | typical use | body |
140
165
  |-------|------------|---------------------------------|------|
141
- | WORK | fresh log | Divide and conquer | self-contained task with necessary context |
142
- | FORK | forked log | Do two things at once | distinct objective; prior context is inherited |
166
+ | WORK | fresh log | Divide and conquer | self-contained task prompt, with necessary context |
167
+ | FORK | forked log | Do two things at once | distinct objective prompt; prior context is inherited |
143
168
  | BARE | no log | Context-free one-shot inference | complete standalone prompt |
144
169
 
145
- * Before delegating a worker with a git branch signal, ensure the repository is clean.
170
+ * Delegation `body` must contain a prompt, not OPs.
146
171
  * Send a worker another message: `## SEND0 (worker://recheck)` with body `Also verify the alternative against the existing tests.`.
147
172
  * Terminate a worker: `## KILL0 (worker://recheck)`.
148
173
 
149
174
  YOU SHOULD decompose distinct subtasks into separate WORKers.
150
-
151
- ## Submit codes
152
-
153
- | submit code | meaning | body message |
154
- |------------------|----------------------------------|---------------------------------------------|
155
- | `## SEND0 [102]` | Continue to results in next turn | Describe expected or intended next steps |
156
- | `## SEND0 [202]` | Wait for workers or streams | Describe expected or intended next steps |
157
- | `## SEND0 [200]` | Successful conclusion | Response to the Active User Prompt |
158
- | `## SEND0 [499]` | Abort and fail prompt | Describe error or issue |
159
-
160
- YOU SHOULD continue or wait rather than conclude when submitting OPs with side effects.
@@ -1,16 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.xyz/v0/LoopFlags.json",
4
- "title": "LoopFlags",
5
- "description": "The complete effective policy posture of one model loop. Persisted partial objects are expanded to this shape by the runtime owner before use or projection.",
6
- "type": "object",
7
- "required": ["mode", "auto", "noWeb", "noInteraction", "noProposals"],
8
- "additionalProperties": false,
9
- "properties": {
10
- "mode": { "enum": ["ask", "act"] },
11
- "auto": { "type": "boolean" },
12
- "noWeb": { "type": "boolean" },
13
- "noInteraction": { "type": "boolean" },
14
- "noProposals": { "type": "boolean" }
15
- }
16
- }