@atrib/revise 0.2.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/LICENSE +190 -0
- package/README.md +76 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +99 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +15 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or otherwise designated in writing by the copyright owner as
|
|
57
|
+
"Not a Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent claims licensable
|
|
76
|
+
by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or a Contribution
|
|
81
|
+
incorporated within the Work constitutes direct or contributory patent
|
|
82
|
+
infringement, then any patent licenses granted to You under this License
|
|
83
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
86
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
87
|
+
modifications, and in Source or Object form, provided that You
|
|
88
|
+
meet the following conditions:
|
|
89
|
+
|
|
90
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
91
|
+
a copy of this License; and
|
|
92
|
+
|
|
93
|
+
(b) You must cause any modified files to carry prominent notices
|
|
94
|
+
stating that You changed the files; and
|
|
95
|
+
|
|
96
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
97
|
+
that You distribute, all copyright, patent, trademark, and
|
|
98
|
+
attribution notices from the Source form of the Work,
|
|
99
|
+
excluding those notices that do not pertain to any part of
|
|
100
|
+
the Derivative Works; and
|
|
101
|
+
|
|
102
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
103
|
+
distribution, You must include a readable copy of the attribution
|
|
104
|
+
notices contained within such NOTICE file, in at least one
|
|
105
|
+
of the following places: within a NOTICE text file distributed
|
|
106
|
+
as part of the Derivative Works; within the Source form or
|
|
107
|
+
documentation, if provided along with the Derivative Works; or,
|
|
108
|
+
within a display generated by the Derivative Works, if and
|
|
109
|
+
wherever such third-party notices normally appear. The contents
|
|
110
|
+
of the NOTICE file are for informational purposes only and
|
|
111
|
+
do not modify the License. You may add Your own attribution
|
|
112
|
+
notices within Derivative Works that You distribute, alongside
|
|
113
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
114
|
+
that such additional attribution notices cannot be construed
|
|
115
|
+
as modifying the License.
|
|
116
|
+
|
|
117
|
+
You may add Your own license statement for Your modifications and
|
|
118
|
+
may provide additional grant of rights to use, modify, or distribute
|
|
119
|
+
those modifications in accordance with this License.
|
|
120
|
+
|
|
121
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
122
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
123
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
124
|
+
this License, without any additional terms or conditions.
|
|
125
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
126
|
+
the terms of any separate license agreement you may have executed
|
|
127
|
+
with Licensor regarding such Contributions.
|
|
128
|
+
|
|
129
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
130
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
131
|
+
except as required for reasonable and customary use in describing the
|
|
132
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
133
|
+
|
|
134
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
135
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
136
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
138
|
+
implied, including, without limitation, any warranties or conditions
|
|
139
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
140
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
141
|
+
appropriateness of using or reproducing the Work and assume any
|
|
142
|
+
risks associated with Your exercise of permissions under this License.
|
|
143
|
+
|
|
144
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
145
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
146
|
+
unless required by applicable law (such as deliberate and grossly
|
|
147
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
148
|
+
liable to You for damages, including any direct, indirect, special,
|
|
149
|
+
incidental, or exemplary damages of any character arising as a
|
|
150
|
+
result of this License or out of the use or inability to use the
|
|
151
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
152
|
+
work stoppage, computer failure or malfunction, or all other
|
|
153
|
+
commercial damages or losses), even if such Contributor has been
|
|
154
|
+
advised of the possibility of such damages.
|
|
155
|
+
|
|
156
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
157
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
158
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
159
|
+
or other liability obligations and/or rights consistent with this
|
|
160
|
+
License. However, in accepting such obligations, You may act only
|
|
161
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
162
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
163
|
+
defend, and hold each Contributor harmless for any liability
|
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
165
|
+
of your accepting any such warranty or additional liability.
|
|
166
|
+
|
|
167
|
+
END OF TERMS AND CONDITIONS
|
|
168
|
+
|
|
169
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
170
|
+
|
|
171
|
+
To apply the Apache License to your work, attach the following
|
|
172
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
173
|
+
replaced with your own identifying information. (Don't include
|
|
174
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
175
|
+
comment syntax for the file format in question. Also, an optional
|
|
176
|
+
"Statement of Purpose" appears after the copyright notice.
|
|
177
|
+
|
|
178
|
+
Copyright 2025-2026 Atrib contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
189
|
+
implied. See the License for the specific language governing
|
|
190
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @atrib/revise
|
|
2
|
+
|
|
3
|
+
MCP server exposing the `atrib-revise` tool. Supersedes a prior signed position with a stated reason, so the contradiction lands as a first-class graph node rather than a silent edit.
|
|
4
|
+
|
|
5
|
+
Records are immutable per spec [§1.6](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#16-immutability): once signed, the bytes are fixed forever. When the agent now holds a position incompatible with a prior claim, the only honest move is to sign a revision that points at the prior record, names the prior position, names the new one, and gives the reason. The prior record stays in the graph; the revision adds a REVISES edge that supersedes it. A reader walking the graph sees both, and any policy or recall pipeline that respects revision can prefer the latest.
|
|
6
|
+
|
|
7
|
+
## Tool
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
mcp__atrib-revise__atrib-revise({
|
|
11
|
+
revises: "sha256:<64-hex>", // REQUIRED: target record_hash to supersede
|
|
12
|
+
prior_position: string, // ≤ 4096 chars; what was previously held
|
|
13
|
+
new_position: string, // ≤ 4096 chars; the new position
|
|
14
|
+
reason: string, // ≤ 4096 chars; why the revision happened
|
|
15
|
+
topics?: string[], // up to 16 lowercase-hyphenated tags
|
|
16
|
+
context_id?: "<32-hex>", // defaults to ATRIB_CONTEXT_ID
|
|
17
|
+
informed_by?: ["sha256:<64-hex>", ...] // optional lineage refs
|
|
18
|
+
})
|
|
19
|
+
→ {
|
|
20
|
+
record_hash: "sha256:<64-hex>", // the new revision record
|
|
21
|
+
log_index: number | null,
|
|
22
|
+
inclusion_proof: ProofBundle["inclusion_proof"] | null,
|
|
23
|
+
context_id: string,
|
|
24
|
+
warnings: string[]
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Writes
|
|
29
|
+
|
|
30
|
+
Signs a `revision` record per spec [§1.2.4](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#124-event_type-values) (event_type `0x06`, promoted via [D059](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d059-promote-revision-to-atrib-normative-event_type-byte-0x06)) and persists it through the same pipeline `@atrib/emit` uses: same key resolution, same chain composition, same JSONL mirror at `ATRIB_MIRROR_FILE`. A verifier cannot distinguish revision records signed via this tool from revision records signed via `@atrib/emit`'s polymorphic surface; the wire format is identical.
|
|
31
|
+
|
|
32
|
+
The graph layer derives a REVISES edge from the new record to the `revises` target per spec [§3.2.4](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#324-edge-derivation-rules) step 9. Policies and recall pipelines that respect revision-aware filtering can demote or hide the superseded record in favor of the new position.
|
|
33
|
+
|
|
34
|
+
## Behaviors
|
|
35
|
+
|
|
36
|
+
- **Required-field enforcement**: `revises`, `prior_position`, `new_position`, and `reason` are required. The Zod schema rejects calls missing any of these before the signing pipeline runs.
|
|
37
|
+
- **Spec validators**: `revises` is rejected on non-revision event_types per spec [§1.2.9](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#129-revises) (the underlying `handleEmit` enforces this; the tool's narrow schema prevents it from happening here).
|
|
38
|
+
- **Env-honoring**: `ATRIB_CONTEXT_ID` is honored as the default `context_id` per [D078](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d078-mcp-servers-honor-atrib_context_id-env-as-context_id-default) when the caller omits the field.
|
|
39
|
+
- **Multi-producer chain composition**: inherits chain state from the mirror or `ATRIB_CHAIN_TAIL_<context_id>` env per [D067](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d067-multi-producer-chain-composition-precedence-contract), the same way `@atrib/emit` does.
|
|
40
|
+
- **Records are immutable**: the prior record is NOT mutated. The revision adds a new node + edge; the original stays in the graph for full lineage.
|
|
41
|
+
- **Graceful degradation**: signing failures surface in `warnings`; never throws to the agent per spec [§5.8](https://github.com/creatornader/atrib/blob/main/atrib-spec.md#58-degradation-contract).
|
|
42
|
+
|
|
43
|
+
## Wire-up
|
|
44
|
+
|
|
45
|
+
Add to your MCP host config (e.g. `~/.claude.json` `mcpServers`):
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"atrib-revise": {
|
|
50
|
+
"command": "node",
|
|
51
|
+
"args": ["/path/to/atrib-revise/dist/main.js"]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or run as a one-off subprocess via `pnpm --filter @atrib/revise start`.
|
|
57
|
+
|
|
58
|
+
### Env vars (inherited from `@atrib/emit`)
|
|
59
|
+
|
|
60
|
+
- `ATRIB_PRIVATE_KEY` / `ATRIB_KEY_FILE` / macOS Keychain `atrib-creator-<ATRIB_AGENT>` / `ATRIB_OP_REFERENCE`: key resolution chain.
|
|
61
|
+
- `ATRIB_MIRROR_FILE`: JSONL mirror destination (where the signed revision persists).
|
|
62
|
+
- `ATRIB_AUTOCHAIN_SOURCE`: optional cross-producer chain inheritance source.
|
|
63
|
+
- `ATRIB_LOG_ENDPOINT`: log.atrib.dev override (e.g. for self-hosted log nodes).
|
|
64
|
+
- `ATRIB_CONTEXT_ID`: default context_id per [D078](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d078-mcp-servers-honor-atrib_context_id-env-as-context_id-default).
|
|
65
|
+
|
|
66
|
+
## Relationship to @atrib/emit
|
|
67
|
+
|
|
68
|
+
`@atrib/revise` depends on `@atrib/emit` per the package layering documented in [D079](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d079-the-six-core-cognitive-primitives--atribs-agent-facing-surface). Each is a monomorphic agent-facing tool with one narrow purpose, but the underlying signing, chain composition, and mirror-writing pipeline is shared via `@atrib/emit`'s `handleEmit` export. When the canonical write pipeline evolves (chain-composition fixes, env-honoring extensions, cross-attestation), `@atrib/revise` inherits the change automatically.
|
|
69
|
+
|
|
70
|
+
## Status
|
|
71
|
+
|
|
72
|
+
Initial scaffold (v0.2.0). Cognitive primitive #3 per [D079](https://github.com/creatornader/atrib/blob/main/DECISIONS.md#d079-the-six-core-cognitive-primitives--atribs-agent-facing-surface). Builds clean against `@atrib/mcp` and `@atrib/emit`'s public exports introduced in `@atrib/emit@0.8.0`. The companion specialized writer `@atrib/annotate` covers the importance-and-meaning primitive (annotation event_type).
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
Apache-2.0.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type ResolvedKey } from '@atrib/emit';
|
|
3
|
+
export interface AtribReviseServer {
|
|
4
|
+
/** Underlying McpServer; expose for testing or composition. */
|
|
5
|
+
mcp: McpServer;
|
|
6
|
+
/** Drain pending submissions (for tests/shutdown). */
|
|
7
|
+
flush(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateAtribReviseServerOptions {
|
|
10
|
+
/** Override the resolved key (primarily for testing). */
|
|
11
|
+
key?: ResolvedKey;
|
|
12
|
+
/** Override the log endpoint (defaults to env or @atrib/mcp default). */
|
|
13
|
+
logEndpoint?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wire up the atrib-revise MCP server with one `atrib-revise` tool.
|
|
17
|
+
* Per D079: this is a specialized form of @atrib/emit; the underlying
|
|
18
|
+
* signing pipeline is shared via handleEmit so revision records are
|
|
19
|
+
* byte-identical regardless of which tool produced them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createAtribReviseServer(options?: CreateAtribReviseServerOptions): Promise<AtribReviseServer>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// @atrib/revise MCP server: cognitive primitive #3 of D079.
|
|
2
|
+
//
|
|
3
|
+
// Specialized form of @atrib/emit that narrows the schema to the revision
|
|
4
|
+
// event_type (spec §1.2.9 / D059). Per D079's package layering: depends on
|
|
5
|
+
// @atrib/emit as the canonical record-signing surface and wraps handleEmit
|
|
6
|
+
// with a narrow Zod schema enforcing the revision-specific required fields
|
|
7
|
+
// (revises + reason + prior_position + new_position). The signing + chain
|
|
8
|
+
// composition path is byte-identical to atrib-emit's; a verifier MUST NOT
|
|
9
|
+
// distinguish revision records signed via this tool from those signed via
|
|
10
|
+
// emit's polymorphic surface.
|
|
11
|
+
//
|
|
12
|
+
// Scope:
|
|
13
|
+
// - One tool: atrib-revise
|
|
14
|
+
// - Narrow input schema: REQUIRES revises (sha256:<64-hex>), reason, prior_position, new_position
|
|
15
|
+
// - One key per process (same identity as the wrapper + atrib-emit)
|
|
16
|
+
// - Persists to the same JSONL mirror convention as atrib-emit
|
|
17
|
+
//
|
|
18
|
+
// Distinct from atrib-annotate: annotation comments on a past record while
|
|
19
|
+
// leaving the prior position intact. Revision asserts the prior is no longer
|
|
20
|
+
// held — the prior remains in the graph (records are immutable per spec
|
|
21
|
+
// §1.6), and the revision adds a REVISES graph edge that supersedes it.
|
|
22
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
import { handleEmit, resolveKey, } from '@atrib/emit';
|
|
25
|
+
import { createSubmissionQueue, EVENT_TYPE_REVISION_URI, } from '@atrib/mcp';
|
|
26
|
+
const SHA256_REF_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
27
|
+
const HEX_32_PATTERN = /^[0-9a-f]{32}$/;
|
|
28
|
+
const ReviseInput = z.object({
|
|
29
|
+
revises: z.string().regex(SHA256_REF_PATTERN).describe("'sha256:<64-hex>' record_hash this revision supersedes per spec §1.2.9 / D059. " +
|
|
30
|
+
'REQUIRED. The target record can be any prior record (yours or another agent\'s).'),
|
|
31
|
+
prior_position: z.string().min(1).max(4096).describe('One-line summary of the position being superseded. Captures what was previously held ' +
|
|
32
|
+
'so a reader sees the contradiction surfaced as a first-class graph node rather than ' +
|
|
33
|
+
'a silent edit.'),
|
|
34
|
+
new_position: z.string().min(1).max(4096).describe('One-line summary of the new position replacing the prior. The substantive claim that ' +
|
|
35
|
+
'supersedes the revised record.'),
|
|
36
|
+
reason: z.string().min(1).max(4096).describe('Why the revision happened. New evidence, contradicting record, model update, ' +
|
|
37
|
+
'corrected reasoning, etc. Recall pipelines surface this verbatim so future-self ' +
|
|
38
|
+
'sees what motivated the change.'),
|
|
39
|
+
topics: z.array(z.string().min(1).max(128)).max(16).optional().describe('Optional topic tags. Used by recall_my_attribution_history\'s topics filter. ' +
|
|
40
|
+
'Lowercase-hyphenated convention (e.g. "contradiction", "model-update").'),
|
|
41
|
+
context_id: z.string().regex(HEX_32_PATTERN).optional().describe('32-hex context_id. Defaults to process.env.ATRIB_CONTEXT_ID per D078 when omitted; ' +
|
|
42
|
+
'falls back to a fresh genesis context_id if neither is set.'),
|
|
43
|
+
informed_by: z.array(z.string().regex(SHA256_REF_PATTERN)).optional().describe("Array of 'sha256:<64-hex>' record_hashes that informed this revision. " +
|
|
44
|
+
'Sorted lexicographically before signing per §1.2.5. The `revises` reference ' +
|
|
45
|
+
'is separate from `informed_by` and need not be duplicated here.'),
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Wire up the atrib-revise MCP server with one `atrib-revise` tool.
|
|
49
|
+
* Per D079: this is a specialized form of @atrib/emit; the underlying
|
|
50
|
+
* signing pipeline is shared via handleEmit so revision records are
|
|
51
|
+
* byte-identical regardless of which tool produced them.
|
|
52
|
+
*/
|
|
53
|
+
export async function createAtribReviseServer(options = {}) {
|
|
54
|
+
const key = options.key ?? (await resolveKey());
|
|
55
|
+
const logEndpoint = options.logEndpoint ?? process.env['ATRIB_LOG_ENDPOINT'];
|
|
56
|
+
const queue = createSubmissionQueue(logEndpoint);
|
|
57
|
+
const mcp = new McpServer({ name: 'atrib-revise', version: '0.1.0' });
|
|
58
|
+
mcp.registerTool('atrib-revise', {
|
|
59
|
+
description: 'Supersede a prior position with a stated reason. Cognitive primitive #3 of ' +
|
|
60
|
+
'D079; produces a signed revision event (spec §1.2.9 / D059) that adds a ' +
|
|
61
|
+
'REVISES graph edge to the target record. Use when you now hold a position ' +
|
|
62
|
+
'incompatible with a prior claim; the revision surfaces the change as a ' +
|
|
63
|
+
'first-class graph node rather than a silent edit (records are immutable).',
|
|
64
|
+
inputSchema: ReviseInput.shape,
|
|
65
|
+
}, async (rawInput) => {
|
|
66
|
+
const input = ReviseInput.parse(rawInput);
|
|
67
|
+
const result = await handleEmit({
|
|
68
|
+
input: {
|
|
69
|
+
event_type: EVENT_TYPE_REVISION_URI,
|
|
70
|
+
content: {
|
|
71
|
+
revises: input.revises,
|
|
72
|
+
prior_position: input.prior_position,
|
|
73
|
+
new_position: input.new_position,
|
|
74
|
+
reason: input.reason,
|
|
75
|
+
...(input.topics ? { topics: input.topics } : {}),
|
|
76
|
+
},
|
|
77
|
+
revises: input.revises,
|
|
78
|
+
...(input.context_id ? { context_id: input.context_id } : {}),
|
|
79
|
+
...(input.informed_by ? { informed_by: input.informed_by } : {}),
|
|
80
|
+
},
|
|
81
|
+
key,
|
|
82
|
+
queue,
|
|
83
|
+
});
|
|
84
|
+
const out = {
|
|
85
|
+
record_hash: result.record_hash,
|
|
86
|
+
log_index: result.log_index,
|
|
87
|
+
inclusion_proof: result.inclusion_proof,
|
|
88
|
+
context_id: result.context_id,
|
|
89
|
+
warnings: result.warnings,
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
mcp,
|
|
97
|
+
flush: () => queue.flush(),
|
|
98
|
+
};
|
|
99
|
+
}
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// atrib-revise standalone binary. Wires the McpServer to a stdio transport
|
|
3
|
+
// so it can be launched as a subprocess by an MCP host (Claude Code,
|
|
4
|
+
// Claude Desktop, etc.).
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { createAtribReviseServer } from './index.js';
|
|
7
|
+
async function main() {
|
|
8
|
+
const { mcp } = await createAtribReviseServer();
|
|
9
|
+
const transport = new StdioServerTransport();
|
|
10
|
+
await mcp.connect(transport);
|
|
11
|
+
}
|
|
12
|
+
main().catch((e) => {
|
|
13
|
+
console.error('atrib-revise: fatal', e instanceof Error ? e.stack ?? e.message : String(e));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atrib/revise",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for atrib. Lets agents supersede a prior signed position with a stated reason. Adds a REVISES graph edge so the contradiction is a first-class node rather than a silent edit.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"atrib-revise": "./dist/main.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
13
|
+
"zod": "^3.25.76",
|
|
14
|
+
"@atrib/emit": "0.8.0",
|
|
15
|
+
"@atrib/mcp": "0.6.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.19.17",
|
|
19
|
+
"tsx": "^4.21.0",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^3.2.4"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "rm -rf dist && tsc",
|
|
31
|
+
"start": "node dist/main.js",
|
|
32
|
+
"dev": "tsx src/main.ts",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
}
|
|
35
|
+
}
|