Open History to see the last commit
1diff --git a/dist/event.js b/dist/event.js
2index a0f0831..c4d39e2 100644
3--- a/dist/event.js
4+++ b/dist/event.js
5@@ -4,7 +4,7 @@ import { optional } from "./schema.js";
6 import { ascending } from "./identifier.js";
7 import { Location } from "./location.js";
8 import { statics } from "./schema.js";
9-export const ID = Schema.String.check(Schema.isStartsWith("evt_")).pipe(Schema.brand("Event.ID"), statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })));
10+export const ID = Schema.String.check(Schema.isStartingWith("evt_")).pipe(Schema.brand("Event.ID"), statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })));
11 /**
12 * Position in one aggregate's durable log. Values originate from the durable
13 * event envelope and synced markers;
14diff --git a/dist/form.js b/dist/form.js
15index 920d0dd..bd4799d 100644
16--- a/dist/form.js
17+++ b/dist/form.js
18@@ -3,7 +3,7 @@ import { Schema } from "effect";
19 import { ephemeral, inventory } from "./event.js";
20 import { ascending } from "./identifier.js";
21 import { NonNegativeInt, optional, statics } from "./schema.js";
22-const IDSchema = Schema.String.check(Schema.isStartsWith("frm_")).pipe(Schema.brand("Form.ID"));
23+const IDSchema = Schema.String.check(Schema.isStartingWith("frm_")).pipe(Schema.brand("Form.ID"));
24 export const ID = IDSchema.pipe(statics((schema) => ({ create: (id) => schema.make(id ?? "frm_" + ascending()) })));
25 export const Metadata = Schema.Record(Schema.String, Schema.Unknown).annotate({ identifier: "Form.Metadata" });
26 export const Option = Schema.Struct({
27diff --git a/dist/permission.js b/dist/permission.js
28index d004da5..9b3f133 100644
29--- a/dist/permission.js
30+++ b/dist/permission.js
31@@ -5,7 +5,7 @@ import { ephemeral, inventory } from "./event.js";
32 import { ascending } from "./identifier.js";
33 import { SessionID } from "./session-id.js";
34 import { statics } from "./schema.js";
35-export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(Schema.brand("Permission.ID"), statics((schema) => ({ create: (id) => schema.make(id ?? "per_" + ascending()) })));
36+export const ID = Schema.String.check(Schema.isStartingWith("per")).pipe(Schema.brand("Permission.ID"), statics((schema) => ({ create: (id) => schema.make(id ?? "per_" + ascending()) })));
37 export const Source = Schema.Union([
38 Schema.Struct({
39 type: Schema.Literal("tool"),
40diff --git a/dist/pty.js b/dist/pty.js
41index b69f558..f5872fd 100644
42--- a/dist/pty.js
43+++ b/dist/pty.js
44@@ -4,7 +4,7 @@ import { optional } from "./schema.js";
45 import { ephemeral, inventory } from "./event.js";
46 import { ascending } from "./identifier.js";
47 import { NonNegativeInt, PositiveInt, statics } from "./schema.js";
48-const IDSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID"));
49+const IDSchema = Schema.String.check(Schema.isStartingWith("pty")).pipe(Schema.brand("PtyID"));
50 export const ID = IDSchema.pipe(statics((schema) => {
51 const create = () => schema.make("pty_" + ascending());
52 return {
53diff --git a/dist/schema.js b/dist/schema.js
54index d90b9f6..ab09ced 100644
55--- a/dist/schema.js
56+++ b/dist/schema.js
57@@ -7,7 +7,17 @@ export const optional = (schema) => Schema.optionalKey(schema).pipe(Schema.decod
58 decode: SchemaGetter.passthrough({ strict: false }),
59 encode: SchemaGetter.transformOptional(Option.filter((value) => value !== undefined)),
60 }));
61-export const statics = (methods) => (schema) => Object.assign(schema, methods(schema));
62+export const statics = (methods) => (schema) => {
63+ // Effect 4.0.0 caches `make` as a non-configurable own property on first
64+ // read, so a static that overrides it is defined before anything reads it:
65+ // `methods` sees a view whose `make` comes from a fresh rebuild.
66+ const base = schema.rebuild(schema.ast);
67+ const view = new Proxy(schema, { get: (target, key) => (key === "make" ? base.make : Reflect.get(target, key)) });
68+ for (const [key, value] of Object.entries(methods(view))) {
69+ Object.defineProperty(schema, key, { value, writable: true, enumerable: true, configurable: true });
70+ }
71+ return schema;
72+};
73 export const DateTimeUtcFromMillis = Schema.Finite.pipe(Schema.decodeTo(Schema.DateTimeUtc, {
74 decode: SchemaGetter.transform((value) => DateTime.makeUnsafe(value)),
75 encode: SchemaGetter.transform((value) => DateTime.toEpochMillis(value)),
76diff --git a/dist/session-id.js b/dist/session-id.js
77index fe5f778..03ef1e6 100644
78--- a/dist/session-id.js
79+++ b/dist/session-id.js
80@@ -1,7 +1,7 @@
81 import { Schema } from "effect";
82 import { descending } from "./identifier.js";
83 import { statics } from "./schema.js";
84-export const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe(Schema.brand("SessionID"), statics((schema) => {
85+export const SessionID = Schema.String.check(Schema.isStartingWith("ses")).pipe(Schema.brand("SessionID"), statics((schema) => {
86 const create = () => schema.make("ses_" + descending());
87 return {
88 create,
89diff --git a/dist/session-message.js b/dist/session-message.js
90index 9ddeda7..6a0a1e2 100644
91--- a/dist/session-message.js
92+++ b/dist/session-message.js
93@@ -18,7 +18,7 @@ import { Skill as SkillSchema } from "./skill.js";
94 import { Money } from "./money.js";
95 import { Snapshot } from "./snapshot.js";
96 import { TokenUsage } from "./token-usage.js";
97-export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(Schema.brand("Session.Message.ID"), statics((schema) => ({
98+export const ID = Schema.String.check(Schema.isStartingWith("msg_")).pipe(Schema.brand("Session.Message.ID"), statics((schema) => ({
99 create: () => schema.make("msg_" + ascending()),
100 fromEvent: (eventID) => schema.make(eventID.replace(/^evt_/, "msg_")),
101 })));
102diff --git a/dist/shell.js b/dist/shell.js
103index 75b981e..969160a 100644
104--- a/dist/shell.js
105+++ b/dist/shell.js
106@@ -4,7 +4,7 @@ import { optional } from "./schema.js";
107 import { ephemeral, inventory } from "./event.js";
108 import { ascending } from "./identifier.js";
109 import { NonNegativeInt, statics } from "./schema.js";
110-const IDSchema = Schema.String.check(Schema.isStartsWith("sh_")).pipe(Schema.brand("Shell.ID"));
111+const IDSchema = Schema.String.check(Schema.isStartingWith("sh_")).pipe(Schema.brand("Shell.ID"));
112 export const ID = IDSchema.pipe(statics((schema) => {
113 const create = () => schema.make("sh_" + ascending());
114 return {
115diff --git a/dist/v1/permission.js b/dist/v1/permission.js
116index 86af654..d4008e5 100644
117--- a/dist/v1/permission.js
118+++ b/dist/v1/permission.js
119@@ -5,7 +5,7 @@ import { ascending } from "../identifier.js";
120 import { Project } from "../project.js";
121 import { statics } from "../schema.js";
122 import { SessionID } from "../session-id.js";
123-export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(Schema.brand("PermissionV1.ID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "per_" + ascending()) })));
124+export const ID = Schema.String.check(Schema.isStartingWith("per")).pipe(Schema.brand("PermissionV1.ID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "per_" + ascending()) })));
125 export const Action = Schema.Literals(["allow", "deny", "ask"]).annotate({ identifier: "PermissionV1.Action" });
126 export const Rule = Schema.Struct({ permission: Schema.String, pattern: Schema.String, action: Action }).annotate({
127 identifier: "PermissionV1.Rule",
128diff --git a/dist/v1/session.js b/dist/v1/session.js
129index 867c87b..e06a17b 100644
130--- a/dist/v1/session.js
131+++ b/dist/v1/session.js
132@@ -11,8 +11,8 @@ import { WorkspaceID } from "../workspace-id.js";
133 import { PermissionV1 } from "./permission.js";
134 import { FileDiff } from "../file-diff.js";
135 const Timestamp = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
136-export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(Schema.brand("SessionV1.MessageID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "msg_" + ascending()) })));
137-export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(Schema.brand("SessionV1.PartID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "prt_" + ascending()) })));
138+export const MessageID = Schema.String.check(Schema.isStartingWith("msg")).pipe(Schema.brand("SessionV1.MessageID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "msg_" + ascending()) })));
139+export const PartID = Schema.String.check(Schema.isStartingWith("prt")).pipe(Schema.brand("SessionV1.PartID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "prt_" + ascending()) })));
140 const namedError = (name, fields) => {
141 const schema = Schema.Struct({ name: Schema.Literal(name), data: Schema.Struct(fields) }).annotate({
142 identifier: name,
143diff --git a/dist/workspace-id.js b/dist/workspace-id.js
144index 4bed474..4ec8671 100644
145--- a/dist/workspace-id.js
146+++ b/dist/workspace-id.js
147@@ -1,7 +1,7 @@
148 import { Schema } from "effect";
149 import { ascending } from "./identifier.js";
150 import { statics } from "./schema.js";
151-export const WorkspaceID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(Schema.brand("Workspace.ID"), statics((schema) => {
152+export const WorkspaceID = Schema.String.check(Schema.isStartingWith("wrk")).pipe(Schema.brand("Workspace.ID"), statics((schema) => {
153 const create = () => schema.make("wrk_" + ascending());
154 return {
155 ascending: (id) => {