Repository navigation
fix(emergent): forged tool names are held to the name rule and skill exports write only inside their folder, and export follow-ups from the cold read of #332 - #338
Conversation
…me, and write a skill export only inside its output folder
…ace's file without waiting, finds two names for one file by the open file, and holds a bounded number of files open
… an object member
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer's GuideThe PR adds defense-in-depth for model- and storage-derived tool names, ensuring forged tools meet both path and identifier rules and skill exports write only within their output directory. It also hardens Markdown/Obsidian exports against special files and filesystem-level collisions while bounding open handles, and centralizes name-error formatting with related regression tests and documentation. Sequence diagram for forged tool name validationsequenceDiagram
participant Caller
participant ForgeToolMetaTool
participant EmergentCapabilityEngine
participant EmergentJudge
participant EmergentToolRegistry
Caller->>ForgeToolMetaTool: execute(args)
ForgeToolMetaTool->>ForgeToolMetaTool: forgedToolNameProblem(args.name)
alt invalid tool name
ForgeToolMetaTool-->>Caller: INVALID_TOOL_NAME
else valid tool name
ForgeToolMetaTool->>EmergentCapabilityEngine: forge(request)
EmergentCapabilityEngine->>EmergentCapabilityEngine: forgedToolNameProblem(request.name)
EmergentCapabilityEngine->>EmergentJudge: judge(candidate)
EmergentJudge-->>EmergentCapabilityEngine: approval
EmergentCapabilityEngine->>EmergentToolRegistry: register(tool)
EmergentCapabilityEngine-->>ForgeToolMetaTool: ForgeResult
ForgeToolMetaTool-->>Caller: ForgeResult
end
Sequence diagram for bounded trace export validationsequenceDiagram
participant Memory
participant MarkdownExporter
participant FileSystem
Memory->>MarkdownExporter: export(outputDir)
MarkdownExporter->>MarkdownExporter: Sort traces oldest first
loop batches of MAX_OPEN_TRACE_FILES
MarkdownExporter->>FileSystem: openTraceFile(path)
FileSystem-->>MarkdownExporter: regular file and device/inode
MarkdownExporter->>MarkdownExporter: Claim file identity
alt link, special file, or collision
MarkdownExporter-->>MarkdownExporter: Add refused trace
else unique regular file
MarkdownExporter->>FileSystem: truncate and write trace
end
MarkdownExporter->>FileSystem: close file handles
end
alt non-refusal error occurred
MarkdownExporter-->>Memory: Reject after other traces are tried
else export complete
MarkdownExporter-->>Memory: ExportResult with refused traces
end
Flow diagram for safe skill export pathsflowchart TD
A[Tool name and outputDir] --> B[resolveToolFolder]
B --> C{pathNameProblem}
C -->|invalid| D[Throw InvalidToolNameError]
C -->|valid| E[resolveInsideFolder]
E --> F{Folder inside outputDir}
F -->|no| D
F -->|yes| G[Create tool folder]
G --> H[Write SKILL.md or CAPABILITY.yaml]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoValidate forged tool names and harden skill and memory exports
AI Description
Diagram
High-Level Assessment
Files changed (18)
|
Code Review by Qodo
1.
|
…ce restoring a spy clears its calls
…se file does not close, and write a skill's files through no link below its folder
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
## [0.13.66](v0.13.65...v0.13.66) (2026-10-12) ### fix * **emergent:** forged tool names are held to the name rule and skill exports write only inside their folder, and export follow-ups from the cold read of #332 (#338) ([ff8e6c5](ff8e6c5)) ### docs * name the late calls charged to a later turn on the GMI study page (#339) ([b2957fa](b2957fa))
## [0.13.92](v0.13.91...v0.13.92) (2026-10-13) ### fix * **discovery:** a capability's files are read only inside its folder, agent workspace folders stay inside the base folder, and follow-ups from the cold read of #338 (#392) ([5c6539b](5c6539b))
Summary
The skill exporter names a forged tool's folder after the tool, and the forge took the name from the model's
forge_toolcall with only a non-empty check. The forge now holds a tool's name to a rule, and the exporter checks the name again and writes only inside its output folder. This pull request also carries the follow-ups from the cold read of #332 for the Markdown and Obsidian exporters.Forged tool names.
forge_toolandEmergentCapabilityEngine.forgehold a tool's name to two rules before anything is tested, judged or registered:pathNameProbleminsrc/core/utils/pathName.ts, the rule the wiki and the memory exporters use), so a name the forge accepts is one the exporter accepts;^[a-zA-Z][a-zA-Z0-9_-]*$, which the agent forge already held a synthesised role to. It is now one constant,IDENTIFIER_PATTERNinsrc/cognition/emergent/ToolName.ts, used by both. It is the form provider function names take, and it keeps a name to one ASCII word.A refused name fails
forge_toolwithdetails: { code: 'INVALID_TOOL_NAME', problem }, and a directengine.forgewith the same message. A missing or empty name keeps itsname is requirederror. Thenamedescription in the tool's input schema states the rule.Skill export.
writeSkillFileandexportToolAsSkillPackbuild the tool's folder withresolveToolFolder. The name is checked against the shared name rule again, so a tool the forge did not check, such as one loaded from a stored row or one a host builds itself, is checked too. The folder must then resolve insideoutputDir(resolveInsideFolder). Otherwise both reject withInvalidToolNameError(exported from@framers/agentos/emergent, withcodeandproblem) before any folder is made or file written.Links below the skills folder. The folder and file checks the Markdown exporter used move to
src/core/utils/linkFreeWrite.ts, and both exporters write through them. The skill exporter makes the tool's folder one name at a time and refuses a link there, looks at each file's place before it opens any, and opens each file never through a link and never waiting, writing only into a regular file with one name. A symbolic link at the folder or at a file, a second name for a file, or anything but a regular file at a file's place rejects withSkillExportRefusedError(code: 'SKILL_EXPORT_REFUSED',problem: 'link'or'special'), and nothing is written. The output folder itself may be a link.Other joins. No other code in
srcbuilds a path to write from a tool, skill, agent or persona name. The other joins use names read from a folder listing, a sanitised provider id, or generated temporary names.Markdown and Obsidian export follow-ups from the cold read of fix(memory): Markdown and Obsidian exports write only inside the export folder, and wiki follow-ups from the cold read of #323 #332:
O_NONBLOCKwhere the platform has it, so a named pipe that no process reads fails the open at once. An open file that is not a regular file, or a folder at the file's place, is left out with a new problem,special, and nothing is written to it.collision. The case key now folds each character through upper case when its upper case is one character, so it joins letters that lower-casing alone keeps apart but macOS and Windows treat as one (the long s and s, the final sigma and sigma, the micro sign and mu), and keeps apart names those systems keep apart (ß and ss).MAX_OPEN_TRACE_FILES), and the identity claims hold across batches, so a large export keeps a bounded number of files open. An error other than a refusal, such as a full disk or a failed close, rejects the export once every other trace has been tried.describeRefusedNamemoves fromWikiPageId.tstopathName.ts, so a refused wiki page id and a refused tool name are described the same way in their errors.Linked issues
None.
Type of change
How this was verified
CI on this branch: Test & Lint (build, lint, type check and the whole suite), Batch-1 gated tests, browser tests and the release dry run. New and changed tests:
src/cognition/emergent/__tests__/skill-export-paths.integration.test.ts, through a real tool orchestrator and engine and a temp skills folder with files one and two levels above it:forge_toolrefuses names that would leave the folder, a dot name and a name with a space, each with the typed details, before the judge runs, and registers nothing;engine.forgerefuses the same kind of name;double_itis written by both exporters to its own folder, and nothing else changes;CAPABILITY.yamlto the file two levels up, and a second name atSKILL.mdfor the file one level up: each is refused withSkillExportRefusedError, no file is made, and the files outside keep their text.src/cognition/emergent/__tests__/tool-name.test.ts: the forge's name rule andresolveToolFolder. Accepted names, the longest among them. Refused names, each with its problem: other types, empty, separators, a drive, a stream, control characters, dot names, edge spaces and dots, past the byte limit, and names that are safe folder names but no identifier. Each refusal checked withpath.posixandpath.win32, a folder the path functions place outside, and the error message.src/cognition/memory/io/__tests__/exportTracePaths.integration.test.ts, throughMemory.importFromandMemory.export:collision, and the older's file holds its own text; ß and ss are both written;special, the export settles at once, and nothing is written into the pipe (skipped on Windows);outside, and nothing is written outside.src/api/__tests__/souledAgent.test.ts: the second start's boot index skips all five pages named after object members and indexes and removes none.Migration notes
writeSkillFileandexportToolAsSkillPackreturn absolute paths, also for a relativeoutputDir, reject withInvalidToolNameErrorfor a refused name, and reject withSkillExportRefusedErrorwhen a link, a second name or anything but a regular file is at the tool's folder or files.RefusedExportTrace.problemhas a new value,special. A folder at a trace's file place is left out with it, where the export rejected with EISDIR.Checklist
!before the colon for a change that breaks users (feat!:orfeat(api)!:).