@smthrs/std 0.0.0-stage → 1.0.0-rc.4
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/CHANGELOG.md +130 -0
- package/LICENSE +21 -0
- package/README.md +152 -2
- package/dist/cjs/ApplyPatch.d.ts +174 -0
- package/dist/cjs/ApplyPatch.d.ts.map +1 -0
- package/dist/cjs/ApplyPatch.js +309 -0
- package/dist/cjs/ApplyPatch.js.map +7 -0
- package/dist/cjs/Bash.d.ts +380 -0
- package/dist/cjs/Bash.d.ts.map +1 -0
- package/dist/cjs/Bash.js +332 -0
- package/dist/cjs/Bash.js.map +7 -0
- package/dist/cjs/Checkpoints.d.ts +279 -0
- package/dist/cjs/Checkpoints.d.ts.map +1 -0
- package/dist/cjs/Checkpoints.js +145 -0
- package/dist/cjs/Checkpoints.js.map +7 -0
- package/dist/cjs/Container.d.ts +132 -0
- package/dist/cjs/Container.d.ts.map +1 -0
- package/dist/cjs/Container.js +113 -0
- package/dist/cjs/Container.js.map +7 -0
- package/dist/cjs/Edit.d.ts +203 -0
- package/dist/cjs/Edit.d.ts.map +1 -0
- package/dist/cjs/Edit.js +258 -0
- package/dist/cjs/Edit.js.map +7 -0
- package/dist/cjs/ExaWebSearch.d.ts +22 -0
- package/dist/cjs/ExaWebSearch.d.ts.map +1 -0
- package/dist/cjs/ExaWebSearch.js +138 -0
- package/dist/cjs/ExaWebSearch.js.map +7 -0
- package/dist/cjs/Explore.d.ts +328 -0
- package/dist/cjs/Explore.d.ts.map +1 -0
- package/dist/cjs/Explore.js +90 -0
- package/dist/cjs/Explore.js.map +7 -0
- package/dist/cjs/Fetch.d.ts +130 -0
- package/dist/cjs/Fetch.d.ts.map +1 -0
- package/dist/cjs/Fetch.js +64 -0
- package/dist/cjs/Fetch.js.map +7 -0
- package/dist/cjs/Glob.d.ts +204 -0
- package/dist/cjs/Glob.d.ts.map +1 -0
- package/dist/cjs/Glob.js +94 -0
- package/dist/cjs/Glob.js.map +7 -0
- package/dist/cjs/Grep.d.ts +347 -0
- package/dist/cjs/Grep.d.ts.map +1 -0
- package/dist/cjs/Grep.js +181 -0
- package/dist/cjs/Grep.js.map +7 -0
- package/dist/cjs/HttpPost.d.ts +130 -0
- package/dist/cjs/HttpPost.d.ts.map +1 -0
- package/dist/cjs/HttpPost.js +72 -0
- package/dist/cjs/HttpPost.js.map +7 -0
- package/dist/cjs/LanguageServer.d.ts +90 -0
- package/dist/cjs/LanguageServer.d.ts.map +1 -0
- package/dist/cjs/LanguageServer.js +60 -0
- package/dist/cjs/LanguageServer.js.map +7 -0
- package/dist/cjs/Ls.d.ts +164 -0
- package/dist/cjs/Ls.d.ts.map +1 -0
- package/dist/cjs/Ls.js +136 -0
- package/dist/cjs/Ls.js.map +7 -0
- package/dist/cjs/Lsp.d.ts +125 -0
- package/dist/cjs/Lsp.d.ts.map +1 -0
- package/dist/cjs/Lsp.js +137 -0
- package/dist/cjs/Lsp.js.map +7 -0
- package/dist/cjs/Manifest.d.ts +918 -0
- package/dist/cjs/Manifest.d.ts.map +1 -0
- package/dist/cjs/Manifest.js +144 -0
- package/dist/cjs/Manifest.js.map +7 -0
- package/dist/cjs/NativeSearch.d.ts +38 -0
- package/dist/cjs/NativeSearch.d.ts.map +1 -0
- package/dist/cjs/NativeSearch.js +326 -0
- package/dist/cjs/NativeSearch.js.map +7 -0
- package/dist/cjs/NodeLanguageServer.d.ts +128 -0
- package/dist/cjs/NodeLanguageServer.d.ts.map +1 -0
- package/dist/cjs/NodeLanguageServer.js +796 -0
- package/dist/cjs/NodeLanguageServer.js.map +7 -0
- package/dist/cjs/PortableSearch.d.ts +24 -0
- package/dist/cjs/PortableSearch.d.ts.map +1 -0
- package/dist/cjs/PortableSearch.js +233 -0
- package/dist/cjs/PortableSearch.js.map +7 -0
- package/dist/cjs/Probe.d.ts +193 -0
- package/dist/cjs/Probe.d.ts.map +1 -0
- package/dist/cjs/Probe.js +134 -0
- package/dist/cjs/Probe.js.map +7 -0
- package/dist/cjs/Read.d.ts +189 -0
- package/dist/cjs/Read.d.ts.map +1 -0
- package/dist/cjs/Read.js +223 -0
- package/dist/cjs/Read.js.map +7 -0
- package/dist/cjs/Relocate.d.ts +73 -0
- package/dist/cjs/Relocate.d.ts.map +1 -0
- package/dist/cjs/Relocate.js +72 -0
- package/dist/cjs/Relocate.js.map +7 -0
- package/dist/cjs/Search.d.ts +163 -0
- package/dist/cjs/Search.d.ts.map +1 -0
- package/dist/cjs/Search.js +51 -0
- package/dist/cjs/Search.js.map +7 -0
- package/dist/cjs/SearchConformance.d.ts +115 -0
- package/dist/cjs/SearchConformance.d.ts.map +1 -0
- package/dist/cjs/SearchConformance.js +172 -0
- package/dist/cjs/SearchConformance.js.map +7 -0
- package/dist/cjs/SearchContract.d.ts +114 -0
- package/dist/cjs/SearchContract.d.ts.map +1 -0
- package/dist/cjs/SearchContract.js +339 -0
- package/dist/cjs/SearchContract.js.map +7 -0
- package/dist/cjs/ShellCommand.d.ts +164 -0
- package/dist/cjs/ShellCommand.d.ts.map +1 -0
- package/dist/cjs/ShellCommand.js +102 -0
- package/dist/cjs/ShellCommand.js.map +7 -0
- package/dist/cjs/StdError.d.ts +55 -0
- package/dist/cjs/StdError.d.ts.map +1 -0
- package/dist/cjs/StdError.js +74 -0
- package/dist/cjs/StdError.js.map +7 -0
- package/dist/cjs/TestRun.d.ts +311 -0
- package/dist/cjs/TestRun.d.ts.map +1 -0
- package/dist/cjs/TestRun.js +228 -0
- package/dist/cjs/TestRun.js.map +7 -0
- package/dist/cjs/TestRunner.d.ts +102 -0
- package/dist/cjs/TestRunner.d.ts.map +1 -0
- package/dist/cjs/TestRunner.js +54 -0
- package/dist/cjs/TestRunner.js.map +7 -0
- package/dist/cjs/TreeFingerprint.d.ts +140 -0
- package/dist/cjs/TreeFingerprint.d.ts.map +1 -0
- package/dist/cjs/TreeFingerprint.js +87 -0
- package/dist/cjs/TreeFingerprint.js.map +7 -0
- package/dist/cjs/UpdatePlan.d.ts +152 -0
- package/dist/cjs/UpdatePlan.d.ts.map +1 -0
- package/dist/cjs/UpdatePlan.js +87 -0
- package/dist/cjs/UpdatePlan.js.map +7 -0
- package/dist/cjs/WebFetch.d.ts +134 -0
- package/dist/cjs/WebFetch.d.ts.map +1 -0
- package/dist/cjs/WebFetch.js +140 -0
- package/dist/cjs/WebFetch.js.map +7 -0
- package/dist/cjs/WebSearch.d.ts +181 -0
- package/dist/cjs/WebSearch.d.ts.map +1 -0
- package/dist/cjs/WebSearch.js +86 -0
- package/dist/cjs/WebSearch.js.map +7 -0
- package/dist/cjs/Write.d.ts +147 -0
- package/dist/cjs/Write.d.ts.map +1 -0
- package/dist/cjs/Write.js +122 -0
- package/dist/cjs/Write.js.map +7 -0
- package/dist/cjs/index.d.ts +127 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +99 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/ApplyPatch.d.ts +145 -0
- package/dist/cjs/internal/ApplyPatch.d.ts.map +1 -0
- package/dist/cjs/internal/ApplyPatch.js +462 -0
- package/dist/cjs/internal/ApplyPatch.js.map +7 -0
- package/dist/cjs/internal/CodexText.d.ts +73 -0
- package/dist/cjs/internal/CodexText.d.ts.map +1 -0
- package/dist/cjs/internal/CodexText.js +108 -0
- package/dist/cjs/internal/CodexText.js.map +7 -0
- package/dist/cjs/internal/Declaration.d.ts +49 -0
- package/dist/cjs/internal/Declaration.d.ts.map +1 -0
- package/dist/cjs/internal/Declaration.js +46 -0
- package/dist/cjs/internal/Declaration.js.map +7 -0
- package/dist/cjs/internal/Diagnostics.d.ts +77 -0
- package/dist/cjs/internal/Diagnostics.d.ts.map +1 -0
- package/dist/cjs/internal/Diagnostics.js +89 -0
- package/dist/cjs/internal/Diagnostics.js.map +7 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts +67 -0
- package/dist/cjs/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/cjs/internal/EnvelopePrecheck.js +124 -0
- package/dist/cjs/internal/EnvelopePrecheck.js.map +7 -0
- package/dist/cjs/internal/Exec.d.ts +139 -0
- package/dist/cjs/internal/Exec.d.ts.map +1 -0
- package/dist/cjs/internal/Exec.js +158 -0
- package/dist/cjs/internal/Exec.js.map +7 -0
- package/dist/cjs/internal/FileMutation.d.ts +109 -0
- package/dist/cjs/internal/FileMutation.d.ts.map +1 -0
- package/dist/cjs/internal/FileMutation.js +116 -0
- package/dist/cjs/internal/FileMutation.js.map +7 -0
- package/dist/cjs/internal/FsFailure.d.ts +38 -0
- package/dist/cjs/internal/FsFailure.d.ts.map +1 -0
- package/dist/cjs/internal/FsFailure.js +40 -0
- package/dist/cjs/internal/FsFailure.js.map +7 -0
- package/dist/cjs/internal/GitWorktree.d.ts +108 -0
- package/dist/cjs/internal/GitWorktree.d.ts.map +1 -0
- package/dist/cjs/internal/GitWorktree.js +276 -0
- package/dist/cjs/internal/GitWorktree.js.map +7 -0
- package/dist/cjs/internal/Grouping.d.ts +51 -0
- package/dist/cjs/internal/Grouping.d.ts.map +1 -0
- package/dist/cjs/internal/Grouping.js +83 -0
- package/dist/cjs/internal/Grouping.js.map +7 -0
- package/dist/cjs/internal/Html.d.ts +20 -0
- package/dist/cjs/internal/Html.d.ts.map +1 -0
- package/dist/cjs/internal/Html.js +81 -0
- package/dist/cjs/internal/Html.js.map +7 -0
- package/dist/cjs/internal/Http.d.ts +95 -0
- package/dist/cjs/internal/Http.d.ts.map +1 -0
- package/dist/cjs/internal/Http.js +153 -0
- package/dist/cjs/internal/Http.js.map +7 -0
- package/dist/cjs/internal/HttpNetwork.d.ts +27 -0
- package/dist/cjs/internal/HttpNetwork.d.ts.map +1 -0
- package/dist/cjs/internal/HttpNetwork.js +146 -0
- package/dist/cjs/internal/HttpNetwork.js.map +7 -0
- package/dist/cjs/internal/Ignore.d.ts +37 -0
- package/dist/cjs/internal/Ignore.d.ts.map +1 -0
- package/dist/cjs/internal/Ignore.js +100 -0
- package/dist/cjs/internal/Ignore.js.map +7 -0
- package/dist/cjs/internal/LinearRegex.d.ts +19 -0
- package/dist/cjs/internal/LinearRegex.d.ts.map +1 -0
- package/dist/cjs/internal/LinearRegex.js +166 -0
- package/dist/cjs/internal/LinearRegex.js.map +7 -0
- package/dist/cjs/internal/Match.d.ts +85 -0
- package/dist/cjs/internal/Match.d.ts.map +1 -0
- package/dist/cjs/internal/Match.js +99 -0
- package/dist/cjs/internal/Match.js.map +7 -0
- package/dist/cjs/internal/Paths.d.ts +23 -0
- package/dist/cjs/internal/Paths.d.ts.map +1 -0
- package/dist/cjs/internal/Paths.js +52 -0
- package/dist/cjs/internal/Paths.js.map +7 -0
- package/dist/cjs/internal/Preserve.d.ts +25 -0
- package/dist/cjs/internal/Preserve.d.ts.map +1 -0
- package/dist/cjs/internal/Preserve.js +88 -0
- package/dist/cjs/internal/Preserve.js.map +7 -0
- package/dist/cjs/internal/Prune.d.ts +35 -0
- package/dist/cjs/internal/Prune.d.ts.map +1 -0
- package/dist/cjs/internal/Prune.js +54 -0
- package/dist/cjs/internal/Prune.js.map +7 -0
- package/dist/cjs/internal/SearchContract.d.ts +63 -0
- package/dist/cjs/internal/SearchContract.d.ts.map +1 -0
- package/dist/cjs/internal/SearchContract.js +46 -0
- package/dist/cjs/internal/SearchContract.js.map +7 -0
- package/dist/cjs/internal/Symbols.d.ts +39 -0
- package/dist/cjs/internal/Symbols.d.ts.map +1 -0
- package/dist/cjs/internal/Symbols.js +59 -0
- package/dist/cjs/internal/Symbols.js.map +7 -0
- package/dist/cjs/internal/TestReport.d.ts +52 -0
- package/dist/cjs/internal/TestReport.d.ts.map +1 -0
- package/dist/cjs/internal/TestReport.js +131 -0
- package/dist/cjs/internal/TestReport.js.map +7 -0
- package/dist/cjs/internal/Text.d.ts +114 -0
- package/dist/cjs/internal/Text.d.ts.map +1 -0
- package/dist/cjs/internal/Text.js +82 -0
- package/dist/cjs/internal/Text.js.map +7 -0
- package/dist/cjs/internal/Url.d.ts +13 -0
- package/dist/cjs/internal/Url.d.ts.map +1 -0
- package/dist/cjs/internal/Url.js +35 -0
- package/dist/cjs/internal/Url.js.map +7 -0
- package/dist/cjs/internal/Walk.d.ts +72 -0
- package/dist/cjs/internal/Walk.d.ts.map +1 -0
- package/dist/cjs/internal/Walk.js +108 -0
- package/dist/cjs/internal/Walk.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/ApplyPatch.d.ts +174 -0
- package/dist/esm/ApplyPatch.d.ts.map +1 -0
- package/dist/esm/ApplyPatch.js +346 -0
- package/dist/esm/ApplyPatch.js.map +1 -0
- package/dist/esm/Bash.d.ts +380 -0
- package/dist/esm/Bash.d.ts.map +1 -0
- package/dist/esm/Bash.js +505 -0
- package/dist/esm/Bash.js.map +1 -0
- package/dist/esm/Checkpoints.d.ts +279 -0
- package/dist/esm/Checkpoints.d.ts.map +1 -0
- package/dist/esm/Checkpoints.js +298 -0
- package/dist/esm/Checkpoints.js.map +1 -0
- package/dist/esm/Container.d.ts +132 -0
- package/dist/esm/Container.d.ts.map +1 -0
- package/dist/esm/Container.js +151 -0
- package/dist/esm/Container.js.map +1 -0
- package/dist/esm/Edit.d.ts +203 -0
- package/dist/esm/Edit.d.ts.map +1 -0
- package/dist/esm/Edit.js +296 -0
- package/dist/esm/Edit.js.map +1 -0
- package/dist/esm/ExaWebSearch.d.ts +22 -0
- package/dist/esm/ExaWebSearch.d.ts.map +1 -0
- package/dist/esm/ExaWebSearch.js +107 -0
- package/dist/esm/ExaWebSearch.js.map +1 -0
- package/dist/esm/Explore.d.ts +328 -0
- package/dist/esm/Explore.d.ts.map +1 -0
- package/dist/esm/Explore.js +106 -0
- package/dist/esm/Explore.js.map +1 -0
- package/dist/esm/Fetch.d.ts +130 -0
- package/dist/esm/Fetch.d.ts.map +1 -0
- package/dist/esm/Fetch.js +91 -0
- package/dist/esm/Fetch.js.map +1 -0
- package/dist/esm/Glob.d.ts +204 -0
- package/dist/esm/Glob.d.ts.map +1 -0
- package/dist/esm/Glob.js +177 -0
- package/dist/esm/Glob.js.map +1 -0
- package/dist/esm/Grep.d.ts +347 -0
- package/dist/esm/Grep.d.ts.map +1 -0
- package/dist/esm/Grep.js +289 -0
- package/dist/esm/Grep.js.map +1 -0
- package/dist/esm/HttpPost.d.ts +130 -0
- package/dist/esm/HttpPost.d.ts.map +1 -0
- package/dist/esm/HttpPost.js +89 -0
- package/dist/esm/HttpPost.js.map +1 -0
- package/dist/esm/LanguageServer.d.ts +90 -0
- package/dist/esm/LanguageServer.d.ts.map +1 -0
- package/dist/esm/LanguageServer.js +57 -0
- package/dist/esm/LanguageServer.js.map +1 -0
- package/dist/esm/Ls.d.ts +164 -0
- package/dist/esm/Ls.d.ts.map +1 -0
- package/dist/esm/Ls.js +178 -0
- package/dist/esm/Ls.js.map +1 -0
- package/dist/esm/Lsp.d.ts +125 -0
- package/dist/esm/Lsp.d.ts.map +1 -0
- package/dist/esm/Lsp.js +165 -0
- package/dist/esm/Lsp.js.map +1 -0
- package/dist/esm/Manifest.d.ts +918 -0
- package/dist/esm/Manifest.d.ts.map +1 -0
- package/dist/esm/Manifest.js +153 -0
- package/dist/esm/Manifest.js.map +1 -0
- package/dist/esm/NativeSearch.d.ts +38 -0
- package/dist/esm/NativeSearch.d.ts.map +1 -0
- package/dist/esm/NativeSearch.js +378 -0
- package/dist/esm/NativeSearch.js.map +1 -0
- package/dist/esm/NodeLanguageServer.d.ts +128 -0
- package/dist/esm/NodeLanguageServer.d.ts.map +1 -0
- package/dist/esm/NodeLanguageServer.js +843 -0
- package/dist/esm/NodeLanguageServer.js.map +1 -0
- package/dist/esm/PortableSearch.d.ts +24 -0
- package/dist/esm/PortableSearch.d.ts.map +1 -0
- package/dist/esm/PortableSearch.js +240 -0
- package/dist/esm/PortableSearch.js.map +1 -0
- package/dist/esm/Probe.d.ts +193 -0
- package/dist/esm/Probe.d.ts.map +1 -0
- package/dist/esm/Probe.js +225 -0
- package/dist/esm/Probe.js.map +1 -0
- package/dist/esm/Read.d.ts +189 -0
- package/dist/esm/Read.d.ts.map +1 -0
- package/dist/esm/Read.js +300 -0
- package/dist/esm/Read.js.map +1 -0
- package/dist/esm/Relocate.d.ts +73 -0
- package/dist/esm/Relocate.d.ts.map +1 -0
- package/dist/esm/Relocate.js +153 -0
- package/dist/esm/Relocate.js.map +1 -0
- package/dist/esm/Search.d.ts +163 -0
- package/dist/esm/Search.d.ts.map +1 -0
- package/dist/esm/Search.js +47 -0
- package/dist/esm/Search.js.map +1 -0
- package/dist/esm/SearchConformance.d.ts +115 -0
- package/dist/esm/SearchConformance.d.ts.map +1 -0
- package/dist/esm/SearchConformance.js +193 -0
- package/dist/esm/SearchConformance.js.map +1 -0
- package/dist/esm/SearchContract.d.ts +114 -0
- package/dist/esm/SearchContract.d.ts.map +1 -0
- package/dist/esm/SearchContract.js +461 -0
- package/dist/esm/SearchContract.js.map +1 -0
- package/dist/esm/ShellCommand.d.ts +164 -0
- package/dist/esm/ShellCommand.d.ts.map +1 -0
- package/dist/esm/ShellCommand.js +159 -0
- package/dist/esm/ShellCommand.js.map +1 -0
- package/dist/esm/StdError.d.ts +55 -0
- package/dist/esm/StdError.d.ts.map +1 -0
- package/dist/esm/StdError.js +71 -0
- package/dist/esm/StdError.js.map +1 -0
- package/dist/esm/TestRun.d.ts +311 -0
- package/dist/esm/TestRun.d.ts.map +1 -0
- package/dist/esm/TestRun.js +316 -0
- package/dist/esm/TestRun.js.map +1 -0
- package/dist/esm/TestRunner.d.ts +102 -0
- package/dist/esm/TestRunner.d.ts.map +1 -0
- package/dist/esm/TestRunner.js +68 -0
- package/dist/esm/TestRunner.js.map +1 -0
- package/dist/esm/TreeFingerprint.d.ts +140 -0
- package/dist/esm/TreeFingerprint.d.ts.map +1 -0
- package/dist/esm/TreeFingerprint.js +170 -0
- package/dist/esm/TreeFingerprint.js.map +1 -0
- package/dist/esm/UpdatePlan.d.ts +152 -0
- package/dist/esm/UpdatePlan.d.ts.map +1 -0
- package/dist/esm/UpdatePlan.js +129 -0
- package/dist/esm/UpdatePlan.js.map +1 -0
- package/dist/esm/WebFetch.d.ts +134 -0
- package/dist/esm/WebFetch.d.ts.map +1 -0
- package/dist/esm/WebFetch.js +151 -0
- package/dist/esm/WebFetch.js.map +1 -0
- package/dist/esm/WebSearch.d.ts +181 -0
- package/dist/esm/WebSearch.d.ts.map +1 -0
- package/dist/esm/WebSearch.js +134 -0
- package/dist/esm/WebSearch.js.map +1 -0
- package/dist/esm/Write.d.ts +147 -0
- package/dist/esm/Write.d.ts.map +1 -0
- package/dist/esm/Write.js +144 -0
- package/dist/esm/Write.js.map +1 -0
- package/dist/esm/index.d.ts +127 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +127 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/ApplyPatch.d.ts +145 -0
- package/dist/esm/internal/ApplyPatch.d.ts.map +1 -0
- package/dist/esm/internal/ApplyPatch.js +489 -0
- package/dist/esm/internal/ApplyPatch.js.map +1 -0
- package/dist/esm/internal/CodexText.d.ts +73 -0
- package/dist/esm/internal/CodexText.d.ts.map +1 -0
- package/dist/esm/internal/CodexText.js +156 -0
- package/dist/esm/internal/CodexText.js.map +1 -0
- package/dist/esm/internal/Declaration.d.ts +49 -0
- package/dist/esm/internal/Declaration.d.ts.map +1 -0
- package/dist/esm/internal/Declaration.js +42 -0
- package/dist/esm/internal/Declaration.js.map +1 -0
- package/dist/esm/internal/Diagnostics.d.ts +77 -0
- package/dist/esm/internal/Diagnostics.d.ts.map +1 -0
- package/dist/esm/internal/Diagnostics.js +99 -0
- package/dist/esm/internal/Diagnostics.js.map +1 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts +67 -0
- package/dist/esm/internal/EnvelopePrecheck.d.ts.map +1 -0
- package/dist/esm/internal/EnvelopePrecheck.js +167 -0
- package/dist/esm/internal/EnvelopePrecheck.js.map +1 -0
- package/dist/esm/internal/Exec.d.ts +139 -0
- package/dist/esm/internal/Exec.d.ts.map +1 -0
- package/dist/esm/internal/Exec.js +193 -0
- package/dist/esm/internal/Exec.js.map +1 -0
- package/dist/esm/internal/FileMutation.d.ts +109 -0
- package/dist/esm/internal/FileMutation.d.ts.map +1 -0
- package/dist/esm/internal/FileMutation.js +123 -0
- package/dist/esm/internal/FileMutation.js.map +1 -0
- package/dist/esm/internal/FsFailure.d.ts +38 -0
- package/dist/esm/internal/FsFailure.d.ts.map +1 -0
- package/dist/esm/internal/FsFailure.js +39 -0
- package/dist/esm/internal/FsFailure.js.map +1 -0
- package/dist/esm/internal/GitWorktree.d.ts +108 -0
- package/dist/esm/internal/GitWorktree.d.ts.map +1 -0
- package/dist/esm/internal/GitWorktree.js +352 -0
- package/dist/esm/internal/GitWorktree.js.map +1 -0
- package/dist/esm/internal/Grouping.d.ts +51 -0
- package/dist/esm/internal/Grouping.d.ts.map +1 -0
- package/dist/esm/internal/Grouping.js +99 -0
- package/dist/esm/internal/Grouping.js.map +1 -0
- package/dist/esm/internal/Html.d.ts +20 -0
- package/dist/esm/internal/Html.d.ts.map +1 -0
- package/dist/esm/internal/Html.js +70 -0
- package/dist/esm/internal/Html.js.map +1 -0
- package/dist/esm/internal/Http.d.ts +95 -0
- package/dist/esm/internal/Http.d.ts.map +1 -0
- package/dist/esm/internal/Http.js +154 -0
- package/dist/esm/internal/Http.js.map +1 -0
- package/dist/esm/internal/HttpNetwork.d.ts +27 -0
- package/dist/esm/internal/HttpNetwork.d.ts.map +1 -0
- package/dist/esm/internal/HttpNetwork.js +114 -0
- package/dist/esm/internal/HttpNetwork.js.map +1 -0
- package/dist/esm/internal/Ignore.d.ts +37 -0
- package/dist/esm/internal/Ignore.d.ts.map +1 -0
- package/dist/esm/internal/Ignore.js +128 -0
- package/dist/esm/internal/Ignore.js.map +1 -0
- package/dist/esm/internal/LinearRegex.d.ts +19 -0
- package/dist/esm/internal/LinearRegex.d.ts.map +1 -0
- package/dist/esm/internal/LinearRegex.js +176 -0
- package/dist/esm/internal/LinearRegex.js.map +1 -0
- package/dist/esm/internal/Match.d.ts +85 -0
- package/dist/esm/internal/Match.d.ts.map +1 -0
- package/dist/esm/internal/Match.js +142 -0
- package/dist/esm/internal/Match.js.map +1 -0
- package/dist/esm/internal/Paths.d.ts +23 -0
- package/dist/esm/internal/Paths.d.ts.map +1 -0
- package/dist/esm/internal/Paths.js +40 -0
- package/dist/esm/internal/Paths.js.map +1 -0
- package/dist/esm/internal/Preserve.d.ts +25 -0
- package/dist/esm/internal/Preserve.d.ts.map +1 -0
- package/dist/esm/internal/Preserve.js +70 -0
- package/dist/esm/internal/Preserve.js.map +1 -0
- package/dist/esm/internal/Prune.d.ts +35 -0
- package/dist/esm/internal/Prune.d.ts.map +1 -0
- package/dist/esm/internal/Prune.js +60 -0
- package/dist/esm/internal/Prune.js.map +1 -0
- package/dist/esm/internal/SearchContract.d.ts +63 -0
- package/dist/esm/internal/SearchContract.d.ts.map +1 -0
- package/dist/esm/internal/SearchContract.js +66 -0
- package/dist/esm/internal/SearchContract.js.map +1 -0
- package/dist/esm/internal/Symbols.d.ts +39 -0
- package/dist/esm/internal/Symbols.d.ts.map +1 -0
- package/dist/esm/internal/Symbols.js +79 -0
- package/dist/esm/internal/Symbols.js.map +1 -0
- package/dist/esm/internal/TestReport.d.ts +52 -0
- package/dist/esm/internal/TestReport.d.ts.map +1 -0
- package/dist/esm/internal/TestReport.js +172 -0
- package/dist/esm/internal/TestReport.js.map +1 -0
- package/dist/esm/internal/Text.d.ts +114 -0
- package/dist/esm/internal/Text.d.ts.map +1 -0
- package/dist/esm/internal/Text.js +130 -0
- package/dist/esm/internal/Text.js.map +1 -0
- package/dist/esm/internal/Url.d.ts +13 -0
- package/dist/esm/internal/Url.d.ts.map +1 -0
- package/dist/esm/internal/Url.js +27 -0
- package/dist/esm/internal/Url.js.map +1 -0
- package/dist/esm/internal/Walk.d.ts +72 -0
- package/dist/esm/internal/Walk.d.ts.map +1 -0
- package/dist/esm/internal/Walk.js +126 -0
- package/dist/esm/internal/Walk.js.map +1 -0
- package/docs/README.md +117 -0
- package/docs/api.md +472 -0
- package/docs/concepts/effects-and-capabilities.md +136 -0
- package/docs/concepts/flows-and-handlers.md +115 -0
- package/docs/concepts/limits-and-disclosure.md +102 -0
- package/docs/concepts/search-contract.md +182 -0
- package/docs/guides/bind-the-standard-flows.md +114 -0
- package/docs/guides/implement-a-search-peer.md +133 -0
- package/docs/guides/pin-a-checkpoint.md +141 -0
- package/docs/guides/query-a-language-server.md +257 -0
- package/docs/guides/reach-the-network.md +141 -0
- package/docs/guides/read-and-edit-a-file.md +240 -0
- package/docs/guides/run-a-shell-command.md +215 -0
- package/docs/guides/run-the-test-suite.md +154 -0
- package/docs/guides/search-a-workspace.md +148 -0
- package/docs/installation.md +111 -0
- package/docs/quickstart.md +125 -0
- package/docs/reference/flows.md +556 -0
- package/docs/troubleshooting.md +322 -0
- package/package.json +439 -3
- package/src/ApplyPatch.ts +458 -0
- package/src/Bash.ts +607 -0
- package/src/Checkpoints.ts +422 -0
- package/src/Container.ts +212 -0
- package/src/Edit.ts +366 -0
- package/src/ExaWebSearch.ts +145 -0
- package/src/Explore.ts +139 -0
- package/src/Fetch.ts +117 -0
- package/src/Glob.ts +200 -0
- package/src/Grep.ts +320 -0
- package/src/HttpPost.ts +120 -0
- package/src/LanguageServer.ts +110 -0
- package/src/Ls.ts +228 -0
- package/src/Lsp.ts +184 -0
- package/src/Manifest.ts +162 -0
- package/src/NativeSearch.ts +457 -0
- package/src/NodeLanguageServer.ts +1148 -0
- package/src/PortableSearch.ts +264 -0
- package/src/Probe.ts +284 -0
- package/src/Read.ts +359 -0
- package/src/Relocate.ts +166 -0
- package/src/Search.ts +185 -0
- package/src/SearchConformance.ts +288 -0
- package/src/SearchContract.ts +489 -0
- package/src/ShellCommand.ts +201 -0
- package/src/StdError.ts +80 -0
- package/src/TestRun.ts +401 -0
- package/src/TestRunner.ts +119 -0
- package/src/TreeFingerprint.ts +200 -0
- package/src/UpdatePlan.ts +171 -0
- package/src/WebFetch.ts +194 -0
- package/src/WebSearch.ts +165 -0
- package/src/Write.ts +195 -0
- package/src/index.ts +154 -0
- package/src/internal/ApplyPatch.ts +601 -0
- package/src/internal/CodexText.ts +182 -0
- package/src/internal/Declaration.ts +60 -0
- package/src/internal/Diagnostics.ts +134 -0
- package/src/internal/EnvelopePrecheck.ts +233 -0
- package/src/internal/Exec.ts +314 -0
- package/src/internal/FileMutation.ts +231 -0
- package/src/internal/FsFailure.ts +51 -0
- package/src/internal/GitWorktree.ts +491 -0
- package/src/internal/Grouping.ts +106 -0
- package/src/internal/Html.ts +87 -0
- package/src/internal/Http.ts +209 -0
- package/src/internal/HttpNetwork.ts +153 -0
- package/src/internal/Ignore.ts +135 -0
- package/src/internal/LinearRegex.ts +173 -0
- package/src/internal/Match.ts +172 -0
- package/src/internal/Paths.ts +42 -0
- package/src/internal/Preserve.ts +108 -0
- package/src/internal/Prune.ts +62 -0
- package/src/internal/SearchContract.ts +77 -0
- package/src/internal/Symbols.ts +88 -0
- package/src/internal/TestReport.ts +194 -0
- package/src/internal/Text.ts +170 -0
- package/src/internal/Url.ts +23 -0
- package/src/internal/Walk.ts +176 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinned trees, and the scratch checkouts a call runs against.
|
|
3
|
+
*
|
|
4
|
+
* A checkpoint is a **value**: minting one changes nothing about the workspace,
|
|
5
|
+
* and running a call against one leaves the live tree exactly as it stands.
|
|
6
|
+
* That is the whole of what it buys. Before it existed, the only way a run
|
|
7
|
+
* could answer "did this command fail before my change" was to undo the change
|
|
8
|
+
* — and the journals price that exactly. On `sympy__sympy-13878` the r95repl
|
|
9
|
+
* lane applied one byte-identical 4,789-character patch **five times**, four of
|
|
10
|
+
* those applications preceded by `git checkout -- sympy/stats/crv_types.py`,
|
|
11
|
+
* because a clean fails-before proof required reverting the very work it was
|
|
12
|
+
* meant to prove.
|
|
13
|
+
*
|
|
14
|
+
* This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and
|
|
15
|
+
* `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,
|
|
16
|
+
* the bound and the refusals; nothing in it knows what a tree is. This owns the
|
|
17
|
+
* two host operations that need one:
|
|
18
|
+
*
|
|
19
|
+
* - {@link Checkpoints.capture} records the working tree under an id, and
|
|
20
|
+
* - {@link Checkpoints.materialize} gives that tree back as a directory for the
|
|
21
|
+
* length of one call.
|
|
22
|
+
*
|
|
23
|
+
* ## The git binding, and the container constraint it is shaped by
|
|
24
|
+
*
|
|
25
|
+
* {@link layerGit} records a checkpoint with `git stash create`, then names the
|
|
26
|
+
* commit it prints in this repository's own git config rather than with a ref —
|
|
27
|
+
* see {@link configSection} for why a ref would hand the agent its own edit back
|
|
28
|
+
* as history. `stash create` is the one git command
|
|
29
|
+
* that records the working tree and changes nothing else: it does not move the
|
|
30
|
+
* worktree and does not touch the stash ref. It runs against a shadow
|
|
31
|
+
* `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),
|
|
32
|
+
* so it never writes the repository's index and never runs a program the
|
|
33
|
+
* workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same
|
|
34
|
+
* workspace and its own `git diff` is the run's evidence, so a capture that
|
|
35
|
+
* staged into the real index would be the harness editing the evidence while
|
|
36
|
+
* recording it. A tree with nothing to record prints nothing, and the
|
|
37
|
+
* checkpoint is then `HEAD` — which is exactly what the tree is.
|
|
38
|
+
*
|
|
39
|
+
* Untracked files are not in the recorded tree, which matches how the rig
|
|
40
|
+
* captures a patch: `capture-patch.sh` drops paths that did not exist when the
|
|
41
|
+
* agent started, so a checkpoint holds what a patch would hold.
|
|
42
|
+
*
|
|
43
|
+
* The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`
|
|
44
|
+
* — **inside** the workspace, which looks wrong and is the only thing that
|
|
45
|
+
* works. A benchmark check runs through `docker exec` inside `/testbed`, and
|
|
46
|
+
* `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere
|
|
47
|
+
* else on the host is simply not visible to the container, so the call would run
|
|
48
|
+
* against a path that does not exist. Placed under the workspace it is visible
|
|
49
|
+
* at the same subpath under the mount, needs no second mount, and needs no
|
|
50
|
+
* change to how the rig starts its container. `TestRun`'s `against: "base"`
|
|
51
|
+
* reached the same conclusion first and this reuses its shape;
|
|
52
|
+
* `evals/swebench/run-instance.sh` excludes the directory from patch capture for
|
|
53
|
+
* the same reason it excludes `.flows-test-base`.
|
|
54
|
+
*
|
|
55
|
+
* The checkout is added and removed around **one call**, which is stricter than
|
|
56
|
+
* the frame lifetime the design asks for and much simpler: there is no cache to
|
|
57
|
+
* invalidate, no id to leak, and a checkpoint used by three calls pays three
|
|
58
|
+
* checkouts rather than risking one stale directory. A run that reuses a
|
|
59
|
+
* checkpoint across frames simply re-materializes it, because the ref is what
|
|
60
|
+
* persists.
|
|
61
|
+
*
|
|
62
|
+
* ## What can be pointed at a checkpoint, and what cannot
|
|
63
|
+
*
|
|
64
|
+
* {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half
|
|
65
|
+
* knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half
|
|
66
|
+
* knows git. They change for different reasons, so they are different modules,
|
|
67
|
+
* and {@link relocate} is re-exported here because the harness reaches the whole
|
|
68
|
+
* feature through this one.
|
|
69
|
+
*
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
72
|
+
import { ChildProcessSpawner } from "@smthrs/kernel/ChildProcessSpawner";
|
|
73
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
74
|
+
import * as StdError from "./StdError.ts";
|
|
75
|
+
/**
|
|
76
|
+
* The id naming the tree a run opened on.
|
|
77
|
+
*
|
|
78
|
+
* It is not minted: the host either recorded one before the agent started or it
|
|
79
|
+
* did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and
|
|
80
|
+
* then to `HEAD`, which is the same precedence `TestRun` uses for the same
|
|
81
|
+
* question — so a workspace that has one answer for a baseline has one answer
|
|
82
|
+
* for both.
|
|
83
|
+
*
|
|
84
|
+
* @category constants
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
*/
|
|
87
|
+
export declare const baseId = "base";
|
|
88
|
+
/**
|
|
89
|
+
* The directory checkpoints are materialized into, relative to the repository
|
|
90
|
+
* root and therefore also relative to a container's view of it.
|
|
91
|
+
*
|
|
92
|
+
* @category constants
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
*/
|
|
95
|
+
export declare const scratchDirectory = ".flows-checkpoints";
|
|
96
|
+
/**
|
|
97
|
+
* The git-config section {@link layerGit} records minted checkpoints under.
|
|
98
|
+
*
|
|
99
|
+
* Config and **not a ref**, and that is the whole of the decision. A ref is
|
|
100
|
+
* history: `git log --all` lists it, `git show` prints it, and `git log --all
|
|
101
|
+
* -S` searches it — so a checkpoint named by a ref would hand an agent a commit
|
|
102
|
+
* containing its own edit and let it read that back as if it were upstream
|
|
103
|
+
* work. That exact class cost the measured program real money before the rig
|
|
104
|
+
* moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:
|
|
105
|
+
* django-13346 applied two of its own snapshots as a fake fix), and a ref here
|
|
106
|
+
* would reintroduce it one wave later.
|
|
107
|
+
*
|
|
108
|
+
* The commit object itself is unreferenced. It stays alive for the life of the
|
|
109
|
+
* run — nothing in a run prunes — and a checkout by id works perfectly well,
|
|
110
|
+
* which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable
|
|
111
|
+
* by id and no command that walks refs can reach it:
|
|
112
|
+
* `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer
|
|
113
|
+
* exactly as they did before the capture.
|
|
114
|
+
*
|
|
115
|
+
* One command still sees it, measured rather than argued in
|
|
116
|
+
* `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,
|
|
117
|
+
* because that is what an unreferenced commit is. A checkout is a standalone
|
|
118
|
+
* repository, not a worktree of this one, so `git log --all` does not list it
|
|
119
|
+
* even while a call runs in it. It is not reachable by a name that looks like project history, and the cell
|
|
120
|
+
* contract's environment section says outright that a dangling commit is this
|
|
121
|
+
* harness holding the agent's own tree — which is the half of the django-13346
|
|
122
|
+
* lesson that a store cannot enforce.
|
|
123
|
+
*
|
|
124
|
+
* @category constants
|
|
125
|
+
* @since 1.0.0
|
|
126
|
+
*/
|
|
127
|
+
export declare const configSection = "flows-checkpoint";
|
|
128
|
+
declare const Snapshot_base: Schema.Class<Snapshot, Schema.Struct<{
|
|
129
|
+
readonly id: Schema.String;
|
|
130
|
+
readonly ref: Schema.String;
|
|
131
|
+
}>, {}>;
|
|
132
|
+
/**
|
|
133
|
+
* One tree this run has pinned.
|
|
134
|
+
*
|
|
135
|
+
* `ref` is the store's own name for it. Nothing above this module interprets
|
|
136
|
+
* it; it travels so the journal says which tree a checkpointed call read.
|
|
137
|
+
*
|
|
138
|
+
* @category models
|
|
139
|
+
* @since 1.0.0
|
|
140
|
+
*/
|
|
141
|
+
export declare class Snapshot extends Snapshot_base {
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A tree handed back as a directory, for the length of one call.
|
|
145
|
+
*
|
|
146
|
+
* `host` is where the process running on this machine finds it. `guest` is
|
|
147
|
+
* where a container finds the same directory, which is the same path when no
|
|
148
|
+
* container is in play. They differ exactly as `TestRunner.Runner`'s `cwd` and
|
|
149
|
+
* `root` differ, and for the same reason: one directory, two names.
|
|
150
|
+
*
|
|
151
|
+
* `root` and `guestRoot` are the workspace itself under those same two names.
|
|
152
|
+
* They travel because a call that named a directory *inside* the workspace has
|
|
153
|
+
* to keep it: a check that runs in `tests/` and is pointed at a checkpoint must
|
|
154
|
+
* run in the checkpoint's `tests/`, not at its top. Silently dropping that
|
|
155
|
+
* subpath is how a baseline comes back failing for a reason nobody chose, which
|
|
156
|
+
* is the one failure a checkpoint exists to make impossible.
|
|
157
|
+
*
|
|
158
|
+
* @category models
|
|
159
|
+
* @since 1.0.0
|
|
160
|
+
*/
|
|
161
|
+
export interface Materialized {
|
|
162
|
+
readonly id: string;
|
|
163
|
+
readonly host: string;
|
|
164
|
+
readonly guest: string;
|
|
165
|
+
/** The workspace this checkpoint is a tree of, as this machine names it. */
|
|
166
|
+
readonly root: string;
|
|
167
|
+
/** The workspace as a container names it; the same as {@link Materialized.root} when none does. */
|
|
168
|
+
readonly guestRoot: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The two host operations a checkpoint needs.
|
|
172
|
+
*
|
|
173
|
+
* @category services
|
|
174
|
+
* @since 1.0.0
|
|
175
|
+
*/
|
|
176
|
+
export interface Checkpoints {
|
|
177
|
+
/** Records the working tree as it stands, under `id`. */
|
|
178
|
+
readonly capture: (id: string) => Effect.Effect<Snapshot, StdError.StdError>;
|
|
179
|
+
/**
|
|
180
|
+
* Hands `id` back as a directory for the length of the effect it wraps.
|
|
181
|
+
*
|
|
182
|
+
* Scoped rather than returned, because the directory has to be removed
|
|
183
|
+
* however the call ends — a benchmark run killed at its wall-clock budget
|
|
184
|
+
* would otherwise leave a second checkout of the whole repository in a tree
|
|
185
|
+
* whose diff is the run's answer.
|
|
186
|
+
*/
|
|
187
|
+
readonly materialize: <A, E, R>(id: string, use: (materialized: Materialized) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | StdError.StdError, R>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The {@link Checkpoints} service tag.
|
|
191
|
+
*
|
|
192
|
+
* @category services
|
|
193
|
+
* @since 1.0.0
|
|
194
|
+
*/
|
|
195
|
+
export declare const Checkpoints: Context.Service<Checkpoints, Checkpoints>;
|
|
196
|
+
/**
|
|
197
|
+
* Builds a store from its two operations.
|
|
198
|
+
*
|
|
199
|
+
* @category constructors
|
|
200
|
+
* @since 1.0.0
|
|
201
|
+
*/
|
|
202
|
+
export declare const make: (service: Checkpoints) => Checkpoints;
|
|
203
|
+
/**
|
|
204
|
+
* The refusal a host with nowhere to pin a tree answers with.
|
|
205
|
+
*
|
|
206
|
+
* @category errors
|
|
207
|
+
* @since 1.0.0
|
|
208
|
+
*/
|
|
209
|
+
export declare const unavailable: (id: string) => StdError.StdError;
|
|
210
|
+
/**
|
|
211
|
+
* Builds a store for a host that pins nothing.
|
|
212
|
+
*
|
|
213
|
+
* @category constructors
|
|
214
|
+
* @since 1.0.0
|
|
215
|
+
*/
|
|
216
|
+
export declare const makeNoop: () => Checkpoints;
|
|
217
|
+
/**
|
|
218
|
+
* Provides {@link makeNoop}.
|
|
219
|
+
*
|
|
220
|
+
* @category layers
|
|
221
|
+
* @since 1.0.0
|
|
222
|
+
*/
|
|
223
|
+
export declare const layerNoop: Layer.Layer<Checkpoints>;
|
|
224
|
+
/**
|
|
225
|
+
* What {@link layerGit} needs to know about the repository it pins.
|
|
226
|
+
*
|
|
227
|
+
* @category models
|
|
228
|
+
* @since 1.0.0
|
|
229
|
+
*/
|
|
230
|
+
export interface GitOptions {
|
|
231
|
+
/** The host path of the git repository whose trees are pinned. */
|
|
232
|
+
readonly root: string;
|
|
233
|
+
/**
|
|
234
|
+
* Where a container sees {@link GitOptions.root}, when one does.
|
|
235
|
+
*
|
|
236
|
+
* Absent means there is no container, and the guest path of a materialized
|
|
237
|
+
* checkpoint is then its host path.
|
|
238
|
+
*/
|
|
239
|
+
readonly cwd?: string | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* The ref naming the tree the run opened on, for {@link baseId}.
|
|
242
|
+
*
|
|
243
|
+
* Absent takes `TestRunner.captureBase` and then `HEAD`, which is the
|
|
244
|
+
* precedence `TestRun` already uses.
|
|
245
|
+
*/
|
|
246
|
+
readonly baseRef?: string | undefined;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Builds the git-backed store.
|
|
250
|
+
*
|
|
251
|
+
* Every git command that records or checks out a tree runs against a shadow
|
|
252
|
+
* `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent
|
|
253
|
+
* can write; see `internal/GitWorktree.ts`. The capture reads a copy of the
|
|
254
|
+
* workspace index, so the agent's own index is untouched: its `git diff` is the
|
|
255
|
+
* run's evidence and must not move because the harness recorded something.
|
|
256
|
+
*
|
|
257
|
+
* @category constructors
|
|
258
|
+
* @since 1.0.0
|
|
259
|
+
*/
|
|
260
|
+
export declare const makeGit: (options: GitOptions) => Effect.Effect<Checkpoints, never, ChildProcessSpawner>;
|
|
261
|
+
/**
|
|
262
|
+
* Provides {@link makeGit}.
|
|
263
|
+
*
|
|
264
|
+
* @category layers
|
|
265
|
+
* @since 1.0.0
|
|
266
|
+
*/
|
|
267
|
+
export declare const layerGit: (options: GitOptions) => Layer.Layer<Checkpoints, never, ChildProcessSpawner>;
|
|
268
|
+
/**
|
|
269
|
+
* Rewrites one call's input so the call runs against a materialized checkpoint.
|
|
270
|
+
*
|
|
271
|
+
* Re-exported from {@link Relocate}, which owns the table of flows and fields
|
|
272
|
+
* this rewrite is driven by. It is exported here because the harness reaches the
|
|
273
|
+
* whole checkpoint feature through this module.
|
|
274
|
+
*
|
|
275
|
+
* @category conversions
|
|
276
|
+
* @since 1.0.0
|
|
277
|
+
*/
|
|
278
|
+
export { relocate, type Relocation } from "./Relocate.ts";
|
|
279
|
+
//# sourceMappingURL=Checkpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkpoints.d.ts","sourceRoot":"","sources":["../../src/Checkpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIvD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAGzC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,SAAS,CAAA;AAE5B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,uBAA0B,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO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xB,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAA0C,CAAA;AAEzF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACtC;AAYD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,GAClB,SAAS,UAAU,KAClB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,mBAAmB,CAIpD,CAAA;AAqGJ;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,mBAAmB,CACrD,CAAA;AAC7C;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinned trees, and the scratch checkouts a call runs against.
|
|
3
|
+
*
|
|
4
|
+
* A checkpoint is a **value**: minting one changes nothing about the workspace,
|
|
5
|
+
* and running a call against one leaves the live tree exactly as it stands.
|
|
6
|
+
* That is the whole of what it buys. Before it existed, the only way a run
|
|
7
|
+
* could answer "did this command fail before my change" was to undo the change
|
|
8
|
+
* — and the journals price that exactly. On `sympy__sympy-13878` the r95repl
|
|
9
|
+
* lane applied one byte-identical 4,789-character patch **five times**, four of
|
|
10
|
+
* those applications preceded by `git checkout -- sympy/stats/crv_types.py`,
|
|
11
|
+
* because a clean fails-before proof required reverting the very work it was
|
|
12
|
+
* meant to prove.
|
|
13
|
+
*
|
|
14
|
+
* This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and
|
|
15
|
+
* `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,
|
|
16
|
+
* the bound and the refusals; nothing in it knows what a tree is. This owns the
|
|
17
|
+
* two host operations that need one:
|
|
18
|
+
*
|
|
19
|
+
* - {@link Checkpoints.capture} records the working tree under an id, and
|
|
20
|
+
* - {@link Checkpoints.materialize} gives that tree back as a directory for the
|
|
21
|
+
* length of one call.
|
|
22
|
+
*
|
|
23
|
+
* ## The git binding, and the container constraint it is shaped by
|
|
24
|
+
*
|
|
25
|
+
* {@link layerGit} records a checkpoint with `git stash create`, then names the
|
|
26
|
+
* commit it prints in this repository's own git config rather than with a ref —
|
|
27
|
+
* see {@link configSection} for why a ref would hand the agent its own edit back
|
|
28
|
+
* as history. `stash create` is the one git command
|
|
29
|
+
* that records the working tree and changes nothing else: it does not move the
|
|
30
|
+
* worktree and does not touch the stash ref. It runs against a shadow
|
|
31
|
+
* `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),
|
|
32
|
+
* so it never writes the repository's index and never runs a program the
|
|
33
|
+
* workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same
|
|
34
|
+
* workspace and its own `git diff` is the run's evidence, so a capture that
|
|
35
|
+
* staged into the real index would be the harness editing the evidence while
|
|
36
|
+
* recording it. A tree with nothing to record prints nothing, and the
|
|
37
|
+
* checkpoint is then `HEAD` — which is exactly what the tree is.
|
|
38
|
+
*
|
|
39
|
+
* Untracked files are not in the recorded tree, which matches how the rig
|
|
40
|
+
* captures a patch: `capture-patch.sh` drops paths that did not exist when the
|
|
41
|
+
* agent started, so a checkpoint holds what a patch would hold.
|
|
42
|
+
*
|
|
43
|
+
* The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`
|
|
44
|
+
* — **inside** the workspace, which looks wrong and is the only thing that
|
|
45
|
+
* works. A benchmark check runs through `docker exec` inside `/testbed`, and
|
|
46
|
+
* `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere
|
|
47
|
+
* else on the host is simply not visible to the container, so the call would run
|
|
48
|
+
* against a path that does not exist. Placed under the workspace it is visible
|
|
49
|
+
* at the same subpath under the mount, needs no second mount, and needs no
|
|
50
|
+
* change to how the rig starts its container. `TestRun`'s `against: "base"`
|
|
51
|
+
* reached the same conclusion first and this reuses its shape;
|
|
52
|
+
* `evals/swebench/run-instance.sh` excludes the directory from patch capture for
|
|
53
|
+
* the same reason it excludes `.flows-test-base`.
|
|
54
|
+
*
|
|
55
|
+
* The checkout is added and removed around **one call**, which is stricter than
|
|
56
|
+
* the frame lifetime the design asks for and much simpler: there is no cache to
|
|
57
|
+
* invalidate, no id to leak, and a checkpoint used by three calls pays three
|
|
58
|
+
* checkouts rather than risking one stale directory. A run that reuses a
|
|
59
|
+
* checkpoint across frames simply re-materializes it, because the ref is what
|
|
60
|
+
* persists.
|
|
61
|
+
*
|
|
62
|
+
* ## What can be pointed at a checkpoint, and what cannot
|
|
63
|
+
*
|
|
64
|
+
* {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half
|
|
65
|
+
* knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half
|
|
66
|
+
* knows git. They change for different reasons, so they are different modules,
|
|
67
|
+
* and {@link relocate} is re-exported here because the harness reaches the whole
|
|
68
|
+
* feature through this one.
|
|
69
|
+
*
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
72
|
+
import { ChildProcessSpawner } from "@smthrs/kernel/ChildProcessSpawner";
|
|
73
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
74
|
+
import { GitWorktree } from "./internal/GitWorktree.js";
|
|
75
|
+
import { withoutTrailingSlash } from "./internal/Paths.js";
|
|
76
|
+
import * as Prune from "./internal/Prune.js";
|
|
77
|
+
import * as StdError from "./StdError.js";
|
|
78
|
+
import * as TestRunner from "./TestRunner.js";
|
|
79
|
+
/**
|
|
80
|
+
* The id naming the tree a run opened on.
|
|
81
|
+
*
|
|
82
|
+
* It is not minted: the host either recorded one before the agent started or it
|
|
83
|
+
* did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and
|
|
84
|
+
* then to `HEAD`, which is the same precedence `TestRun` uses for the same
|
|
85
|
+
* question — so a workspace that has one answer for a baseline has one answer
|
|
86
|
+
* for both.
|
|
87
|
+
*
|
|
88
|
+
* @category constants
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
*/
|
|
91
|
+
export const baseId = "base";
|
|
92
|
+
/**
|
|
93
|
+
* The directory checkpoints are materialized into, relative to the repository
|
|
94
|
+
* root and therefore also relative to a container's view of it.
|
|
95
|
+
*
|
|
96
|
+
* @category constants
|
|
97
|
+
* @since 1.0.0
|
|
98
|
+
*/
|
|
99
|
+
export const scratchDirectory = Prune.checkpointScratch;
|
|
100
|
+
/**
|
|
101
|
+
* The git-config section {@link layerGit} records minted checkpoints under.
|
|
102
|
+
*
|
|
103
|
+
* Config and **not a ref**, and that is the whole of the decision. A ref is
|
|
104
|
+
* history: `git log --all` lists it, `git show` prints it, and `git log --all
|
|
105
|
+
* -S` searches it — so a checkpoint named by a ref would hand an agent a commit
|
|
106
|
+
* containing its own edit and let it read that back as if it were upstream
|
|
107
|
+
* work. That exact class cost the measured program real money before the rig
|
|
108
|
+
* moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:
|
|
109
|
+
* django-13346 applied two of its own snapshots as a fake fix), and a ref here
|
|
110
|
+
* would reintroduce it one wave later.
|
|
111
|
+
*
|
|
112
|
+
* The commit object itself is unreferenced. It stays alive for the life of the
|
|
113
|
+
* run — nothing in a run prunes — and a checkout by id works perfectly well,
|
|
114
|
+
* which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable
|
|
115
|
+
* by id and no command that walks refs can reach it:
|
|
116
|
+
* `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer
|
|
117
|
+
* exactly as they did before the capture.
|
|
118
|
+
*
|
|
119
|
+
* One command still sees it, measured rather than argued in
|
|
120
|
+
* `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,
|
|
121
|
+
* because that is what an unreferenced commit is. A checkout is a standalone
|
|
122
|
+
* repository, not a worktree of this one, so `git log --all` does not list it
|
|
123
|
+
* even while a call runs in it. It is not reachable by a name that looks like project history, and the cell
|
|
124
|
+
* contract's environment section says outright that a dangling commit is this
|
|
125
|
+
* harness holding the agent's own tree — which is the half of the django-13346
|
|
126
|
+
* lesson that a store cannot enforce.
|
|
127
|
+
*
|
|
128
|
+
* @category constants
|
|
129
|
+
* @since 1.0.0
|
|
130
|
+
*/
|
|
131
|
+
export const configSection = "flows-checkpoint";
|
|
132
|
+
/**
|
|
133
|
+
* One tree this run has pinned.
|
|
134
|
+
*
|
|
135
|
+
* `ref` is the store's own name for it. Nothing above this module interprets
|
|
136
|
+
* it; it travels so the journal says which tree a checkpointed call read.
|
|
137
|
+
*
|
|
138
|
+
* @category models
|
|
139
|
+
* @since 1.0.0
|
|
140
|
+
*/
|
|
141
|
+
export class Snapshot extends Schema.Class("@smthrs/std/Checkpoints/Snapshot")({
|
|
142
|
+
id: Schema.String,
|
|
143
|
+
ref: Schema.String
|
|
144
|
+
}) {
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The {@link Checkpoints} service tag.
|
|
148
|
+
*
|
|
149
|
+
* @category services
|
|
150
|
+
* @since 1.0.0
|
|
151
|
+
*/
|
|
152
|
+
export const Checkpoints = Context.Service("@smthrs/std/Checkpoints");
|
|
153
|
+
/**
|
|
154
|
+
* Builds a store from its two operations.
|
|
155
|
+
*
|
|
156
|
+
* @category constructors
|
|
157
|
+
* @since 1.0.0
|
|
158
|
+
*/
|
|
159
|
+
export const make = (service) => Checkpoints.of(service);
|
|
160
|
+
/**
|
|
161
|
+
* The refusal a host with nowhere to pin a tree answers with.
|
|
162
|
+
*
|
|
163
|
+
* @category errors
|
|
164
|
+
* @since 1.0.0
|
|
165
|
+
*/
|
|
166
|
+
export const unavailable = (id) => new StdError.StdError({
|
|
167
|
+
code: "provider_unavailable",
|
|
168
|
+
message: `This host pins no trees, so it holds no checkpoint "${id}". Take the reading on the live tree instead.`
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* Builds a store for a host that pins nothing.
|
|
172
|
+
*
|
|
173
|
+
* @category constructors
|
|
174
|
+
* @since 1.0.0
|
|
175
|
+
*/
|
|
176
|
+
export const makeNoop = () => make({
|
|
177
|
+
capture: (id) => Effect.fail(unavailable(id)),
|
|
178
|
+
materialize: (id) => Effect.fail(unavailable(id))
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* Provides {@link makeNoop}.
|
|
182
|
+
*
|
|
183
|
+
* @category layers
|
|
184
|
+
* @since 1.0.0
|
|
185
|
+
*/
|
|
186
|
+
export const layerNoop = Layer.succeed(Checkpoints, makeNoop());
|
|
187
|
+
const failed = (message, code = "command_failed") => new StdError.StdError({ code, message });
|
|
188
|
+
/**
|
|
189
|
+
* A checkpoint id, restricted to what can safely become a git-config key and a
|
|
190
|
+
* directory name. No dots: a dot would split the config key into another
|
|
191
|
+
* subsection.
|
|
192
|
+
*/
|
|
193
|
+
const namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
194
|
+
/**
|
|
195
|
+
* Builds the git-backed store.
|
|
196
|
+
*
|
|
197
|
+
* Every git command that records or checks out a tree runs against a shadow
|
|
198
|
+
* `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent
|
|
199
|
+
* can write; see `internal/GitWorktree.ts`. The capture reads a copy of the
|
|
200
|
+
* workspace index, so the agent's own index is untouched: its `git diff` is the
|
|
201
|
+
* run's evidence and must not move because the harness recorded something.
|
|
202
|
+
*
|
|
203
|
+
* @category constructors
|
|
204
|
+
* @since 1.0.0
|
|
205
|
+
*/
|
|
206
|
+
export const makeGit = (options) => Effect.gen(function* () {
|
|
207
|
+
const spawner = yield* ChildProcessSpawner;
|
|
208
|
+
return gitStore(options, spawner);
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* The store itself, with the spawner it runs git through already resolved.
|
|
212
|
+
*
|
|
213
|
+
* Resolving it here rather than threading it through {@link Checkpoints} keeps
|
|
214
|
+
* the service's own requirement empty, which is what lets a browser host bind
|
|
215
|
+
* {@link layerNoop} against the identical interface — the same shape
|
|
216
|
+
* `TestRunner` and `Container` take.
|
|
217
|
+
*/
|
|
218
|
+
const gitStore = (options, spawner) => {
|
|
219
|
+
const spawn = (effect) => Effect.provideService(effect, ChildProcessSpawner, spawner);
|
|
220
|
+
const root = withoutTrailingSlash(options.root);
|
|
221
|
+
const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd);
|
|
222
|
+
const keyOf = (id) => `${configSection}.${id}`;
|
|
223
|
+
const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, "HEAD"] : [options.baseRef];
|
|
224
|
+
/**
|
|
225
|
+
* The commit one id names.
|
|
226
|
+
*
|
|
227
|
+
* `base` is the one id nobody mints, so it is resolved from refs — the same
|
|
228
|
+
* precedence `TestRun` uses. Every other id was recorded by {@link capture}
|
|
229
|
+
* into this repository's config file, which is where a checkpoint is named
|
|
230
|
+
* *without* becoming history. See {@link configSection}.
|
|
231
|
+
*/
|
|
232
|
+
const commitOf = (id) => Effect.gen(function* () {
|
|
233
|
+
if (id === baseId)
|
|
234
|
+
return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit;
|
|
235
|
+
const repository = yield* GitWorktree.open(root);
|
|
236
|
+
const found = yield* GitWorktree.config(repository, ["--get", keyOf(id)]);
|
|
237
|
+
const commit = found.stdout.trim();
|
|
238
|
+
if (found.exitCode !== 0 || commit === "") {
|
|
239
|
+
return yield* Effect.fail(failed(`No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`, "not_found"));
|
|
240
|
+
}
|
|
241
|
+
return commit;
|
|
242
|
+
});
|
|
243
|
+
const capture = (id) => spawn(Effect.gen(function* () {
|
|
244
|
+
if (!namable.test(id)) {
|
|
245
|
+
return yield* Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"));
|
|
246
|
+
}
|
|
247
|
+
const repository = yield* GitWorktree.open(root);
|
|
248
|
+
const commit = yield* GitWorktree.withShadow(repository, (shadow) => Effect.gen(function* () {
|
|
249
|
+
const head = (yield* GitWorktree.resolveCommit(root, ["HEAD"])).commit;
|
|
250
|
+
yield* shadow.adoptIndex;
|
|
251
|
+
const pinned = yield* shadow.git(["update-ref", "--no-deref", "HEAD", head]);
|
|
252
|
+
if (pinned.exitCode !== 0) {
|
|
253
|
+
return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`));
|
|
254
|
+
}
|
|
255
|
+
const recorded = yield* shadow.git(["stash", "create", `flows checkpoint ${id}`], root);
|
|
256
|
+
if (recorded.exitCode !== 0) {
|
|
257
|
+
return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`));
|
|
258
|
+
}
|
|
259
|
+
// Nothing to record means the working tree IS the commit it is on, so
|
|
260
|
+
// that commit is the checkpoint. `stash create` says so by printing
|
|
261
|
+
// nothing, which is not an error and must not be read as one.
|
|
262
|
+
return recorded.stdout.trim() === "" ? head : recorded.stdout.trim();
|
|
263
|
+
}));
|
|
264
|
+
const named = yield* GitWorktree.config(repository, [keyOf(id), commit]);
|
|
265
|
+
if (named.exitCode !== 0) {
|
|
266
|
+
return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`));
|
|
267
|
+
}
|
|
268
|
+
return new Snapshot({ id, ref: commit });
|
|
269
|
+
}));
|
|
270
|
+
const materialize = (id, use) => Effect.gen(function* () {
|
|
271
|
+
if (!namable.test(id)) {
|
|
272
|
+
return yield* Effect.fail(failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, "invalid_input"));
|
|
273
|
+
}
|
|
274
|
+
const commit = yield* spawn(commitOf(id));
|
|
275
|
+
const context = yield* Effect.context();
|
|
276
|
+
return yield* GitWorktree.withDetachedWorktree(root, `${scratchDirectory}/${id}`, commit, (host) => use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(Effect.provideContext(context))).pipe(Effect.provideService(ChildProcessSpawner, spawner));
|
|
277
|
+
});
|
|
278
|
+
return make({ capture, materialize });
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Provides {@link makeGit}.
|
|
282
|
+
*
|
|
283
|
+
* @category layers
|
|
284
|
+
* @since 1.0.0
|
|
285
|
+
*/
|
|
286
|
+
export const layerGit = (options) => Layer.effect(Checkpoints)(makeGit(options));
|
|
287
|
+
/**
|
|
288
|
+
* Rewrites one call's input so the call runs against a materialized checkpoint.
|
|
289
|
+
*
|
|
290
|
+
* Re-exported from {@link Relocate}, which owns the table of flows and fields
|
|
291
|
+
* this rewrite is driven by. It is exported here because the harness reaches the
|
|
292
|
+
* whole checkpoint feature through this module.
|
|
293
|
+
*
|
|
294
|
+
* @category conversions
|
|
295
|
+
* @since 1.0.0
|
|
296
|
+
*/
|
|
297
|
+
export { relocate } from "./Relocate.js";
|
|
298
|
+
//# sourceMappingURL=Checkpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkpoints.js","sourceRoot":"","sources":["../../src/Checkpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAC5C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;;;;;;;;;G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,CAAC,cAAc,CAAC,OAAO,CAAC,CAC/B,CACJ,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAmB,EAAwD,EAAE,CACpG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAC7C;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAA","sourcesContent":["/**\n * Pinned trees, and the scratch checkouts a call runs against.\n *\n * A checkpoint is a **value**: minting one changes nothing about the workspace,\n * and running a call against one leaves the live tree exactly as it stands.\n * That is the whole of what it buys. Before it existed, the only way a run\n * could answer \"did this command fail before my change\" was to undo the change\n * — and the journals price that exactly. On `sympy__sympy-13878` the r95repl\n * lane applied one byte-identical 4,789-character patch **five times**, four of\n * those applications preceded by `git checkout -- sympy/stats/crv_types.py`,\n * because a clean fails-before proof required reverting the very work it was\n * meant to prove.\n *\n * This module is the host half of `@smthrs/harness`'s `ctx.checkpoint()` and\n * `ctx.call(flow, input, { at })`. The harness owns the surface, the identity,\n * the bound and the refusals; nothing in it knows what a tree is. This owns the\n * two host operations that need one:\n *\n * - {@link Checkpoints.capture} records the working tree under an id, and\n * - {@link Checkpoints.materialize} gives that tree back as a directory for the\n * length of one call.\n *\n * ## The git binding, and the container constraint it is shaped by\n *\n * {@link layerGit} records a checkpoint with `git stash create`, then names the\n * commit it prints in this repository's own git config rather than with a ref —\n * see {@link configSection} for why a ref would hand the agent its own edit back\n * as history. `stash create` is the one git command\n * that records the working tree and changes nothing else: it does not move the\n * worktree and does not touch the stash ref. It runs against a shadow\n * `GIT_DIR` over a copy of the workspace index (see `internal/GitWorktree.ts`),\n * so it never writes the repository's index and never runs a program the\n * workspace's `.git` names. That matters more than it sounds. The agent runs `git` in this same\n * workspace and its own `git diff` is the run's evidence, so a capture that\n * staged into the real index would be the harness editing the evidence while\n * recording it. A tree with nothing to record prints nothing, and the\n * checkpoint is then `HEAD` — which is exactly what the tree is.\n *\n * Untracked files are not in the recorded tree, which matches how the rig\n * captures a patch: `capture-patch.sh` drops paths that did not exist when the\n * agent started, so a checkpoint holds what a patch would hold.\n *\n * The materialization is a detached checkout at `<root>/.flows-checkpoints/<id>-<lease>`\n * — **inside** the workspace, which looks wrong and is the only thing that\n * works. A benchmark check runs through `docker exec` inside `/testbed`, and\n * `/testbed` is a bind mount of the live workspace. A scratch checkout anywhere\n * else on the host is simply not visible to the container, so the call would run\n * against a path that does not exist. Placed under the workspace it is visible\n * at the same subpath under the mount, needs no second mount, and needs no\n * change to how the rig starts its container. `TestRun`'s `against: \"base\"`\n * reached the same conclusion first and this reuses its shape;\n * `evals/swebench/run-instance.sh` excludes the directory from patch capture for\n * the same reason it excludes `.flows-test-base`.\n *\n * The checkout is added and removed around **one call**, which is stricter than\n * the frame lifetime the design asks for and much simpler: there is no cache to\n * invalidate, no id to leak, and a checkpoint used by three calls pays three\n * checkouts rather than risking one stale directory. A run that reuses a\n * checkpoint across frames simply re-materializes it, because the ref is what\n * persists.\n *\n * ## What can be pointed at a checkpoint, and what cannot\n *\n * {@link relocate} is the closed answer, and `Relocate.ts` owns it. That half\n * knows the input shapes of `bash`, `read`, `ls`, `grep` and `glob`; this half\n * knows git. They change for different reasons, so they are different modules,\n * and {@link relocate} is re-exported here because the harness reaches the whole\n * feature through this one.\n *\n * @since 1.0.0\n */\n\nimport { ChildProcessSpawner } from \"@smthrs/kernel/ChildProcessSpawner\"\nimport { Context, Effect, Layer, Schema } from \"effect\"\nimport { GitWorktree } from \"./internal/GitWorktree.ts\"\nimport { withoutTrailingSlash } from \"./internal/Paths.ts\"\nimport * as Prune from \"./internal/Prune.ts\"\nimport * as StdError from \"./StdError.ts\"\nimport * as TestRunner from \"./TestRunner.ts\"\n\n/**\n * The id naming the tree a run opened on.\n *\n * It is not minted: the host either recorded one before the agent started or it\n * did not. {@link layerGit} resolves it to {@link TestRunner.captureBase} and\n * then to `HEAD`, which is the same precedence `TestRun` uses for the same\n * question — so a workspace that has one answer for a baseline has one answer\n * for both.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const baseId = \"base\"\n\n/**\n * The directory checkpoints are materialized into, relative to the repository\n * root and therefore also relative to a container's view of it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const scratchDirectory = Prune.checkpointScratch\n\n/**\n * The git-config section {@link layerGit} records minted checkpoints under.\n *\n * Config and **not a ref**, and that is the whole of the decision. A ref is\n * history: `git log --all` lists it, `git show` prints it, and `git log --all\n * -S` searches it — so a checkpoint named by a ref would hand an agent a commit\n * containing its own edit and let it read that back as if it were upstream\n * work. That exact class cost the measured program real money before the rig\n * moved jj's store out of the workspace (`evals/swebench/run-instance.sh`:\n * django-13346 applied two of its own snapshots as a fake fix), and a ref here\n * would reintroduce it one wave later.\n *\n * The commit object itself is unreferenced. It stays alive for the life of the\n * run — nothing in a run prunes — and a checkout by id works perfectly well,\n * which is measured in `CheckpointsFixture.test.ts`. So the tree is reachable\n * by id and no command that walks refs can reach it:\n * `git log`, `git log --all`, `git log -S` and `git show <ref>` all answer\n * exactly as they did before the capture.\n *\n * One command still sees it, measured rather than argued in\n * `CheckpointsFixture.test.ts`: `git fsck` reports it as a dangling commit,\n * because that is what an unreferenced commit is. A checkout is a standalone\n * repository, not a worktree of this one, so `git log --all` does not list it\n * even while a call runs in it. It is not reachable by a name that looks like project history, and the cell\n * contract's environment section says outright that a dangling commit is this\n * harness holding the agent's own tree — which is the half of the django-13346\n * lesson that a store cannot enforce.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const configSection = \"flows-checkpoint\"\n\n/**\n * One tree this run has pinned.\n *\n * `ref` is the store's own name for it. Nothing above this module interprets\n * it; it travels so the journal says which tree a checkpointed call read.\n *\n * @category models\n * @since 1.0.0\n */\nexport class Snapshot extends Schema.Class<Snapshot>(\"@smthrs/std/Checkpoints/Snapshot\")({\n id: Schema.String,\n ref: Schema.String\n}) {}\n\n/**\n * A tree handed back as a directory, for the length of one call.\n *\n * `host` is where the process running on this machine finds it. `guest` is\n * where a container finds the same directory, which is the same path when no\n * container is in play. They differ exactly as `TestRunner.Runner`'s `cwd` and\n * `root` differ, and for the same reason: one directory, two names.\n *\n * `root` and `guestRoot` are the workspace itself under those same two names.\n * They travel because a call that named a directory *inside* the workspace has\n * to keep it: a check that runs in `tests/` and is pointed at a checkpoint must\n * run in the checkpoint's `tests/`, not at its top. Silently dropping that\n * subpath is how a baseline comes back failing for a reason nobody chose, which\n * is the one failure a checkpoint exists to make impossible.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Materialized {\n readonly id: string\n readonly host: string\n readonly guest: string\n /** The workspace this checkpoint is a tree of, as this machine names it. */\n readonly root: string\n /** The workspace as a container names it; the same as {@link Materialized.root} when none does. */\n readonly guestRoot: string\n}\n\n/**\n * The two host operations a checkpoint needs.\n *\n * @category services\n * @since 1.0.0\n */\nexport interface Checkpoints {\n /** Records the working tree as it stands, under `id`. */\n readonly capture: (id: string) => Effect.Effect<Snapshot, StdError.StdError>\n /**\n * Hands `id` back as a directory for the length of the effect it wraps.\n *\n * Scoped rather than returned, because the directory has to be removed\n * however the call ends — a benchmark run killed at its wall-clock budget\n * would otherwise leave a second checkout of the whole repository in a tree\n * whose diff is the run's answer.\n */\n readonly materialize: <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | StdError.StdError, R>\n}\n\n/**\n * The {@link Checkpoints} service tag.\n *\n * @category services\n * @since 1.0.0\n */\nexport const Checkpoints: Context.Service<Checkpoints, Checkpoints> = Context.Service(\"@smthrs/std/Checkpoints\")\n\n/**\n * Builds a store from its two operations.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = (service: Checkpoints): Checkpoints => Checkpoints.of(service)\n\n/**\n * The refusal a host with nowhere to pin a tree answers with.\n *\n * @category errors\n * @since 1.0.0\n */\nexport const unavailable = (id: string): StdError.StdError =>\n new StdError.StdError({\n code: \"provider_unavailable\",\n message: `This host pins no trees, so it holds no checkpoint \"${id}\". Take the reading on the live tree instead.`\n })\n\n/**\n * Builds a store for a host that pins nothing.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeNoop = (): Checkpoints =>\n make({\n capture: (id) => Effect.fail(unavailable(id)),\n materialize: (id) => Effect.fail(unavailable(id))\n })\n\n/**\n * Provides {@link makeNoop}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerNoop: Layer.Layer<Checkpoints> = Layer.succeed(Checkpoints, makeNoop())\n\n/**\n * What {@link layerGit} needs to know about the repository it pins.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface GitOptions {\n /** The host path of the git repository whose trees are pinned. */\n readonly root: string\n /**\n * Where a container sees {@link GitOptions.root}, when one does.\n *\n * Absent means there is no container, and the guest path of a materialized\n * checkpoint is then its host path.\n */\n readonly cwd?: string | undefined\n /**\n * The ref naming the tree the run opened on, for {@link baseId}.\n *\n * Absent takes `TestRunner.captureBase` and then `HEAD`, which is the\n * precedence `TestRun` already uses.\n */\n readonly baseRef?: string | undefined\n}\n\nconst failed = (message: string, code: StdError.Code = \"command_failed\"): StdError.StdError =>\n new StdError.StdError({ code, message })\n\n/**\n * A checkpoint id, restricted to what can safely become a git-config key and a\n * directory name. No dots: a dot would split the config key into another\n * subsection.\n */\nconst namable = /^[A-Za-z0-9][A-Za-z0-9-]*$/\n\n/**\n * Builds the git-backed store.\n *\n * Every git command that records or checks out a tree runs against a shadow\n * `GIT_DIR` the harness owns, never the workspace's `.git`, which the agent\n * can write; see `internal/GitWorktree.ts`. The capture reads a copy of the\n * workspace index, so the agent's own index is untouched: its `git diff` is the\n * run's evidence and must not move because the harness recorded something.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeGit = (\n options: GitOptions\n): Effect.Effect<Checkpoints, never, ChildProcessSpawner> =>\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n return gitStore(options, spawner)\n })\n\n/**\n * The store itself, with the spawner it runs git through already resolved.\n *\n * Resolving it here rather than threading it through {@link Checkpoints} keeps\n * the service's own requirement empty, which is what lets a browser host bind\n * {@link layerNoop} against the identical interface — the same shape\n * `TestRunner` and `Container` take.\n */\nconst gitStore = (options: GitOptions, spawner: ChildProcessSpawner[\"Service\"]): Checkpoints => {\n const spawn = <A, E>(effect: Effect.Effect<A, E, ChildProcessSpawner>): Effect.Effect<A, E> =>\n Effect.provideService(effect, ChildProcessSpawner, spawner)\n const root = withoutTrailingSlash(options.root)\n const guestRoot = options.cwd === undefined ? root : withoutTrailingSlash(options.cwd)\n const keyOf = (id: string) => `${configSection}.${id}`\n const baseRefs = options.baseRef === undefined ? [TestRunner.captureBase, \"HEAD\"] : [options.baseRef]\n\n /**\n * The commit one id names.\n *\n * `base` is the one id nobody mints, so it is resolved from refs — the same\n * precedence `TestRun` uses. Every other id was recorded by {@link capture}\n * into this repository's config file, which is where a checkpoint is named\n * *without* becoming history. See {@link configSection}.\n */\n const commitOf = (id: string) =>\n Effect.gen(function*() {\n if (id === baseId) return (yield* GitWorktree.resolveCommit(root, baseRefs)).commit\n const repository = yield* GitWorktree.open(root)\n const found = yield* GitWorktree.config(repository, [\"--get\", keyOf(id)])\n const commit = found.stdout.trim()\n if (found.exitCode !== 0 || commit === \"\") {\n return yield* Effect.fail(\n failed(\n `No checkpoint is stored under ${id} in ${root}. Take the reading on the live tree instead.`,\n \"not_found\"\n )\n )\n }\n return commit\n })\n\n const capture = (id: string) =>\n spawn(Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const repository = yield* GitWorktree.open(root)\n const commit = yield* GitWorktree.withShadow(repository, (shadow) =>\n Effect.gen(function*() {\n const head = (yield* GitWorktree.resolveCommit(root, [\"HEAD\"])).commit\n yield* shadow.adoptIndex\n const pinned = yield* shadow.git([\"update-ref\", \"--no-deref\", \"HEAD\", head])\n if (pinned.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${pinned.stderr.trim()}`))\n }\n const recorded = yield* shadow.git([\"stash\", \"create\", `flows checkpoint ${id}`], root)\n if (recorded.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not record the working tree: ${recorded.stderr.trim()}`))\n }\n // Nothing to record means the working tree IS the commit it is on, so\n // that commit is the checkpoint. `stash create` says so by printing\n // nothing, which is not an error and must not be read as one.\n return recorded.stdout.trim() === \"\" ? head : recorded.stdout.trim()\n }))\n const named = yield* GitWorktree.config(repository, [keyOf(id), commit])\n if (named.exitCode !== 0) {\n return yield* Effect.fail(failed(`Could not name the checkpoint: ${named.stderr.trim()}`))\n }\n return new Snapshot({ id, ref: commit })\n }))\n\n const materialize = <A, E, R>(\n id: string,\n use: (materialized: Materialized) => Effect.Effect<A, E, R>\n ): Effect.Effect<A, E | StdError.StdError, R> =>\n Effect.gen(function*() {\n if (!namable.test(id)) {\n return yield* Effect.fail(\n failed(`A checkpoint id must match ${namable.source}; ${id} does not.`, \"invalid_input\")\n )\n }\n const commit = yield* spawn(commitOf(id))\n const context = yield* Effect.context<R>()\n return yield* GitWorktree.withDetachedWorktree(\n root,\n `${scratchDirectory}/${id}`,\n commit,\n (host) =>\n use({ id, host, guest: `${guestRoot}${host.slice(root.length)}`, root, guestRoot }).pipe(\n Effect.provideContext(context)\n )\n ).pipe(Effect.provideService(ChildProcessSpawner, spawner))\n })\n\n return make({ capture, materialize })\n}\n\n/**\n * Provides {@link makeGit}.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerGit = (options: GitOptions): Layer.Layer<Checkpoints, never, ChildProcessSpawner> =>\n Layer.effect(Checkpoints)(makeGit(options))\n/**\n * Rewrites one call's input so the call runs against a materialized checkpoint.\n *\n * Re-exported from {@link Relocate}, which owns the table of flows and fields\n * this rewrite is driven by. It is exported here because the harness reaches the\n * whole checkpoint feature through this module.\n *\n * @category conversions\n * @since 1.0.0\n */\nexport { relocate, type Relocation } from \"./Relocate.ts\"\n"]}
|