homegraph 1.2.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -11
- package/dist/bin/homegraph.js +298 -72
- package/dist/bin/homegraph.js.map +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +117 -11
- package/dist/context/index.js.map +1 -1
- package/dist/db/index.d.ts +207 -6
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +461 -20
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +19 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +157 -3
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +426 -9
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +32 -1
- package/dist/db/sqlite-adapter.d.ts +24 -17
- package/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/dist/db/sqlite-adapter.js +292 -36
- package/dist/db/sqlite-adapter.js.map +1 -1
- package/dist/db/wal-valve.d.ts +119 -0
- package/dist/db/wal-valve.d.ts.map +1 -0
- package/dist/db/wal-valve.js +290 -0
- package/dist/db/wal-valve.js.map +1 -0
- package/dist/directory.d.ts +9 -5
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +210 -19
- package/dist/directory.js.map +1 -1
- package/dist/extraction/arkts-batch-worker.js +3 -2
- package/dist/extraction/arkts-batch-worker.js.map +1 -1
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/dist/extraction/cfml-extractor.js +494 -0
- package/dist/extraction/cfml-extractor.js.map +1 -0
- package/dist/extraction/default-ignore.d.ts +39 -0
- package/dist/extraction/default-ignore.d.ts.map +1 -0
- package/dist/extraction/default-ignore.js +221 -0
- package/dist/extraction/default-ignore.js.map +1 -0
- package/dist/extraction/grammars.d.ts +25 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +177 -24
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +52 -14
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +521 -314
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +90 -6
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +1579 -128
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +42 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +369 -4
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/dist/extraction/languages/cfquery.js +28 -0
- package/dist/extraction/languages/cfquery.js.map +1 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/dist/extraction/languages/cfscript.js +73 -0
- package/dist/extraction/languages/cfscript.js.map +1 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/dist/extraction/languages/cobol.js +499 -0
- package/dist/extraction/languages/cobol.js.map +1 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/dist/extraction/languages/erlang.js +350 -0
- package/dist/extraction/languages/erlang.js.map +1 -0
- package/dist/extraction/languages/index.d.ts.map +1 -1
- package/dist/extraction/languages/index.js +16 -0
- package/dist/extraction/languages/index.js.map +1 -1
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts.map +1 -0
- package/dist/extraction/languages/nix.js +294 -0
- package/dist/extraction/languages/nix.js.map +1 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/dist/extraction/languages/solidity.js +293 -0
- package/dist/extraction/languages/solidity.js.map +1 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/dist/extraction/languages/terraform.js +641 -0
- package/dist/extraction/languages/terraform.js.map +1 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/dist/extraction/languages/vbnet.js +141 -0
- package/dist/extraction/languages/vbnet.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +30 -10
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -1
- package/dist/extraction/mybatis-extractor.js +140 -38
- package/dist/extraction/mybatis-extractor.js.map +1 -1
- package/dist/extraction/parse-pool.d.ts +27 -1
- package/dist/extraction/parse-pool.d.ts.map +1 -1
- package/dist/extraction/parse-pool.js +75 -7
- package/dist/extraction/parse-pool.js.map +1 -1
- package/dist/extraction/parse-worker.js +9 -2
- package/dist/extraction/parse-worker.js.map +1 -1
- package/dist/extraction/store-worker.d.ts +20 -0
- package/dist/extraction/store-worker.d.ts.map +1 -0
- package/dist/extraction/store-worker.js +102 -0
- package/dist/extraction/store-worker.js.map +1 -0
- package/dist/extraction/store-writer.d.ts +48 -0
- package/dist/extraction/store-writer.d.ts.map +1 -0
- package/dist/extraction/store-writer.js +167 -0
- package/dist/extraction/store-writer.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/dist/extraction/tree-sitter-helpers.js +1 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/dist/extraction/tree-sitter-types.d.ts +3 -1
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +38 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +801 -10
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +14 -4
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/dist/extraction/wasm-runtime-flags.js +55 -7
- package/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +1 -1
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +74 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +436 -55
- package/dist/index.js.map +1 -1
- package/dist/installer/index.d.ts +42 -0
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +97 -2
- package/dist/installer/index.js.map +1 -1
- package/dist/mcp/daemon.d.ts +25 -3
- package/dist/mcp/daemon.d.ts.map +1 -1
- package/dist/mcp/daemon.js +62 -8
- package/dist/mcp/daemon.js.map +1 -1
- package/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
- package/dist/mcp/dynamic-boundaries.js +2 -1
- package/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/early-ppid.d.ts.map +1 -0
- package/dist/mcp/early-ppid.js +29 -0
- package/dist/mcp/early-ppid.js.map +1 -0
- package/dist/mcp/engine.d.ts +4 -5
- package/dist/mcp/engine.d.ts.map +1 -1
- package/dist/mcp/engine.js +27 -1
- package/dist/mcp/engine.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +41 -6
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/liveness-watchdog.d.ts +18 -1
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/dist/mcp/liveness-watchdog.js +73 -13
- package/dist/mcp/liveness-watchdog.js.map +1 -1
- package/dist/mcp/memory-budget.d.ts +30 -0
- package/dist/mcp/memory-budget.d.ts.map +1 -0
- package/dist/mcp/memory-budget.js +123 -0
- package/dist/mcp/memory-budget.js.map +1 -0
- package/dist/mcp/proxy.d.ts.map +1 -1
- package/dist/mcp/proxy.js +88 -4
- package/dist/mcp/proxy.js.map +1 -1
- package/dist/mcp/query-cache.d.ts +35 -4
- package/dist/mcp/query-cache.d.ts.map +1 -1
- package/dist/mcp/query-cache.js +89 -19
- package/dist/mcp/query-cache.js.map +1 -1
- package/dist/mcp/query-pool.d.ts +46 -12
- package/dist/mcp/query-pool.d.ts.map +1 -1
- package/dist/mcp/query-pool.js +100 -23
- package/dist/mcp/query-pool.js.map +1 -1
- package/dist/mcp/query-worker.d.ts +2 -2
- package/dist/mcp/query-worker.js +2 -2
- package/dist/mcp/server-instructions.d.ts +4 -27
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +39 -84
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/session.d.ts +14 -0
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +28 -1
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/dist/mcp/startup-handshake.js +73 -0
- package/dist/mcp/startup-handshake.js.map +1 -0
- package/dist/mcp/tools.d.ts +104 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +2432 -217
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +18 -0
- package/dist/mcp/transport.js.map +1 -1
- package/dist/project-config.d.ts +38 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +101 -2
- package/dist/project-config.js.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.d.ts +2 -1
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.js +178 -146
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +54 -10
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +1299 -257
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/cooperative-yield.d.ts +10 -2
- package/dist/resolution/cooperative-yield.d.ts.map +1 -1
- package/dist/resolution/cooperative-yield.js +6 -4
- package/dist/resolution/cooperative-yield.js.map +1 -1
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/dist/resolution/frameworks/cics.js +90 -0
- package/dist/resolution/frameworks/cics.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/dist/resolution/frameworks/go.js +29 -6
- package/dist/resolution/frameworks/go.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +3 -0
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/dist/resolution/frameworks/java.js +14 -6
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/dist/resolution/frameworks/terraform.js +277 -0
- package/dist/resolution/frameworks/terraform.js.map +1 -0
- package/dist/resolution/goframe-synthesizer.d.ts +2 -1
- package/dist/resolution/goframe-synthesizer.d.ts.map +1 -1
- package/dist/resolution/goframe-synthesizer.js +8 -3
- package/dist/resolution/goframe-synthesizer.js.map +1 -1
- package/dist/resolution/import-resolver.d.ts +9 -3
- package/dist/resolution/import-resolver.d.ts.map +1 -1
- package/dist/resolution/import-resolver.js +295 -11
- package/dist/resolution/import-resolver.js.map +1 -1
- package/dist/resolution/index.d.ts +146 -8
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +1089 -131
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/memory-budget.d.ts +48 -0
- package/dist/resolution/memory-budget.d.ts.map +1 -0
- package/dist/resolution/memory-budget.js +162 -0
- package/dist/resolution/memory-budget.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +12 -4
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +793 -130
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/resolver-pool.d.ts +106 -0
- package/dist/resolution/resolver-pool.d.ts.map +1 -0
- package/dist/resolution/resolver-pool.js +344 -0
- package/dist/resolution/resolver-pool.js.map +1 -0
- package/dist/resolution/resolver-worker.d.ts +17 -0
- package/dist/resolution/resolver-worker.d.ts.map +1 -0
- package/dist/resolution/resolver-worker.js +141 -0
- package/dist/resolution/resolver-worker.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +1 -1
- package/dist/resolution/strip-comments.d.ts.map +1 -1
- package/dist/resolution/strip-comments.js +49 -0
- package/dist/resolution/strip-comments.js.map +1 -1
- package/dist/resolution/types.d.ts +32 -0
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.d.ts +10 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.js +142 -4
- package/dist/resolution/workspace-packages.js.map +1 -1
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/search/identifier-segments.d.ts.map +1 -0
- package/dist/search/identifier-segments.js +176 -0
- package/dist/search/identifier-segments.js.map +1 -0
- package/dist/search/query-utils.d.ts +201 -0
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +919 -2
- package/dist/search/query-utils.js.map +1 -1
- package/dist/spec/build/diff-parser.d.ts +55 -0
- package/dist/spec/build/diff-parser.d.ts.map +1 -0
- package/dist/spec/build/diff-parser.js +205 -0
- package/dist/spec/build/diff-parser.js.map +1 -0
- package/dist/spec/build/git-scanner.d.ts +93 -0
- package/dist/spec/build/git-scanner.d.ts.map +1 -0
- package/dist/spec/build/git-scanner.js +254 -0
- package/dist/spec/build/git-scanner.js.map +1 -0
- package/dist/spec/build/pipeline.d.ts +54 -0
- package/dist/spec/build/pipeline.d.ts.map +1 -0
- package/dist/spec/build/pipeline.js +170 -0
- package/dist/spec/build/pipeline.js.map +1 -0
- package/dist/spec/build/scan.d.ts +48 -0
- package/dist/spec/build/scan.d.ts.map +1 -0
- package/dist/spec/build/scan.js +89 -0
- package/dist/spec/build/scan.js.map +1 -0
- package/dist/spec/build/scope-resolver.d.ts +50 -0
- package/dist/spec/build/scope-resolver.d.ts.map +1 -0
- package/dist/spec/build/scope-resolver.js +105 -0
- package/dist/spec/build/scope-resolver.js.map +1 -0
- package/dist/spec/build/spec-extractor.d.ts +74 -0
- package/dist/spec/build/spec-extractor.d.ts.map +1 -0
- package/dist/spec/build/spec-extractor.js +344 -0
- package/dist/spec/build/spec-extractor.js.map +1 -0
- package/dist/spec/config.d.ts +35 -1
- package/dist/spec/config.d.ts.map +1 -1
- package/dist/spec/config.js +30 -5
- package/dist/spec/config.js.map +1 -1
- package/dist/spec/db/fts.d.ts.map +1 -1
- package/dist/spec/db/fts.js +19 -50
- package/dist/spec/db/fts.js.map +1 -1
- package/dist/spec/db/index.d.ts +5 -3
- package/dist/spec/db/index.d.ts.map +1 -1
- package/dist/spec/db/index.js +16 -1
- package/dist/spec/db/index.js.map +1 -1
- package/dist/spec/db/persist.d.ts +45 -0
- package/dist/spec/db/persist.d.ts.map +1 -0
- package/dist/spec/db/persist.js +66 -0
- package/dist/spec/db/persist.js.map +1 -0
- package/dist/spec/db/relations.d.ts +80 -1
- package/dist/spec/db/relations.d.ts.map +1 -1
- package/dist/spec/db/relations.js +175 -4
- package/dist/spec/db/relations.js.map +1 -1
- package/dist/spec/db/schema.d.ts +4 -0
- package/dist/spec/db/schema.d.ts.map +1 -1
- package/dist/spec/db/schema.js +4 -0
- package/dist/spec/db/schema.js.map +1 -1
- package/dist/spec/db/schema.sql +5 -1
- package/dist/spec/db/spec-node.d.ts +5 -0
- package/dist/spec/db/spec-node.d.ts.map +1 -1
- package/dist/spec/db/spec-node.js +11 -5
- package/dist/spec/db/spec-node.js.map +1 -1
- package/dist/spec/db/sql-utils.d.ts +11 -0
- package/dist/spec/db/sql-utils.d.ts.map +1 -0
- package/dist/spec/db/sql-utils.js +19 -0
- package/dist/spec/db/sql-utils.js.map +1 -0
- package/dist/spec/evolve/cluster-context.d.ts +30 -0
- package/dist/spec/evolve/cluster-context.d.ts.map +1 -0
- package/dist/spec/evolve/cluster-context.js +78 -0
- package/dist/spec/evolve/cluster-context.js.map +1 -0
- package/dist/spec/evolve/commit-spec-analyzer.d.ts +51 -0
- package/dist/spec/evolve/commit-spec-analyzer.d.ts.map +1 -0
- package/dist/spec/evolve/commit-spec-analyzer.js +88 -0
- package/dist/spec/evolve/commit-spec-analyzer.js.map +1 -0
- package/dist/spec/evolve/commit-spec-persister.d.ts +53 -0
- package/dist/spec/evolve/commit-spec-persister.d.ts.map +1 -0
- package/dist/spec/evolve/commit-spec-persister.js +93 -0
- package/dist/spec/evolve/commit-spec-persister.js.map +1 -0
- package/dist/spec/evolve/impact-locator.d.ts +23 -7
- package/dist/spec/evolve/impact-locator.d.ts.map +1 -1
- package/dist/spec/evolve/impact-locator.js +58 -14
- package/dist/spec/evolve/impact-locator.js.map +1 -1
- package/dist/spec/evolve/pipeline.d.ts +62 -25
- package/dist/spec/evolve/pipeline.d.ts.map +1 -1
- package/dist/spec/evolve/pipeline.js +436 -457
- package/dist/spec/evolve/pipeline.js.map +1 -1
- package/dist/spec/evolve/spec-rewriter.d.ts +13 -13
- package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -1
- package/dist/spec/evolve/spec-rewriter.js +45 -45
- package/dist/spec/evolve/spec-rewriter.js.map +1 -1
- package/dist/spec/git/commits.d.ts +85 -0
- package/dist/spec/git/commits.d.ts.map +1 -0
- package/dist/spec/git/commits.js +218 -0
- package/dist/spec/git/commits.js.map +1 -0
- package/dist/spec/git/exec.d.ts +13 -0
- package/dist/spec/git/exec.d.ts.map +1 -0
- package/dist/spec/git/exec.js +19 -0
- package/dist/spec/git/exec.js.map +1 -0
- package/dist/spec/git/index.d.ts +9 -0
- package/dist/spec/git/index.d.ts.map +1 -0
- package/dist/spec/git/index.js +22 -0
- package/dist/spec/git/index.js.map +1 -0
- package/dist/spec/git-utils.d.ts +8 -0
- package/dist/spec/git-utils.d.ts.map +1 -0
- package/dist/spec/git-utils.js +14 -0
- package/dist/spec/git-utils.js.map +1 -0
- package/dist/spec/graph/index.d.ts +8 -0
- package/dist/spec/graph/index.d.ts.map +1 -0
- package/dist/spec/graph/index.js +17 -0
- package/dist/spec/graph/index.js.map +1 -0
- package/dist/spec/graph/queries.d.ts +6 -35
- package/dist/spec/graph/queries.d.ts.map +1 -1
- package/dist/spec/graph/queries.js +71 -248
- package/dist/spec/graph/queries.js.map +1 -1
- package/dist/spec/llm/agent-client.d.ts +59 -0
- package/dist/spec/llm/agent-client.d.ts.map +1 -0
- package/dist/spec/llm/agent-client.js +213 -0
- package/dist/spec/llm/agent-client.js.map +1 -0
- package/dist/spec/llm/agents/claude-code.d.ts +32 -0
- package/dist/spec/llm/agents/claude-code.d.ts.map +1 -0
- package/dist/spec/llm/agents/claude-code.js +125 -0
- package/dist/spec/llm/agents/claude-code.js.map +1 -0
- package/dist/spec/llm/agents/codex.d.ts +32 -0
- package/dist/spec/llm/agents/codex.d.ts.map +1 -0
- package/dist/spec/llm/agents/codex.js +145 -0
- package/dist/spec/llm/agents/codex.js.map +1 -0
- package/dist/spec/llm/agents/detect-utils.d.ts +28 -0
- package/dist/spec/llm/agents/detect-utils.d.ts.map +1 -0
- package/dist/spec/llm/agents/detect-utils.js +91 -0
- package/dist/spec/llm/agents/detect-utils.js.map +1 -0
- package/dist/spec/llm/agents/deveco-code.d.ts +33 -0
- package/dist/spec/llm/agents/deveco-code.d.ts.map +1 -0
- package/dist/spec/llm/agents/deveco-code.js +165 -0
- package/dist/spec/llm/agents/deveco-code.js.map +1 -0
- package/dist/spec/llm/agents/index.d.ts +31 -0
- package/dist/spec/llm/agents/index.d.ts.map +1 -0
- package/dist/spec/llm/agents/index.js +65 -0
- package/dist/spec/llm/agents/index.js.map +1 -0
- package/dist/spec/llm/agents/types.d.ts +76 -0
- package/dist/spec/llm/agents/types.d.ts.map +1 -0
- package/dist/spec/llm/agents/types.js +15 -0
- package/dist/spec/llm/agents/types.js.map +1 -0
- package/dist/spec/llm/client.d.ts +31 -11
- package/dist/spec/llm/client.d.ts.map +1 -1
- package/dist/spec/llm/client.js +143 -81
- package/dist/spec/llm/client.js.map +1 -1
- package/dist/spec/llm/factory.d.ts +41 -0
- package/dist/spec/llm/factory.d.ts.map +1 -0
- package/dist/spec/llm/factory.js +80 -0
- package/dist/spec/llm/factory.js.map +1 -0
- package/dist/spec/llm/prompts.d.ts +24 -8
- package/dist/spec/llm/prompts.d.ts.map +1 -1
- package/dist/spec/llm/prompts.js +100 -50
- package/dist/spec/llm/prompts.js.map +1 -1
- package/dist/spec/llm/retry.d.ts +53 -0
- package/dist/spec/llm/retry.d.ts.map +1 -0
- package/dist/spec/llm/retry.js +153 -0
- package/dist/spec/llm/retry.js.map +1 -0
- package/dist/spec/mine/clusterer.d.ts +63 -0
- package/dist/spec/mine/clusterer.d.ts.map +1 -0
- package/dist/spec/mine/clusterer.js +904 -0
- package/dist/spec/mine/clusterer.js.map +1 -0
- package/dist/spec/mine/clustering/features.d.ts +38 -0
- package/dist/spec/mine/clustering/features.d.ts.map +1 -0
- package/dist/spec/mine/clustering/features.js +108 -0
- package/dist/spec/mine/clustering/features.js.map +1 -0
- package/dist/spec/mine/clustering/index.d.ts +62 -0
- package/dist/spec/mine/clustering/index.d.ts.map +1 -0
- package/dist/spec/mine/clustering/index.js +259 -0
- package/dist/spec/mine/clustering/index.js.map +1 -0
- package/dist/spec/mine/clustering/leiden.d.ts +61 -0
- package/dist/spec/mine/clustering/leiden.d.ts.map +1 -0
- package/dist/spec/mine/clustering/leiden.js +489 -0
- package/dist/spec/mine/clustering/leiden.js.map +1 -0
- package/dist/spec/mine/clustering/text-similarity.d.ts +22 -0
- package/dist/spec/mine/clustering/text-similarity.d.ts.map +1 -0
- package/dist/spec/mine/clustering/text-similarity.js +98 -0
- package/dist/spec/mine/clustering/text-similarity.js.map +1 -0
- package/dist/spec/mine/generator.d.ts +54 -0
- package/dist/spec/mine/generator.d.ts.map +1 -0
- package/dist/spec/mine/generator.js +267 -0
- package/dist/spec/mine/generator.js.map +1 -0
- package/dist/spec/mine/persist.d.ts +37 -0
- package/dist/spec/mine/persist.d.ts.map +1 -0
- package/dist/spec/mine/persist.js +170 -0
- package/dist/spec/mine/persist.js.map +1 -0
- package/dist/spec/mine/pipeline.d.ts +41 -0
- package/dist/spec/mine/pipeline.d.ts.map +1 -0
- package/dist/spec/mine/pipeline.js +236 -0
- package/dist/spec/mine/pipeline.js.map +1 -0
- package/dist/spec/mine/progress-handler.d.ts +22 -0
- package/dist/spec/mine/progress-handler.d.ts.map +1 -0
- package/dist/spec/mine/progress-handler.js +108 -0
- package/dist/spec/mine/progress-handler.js.map +1 -0
- package/dist/spec/mine/progress.d.ts +23 -0
- package/dist/spec/mine/progress.d.ts.map +1 -0
- package/dist/spec/mine/progress.js +12 -0
- package/dist/spec/mine/progress.js.map +1 -0
- package/dist/spec/mine/scanner.d.ts +59 -0
- package/dist/spec/mine/scanner.d.ts.map +1 -0
- package/dist/spec/mine/scanner.js +383 -0
- package/dist/spec/mine/scanner.js.map +1 -0
- package/dist/spec/types.d.ts +32 -0
- package/dist/spec/types.d.ts.map +1 -1
- package/dist/spec/ui/index.d.ts +9 -0
- package/dist/spec/ui/index.d.ts.map +1 -0
- package/dist/spec/ui/index.js +16 -0
- package/dist/spec/ui/index.js.map +1 -0
- package/dist/spec/ui/progress-handler.d.ts +33 -0
- package/dist/spec/ui/progress-handler.d.ts.map +1 -0
- package/dist/spec/ui/progress-handler.js +132 -0
- package/dist/spec/ui/progress-handler.js.map +1 -0
- package/dist/spec/ui/progress.d.ts +24 -0
- package/dist/spec/ui/progress.d.ts.map +1 -0
- package/dist/spec/ui/progress.js +13 -0
- package/dist/spec/ui/progress.js.map +1 -0
- package/dist/spec/utils/fs.d.ts +45 -0
- package/dist/spec/utils/fs.d.ts.map +1 -0
- package/dist/spec/utils/fs.js +163 -0
- package/dist/spec/utils/fs.js.map +1 -0
- package/dist/spec/utils/index.d.ts +12 -0
- package/dist/spec/utils/index.d.ts.map +1 -0
- package/dist/spec/utils/index.js +26 -0
- package/dist/spec/utils/index.js.map +1 -0
- package/dist/spec/utils/meta.d.ts +32 -0
- package/dist/spec/utils/meta.d.ts.map +1 -0
- package/dist/spec/utils/meta.js +122 -0
- package/dist/spec/utils/meta.js.map +1 -0
- package/dist/spec/utils/truncate.d.ts +86 -0
- package/dist/spec/utils/truncate.d.ts.map +1 -0
- package/dist/spec/utils/truncate.js +172 -0
- package/dist/spec/utils/truncate.js.map +1 -0
- package/dist/spec/utils.d.ts +4 -16
- package/dist/spec/utils.d.ts.map +1 -1
- package/dist/spec/utils.js +6 -58
- package/dist/spec/utils.js.map +1 -1
- package/dist/sync/git-hooks.d.ts.map +1 -1
- package/dist/sync/git-hooks.js +2 -0
- package/dist/sync/git-hooks.js.map +1 -1
- package/dist/sync/watcher.d.ts +35 -6
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +127 -17
- package/dist/sync/watcher.js.map +1 -1
- package/dist/sync/worktree.d.ts.map +1 -1
- package/dist/sync/worktree.js +5 -0
- package/dist/sync/worktree.js.map +1 -1
- package/dist/telemetry/index.js +3 -3
- package/dist/telemetry/index.js.map +1 -1
- package/dist/types.d.ts +22 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/dist/upgrade/index.d.ts +32 -0
- package/dist/upgrade/index.d.ts.map +1 -1
- package/dist/upgrade/index.js +162 -14
- package/dist/upgrade/index.js.map +1 -1
- package/dist/upgrade/remove-binary.d.ts +87 -0
- package/dist/upgrade/remove-binary.d.ts.map +1 -0
- package/dist/upgrade/remove-binary.js +289 -0
- package/dist/upgrade/remove-binary.js.map +1 -0
- package/dist/upgrade/update-check.d.ts +92 -0
- package/dist/upgrade/update-check.d.ts.map +1 -0
- package/dist/upgrade/update-check.js +258 -0
- package/dist/upgrade/update-check.js.map +1 -0
- package/package.json +6 -2
- package/scripts/agent-eval/run-all.sh +6 -0
- package/scripts/build-bundle.sh +5 -0
- package/scripts/npm-shim.js +8 -1
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/data/agents.json +0 -109
- package/scripts/exp_boundary_eval/data/experiments.json +0 -140
- package/scripts/qa_eval/README.md +0 -407
- package/scripts/qa_eval/_test_deveco_probe.py +0 -41
- package/scripts/qa_eval/agent_runner.py +0 -526
- package/scripts/qa_eval/data/.gitignore +0 -4
- package/scripts/qa_eval/data/test-set.jsonl +0 -2
- package/scripts/qa_eval/eval_metrics.py +0 -274
- package/scripts/qa_eval/external_agent.py +0 -976
- package/scripts/qa_eval/llm_config.py +0 -92
- package/scripts/qa_eval/memory_monitor.py +0 -132
- package/scripts/qa_eval/my_answer_accuracy.py +0 -187
- package/scripts/qa_eval/requirements.txt +0 -2
- package/scripts/qa_eval/run_pipeline.py +0 -804
- package/scripts/qa_eval/stats_efficiency.py +0 -279
- package/scripts/qa_eval/stats_scores.py +0 -207
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WAL checkpoint valve — bounds WAL growth while auto-checkpointing is
|
|
4
|
+
* deferred during a bulk index (#1231).
|
|
5
|
+
*
|
|
6
|
+
* Why deferral: SQLite's default `wal_autocheckpoint` (1000 pages) re-writes
|
|
7
|
+
* hot B-tree/FTS pages into the main DB file over and over during a bulk
|
|
8
|
+
* index — measured at ~95% of ALL disk I/O, and the difference between 45s
|
|
9
|
+
* and 19+ minutes on HDD-class storage (150 random IOPS). Deferring
|
|
10
|
+
* checkpoints turns the store into pure sequential WAL appends; each backfill
|
|
11
|
+
* pass writes distinct pages once, in page order (≈ sequential).
|
|
12
|
+
*
|
|
13
|
+
* Why a valve: unbounded deferral is its own failure mode, both measured in
|
|
14
|
+
* the #1231 repro. The WAL duplicates hot pages per COMMIT, so it grows far
|
|
15
|
+
* faster than the DB (5.9GB WAL for a ~340MB DB on a 3.3k-file index) —
|
|
16
|
+
* filling the disk, and poisoning every subsequent read that must page
|
|
17
|
+
* through it (the first resolution-phase read blocked the main thread >60s
|
|
18
|
+
* and the #850 liveness watchdog killed the healthy index). The valve
|
|
19
|
+
* watches WAL growth on a timer and, past a soft threshold, backfills with
|
|
20
|
+
* `PRAGMA wal_checkpoint(PASSIVE)` on a worker-thread connection — PASSIVE
|
|
21
|
+
* never blocks the writer, and off-thread means the main thread (and the
|
|
22
|
+
* watchdog heartbeat) keep turning regardless of how long a backfill takes.
|
|
23
|
+
*
|
|
24
|
+
* The load-bearing subtlety: a WAL file's SIZE never shrinks. After a full
|
|
25
|
+
* backfill, the writer's next commit RESTARTS the WAL from the top and the
|
|
26
|
+
* frames recycle inside the same file — so raw size says nothing about the
|
|
27
|
+
* un-backfilled backlog, and a size-triggered valve degenerates into firing
|
|
28
|
+
* (and pausing the writer) forever once the file passes its threshold
|
|
29
|
+
* (measured: guava crawled at ~9min per 160 files). Instead the valve
|
|
30
|
+
* tracks `sizeAtLastFullBackfill` — refreshed whenever a checkpoint reports
|
|
31
|
+
* `log === checkpointed` (everything backfilled) — and triggers on GROWTH
|
|
32
|
+
* beyond that baseline, which only happens when genuinely un-backfilled
|
|
33
|
+
* frames push past the file's high-water mark.
|
|
34
|
+
*
|
|
35
|
+
* Backpressure: if the writer outruns the checkpointer past a hard cap of
|
|
36
|
+
* growth (2× soft), {@link backpressure} pauses the writer (at a safe,
|
|
37
|
+
* between-transactions boundary) until a FULL backfill lands. One in-flight
|
|
38
|
+
* pass is not enough: on a disk saturated by the writer, every concurrent
|
|
39
|
+
* PASSIVE pass is already stale by the time it finishes (the writer appended
|
|
40
|
+
* past its snapshot), so neither SQLite's WAL wrap nor the baseline ever
|
|
41
|
+
* trigger and the WAL grows without bound (measured: 5.9GB on guava at 150
|
|
42
|
+
* IOPS, then a >60s read stall and a watchdog kill). With the writer parked,
|
|
43
|
+
* the next pass covers everything, the WAL wraps on the following commit,
|
|
44
|
+
* and the pause is the disk's honest catch-up cost — the correct terminal
|
|
45
|
+
* mode when hardware genuinely can't keep up with the append rate.
|
|
46
|
+
*/
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.WalCheckpointValve = void 0;
|
|
49
|
+
exports.resolveWalValveMb = resolveWalValveMb;
|
|
50
|
+
/** Soft WAL-growth threshold (MB) that triggers an off-thread passive checkpoint. */
|
|
51
|
+
const DEFAULT_WAL_VALVE_MB = 256;
|
|
52
|
+
/** Hard cap = this × soft threshold; past it the writer pauses for a full backfill. */
|
|
53
|
+
const HARD_CAP_MULTIPLIER = 2;
|
|
54
|
+
/** File cap = this × soft threshold; past it the barrier also TRUNCATEs the file. */
|
|
55
|
+
const FILE_CAP_MULTIPLIER = 4;
|
|
56
|
+
/** Passes attempted per writer pause before giving up (a pinned reader could stall forever). */
|
|
57
|
+
const MAX_PAUSED_BACKFILL_PASSES = 20;
|
|
58
|
+
/** How often the timer looks at the WAL file size. */
|
|
59
|
+
const CHECK_INTERVAL_MS = 2000;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the valve's soft threshold from the `HOMEGRAPH_WAL_VALVE_MB`
|
|
62
|
+
* override; non-numeric / non-positive values fall back to the default.
|
|
63
|
+
*/
|
|
64
|
+
function resolveWalValveMb(envVal, dbSizeBytes) {
|
|
65
|
+
if (envVal !== undefined && envVal !== '') {
|
|
66
|
+
const n = Number(envVal);
|
|
67
|
+
if (Number.isFinite(n) && n > 0)
|
|
68
|
+
return Math.floor(n);
|
|
69
|
+
}
|
|
70
|
+
// Scale with the project when the caller knows the DB size: every fold
|
|
71
|
+
// re-writes hot B-tree pages into the main file (the #1231 pathology in
|
|
72
|
+
// bounded form — 111s of a kernel-scale batch loop at the flat 256MB cap,
|
|
73
|
+
// §7a.2), so a big project affords a proportionally bigger transient WAL
|
|
74
|
+
// (~dbSize/4 soft ⇒ file cap ≈ dbSize) in exchange for ~4× fewer folds.
|
|
75
|
+
if (dbSizeBytes !== undefined && dbSizeBytes > 0) {
|
|
76
|
+
return Math.min(2048, Math.max(DEFAULT_WAL_VALVE_MB, Math.floor(dbSizeBytes / 4 / (1024 * 1024))));
|
|
77
|
+
}
|
|
78
|
+
return DEFAULT_WAL_VALVE_MB;
|
|
79
|
+
}
|
|
80
|
+
class WalCheckpointValve {
|
|
81
|
+
db;
|
|
82
|
+
intervalMs;
|
|
83
|
+
timer = null;
|
|
84
|
+
inflight = null;
|
|
85
|
+
/** Writer pause in progress (hard cap breached): passes loop until a full backfill. */
|
|
86
|
+
pause = null;
|
|
87
|
+
/**
|
|
88
|
+
* WAL file size observed when a checkpoint last reported the ENTIRE WAL
|
|
89
|
+
* backfilled. Growth is measured against this baseline — see the header
|
|
90
|
+
* comment for why absolute size cannot be used.
|
|
91
|
+
*/
|
|
92
|
+
sizeAtLastFullBackfill = 0;
|
|
93
|
+
softBytes;
|
|
94
|
+
hardBytes;
|
|
95
|
+
fileCapBytes;
|
|
96
|
+
/**
|
|
97
|
+
* Futility latch: consecutive backfill give-ups (a reader pinning the WAL)
|
|
98
|
+
* disable further writer pauses for a cooldown, so a pinned phase degrades
|
|
99
|
+
* to the pre-valve behavior (unbounded WAL, folded when the pinner exits)
|
|
100
|
+
* instead of burning a 20-pass checkpoint attempt — each pass a worker
|
|
101
|
+
* thread + fresh connection — at EVERY over-cap boundary. That churn is
|
|
102
|
+
* what turned a pinned kernel-scale resolution from slow into OOM-killed
|
|
103
|
+
* (§7a.1 run 1: 22GB WAL, exit 137 at an envelope the pre-fix build
|
|
104
|
+
* survived).
|
|
105
|
+
*/
|
|
106
|
+
consecutiveGiveUps = 0;
|
|
107
|
+
futileUntil = 0;
|
|
108
|
+
constructor(db, softMb = resolveWalValveMb(process.env.HOMEGRAPH_WAL_VALVE_MB), intervalMs = CHECK_INTERVAL_MS, log = () => { }) {
|
|
109
|
+
this.db = db;
|
|
110
|
+
this.intervalMs = intervalMs;
|
|
111
|
+
this.softBytes = softMb * 1024 * 1024;
|
|
112
|
+
this.hardBytes = this.softBytes * HARD_CAP_MULTIPLIER;
|
|
113
|
+
this.fileCapBytes = this.softBytes * FILE_CAP_MULTIPLIER;
|
|
114
|
+
// HOMEGRAPH_WAL_VALVE_DEBUG=1 surfaces valve decisions to stderr without
|
|
115
|
+
// needing the caller's verbose plumbing — the observability gap that let
|
|
116
|
+
// §7a.1 run 1 fail silently (give-ups were verbose-gated and invisible).
|
|
117
|
+
this.log = process.env.HOMEGRAPH_WAL_VALVE_DEBUG
|
|
118
|
+
? (m) => console.error(`[wal-valve] ${m}`)
|
|
119
|
+
: log;
|
|
120
|
+
}
|
|
121
|
+
log;
|
|
122
|
+
mb(n) {
|
|
123
|
+
return `${Math.round(n / 1024 / 1024)}MB`;
|
|
124
|
+
}
|
|
125
|
+
/** Un-backfilled growth estimate: bytes the WAL has grown past the last full backfill. */
|
|
126
|
+
growthBytes() {
|
|
127
|
+
return this.db.getWalSizeBytes() - this.sizeAtLastFullBackfill;
|
|
128
|
+
}
|
|
129
|
+
/** Begin watching the WAL. Idempotent; the timer never holds the loop open. */
|
|
130
|
+
start() {
|
|
131
|
+
if (this.timer)
|
|
132
|
+
return;
|
|
133
|
+
// One armed line per run under either diagnostics env: §7a.1's failed
|
|
134
|
+
// kernel-scale runs burned three 25-minute cycles before "is the valve
|
|
135
|
+
// even alive?" could be answered.
|
|
136
|
+
if (process.env.HOMEGRAPH_SYNTH_TIMINGS || process.env.HOMEGRAPH_WAL_VALVE_DEBUG) {
|
|
137
|
+
console.error(`[wal-valve] armed soft=${this.mb(this.softBytes)} hard=${this.mb(this.hardBytes)} wal=${this.mb(this.db.getWalSizeBytes())}`);
|
|
138
|
+
}
|
|
139
|
+
let ticks = 0;
|
|
140
|
+
this.timer = setInterval(() => {
|
|
141
|
+
if ((++ticks % 15) === 0) {
|
|
142
|
+
this.log(`alive: wal=${this.mb(this.db.getWalSizeBytes())} baseline=${this.mb(this.sizeAtLastFullBackfill)} inflight=${this.inflight ? 'y' : 'n'} paused=${this.pause ? 'y' : 'n'}`);
|
|
143
|
+
}
|
|
144
|
+
this.check();
|
|
145
|
+
}, this.intervalMs);
|
|
146
|
+
this.timer.unref?.();
|
|
147
|
+
}
|
|
148
|
+
/** Stop watching. Any in-flight checkpoint keeps running — await drain(). */
|
|
149
|
+
stop() {
|
|
150
|
+
if (this.timer) {
|
|
151
|
+
clearInterval(this.timer);
|
|
152
|
+
this.timer = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** One poll: fire an off-thread passive checkpoint when growth passes the soft threshold. */
|
|
156
|
+
check() {
|
|
157
|
+
if (!this.pause && !this.inflight && this.growthBytes() > this.softBytes)
|
|
158
|
+
this.fire();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Writer-side backstop, called at a between-transactions boundary. Returns
|
|
162
|
+
* null (no wait) while growth is under the hard cap; past it, returns a
|
|
163
|
+
* promise that resolves only once a FULL backfill has landed — see the
|
|
164
|
+
* header comment for why a single pass is not enough on a saturated disk.
|
|
165
|
+
*/
|
|
166
|
+
backpressure() {
|
|
167
|
+
if (this.pause)
|
|
168
|
+
return this.pause;
|
|
169
|
+
if (Date.now() < this.futileUntil)
|
|
170
|
+
return null; // pinned reader — parking is churn, not progress
|
|
171
|
+
// Two independent triggers:
|
|
172
|
+
// - growth: un-backfilled BACKLOG past the hard cap (the original valve).
|
|
173
|
+
// - file size: a WAL can stay fully backfilled and still grow without
|
|
174
|
+
// bound — the writer only restarts at frame 0 if a commit finds no
|
|
175
|
+
// reader marks, which §7a.1's instrumented run showed never happens
|
|
176
|
+
// in practice (file marched 361→721MB through two COMPLETE
|
|
177
|
+
// backfills). Past the file cap, park and TRUNCATE at the barrier —
|
|
178
|
+
// the backfill part is instant when the backlog is already folded.
|
|
179
|
+
if (this.growthBytes() <= this.hardBytes && this.db.getWalSizeBytes() <= this.fileCapBytes)
|
|
180
|
+
return null;
|
|
181
|
+
this.log(`backpressure: wal=${this.mb(this.db.getWalSizeBytes())} baseline=${this.mb(this.sizeAtLastFullBackfill)} — pausing writer for full backfill`);
|
|
182
|
+
const t0 = Date.now();
|
|
183
|
+
this.pause = this.backfillFully().finally(() => {
|
|
184
|
+
this.pause = null;
|
|
185
|
+
this.log(`backpressure released after ${Date.now() - t0}ms: wal=${this.mb(this.db.getWalSizeBytes())} baseline=${this.mb(this.sizeAtLastFullBackfill)}`);
|
|
186
|
+
});
|
|
187
|
+
return this.pause;
|
|
188
|
+
}
|
|
189
|
+
/** Await any in-flight checkpoint and writer pause. */
|
|
190
|
+
async drain() {
|
|
191
|
+
while (this.pause || this.inflight) {
|
|
192
|
+
if (this.pause)
|
|
193
|
+
await this.pause;
|
|
194
|
+
if (this.inflight)
|
|
195
|
+
await this.inflight;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Phase-boundary fold: backfill the ENTIRE WAL now (off-thread, awaited).
|
|
200
|
+
* Called between bulk phases — e.g. after parsing, before resolution's
|
|
201
|
+
* first reads — so the next phase never pages a bulk-write-sized WAL on
|
|
202
|
+
* the main thread (the post-parse read against a multi-GB WAL is what
|
|
203
|
+
* blew the #850 watchdog's 60s window in the #1231 repro). The await
|
|
204
|
+
* keeps the event loop (and the watchdog heartbeat) turning.
|
|
205
|
+
*/
|
|
206
|
+
async foldNow() {
|
|
207
|
+
await this.drain();
|
|
208
|
+
if (this.growthBytes() <= 0)
|
|
209
|
+
return;
|
|
210
|
+
this.log(`foldNow: wal=${this.mb(this.db.getWalSizeBytes())} baseline=${this.mb(this.sizeAtLastFullBackfill)}`);
|
|
211
|
+
this.pause = this.backfillFully().finally(() => { this.pause = null; });
|
|
212
|
+
await this.pause;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* With the writer parked on the returned promise, loop passive passes until
|
|
216
|
+
* one reports the entire WAL backfilled (typically the second: the first
|
|
217
|
+
* drains the pass that was already running against a stale snapshot). Gives
|
|
218
|
+
* up after a bounded number of passes — e.g. a reader pinning the WAL —
|
|
219
|
+
* because unbounded WAL growth degrades; a wedged writer never recovers.
|
|
220
|
+
*/
|
|
221
|
+
async backfillFully() {
|
|
222
|
+
for (let i = 0; i < MAX_PAUSED_BACKFILL_PASSES; i++) {
|
|
223
|
+
if (this.inflight)
|
|
224
|
+
await this.inflight; // fold in the stale in-flight pass first
|
|
225
|
+
const res = await this.db.checkpointWalPassive();
|
|
226
|
+
if (!res)
|
|
227
|
+
return; // checkpoint machinery unavailable — don't spin
|
|
228
|
+
this.log(`backfill pass ${i + 1}: busy=${res.busy} log=${res.log} checkpointed=${res.checkpointed} wal=${this.mb(this.db.getWalSizeBytes())}`);
|
|
229
|
+
if (res.busy === 0 && res.log === res.checkpointed) {
|
|
230
|
+
// Backfill complete AND we are at a parked barrier (backfillFully only
|
|
231
|
+
// runs under a writer pause): the no-reader window is guaranteed, so
|
|
232
|
+
// chop the FILE too — a fully-backfilled WAL otherwise keeps growing
|
|
233
|
+
// whenever commits land while pool readers hold marks (§7a.1: 22GB
|
|
234
|
+
// on-disk at kernel scale despite backfills). A racing reader turns
|
|
235
|
+
// this into a no-op (busy=1); the passive result above still stands.
|
|
236
|
+
const trunc = await this.db.checkpointWalTruncate();
|
|
237
|
+
if (trunc)
|
|
238
|
+
this.log(`truncate: busy=${trunc.busy} wal=${this.mb(this.db.getWalSizeBytes())}`);
|
|
239
|
+
this.sizeAtLastFullBackfill = this.db.getWalSizeBytes();
|
|
240
|
+
this.consecutiveGiveUps = 0;
|
|
241
|
+
this.futileUntil = 0;
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
this.consecutiveGiveUps++;
|
|
246
|
+
if (this.consecutiveGiveUps >= 2) {
|
|
247
|
+
this.futileUntil = Date.now() + 60_000;
|
|
248
|
+
}
|
|
249
|
+
const msg = `backfill gave up after ${MAX_PAUSED_BACKFILL_PASSES} passes (streak ${this.consecutiveGiveUps}${this.futileUntil ? ', parking disabled 60s' : ''}) — a reader is pinning the WAL`;
|
|
250
|
+
this.log(msg);
|
|
251
|
+
// Give-ups are rare and load-bearing for §7a.1-class diagnosis — surface
|
|
252
|
+
// them on any timing-instrumented run, not just valve-debug ones.
|
|
253
|
+
if (process.env.HOMEGRAPH_SYNTH_TIMINGS && !process.env.HOMEGRAPH_WAL_VALVE_DEBUG) {
|
|
254
|
+
console.error(`[wal-valve] ${msg}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
fire() {
|
|
258
|
+
this.log(`fire: wal=${this.mb(this.db.getWalSizeBytes())} baseline=${this.mb(this.sizeAtLastFullBackfill)}`);
|
|
259
|
+
const p = this.db
|
|
260
|
+
.checkpointWalPassive()
|
|
261
|
+
.then((res) => {
|
|
262
|
+
this.log(`timer pass: ${res ? `busy=${res.busy} log=${res.log} checkpointed=${res.checkpointed}` : 'null (machinery unavailable)'} wal=${this.mb(this.db.getWalSizeBytes())}`);
|
|
263
|
+
// Full backfill (busy 0, every log frame checkpointed) ⇒ the writer's
|
|
264
|
+
// next commit wraps the WAL; the file's current size becomes the new
|
|
265
|
+
// growth baseline. A partial pass (writer appended during it, or a
|
|
266
|
+
// read transaction pinned frames) leaves the baseline alone, so the
|
|
267
|
+
// next tick fires again and copies the remainder. In non-WAL mode
|
|
268
|
+
// SQLite reports log = checkpointed = -1, which is harmless here.
|
|
269
|
+
if (res && res.busy === 0 && res.log === res.checkpointed) {
|
|
270
|
+
this.sizeAtLastFullBackfill = this.db.getWalSizeBytes();
|
|
271
|
+
// NO truncate here. A truncate checkpoint that starts against an
|
|
272
|
+
// ACTIVE writer wins the lock race and then blocks that writer for
|
|
273
|
+
// its entire backfill — after a multi-GB single-transaction burst
|
|
274
|
+
// (edge-index recreate) that exceeds the writer's 5s busy_timeout
|
|
275
|
+
// and fails the index with "database is locked" (§7a.2 record run).
|
|
276
|
+
// The file chop happens exclusively at parked barriers
|
|
277
|
+
// (backpressure/foldNow), where the writer is awaiting us by
|
|
278
|
+
// construction and cannot collide.
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
.catch(() => { })
|
|
282
|
+
.finally(() => {
|
|
283
|
+
if (this.inflight === p)
|
|
284
|
+
this.inflight = null;
|
|
285
|
+
});
|
|
286
|
+
this.inflight = p;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.WalCheckpointValve = WalCheckpointValve;
|
|
290
|
+
//# sourceMappingURL=wal-valve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wal-valve.js","sourceRoot":"","sources":["../../src/db/wal-valve.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;;AAmBH,8CAcC;AA7BD,qFAAqF;AACrF,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,uFAAuF;AACvF,MAAM,mBAAmB,GAAG,CAAC,CA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ots(root: string, opts?: {
|
|
|
77
77
|
max?: number;
|
|
78
78
|
}): string[];
|
|
79
79
|
/**
|
|
80
|
-
* Does `prompt` contain an explicit structural keyword
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* Does `prompt` contain an explicit structural keyword? A keyword is a strong,
|
|
81
|
+
* self-contained signal, so the front-load hook fires on it directly — no graph
|
|
82
|
+
* check needed. (A *code-token* match, by contrast, is only a candidate the
|
|
83
|
+
* hook verifies against the graph first; see {@link extractCodeTokens}.)
|
|
84
|
+
* Coverage is multilingual (#994, #1126): the ~29 languages with the largest
|
|
85
|
+
* developer populations, across Latin, Cyrillic, Greek, CJK, Hangul, Arabic,
|
|
86
|
+
* Hebrew, Thai, and Devanagari scripts. Languages beyond the keyword table
|
|
87
|
+
* still fire through the language-agnostic code-token path.
|
|
84
88
|
*/
|
|
85
89
|
export declare function hasStructuralKeyword(prompt: string): boolean;
|
|
86
90
|
/**
|
|
@@ -101,7 +105,7 @@ export declare function extractCodeTokens(prompt: string): string[];
|
|
|
101
105
|
/**
|
|
102
106
|
* Cheap, graph-free candidate gate for the front-load hook: could `prompt` be a
|
|
103
107
|
* structural / flow / impact / "where-how" question worth front-loading context
|
|
104
|
-
* for? True on an explicit keyword
|
|
108
|
+
* for? True on an explicit keyword in any covered language (#994, #1126) OR an
|
|
105
109
|
* identifier-shaped token. A keyword is sufficient to fire on its own; a
|
|
106
110
|
* token-only match is only a candidate the hook then verifies against the graph
|
|
107
111
|
* (a brand name like `JavaScript` is token-shaped but isn't a symbol). Every
|
package/dist/directory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAqBzC;AAED,qFAAqF;AACrF,eAAO,MAAM,aAAa,eAAwB,CAAC;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ED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG;IACtD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA6BA"}
|
package/dist/directory.js
CHANGED
|
@@ -263,33 +263,224 @@ function findIndexedSubprojectRoots(root, opts = {}) {
|
|
|
263
263
|
return out;
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
266
|
+
* Unicode-aware word-boundary emulation for the keyword lists below. JS's `\b`
|
|
267
|
+
* is ASCII-only — it fires only at `[A-Za-z0-9_]` edges — so it can never bound
|
|
268
|
+
* a keyword whose first or last character is accented or non-Latin: `/\boù\b/`
|
|
269
|
+
* NEVER matches "où est …" (ù isn't an ASCII word char, so no boundary exists
|
|
270
|
+
* next to it). That is the #994 CJK mechanism resurfaced for Latin scripts and
|
|
271
|
+
* Cyrillic (#1126). A lookaround — "not flanked by a letter, digit, or
|
|
272
|
+
* underscore" — is the script-independent equivalent.
|
|
268
273
|
*/
|
|
269
|
-
const
|
|
274
|
+
const NOT_WORD_BEFORE = /(?<![\p{L}\p{N}_])/u.source;
|
|
275
|
+
const NOT_WORD_AFTER = /(?![\p{L}\p{N}_])/u.source;
|
|
270
276
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* set mirrors the English intent (如何=how, 在哪/哪里=where, 流程/流向=flow,
|
|
277
|
-
* 路径=path, 调用=call, 依赖=depend, 影响=impact/affect, 实现=implement,
|
|
278
|
-
* 架构=architect, 结构=structure, 追踪/跟踪=trace) plus structural-overview words
|
|
279
|
-
* with no single clean English equivalent (介绍/解析/分析/原理/机制).
|
|
277
|
+
* Structural keywords matched as EXACT words (boundary on both sides): short
|
|
278
|
+
* or ambiguous tokens where prefix matching would false-positive ("flow" in
|
|
279
|
+
* "flower", "path" in "pathological"). Grouped by language; a term appears once
|
|
280
|
+
* even when several languages share it ("como" is Portuguese for how AND
|
|
281
|
+
* unaccented-typed Spanish "cómo").
|
|
280
282
|
*/
|
|
281
|
-
const
|
|
283
|
+
const STRUCTURAL_WORDS = [
|
|
284
|
+
// English — the pre-#1126 list minus what moved to STRUCTURAL_STEMS: the
|
|
285
|
+
// bare-stem entries never matched their own derived forms (`\barchitect\b`
|
|
286
|
+
// can't match "architecture"), and "what calls" is subsumed by the "call" stem.
|
|
287
|
+
'how', 'where', 'tracing', 'flows?', 'paths?', 'reach(?:es|ed)?', 'wired?', 'breaks?', 'why does',
|
|
288
|
+
// French (où=where, flux=flow, chemin=path, casse=breaks)
|
|
289
|
+
'comment', 'où', 'flux', 'chemins?', 'casse',
|
|
290
|
+
// Spanish (cómo/como=how, dónde/donde=where, flujo=flow, ruta/camino=path,
|
|
291
|
+
// rompe=breaks, llaman / quién llama = call(s) — bare "llama" is excluded:
|
|
292
|
+
// it's also the animal/model name in English prompts)
|
|
293
|
+
'cómo', 'dónde', 'donde', 'flujos?', 'rutas?', 'caminos?', 'rompe', 'llaman', 'quién llama', 'quien llama',
|
|
294
|
+
// Portuguese (como=how — also covers unaccented Spanish; onde=where,
|
|
295
|
+
// fluxo=flow, caminho=path)
|
|
296
|
+
'como', 'onde', 'fluxos?', 'caminhos?',
|
|
297
|
+
// German (wie=how, wo/woher/wohin=where, Pfad=path, Fluss/Ablauf=flow,
|
|
298
|
+
// bricht/kaputt=breaks, ruft=calls, hängt=depends — "hängt … von X ab"
|
|
299
|
+
// splits the separable verb "abhängen", so the "abhäng" stem can't catch it)
|
|
300
|
+
'wie', 'wo', 'woher', 'wohin', 'pfade?', 'fluss', 'ablauf', 'bricht', 'kaputt', 'ruft', 'hängt',
|
|
301
|
+
// Italian (dove=where, flusso=flow, percorso/i=path)
|
|
302
|
+
'dove', 'flusso', 'percors[oi]',
|
|
303
|
+
// Russian (как=how, где=where, путь/пути=path, работает=works)
|
|
304
|
+
'как', 'где', 'путь', 'пути', 'работает',
|
|
305
|
+
// Ukrainian (як=how, де=where, потік=flow — обліque cases reuse the RU
|
|
306
|
+
// "поток" stem; працює=works)
|
|
307
|
+
'як', 'де', 'потік', 'працює',
|
|
308
|
+
// Dutch (hoe=how, waar=where, roept=calls, werkt=works, aangeroepen=called —
|
|
309
|
+
// the ge- participle escapes the "aanroep" stem)
|
|
310
|
+
'hoe', 'waar', 'roept', 'werkt', 'aangeroepen',
|
|
311
|
+
// Polish + Czech (jak=how — shared; gdzie/kde=where, cesta=path)
|
|
312
|
+
'jak', 'gdzie', 'kde', 'cesta',
|
|
313
|
+
// Romanian (cum=how, unde=where; flux is shared with French)
|
|
314
|
+
'cum', 'unde',
|
|
315
|
+
// Hungarian (hogyan=how, hol=where)
|
|
316
|
+
'hogyan', 'hol',
|
|
317
|
+
// Turkish (nasıl=how, mimari=architecture, takip=trace/follow)
|
|
318
|
+
'nasıl', 'mimari', 'takip',
|
|
319
|
+
// Indonesian/Malay (bagaimana=how, di mana/dimana=where, alur=flow, jalur=path)
|
|
320
|
+
'bagaimana', 'di mana', 'dimana', 'alur', 'jalur',
|
|
321
|
+
// Vietnamese — spaced Latin with heavy diacritics, the exact class ASCII `\b`
|
|
322
|
+
// breaks (làm sao/thế nào=how, ở đâu=where, gọi=call, phụ thuộc=depend,
|
|
323
|
+
// ảnh hưởng=affect, kiến trúc=architecture, cấu trúc=structure, luồng=flow,
|
|
324
|
+
// đường dẫn=path, hoạt động=works, giải thích=explain, theo dõi=trace)
|
|
325
|
+
'làm sao', 'thế nào', 'ở đâu', 'gọi', 'phụ thuộc', 'ảnh hưởng', 'kiến trúc',
|
|
326
|
+
'cấu trúc', 'luồng', 'đường dẫn', 'hoạt động', 'giải thích', 'theo dõi',
|
|
327
|
+
// Swedish / Danish / Norwegian (hur/hvordan=how, hvor=where, beror=depends,
|
|
328
|
+
// flöde=flow)
|
|
329
|
+
'hur', 'hvordan', 'hvor', 'beror', 'flöde',
|
|
330
|
+
// Finnish (miten=how, missä=where, toimii=works)
|
|
331
|
+
'miten', 'missä', 'toimii',
|
|
332
|
+
// Greek (πώς=how, πού=where — accented forms only: unaccented πως/που are
|
|
333
|
+
// ubiquitous conjunctions; καλεί=calls, δομή=structure, ροή=flow)
|
|
334
|
+
'πώς', 'πού', 'καλεί', 'δομή', 'ροή',
|
|
335
|
+
// Hindi (कैसे=how, कहाँ/कहां=where, कॉल=call, निर्भर=depends,
|
|
336
|
+
// संरचना=structure, प्रवाह=flow)
|
|
337
|
+
'कैसे', 'कहाँ', 'कहां', 'कॉल', 'निर्भर', 'संरचना', 'प्रवाह',
|
|
338
|
+
];
|
|
339
|
+
/**
|
|
340
|
+
* Structural keyword STEMS matched as word PREFIXES (boundary on the left
|
|
341
|
+
* only), so derived forms match without enumerating each: "architect" fires on
|
|
342
|
+
* architecture/architectural, "depend" on depends/dependency/dependencies,
|
|
343
|
+
* "вызыва" on вызывает/вызывается. Mid-word occurrences stay excluded —
|
|
344
|
+
* "restructure"/"independent" don't fire — so precision stays close to the
|
|
345
|
+
* exact-word class. Add a stem only when every plausible completion is still a
|
|
346
|
+
* structural word; a stem with ordinary-English completions must instead
|
|
347
|
+
* enumerate its structural suffixes and re-assert the right boundary (see the
|
|
348
|
+
* four bounded English entries below, #1138).
|
|
349
|
+
*/
|
|
350
|
+
const STRUCTURAL_STEMS = [
|
|
351
|
+
// English + the Latin-script languages that share the spelling (French
|
|
352
|
+
// architecture/structure/trace/impact, Spanish depende/implementa/impacto, …).
|
|
353
|
+
// call/trace/affect/connect are NOT safe as open prefixes — callus,
|
|
354
|
+
// calligraphy, Connecticut, connective, affectionate, Tracey are ordinary
|
|
355
|
+
// words that would false-fire the full-explore tier (#1138) — so they carry
|
|
356
|
+
// an enumerated suffix set + right boundary. "tracing" lives in
|
|
357
|
+
// STRUCTURAL_WORDS (the e is dropped, so no trace-prefix form matches it).
|
|
358
|
+
'architect', 'structur', 'depend', 'implement', 'impact', 'explain',
|
|
359
|
+
`call(?:s|ing|ed|ers?|backs?|able|sites?)?${NOT_WORD_AFTER}`,
|
|
360
|
+
`trace(?:s|d|rs?)?${NOT_WORD_AFTER}`,
|
|
361
|
+
`affect(?:s|ed|ing)?${NOT_WORD_AFTER}`,
|
|
362
|
+
`connect(?:s|ed|ing|ions?|ors?|ivity)?${NOT_WORD_AFTER}`,
|
|
363
|
+
// French (appel(le)=call, dépend=depends, implément(e)=implement,
|
|
364
|
+
// connex(ion)=connection, expliqu(e)=explain, fonctionn(e/ement)=works)
|
|
365
|
+
'appel', 'dépend', 'implément', 'connex', 'expliqu', 'fonctionn',
|
|
366
|
+
// Spanish (llamad(a)=call, afect(a)=affect, conect(a)/conexi(ón)=connect,
|
|
367
|
+
// arquitec(tura)=architecture, estructur(a)=structure, funcion(a)=works,
|
|
368
|
+
// traza(r)=trace, explica=explain)
|
|
369
|
+
'llamad', 'afect', 'conect', 'conexi', 'arquitec', 'estructur', 'funcion', 'traza', 'explica',
|
|
370
|
+
// Portuguese (chama(da)=call, afeta=affect, arquitet(ura)=architecture,
|
|
371
|
+
// estrutur(a)=structure, quebra(do)=breaks)
|
|
372
|
+
'chama', 'afeta', 'arquitet', 'estrutur', 'quebra',
|
|
373
|
+
// German (abhäng(t)=depend, Auswirkung=impact, beeinfluss(t)=affect,
|
|
374
|
+
// verbind(et)=connect, Architektur, Struktur, funktionier(t)=works,
|
|
375
|
+
// Aufruf/aufgerufen=call, erklär(t)=explain, verfolg(en)=trace)
|
|
376
|
+
'abhäng', 'auswirkung', 'beeinfluss', 'verbind', 'architekt', 'struktur', 'funktionier', 'aufruf', 'aufgerufen', 'erklär', 'verfolg',
|
|
377
|
+
// Italian (chiam(a/ata)=call, dipend(e/enza)=depend, impatt(o)=impact,
|
|
378
|
+
// connett(e)/conness(ione)=connect, architett(ura), struttur(a),
|
|
379
|
+
// funzion(a/amento)=works, tracci(a)=trace, spiega(mi)=explain)
|
|
380
|
+
'chiam', 'dipend', 'impatt', 'connett', 'conness', 'architett', 'struttur', 'funzion', 'tracci', 'spiega',
|
|
381
|
+
// Russian (вызыва(ет)=calls, завис(ит)=depends, влия(ет)=affects,
|
|
382
|
+
// реализ(ация)=implementation, структур(а), архитектур(а),
|
|
383
|
+
// трассир(овка)=trace, лома(ет)=breaks, объясн(и)=explain, поток=flow)
|
|
384
|
+
'вызыва', 'завис', 'влия', 'реализ', 'структур', 'архитектур', 'трассир', 'лома', 'объясн', 'поток',
|
|
385
|
+
// Ukrainian — і/и spellings diverge from Russian (виклика(є)=calls,
|
|
386
|
+
// залеж(ить)=depends, вплива(є)=affects, архітектур(а), реаліз(ація),
|
|
387
|
+
// поясн(и)=explain, шлях(у)=path; структур(а) is shared with Russian)
|
|
388
|
+
'виклика', 'залеж', 'вплива', 'архітектур', 'реаліз', 'поясн', 'шлях',
|
|
389
|
+
// Dutch (aanroep(en)=call, afhankelijk(heid)=depends, beïnvloed(t)=affects,
|
|
390
|
+
// structuur — "structur" can't reach the uu; uitleg(gen)=explain)
|
|
391
|
+
'aanroep', 'afhankelijk', 'beïnvloed', 'structuur', 'uitleg',
|
|
392
|
+
// Polish (wywoł(uje)=calls, zależ(y)=depends, wpływ(a)=affects/impact,
|
|
393
|
+
// przepływ=flow, ścieżk(a)=path, działa(nie)=works, wyjaśni(j)=explain,
|
|
394
|
+
// śledz(enie)=trace; architektura/struktura fire via the German stems)
|
|
395
|
+
'wywoł', 'zależ', 'wpływ', 'przepływ', 'ścieżk', 'działa', 'wyjaśni', 'śledz',
|
|
396
|
+
// Czech (volá(ní)=calls, závis(í)=depends, ovlivň(uje)=affects,
|
|
397
|
+
// funguj(e)=works, vysvětl(i)=explain)
|
|
398
|
+
'volá', 'závis', 'ovlivň', 'funguj', 'vysvětl',
|
|
399
|
+
// Romanian (apel(ează)=calls, depind(e)=depends — i not e, so "depend" misses
|
|
400
|
+
// it; arhitectur(a) — no c; funcțion(ează)=works, explică=explain)
|
|
401
|
+
'apel', 'depind', 'arhitectur', 'funcțion', 'explică',
|
|
402
|
+
// Hungarian (hív(ja)=calls, függ(őség)=depends, működ(ik)=works,
|
|
403
|
+
// struktúr(a) — ú escapes "struktur"; magyaráz(d)=explain;
|
|
404
|
+
// architektúra fires via the German stem)
|
|
405
|
+
'hív', 'függ', 'működ', 'struktúr', 'magyaráz',
|
|
406
|
+
// Turkish — agglutinative, so stems beat exact words (nere(de/ye/den)=where,
|
|
407
|
+
// çağır/çağrı=call, bağıml(ı)=depends, bağlant(ı)=connection, akış(ı)=flow,
|
|
408
|
+
// etkile(r)/etkisi=affects/impact)
|
|
409
|
+
'nere', 'çağır', 'çağrı', 'bağıml', 'bağlant', 'akış', 'etkile', 'etkisi',
|
|
410
|
+
// Indonesian/Malay — me-/di-/ber- prefixes block a bare stem, so affixed
|
|
411
|
+
// forms are listed too (panggil(an)/memanggil/dipanggil=call,
|
|
412
|
+
// bergantung/tergantung=depends, pengaruh/mempengaruhi/memengaruhi=affect,
|
|
413
|
+
// arsitektur=architecture, fungsi/berfungsi=works,
|
|
414
|
+
// jelaskan/menjelaskan=explain)
|
|
415
|
+
'panggil', 'memanggil', 'dipanggil', 'bergantung', 'tergantung', 'pengaruh',
|
|
416
|
+
'mempengaruhi', 'memengaruhi', 'arsitektur', 'fungsi', 'berfungsi', 'jelaskan', 'menjelaskan',
|
|
417
|
+
// Swedish / Danish / Norwegian (anrop(ar)=calls, påverk(ar)/påvirk(er)=affects,
|
|
418
|
+
// afhæng(er)/avheng(er)=depends, förklar(a)/forklar=explain,
|
|
419
|
+
// arkitektur — k not ch; funger(ar/er)=works)
|
|
420
|
+
'anrop', 'påverk', 'påvirk', 'afhæng', 'avheng', 'förklar', 'forklar', 'arkitektur', 'funger',
|
|
421
|
+
// Finnish (kutsu(u)=calls, riippu(u)=depends, arkkitehtuur(i),
|
|
422
|
+
// rakente(en)=structure, selit(ä)=explain)
|
|
423
|
+
'kutsu', 'riippu', 'arkkitehtuur', 'rakente', 'selit',
|
|
424
|
+
// Greek — accented and unaccented stem spellings both occur
|
|
425
|
+
// (εξαρτ(άται)=depends, επηρε(άζει)=affects, αρχιτεκτονικ(ή),
|
|
426
|
+
// διαδρομ(ή)=path, εξηγ/εξήγ(ησε)=explain)
|
|
427
|
+
'εξαρτ', 'επηρε', 'αρχιτεκτονικ', 'διαδρομ', 'εξηγ', 'εξήγ',
|
|
428
|
+
// Hindi (समझा(ओ/इए)=explain, आर्किटेक्चर=architecture)
|
|
429
|
+
'समझा', 'आर्किटेक्चर',
|
|
430
|
+
];
|
|
431
|
+
const STRUCTURAL_WORDS_RE = new RegExp(`${NOT_WORD_BEFORE}(?:${STRUCTURAL_WORDS.join('|')})${NOT_WORD_AFTER}`, 'iu');
|
|
432
|
+
const STRUCTURAL_STEMS_RE = new RegExp(`${NOT_WORD_BEFORE}(?:${STRUCTURAL_STEMS.join('|')})`, 'iu');
|
|
433
|
+
/**
|
|
434
|
+
* Structural keywords matched as bare SUBSTRINGS, for languages where a
|
|
435
|
+
* boundary can't be relied on: scripts with no word separators (Chinese —
|
|
436
|
+
* simplified AND traditional; the original #994 set was simplified-only —
|
|
437
|
+
* Japanese, Thai), Korean (spaced, but particles attach directly to the noun:
|
|
438
|
+
* 구조가/구조를), and Arabic / Farsi / Hebrew (spaced, but proclitics attach to
|
|
439
|
+
* the word: وكيف "and-how", והמבנה "and-the-structure"). JS's `\b` can never
|
|
440
|
+
* fire between Han characters, which was issue #994: the English-only gate
|
|
441
|
+
* silently no-op'd every Chinese prompt, so non-English users got no front-load
|
|
442
|
+
* nudge and no error to explain why. The sets mirror the English intent
|
|
443
|
+
* (如何/怎么/怎麼/どうやって/どのように/어떻게/كيف/چگونه/چطور/איך/อย่างไร/ยังไง=how,
|
|
444
|
+
* 在哪/哪里/哪裡/어디/أين/كجا/איפה/ที่ไหน=where, 流程/流向/流れ/흐름/تدفق/זרימה=flow,
|
|
445
|
+
* 路径/路徑/経路/경로/مسار/مسیر/נתיב/เส้นทาง=path,
|
|
446
|
+
* 调用/調用/呼び出/호출/يستدعي/استدعاء/فراخوان/קורא/เรียกใช้=call,
|
|
447
|
+
* 依赖/依賴/依存/의존/يعتمد/تعتمد/وابسته/תלוי/ขึ้นอยู่กับ=depend,
|
|
448
|
+
* 影响/影響/영향/يؤثر/تأثير/تأثیر/משפיע/ผลกระทบ=impact/affect,
|
|
449
|
+
* 实现/實現/実装/구현=implement,
|
|
450
|
+
* 架构/架構/アーキテクチャ/아키텍처/معماري/معماری/ארכיטקטור/สถาปัตยกรรม=architecture,
|
|
451
|
+
* 结构/結構/構造/구조/بنية/هيكل/ساختار/מבנה/โครงสร้าง=structure,
|
|
452
|
+
* 追踪/跟踪/追蹤/追跡/トレース/추적/تتبع/ติดตาม=trace,
|
|
453
|
+
* يعمل/تعمل/ทำงาน=works) plus structural-overview words with no single clean
|
|
454
|
+
* English equivalent (介绍/介紹/解析/分析/原理/机制/機制/仕組み/説明/설명/動作/동작/작동/
|
|
455
|
+
* اشرح/شرح/توضیح/הסבר/อธิบาย=explain).
|
|
456
|
+
*
|
|
457
|
+
* KNOWN, ACCEPTED false-positive class (#1140): substring matching cannot see
|
|
458
|
+
* homograph compounds — Korean 구조 (structure) also fires inside 구조대
|
|
459
|
+
* (rescue squad). Verified unfixable at this layer: ICU word segmentation
|
|
460
|
+
* (Intl.Segmenter) returns 구조대 and the particle form 구조가 (which the gate
|
|
461
|
+
* MUST keep matching) as equally opaque single segments, and a 구조대 denylist
|
|
462
|
+
* would break 구조대로 ("according to the structure" — 구조 + the 대로
|
|
463
|
+
* particle), a legitimate structural prompt. The miss rate this design avoids
|
|
464
|
+
* (silently no-op'ing every prompt in these languages, #994) outweighs the
|
|
465
|
+
* occasional off-domain fire.
|
|
466
|
+
*/
|
|
467
|
+
const STRUCTURAL_UNSEGMENTED = /如何|怎么|怎麼|在哪|哪里|哪裡|追踪|跟踪|追蹤|追跡|トレース|流程|流向|流れ|路径|路徑|経路|调用|調用|呼び出|依赖|依賴|依存|影响|影響|实现|實現|実装|架构|架構|アーキテクチャ|结构|結構|構造|介绍|介紹|解析|分析|原理|机制|機制|仕組み|説明|動作|どうやって|どのように|어떻게|어디|호출|흐름|경로|의존|영향|구현|구조|아키텍처|추적|동작|작동|설명|كيف|أين|اين|يستدعي|استدعاء|يعتمد|تعتمد|يؤثر|تأثير|معماري|بنية|هيكل|تدفق|مسار|تتبع|يعمل|تعمل|اشرح|شرح|چگونه|چطور|کجا|فراخوان|وابسته|تأثیر|معماری|ساختار|مسیر|توضیح|איך|איפה|קורא|תלוי|משפיע|ארכיטקטור|מבנה|זרימה|נתיב|הסבר|อย่างไร|ยังไง|ที่ไหน|เรียกใช้|ขึ้นอยู่กับ|ผลกระทบ|สถาปัตยกรรม|โครงสร้าง|เส้นทาง|ติดตาม|ทำงาน|อธิบาย/;
|
|
282
468
|
/** Doc/data/asset file extensions — a `name.ext` of this kind is a file
|
|
283
469
|
* reference, not a code symbol, so it must not trip the member-access signal. */
|
|
284
470
|
const DOC_DATA_EXT = /\.(md|markdown|txt|rst|json|ya?ml|toml|lock|csv|tsv|log|ini|cfg|conf|env|xml|html?|png|jpe?g|gif|svg|pdf)$/i;
|
|
285
471
|
/**
|
|
286
|
-
* Does `prompt` contain an explicit structural keyword
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
472
|
+
* Does `prompt` contain an explicit structural keyword? A keyword is a strong,
|
|
473
|
+
* self-contained signal, so the front-load hook fires on it directly — no graph
|
|
474
|
+
* check needed. (A *code-token* match, by contrast, is only a candidate the
|
|
475
|
+
* hook verifies against the graph first; see {@link extractCodeTokens}.)
|
|
476
|
+
* Coverage is multilingual (#994, #1126): the ~29 languages with the largest
|
|
477
|
+
* developer populations, across Latin, Cyrillic, Greek, CJK, Hangul, Arabic,
|
|
478
|
+
* Hebrew, Thai, and Devanagari scripts. Languages beyond the keyword table
|
|
479
|
+
* still fire through the language-agnostic code-token path.
|
|
290
480
|
*/
|
|
291
481
|
function hasStructuralKeyword(prompt) {
|
|
292
|
-
return !!prompt &&
|
|
482
|
+
return (!!prompt &&
|
|
483
|
+
(STRUCTURAL_WORDS_RE.test(prompt) || STRUCTURAL_STEMS_RE.test(prompt) || STRUCTURAL_UNSEGMENTED.test(prompt)));
|
|
293
484
|
}
|
|
294
485
|
/**
|
|
295
486
|
* Identifier-shaped tokens in `prompt` — camelCase / PascalCase-with-inner-cap,
|
|
@@ -333,7 +524,7 @@ function extractCodeTokens(prompt) {
|
|
|
333
524
|
/**
|
|
334
525
|
* Cheap, graph-free candidate gate for the front-load hook: could `prompt` be a
|
|
335
526
|
* structural / flow / impact / "where-how" question worth front-loading context
|
|
336
|
-
* for? True on an explicit keyword
|
|
527
|
+
* for? True on an explicit keyword in any covered language (#994, #1126) OR an
|
|
337
528
|
* identifier-shaped token. A keyword is sufficient to fire on its own; a
|
|
338
529
|
* token-only match is only a candidate the hook then verifies against the graph
|
|
339
530
|
* (a brand name like `JavaScript` is token-shaped but isn't a symbol). Every
|