From 4b2f722da07d7b480ae10b587d83f76b1025d5c1 Mon Sep 17 00:00:00 2001 From: Gabriel Darbord <78592838+Gabriel-Darbord@users.noreply.github.com> Date: Tue, 24 Nov 2026 08:16:52 +0100 Subject: [PATCH] Keep the version of the filter that kept each span, and release 0.4.0 The allowlist lists pharo_agent_telemetry.filter.version, which pharo-agent-telemetry 0.3.0's agent stamps on each span: spans from participants who have not joined again since tell themselves apart. That release also counts, in status, the spans the filter drops. Co-Authored-By: Claude Opus 5.5 --- allowlist.json | 3 ++- collector/otelcol.yaml | 8 +++++++- docs/participants.md | 1 + package-lock.json | 12 ++++++------ package.json | 4 ++-- telemetry-transform.mjs | 28 ++++++++++++++++++++-------- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/allowlist.json b/allowlist.json index f24b01e..08dfa34 100644 --- a/allowlist.json +++ b/allowlist.json @@ -44,7 +44,8 @@ "process.runtime.name": {"about": "nodejs or pharo.", "type": "string", "values": ["nodejs", "pharo"]}, "process.runtime.version": {"about": "Node's major version, or Pharo's major and minor.", "type": "string", "extract": {"plexus": "^v?([0-9]{1,4})(?:\\.[\\s\\S]*)?$", "pharo-mcp": "^v?([0-9]{1,4}\\.[0-9]{1,4})(?:[.+-][\\s\\S]*)?$"}, "pattern": "version"}, "deployment.environment.name": {"about": "field for participants, eval for our own evaluation runs, preview while previewing, check for pharo-agent-telemetry check-deployment.", "type": "string", "values": ["field", "eval", "preview", "check"]}, - "pharo_agent_evals.variant": {"about": "Which variant of an evaluation run sent the span: the build under test, which may report a released version. Kept only for eval.", "type": "string", "pattern": "variant", "when": {"deployment.environment.name": "eval"}} + "pharo_agent_evals.variant": {"about": "Which variant of an evaluation run sent the span: the build under test, which may report a released version. Kept only for eval.", "type": "string", "pattern": "variant", "when": {"deployment.environment.name": "eval"}}, + "pharo_agent_telemetry.filter.version": {"about": "The version of this study's filter on your machine that kept the span, which the agent sets: data kept by an older filter, before you joined again, tells itself apart.", "type": "string", "pattern": "version"} }, "span": { "session.id": {"about": "Groups the calls of one working session. PLexus makes it at random, or MCP when the call came without one, and either starts another after 30 minutes without a call; it is replaced by its keyed hash before it leaves your machine.", "type": "string", "pattern": "text", "hash": "session"}, diff --git a/collector/otelcol.yaml b/collector/otelcol.yaml index 369366c..7705876 100644 --- a/collector/otelcol.yaml +++ b/collector/otelcol.yaml @@ -63,7 +63,7 @@ processors: trace_statements: - context: resource statements: - - "keep_keys(attributes, [\"service.name\", \"service.version\", \"os.type\", \"process.runtime.name\", \"process.runtime.version\", \"deployment.environment.name\", \"pharo_agent_evals.variant\"])" + - "keep_keys(attributes, [\"service.name\", \"service.version\", \"os.type\", \"process.runtime.name\", \"process.runtime.version\", \"deployment.environment.name\", \"pharo_agent_evals.variant\", \"pharo_agent_telemetry.filter.version\"])" - "delete_key(attributes, \"service.name\") where not IsString(attributes[\"service.name\"])" - "set(attributes[\"service.name\"], \"****\") where IsString(attributes[\"service.name\"]) and IsMatch(attributes[\"service.name\"], \"(?is)^.*(/Users/|/home/|[A-Z]:\\\\\\\\Users\\\\\\\\).*$\")" - "set(attributes[\"service.name\"], \"****\") where IsString(attributes[\"service.name\"]) and IsMatch(attributes[\"service.name\"], \"(?s)^.*[A-Za-z0-9._%+-]@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2}.*$\")" @@ -109,6 +109,12 @@ processors: - "set(attributes[\"pharo_agent_evals.variant\"], \"****\") where IsString(attributes[\"pharo_agent_evals.variant\"]) and IsMatch(attributes[\"pharo_agent_evals.variant\"], \"(?s)^.*\\\\b(?:[0-9]{1,3}\\\\.){3}[0-9]{1,3}\\\\b.*$\")" - "set(attributes[\"pharo_agent_evals.variant\"], \"****\") where IsString(attributes[\"pharo_agent_evals.variant\"]) and IsMatch(attributes[\"pharo_agent_evals.variant\"], \"(?is)^.*(?:::|\\\\b[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}\\\\b).*$\")" - "delete_key(attributes, \"pharo_agent_evals.variant\") where IsString(attributes[\"pharo_agent_evals.variant\"]) and not IsMatch(attributes[\"pharo_agent_evals.variant\"], \"^(?:[A-Za-z0-9][A-Za-z0-9._-]{0,63})$\")" + - "delete_key(attributes, \"pharo_agent_telemetry.filter.version\") where not IsString(attributes[\"pharo_agent_telemetry.filter.version\"])" + - "set(attributes[\"pharo_agent_telemetry.filter.version\"], \"****\") where IsString(attributes[\"pharo_agent_telemetry.filter.version\"]) and IsMatch(attributes[\"pharo_agent_telemetry.filter.version\"], \"(?is)^.*(/Users/|/home/|[A-Z]:\\\\\\\\Users\\\\\\\\).*$\")" + - "set(attributes[\"pharo_agent_telemetry.filter.version\"], \"****\") where IsString(attributes[\"pharo_agent_telemetry.filter.version\"]) and IsMatch(attributes[\"pharo_agent_telemetry.filter.version\"], \"(?s)^.*[A-Za-z0-9._%+-]@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2}.*$\")" + - "set(attributes[\"pharo_agent_telemetry.filter.version\"], \"****\") where IsString(attributes[\"pharo_agent_telemetry.filter.version\"]) and IsMatch(attributes[\"pharo_agent_telemetry.filter.version\"], \"(?s)^.*\\\\b(?:[0-9]{1,3}\\\\.){3}[0-9]{1,3}\\\\b.*$\")" + - "set(attributes[\"pharo_agent_telemetry.filter.version\"], \"****\") where IsString(attributes[\"pharo_agent_telemetry.filter.version\"]) and IsMatch(attributes[\"pharo_agent_telemetry.filter.version\"], \"(?is)^.*(?:::|\\\\b[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}\\\\b).*$\")" + - "delete_key(attributes, \"pharo_agent_telemetry.filter.version\") where IsString(attributes[\"pharo_agent_telemetry.filter.version\"]) and not IsMatch(attributes[\"pharo_agent_telemetry.filter.version\"], \"^(?:[0-9]{1,4}(?:\\\\.[0-9]{1,4}){0,2}(?:-(?:alpha|beta|rc)(?:\\\\.[0-9]{1,4})?)?)$\")" - "delete_key(attributes, \"pharo_agent_evals.variant\") where attributes[\"deployment.environment.name\"] != \"eval\"" - "set(schema_url, \"\")" - "set(dropped_attributes_count, 0)" diff --git a/docs/participants.md b/docs/participants.md index 907e315..99ae375 100644 --- a/docs/participants.md +++ b/docs/participants.md @@ -104,6 +104,7 @@ Where it ran: | `process.runtime.version` | plexus, pharo-mcp | Node's major version, or Pharo's major and minor. | a version, major from plexus, major and minor from pharo-mcp | | `deployment.environment.name` | plexus, pharo-mcp | field for participants, eval for our own evaluation runs, preview while previewing, check for pharo-agent-telemetry check-deployment. | one of `field`, `eval`, `preview`, `check` | | `pharo_agent_evals.variant` | plexus, pharo-mcp | Which variant of an evaluation run sent the span: the build under test, which may report a released version. Kept only for eval. | a build's name, only beside `deployment.environment.name` `eval` | +| `pharo_agent_telemetry.filter.version` | plexus, pharo-mcp | The version of this study's filter on your machine that kept the span, which the agent sets: data kept by an older filter, before you joined again, tells itself apart. | a version | What happened: diff --git a/package-lock.json b/package-lock.json index 11f3f14..85b416f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@evref-bl/pharo-agent-study", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@evref-bl/pharo-agent-study", - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "dependencies": { - "@evref-bl/pharo-agent-telemetry": "0.2.0" + "@evref-bl/pharo-agent-telemetry": "0.3.0" }, "bin": { "pharo-agent-study": "bin/pharo-agent-study.js" @@ -19,9 +19,9 @@ } }, "node_modules/@evref-bl/pharo-agent-telemetry": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@evref-bl/pharo-agent-telemetry/-/pharo-agent-telemetry-0.2.0.tgz", - "integrity": "sha512-N6VxE6Sdrpp34fRHvRyfJqAFBLl/znE2OFfrlizkhyL+t1f5U9YbmZ4z7OTFjCYJRPbXj5ljH1wwtbO3rHE8Tw==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@evref-bl/pharo-agent-telemetry/-/pharo-agent-telemetry-0.3.0.tgz", + "integrity": "sha512-GG1k1x3r8VBsZLPU1Iu/upQQx3Z1uR74KZ6iyuVJ1kjlRr+DXCsgifk4uAxy/RO6GGEAadYR2vO96g7Uc/J3VQ==", "license": "MIT", "bin": { "pharo-agent-telemetry": "bin/pharo-agent-telemetry.js" diff --git a/package.json b/package.json index 74172af..b3292b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@evref-bl/pharo-agent-study", - "version": "0.3.0", + "version": "0.4.0", "description": "Evref-BL's study of how agents use the Pharo tools: preview, join or leave it.", "license": "MIT", "type": "module", @@ -19,7 +19,7 @@ "node": ">=22.15.0" }, "dependencies": { - "@evref-bl/pharo-agent-telemetry": "0.2.0" + "@evref-bl/pharo-agent-telemetry": "0.3.0" }, "scripts": { "generate": "pharo-agent-telemetry generate", diff --git a/telemetry-transform.mjs b/telemetry-transform.mjs index 9f1dd5f..f1cf1d5 100644 --- a/telemetry-transform.mjs +++ b/telemetry-transform.mjs @@ -8,7 +8,7 @@ import { createHash } from "node:crypto"; import { readFileSync } from "node:fs"; -export const version = "0.3.0"; +export const version = "0.4.0"; const allowlist = { "$comment": "What the study keeps, and in what shape. `pharo-agent-telemetry generate` writes, from this file and catalog.json (the tools and words `pharo-agent-telemetry catalog` reads in the projects' source, and the classes MCP names an exception by in an image of each Pharo version), the filter `join` installs on a participant's machine (telemetry-transform.mjs), the collector's configuration (collector/otelcol.yaml), which applies the same rules again, and docs/participants.md; `pharo-agent-telemetry check` fails when any is out of date. A span is kept only from the services listed, with their scope, one of their span names, and the kinds and attributes a service `requires`. Every attribute not listed is dropped; a listed one is kept only from the services in `from` (both when absent), with the type given, and only when its value has the shape given (and, with `words`, is made of `vocabulary` words in that form: a name, or a JSON pointer of names), else it is dropped, or replaced by `otherwise`; a list with an element of another shape is dropped, but for `published`, whose elements not in a `published` set become `otherwise`. `extract` keeps the first group of a pattern, per service; `when` keeps a resource attribute only beside another's value; `beside` keeps an attribute only beside another that holds a value of its set, not its `otherwise`. `name` marks a name of the tool called: dropped (or replaced by `nameOther`) on a pharo-mcp span whose origin is other for a tool no project publishes, and on a plexus span unless it is for one of PLexus's own tools it did not forward. `own` marks what MCP says only of its own answer: dropped on a pharo-mcp span whose origin is other, for a tool no project publishes. `tool` marks the tool's name: kept when a project publishes it; else, on a pharo-mcp span whose origin is mcp or unknown, when it is made of vocabulary words; else `otherwise`. `grows` names the sets that grow with the projects' releases, by the shape of their members (a tool's name, a word, a code, a class): the only sets a signed catalog the agents fetch may add to.", @@ -103,6 +103,11 @@ const allowlist = { "when": { "deployment.environment.name": "eval" } + }, + "pharo_agent_telemetry.filter.version": { + "about": "The version of this study's filter on your machine that kept the span, which the agent sets: data kept by an older filter, before you joined again, tells itself apart.", + "type": "string", + "pattern": "version" } }, "span": { @@ -404,6 +409,9 @@ const sessionKey = "session.id"; /** The attribute the agent adds: where a span comes in its session, which times kept to the week lose. */ const offsetKey = "pharo_agent_telemetry.session.offset_ms"; +/** The resource attribute the agent adds when its allowlist lists it: the version of the study's filter that kept the span. */ +const filterVersionKey = "pharo_agent_telemetry.filter.version"; + /** * A name as the vocabulary check reads it: each camelCase word boundary * (`className`, `HTTPServer`) made a `_`, in lower case. Written as the two @@ -817,12 +825,15 @@ function keepSpan(rules, span, service, options) { * hash?: (tag: string, value: string, length?: number) => string, * report?: (problem: string) => void, * sessionOffset?: (session: string, start: bigint) => bigint, + * filterVersion?: string, * }} [options] * without `hash`, ids and session ids are kept as they are, as `pharo-agent-telemetry audit` reads an archive; - * with `sessionOffset`, each span with a session gets its offset in it, as the agent adds it + * with `sessionOffset`, each span with a session gets its offset in it, as the agent adds it; + * with `filterVersion`, each resource the version of the filter, in place of any a tool sent, when the allowlist lists it */ function transformTraces(rules, request, options = {}) { const settings = { hash: options.hash, report: options.report ?? (() => {}), sessionOffset: options.sessionOffset }; + const stamp = typeof options.filterVersion === "string" && rules.resource.some((spec) => spec.key === filterVersionKey) ? options.filterVersion : undefined; if (request === null || typeof request !== "object" || !Array.isArray(request.resourceSpans)) return null; const resourceSpans = []; for (const each of request.resourceSpans) { @@ -837,6 +848,7 @@ function transformTraces(rules, request, options = {}) { settings.report("resource: gives an attribute twice"); continue; } + if (stamp !== undefined) resource.set(filterVersionKey, { type: "string", value: stamp }); const scopeSpans = []; for (const scoped of Array.isArray(each.scopeSpans) ? each.scopeSpans : []) { if (scoped?.scope?.name !== rules.services[service].scope) { @@ -995,9 +1007,9 @@ function withCatalogSets(allowlist, catalog) { * * @param {any} allowlist * @param {string | undefined} key - * @param {{ offsets?: boolean, sessions?: Map, catalog?: any }} [options] `offsets: false` leaves out the places, as the collector, which cannot know them; `sessions`, the first span of each session the agent saw, which it keeps across its restarts; `catalog`, a newer catalog the agent accepted (catalogProblem finds nothing in it), whose additions the sets take + * @param {{ offsets?: boolean, sessions?: Map, catalog?: any, filterVersion?: string }} [options] `offsets: false` leaves out the places, as the collector, which cannot know them; `sessions`, the first span of each session the agent saw, which it keeps across its restarts; `catalog`, a newer catalog the agent accepted (catalogProblem finds nothing in it), whose additions the sets take; `filterVersion`, the study's version, stamped on each resource */ -function createTransform(allowlist, key, { offsets = true, sessions, catalog } = {}) { +function createTransform(allowlist, key, { offsets = true, sessions, catalog, filterVersion } = {}) { if (catalog !== undefined && catalogProblem(catalog)) throw new Error(`The catalog is refused: ${catalogProblem(catalog)}.`); const rules = compile(catalog === undefined ? allowlist : withCatalogSets(allowlist, catalog)); const hash = typeof key === "string" && /^[0-9a-f]{32,128}$/.test(key) ? keyedHash(key) : undefined; @@ -1005,7 +1017,7 @@ function createTransform(allowlist, key, { offsets = true, sessions, catalog } = return (signal, request) => { if (signal !== "traces" || hash === undefined) return null; try { - return transformTraces(rules, request, { hash, sessionOffset }); + return transformTraces(rules, request, { hash, sessionOffset, filterVersion }); } catch { return null; } @@ -1019,10 +1031,10 @@ try { key = undefined; } -export default createTransform(allowlist, key); +export default createTransform(allowlist, key, { filterVersion: version }); -/** The same filter with another key, as `preview` runs it; without the places in sessions with `{ offsets: false }`; with a newer catalog's sets with `{ catalog }`. */ -export const filter = (other, options) => createTransform(allowlist, other, options); +/** The same filter with another key, as `preview` runs it; without the places in sessions with `{ offsets: false }`; without its version on each span with `{ filterVersion: undefined }`; with a newer catalog's sets with `{ catalog }`. */ +export const filter = (other, options) => createTransform(allowlist, other, { filterVersion: version, ...options }); /** The catalog this filter was generated with: its form, its date, and the releases it was read from. */ export const catalog = { schema: catalogSchema, published: allowlist.catalogPublished, releases: allowlist.releases };