@namewta/skills-hub 0.1.49 → 0.1.52
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 +4 -1
- package/THIRD_PARTY_NOTICES.md +19 -7
- package/cli.mjs +2 -2
- package/install.mjs +11 -4
- package/package.json +1 -1
- package/scripts/persistence/home.md +1 -1
- package/skills/dev/dev-build/SKILL.md +2 -0
- package/skills/dev/dev-build/references/implement-request.md +7 -2
- package/skills/dev/dev-formal-verify/SKILL.md +2 -1
- package/skills/dev/dev-formal-verify/references/create-check.md +3 -1
- package/skills/dev/dev-formal-verify/references/example.md +1 -1
- package/skills/dev/dev-formal-verify/references/tool-choice.md +1 -1
- package/skills/dev/dev-help/references/capabilities.md +6 -6
- package/skills/dev/dev-help/references/guide-verification.md +7 -1
- package/skills/dev/dev-help/references/help-method.md +7 -1
- package/skills/dev/dev-issue/SKILL.md +1 -0
- package/skills/dev/dev-issue/references/github-operations.md +8 -0
- package/skills/dev/dev-plan/references/plan-template.md +1 -0
- package/skills/dev/dev-plan/references/vertical-slicing.md +2 -0
- package/skills/dev/dev-pr/references/pull-request-evidence.md +2 -0
- package/skills/dev/dev-review/references/host-parity.md +12 -0
- package/skills/dev/dev-review/references/review-baseline.md +2 -0
- package/skills/dev/dev-setup/references/formal-options.md +1 -1
- package/skills/dev/dev-statechart/SKILL.md +17 -19
- package/skills/dev/dev-statechart/agents/openai.yaml +3 -3
- package/skills/dev/dev-statechart/assets/theme.css +135 -0
- package/skills/dev/dev-statechart/references/lean-proof.md +47 -0
- package/skills/dev/dev-statechart/references/render.md +15 -83
- package/skills/dev/dev-statechart/references/runtime.md +21 -1
- package/skills/dev/dev-statechart/scripts/lean/backends/lemma-chart.mjs +285 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/mermaid.mjs +174 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/proof-chart.mjs +540 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/report.mjs +242 -0
- package/skills/dev/dev-statechart/scripts/lean/frontends/facts.mjs +234 -0
- package/skills/dev/dev-statechart/scripts/lean/frontends/view.mjs +217 -0
- package/skills/dev/dev-statechart/scripts/lean/ir.mjs +226 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/attribute.mjs +148 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/blocks.mjs +32 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/budget.mjs +167 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/check.mjs +70 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/contract.mjs +160 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/fold.mjs +206 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/inline.mjs +84 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/mark.mjs +432 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/reduce.mjs +73 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/trust.mjs +111 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/view-lemmas.mjs +155 -0
- package/skills/dev/dev-statechart/scripts/lean/pipeline.mjs +164 -0
- package/skills/dev/dev-statechart/scripts/lean/run.mjs +168 -0
- package/skills/dev/dev-statechart/scripts/statechart.mjs +42 -23
- package/skills/dev/dev-statechart/scripts/worker.mjs +33 -7
- package/skills/dev/dev-ui-design/SKILL.md +2 -2
- package/skills/dev/dev-ui-design/references/interaction-review.md +9 -0
- package/skills/dev/dev-verify/SKILL.md +1 -1
- package/skills/dev/dev-verify/references/evidence-storage.md +12 -0
- package/skills/dev/dev-workflow/SKILL.md +6 -6
- package/skills/dev/dev-workflow/references/method-handoffs.md +7 -1
- package/skills/dev/dev-writing/SKILL.md +2 -0
- package/skills/dev/dev-writing/references/library-docs.md +37 -0
- package/skills/home/home-doctor/references/diagnosis.md +2 -2
- package/skills/home/home-doctor/scripts/doctor.mjs +68 -38
- package/skills/home/home-project-changelog/SKILL.md +7 -7
- package/skills/home/home-project-changelog/assets/project-changelog.example.json +188 -0
- package/skills/home/home-project-changelog/assets/project-changelog.schema.json +156 -0
- package/skills/home/home-project-changelog/assets/worker-brief.md +1 -1
- package/skills/home/home-project-changelog/references/git-ranges.md +2 -2
- package/skills/home/home-project-changelog/references/schema.md +61 -0
- package/skills/home/home-project-changelog/references/tools.md +28 -22
- package/skills/home/home-project-changelog/references/workflow.md +12 -9
- package/skills/home/home-project-changelog/references/writing.md +5 -3
- package/skills/home/home-project-changelog/scripts/changelog.mjs +42 -38
- package/skills/home/home-project-changelog/scripts/contract.mjs +40 -3
- package/skills/home/home-project-changelog/scripts/legacy-markdown.mjs +116 -0
- package/skills/home/home-project-changelog/scripts/migrate.mjs +122 -0
- package/skills/home/home-project-changelog/scripts/revision.mjs +2 -196
- package/skills/home/home-project-changelog/scripts/storage.mjs +120 -125
- package/skills/home/home-project-changelog/scripts/summary.mjs +0 -60
- package/skills/home/home-route/SKILL.md +2 -2
- package/skills/home/home-route/references/routing.md +3 -1
- package/skills/home/home-route/scripts/route.mjs +79 -11
- package/skills/home/home-setup/SKILL.md +2 -1
- package/skills/home/home-setup/assets/repos.schema.json +10 -0
- package/skills/home/home-setup/references/registry.md +18 -1
- package/skills/home/home-setup/scripts/registry.mjs +67 -7
- package/skills/home/home-website/SKILL.md +13 -9
- package/skills/home/home-website/assets/website/scripts/inputs.mjs +143 -128
- package/skills/home/home-website/assets/website/scripts/render.mjs +8 -6
- package/skills/home/home-website/assets/website/scripts/site.mjs +21 -10
- package/skills/home/home-website/assets/website/site/public/home-assets/app.js +81 -34
- package/skills/home/home-website/assets/website/site/public/home-assets/site.css +92 -70
- package/skills/home/home-website/assets/website/site/templates/favicon.png +0 -0
- package/skills/home/home-website/assets/website/site/templates/layout.mjs +13 -10
- package/skills/home/home-website/assets/website/site/templates/ledger.mjs +51 -46
- package/skills/home/home-website/assets/website/site/templates/model.mjs +58 -14
- package/skills/home/home-website/assets/website/site/templates/pages.mjs +28 -30
- package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +3 -107
- package/skills/home/home-website/assets/website/site.config.json +1 -1
- package/skills/home/home-website/references/website.md +64 -46
- package/skills/home/home-website/scripts/activate.mjs +106 -0
- package/skills/home/home-website/scripts/init.mjs +98 -11
- package/skills/home/home-workflow/SKILL.md +6 -4
- package/skills/system/system-clash-proxy-config/SKILL.md +21 -0
- package/skills/system/system-clash-proxy-config/agents/openai.yaml +4 -0
- package/skills/system/system-clash-proxy-config/assets/clash-override.js +328 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/browser-privacy.md +2 -2
- package/skills/system/{system-config → system-clash-proxy-config}/references/changes.md +2 -2
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/clash-verge.md +1 -1
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/diagnosis.md +1 -1
- package/skills/system/system-clash-proxy-config/references/dns-workflow.md +42 -0
- package/skills/system/system-clash-proxy-config/references/egress-macos.md +31 -0
- package/skills/system/system-clash-proxy-config/references/egress-windows.md +37 -0
- package/skills/system/system-clash-proxy-config/references/egress.md +12 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/flclash.md +1 -1
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/index.md +1 -1
- package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/linux-cutover.md +29 -0
- package/skills/system/system-clash-proxy-config/references/locale-workflow.md +9 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/mihomo.md +1 -25
- package/skills/system/system-clash-proxy-config/references/session.md +34 -0
- package/skills/system/system-clash-proxy-config/references/subscription.md +29 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/troubleshooting.md +7 -7
- package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/verification.md +2 -0
- package/skills/system/system-clash-proxy-config/scripts/prepare-session.mjs +155 -0
- package/skills/system/system-clash-proxy-config/scripts/run-session.mjs +138 -0
- package/skills/system/system-inspect/SKILL.md +1 -1
- package/skills/system/system-inspect/references/health-audit.md +1 -1
- package/upstream-skills/zh-archify/SKILL.md +11 -11
- package/upstream-skills/zh-archify/assets/template.html +6 -3
- package/upstream-skills/zh-archify/bin/archify.mjs +67 -4
- package/upstream-skills/zh-archify/modules/code-analysis/ARCHITECTURE.md +7 -1
- package/upstream-skills/zh-archify/modules/code-analysis/bin/analyze-run.mjs +2 -1
- package/upstream-skills/zh-archify/modules/code-analysis/bin/check.mjs +29 -15
- package/upstream-skills/zh-archify/modules/code-analysis/bin/drift.mjs +3 -3
- package/upstream-skills/zh-archify/modules/code-analysis/bin/prepare.mjs +5 -6
- package/upstream-skills/zh-archify/modules/code-analysis/bin/serve.mjs +66 -36
- package/upstream-skills/zh-archify/modules/code-analysis/bin/verify-change.mjs +43 -13
- package/upstream-skills/zh-archify/modules/code-analysis/docs/TECH-GUIDE.md +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/docs/USAGE.md +37 -4
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/functions.mjs +7 -5
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/index.mjs +4 -1
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/snapshot-host.mjs +9 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/architecture-drift.mjs +28 -7
- package/upstream-skills/zh-archify/modules/code-analysis/lib/drift-capture.mjs +4 -3
- package/upstream-skills/zh-archify/modules/code-analysis/lib/git-sources.mjs +5 -3
- package/upstream-skills/zh-archify/modules/code-analysis/lib/output.mjs +272 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/pull-request.mjs +34 -4
- package/upstream-skills/zh-archify/modules/code-analysis/lib/task.mjs +4 -2
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-context.mjs +13 -1
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-history.mjs +112 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification.mjs +6 -2
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/atlas.mjs +71 -5
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.css +16 -2
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.js +121 -5
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas3d.js +38 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.css +14 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.js +187 -27
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/verification.js +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/i18n.mjs +9 -0
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/inject.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/page.mjs +11 -6
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/pull-request.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/schemas/ai-task.schema.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/atlas.test.mjs +88 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/duplicates.test.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/external-workflow.test.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.missing.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.valid.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.changed.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/module-cycle.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/function-source-range.test.mjs +10 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/output-recovery.test.mjs +626 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/pull-request.test.mjs +98 -2
- package/upstream-skills/zh-archify/modules/code-analysis/test/review.test.mjs +37 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/source-panel.test.mjs +2 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/task.test.mjs +3 -2
- package/upstream-skills/zh-archify/modules/code-analysis/test/verification-history.test.mjs +216 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/verification.test.mjs +122 -0
- package/upstream-skills/zh-archify/package-lock.json +2 -2
- package/upstream-skills/zh-archify/package.json +1 -1
- package/upstream-skills/zh-archify/references/authoring-contract.md +2 -0
- package/upstream-skills/zh-archify/references/explainer-authoring.md +1 -1
- package/upstream-skills/zh-archify/renderers/architecture/render-architecture.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/class/render-class.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/dataflow/render-dataflow.mjs +2 -1
- package/upstream-skills/zh-archify/renderers/erd/render-erd.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/lifecycle/render-lifecycle.mjs +4 -2
- package/upstream-skills/zh-archify/renderers/sequence/render-sequence.mjs +4 -2
- package/upstream-skills/zh-archify/renderers/shared/cli.mjs +7 -1
- package/upstream-skills/zh-archify/renderers/timeline/render-timeline.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/tree/render-tree.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/waterfall/render-waterfall.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/workflow/render-workflow.mjs +3 -2
- package/upstream-skills/zh-archify/renderers/workflow/workflow-compiler.mjs +68 -7
- package/upstream-skills/zh-archify/skill-release.json +1 -1
- package/upstream-skills/zh-modern-web-guidance/SKILL.md +4 -11
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-detection.md +20 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-model.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/prompt-api.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/summarizer.md +20 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/translator.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/custom-ml-model-inference.md +342 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/data-parallel-computation.md +337 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/improve-next-page-load-performance.md +4 -1
- package/upstream-skills/zh-modern-web-guidance/guides/performance/large-scene-rendering.md +350 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/viewport-aware-dropdowns.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/declarative-dialog-popover-control.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md +29 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/sortable-table.md +1 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/app-menus.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/context-menu.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/copy-button.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/dialog.md +10 -1
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/hovercard.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/menu.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/navbar.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-app-tours.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-toast-notifications.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/toolbar.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/user-experience/content-first-noise-reduction.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/user-experience/natural-interactions.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/webmcp/agentic-javascript-tools.md +27 -0
- package/skills/home/home-project-changelog/assets/project-changelog.md +0 -35
- package/skills/system/system-clash-tun-egress/SKILL.md +0 -22
- package/skills/system/system-clash-tun-egress/agents/openai.yaml +0 -4
- package/skills/system/system-config/SKILL.md +0 -37
- package/skills/system/system-config/agents/openai.yaml +0 -4
- package/skills/system/system-config/references/ai-cli-config.md +0 -75
- package/skills/system/system-config/references/ai-cli-optimization.md +0 -37
- package/skills/system/system-config/references/index.md +0 -12
- package/skills/system/system-config/references/locale-workflow.md +0 -33
- package/skills/system/system-config/references/locale.md +0 -50
- package/skills/system/system-proxy/SKILL.md +0 -40
- package/skills/system/system-proxy/agents/openai.yaml +0 -4
- package/skills/system/system-proxy/assets/protected-rules.yaml +0 -7
- package/skills/system/system-proxy/references/dns-workflow.md +0 -152
- /package/skills/system/{system-config → system-clash-proxy-config}/assets/configuration.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/assets/network.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/acceptance.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-fields.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-misconceptions.md +0 -0
- /package/skills/system/{system-clash-tun-egress/references/troubleshooting.md → system-clash-proxy-config/references/egress-troubleshooting.md} +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-linux.md +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-macos.md +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-windows.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/network-performance.md +0 -0
- /package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/nodes-and-dns.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platform-dns.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platforms.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/tun-dns.md +0 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import {
|
|
2
|
+
doubtKey,
|
|
3
|
+
hasSubtreeMark,
|
|
4
|
+
isNativeAxiom,
|
|
5
|
+
isStandardAxiom,
|
|
6
|
+
spanContainsPlace,
|
|
7
|
+
spanSize,
|
|
8
|
+
} from "../ir.mjs";
|
|
9
|
+
function innermostStepAt(steps, at) {
|
|
10
|
+
let best;
|
|
11
|
+
let bestSize = Number.MAX_SAFE_INTEGER;
|
|
12
|
+
for (const s of steps) {
|
|
13
|
+
if (!spanContainsPlace(s.span, at)) continue;
|
|
14
|
+
const sz = spanSize(s.span);
|
|
15
|
+
if (sz < bestSize) {
|
|
16
|
+
best = s;
|
|
17
|
+
bestSize = sz;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return best?.id;
|
|
21
|
+
}
|
|
22
|
+
function collectEvents(events, out) {
|
|
23
|
+
for (const ev of events) {
|
|
24
|
+
out.push(ev);
|
|
25
|
+
collectEvents(ev.children, out);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function addTaintEntry(map, name, kinds, keys) {
|
|
29
|
+
let entry = map.get(name);
|
|
30
|
+
if (!entry) {
|
|
31
|
+
entry = {
|
|
32
|
+
kinds: new Set(),
|
|
33
|
+
keys: new Set(),
|
|
34
|
+
};
|
|
35
|
+
map.set(name, entry);
|
|
36
|
+
}
|
|
37
|
+
for (const k of kinds) entry.kinds.add(k);
|
|
38
|
+
for (const key of keys) entry.keys.add(key);
|
|
39
|
+
}
|
|
40
|
+
function buildAllTaint(facts, trust, targetDoubtKinds, targetDoubtKeys) {
|
|
41
|
+
const declByName = new Map();
|
|
42
|
+
for (const d of facts.decls) declByName.set(d.name, d);
|
|
43
|
+
const outsideByName = new Map();
|
|
44
|
+
for (const o of facts.outside) outsideByName.set(o.name, o);
|
|
45
|
+
const targetUserName = declByName.get(facts.target)?.userName ?? facts.target;
|
|
46
|
+
const taint = new Map();
|
|
47
|
+
for (const [name, doubts] of trust.below) {
|
|
48
|
+
if (doubts.length === 0) continue;
|
|
49
|
+
addTaintEntry(
|
|
50
|
+
taint,
|
|
51
|
+
name,
|
|
52
|
+
doubts.map((d) => d.kind),
|
|
53
|
+
doubts.map((d) => doubtKey(d)),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
for (const o of facts.outside) {
|
|
57
|
+
const kinds = new Set();
|
|
58
|
+
const keys = new Set();
|
|
59
|
+
for (const ax of o.axioms) {
|
|
60
|
+
if (ax === "sorryAx") {
|
|
61
|
+
kinds.add("sorry");
|
|
62
|
+
if (o.name !== "sorryAx") {
|
|
63
|
+
keys.add(
|
|
64
|
+
doubtKey({
|
|
65
|
+
kind: "sorry",
|
|
66
|
+
in: `${o.name} (${o.home})`,
|
|
67
|
+
at: undefined,
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} else if (isStandardAxiom(ax)) continue;
|
|
72
|
+
else if (isNativeAxiom(ax)) {
|
|
73
|
+
kinds.add("native");
|
|
74
|
+
keys.add(
|
|
75
|
+
doubtKey({
|
|
76
|
+
kind: "native",
|
|
77
|
+
name: ax,
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
} else {
|
|
81
|
+
kinds.add("axiom");
|
|
82
|
+
keys.add(
|
|
83
|
+
doubtKey({
|
|
84
|
+
kind: "axiom",
|
|
85
|
+
name: ax,
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (kinds.size > 0) addTaintEntry(taint, o.name, kinds, keys);
|
|
91
|
+
}
|
|
92
|
+
const directDeclTaint = (d) => {
|
|
93
|
+
const kinds = new Set();
|
|
94
|
+
const keys = new Set();
|
|
95
|
+
const ownerFallback =
|
|
96
|
+
d.visible || d.isUserDef ? d.userName : targetUserName;
|
|
97
|
+
for (const s of d.sorries) {
|
|
98
|
+
const kind = s.synthetic ? "error" : "sorry";
|
|
99
|
+
kinds.add(kind);
|
|
100
|
+
keys.add(
|
|
101
|
+
doubtKey({
|
|
102
|
+
kind,
|
|
103
|
+
in: s.in ?? ownerFallback,
|
|
104
|
+
at: s.at,
|
|
105
|
+
}),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
if (d.kind === "axiom") {
|
|
109
|
+
if (d.name === "sorryAx") {
|
|
110
|
+
kinds.add("sorry");
|
|
111
|
+
} else if (!isStandardAxiom(d.name)) {
|
|
112
|
+
const kind = isNativeAxiom(d.name) ? "native" : "axiom";
|
|
113
|
+
kinds.add(kind);
|
|
114
|
+
keys.add(
|
|
115
|
+
doubtKey({
|
|
116
|
+
kind,
|
|
117
|
+
name: d.name,
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
kinds,
|
|
124
|
+
keys,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
for (const d of facts.decls) {
|
|
128
|
+
if (d.name === facts.target) continue;
|
|
129
|
+
const { kinds, keys } = directDeclTaint(d);
|
|
130
|
+
const seen = new Set([d.name]);
|
|
131
|
+
const queue = d.uses.map((ref) => ({
|
|
132
|
+
ref,
|
|
133
|
+
fromHasSorries: d.sorries.length > 0,
|
|
134
|
+
}));
|
|
135
|
+
while (queue.length > 0) {
|
|
136
|
+
const item = queue.shift();
|
|
137
|
+
const ref = item.ref;
|
|
138
|
+
if (ref === "sorryAx" && item.fromHasSorries) continue;
|
|
139
|
+
if (seen.has(ref) || ref === facts.target) continue;
|
|
140
|
+
seen.add(ref);
|
|
141
|
+
const ext = outsideByName.get(ref);
|
|
142
|
+
if (ext) {
|
|
143
|
+
const extTaint = taint.get(ext.name);
|
|
144
|
+
if (extTaint) {
|
|
145
|
+
for (const k of extTaint.kinds) kinds.add(k);
|
|
146
|
+
for (const key of extTaint.keys) keys.add(key);
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const sub = declByName.get(ref);
|
|
151
|
+
if (sub) {
|
|
152
|
+
const subTaint = directDeclTaint(sub);
|
|
153
|
+
for (const k of subTaint.kinds) kinds.add(k);
|
|
154
|
+
for (const key of subTaint.keys) keys.add(key);
|
|
155
|
+
const subHasSorries = sub.sorries.length > 0;
|
|
156
|
+
for (const next of sub.uses) {
|
|
157
|
+
if (!seen.has(next))
|
|
158
|
+
queue.push({
|
|
159
|
+
ref: next,
|
|
160
|
+
fromHasSorries: subHasSorries,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (kinds.size > 0) addTaintEntry(taint, d.name, kinds, keys);
|
|
166
|
+
}
|
|
167
|
+
if (targetDoubtKinds.size > 0) {
|
|
168
|
+
const targetDecl = declByName.get(facts.target);
|
|
169
|
+
if (targetDecl) {
|
|
170
|
+
for (const member of targetDecl.group) {
|
|
171
|
+
if (member !== facts.target && declByName.has(member)) continue;
|
|
172
|
+
addTaintEntry(taint, member, targetDoubtKinds, targetDoubtKeys);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return taint;
|
|
177
|
+
}
|
|
178
|
+
function findMatchingErrorStep(input) {
|
|
179
|
+
const errorMsgs = input.facts.messages.filter(
|
|
180
|
+
(m) =>
|
|
181
|
+
m.severity === "error" && spanContainsPlace(input.facts.targetSpan, m.at),
|
|
182
|
+
);
|
|
183
|
+
let best;
|
|
184
|
+
for (const ev of input.allEvents) {
|
|
185
|
+
if (ev.assigned.length > 0) continue;
|
|
186
|
+
if (!ev.before.includes(input.goalId)) continue;
|
|
187
|
+
const step = input.stepById.get(ev.step);
|
|
188
|
+
if (!step) continue;
|
|
189
|
+
const matchesError = errorMsgs.some((msg) =>
|
|
190
|
+
spanContainsPlace(step.span, msg.at),
|
|
191
|
+
);
|
|
192
|
+
if (!matchesError) continue;
|
|
193
|
+
const sz = spanSize(step.span);
|
|
194
|
+
if (!best || sz <= best.size) {
|
|
195
|
+
best = {
|
|
196
|
+
text: step.text,
|
|
197
|
+
size: sz,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return best?.text;
|
|
202
|
+
}
|
|
203
|
+
function findFailingStep(input) {
|
|
204
|
+
const matched = findMatchingErrorStep(input);
|
|
205
|
+
if (matched !== undefined) return matched;
|
|
206
|
+
const errorMsgs = input.facts.messages.filter(
|
|
207
|
+
(m) =>
|
|
208
|
+
m.severity === "error" && spanContainsPlace(input.facts.targetSpan, m.at),
|
|
209
|
+
);
|
|
210
|
+
let best;
|
|
211
|
+
for (const ev of input.allEvents) {
|
|
212
|
+
if (ev.assigned.length > 0) continue;
|
|
213
|
+
if (ev.before[0] !== input.goalId) continue;
|
|
214
|
+
const step = input.stepById.get(ev.step);
|
|
215
|
+
if (!step) continue;
|
|
216
|
+
const sz = spanSize(step.span);
|
|
217
|
+
if (!best || sz <= best.size) {
|
|
218
|
+
best = {
|
|
219
|
+
text: step.text,
|
|
220
|
+
size: sz,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (best) return best.text;
|
|
225
|
+
if (errorMsgs.length > 0) {
|
|
226
|
+
const firstLine = errorMsgs[0].text.split(/\r?\n/)[0]?.trim();
|
|
227
|
+
if (firstLine) return firstLine;
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
export function analyzeProofMarks(input) {
|
|
232
|
+
const { roots, script, tree, facts, trust } = input;
|
|
233
|
+
const goalById = new Map();
|
|
234
|
+
for (const g of script.goals) goalById.set(g.id, g);
|
|
235
|
+
const stepById = new Map();
|
|
236
|
+
for (const s of script.steps) stepById.set(s.id, s);
|
|
237
|
+
const targetErrorMsgs = facts.messages.filter(
|
|
238
|
+
(m) => m.severity === "error" && spanContainsPlace(facts.targetSpan, m.at),
|
|
239
|
+
);
|
|
240
|
+
const targetDoubts = trust.below.get(facts.target) ?? [];
|
|
241
|
+
const targetOwn = trust.own.get(facts.target) ?? [];
|
|
242
|
+
const targetDoubtKinds = new Set();
|
|
243
|
+
const targetDoubtKeys = new Set();
|
|
244
|
+
const requiredDoubts = [];
|
|
245
|
+
for (const d of targetDoubts) {
|
|
246
|
+
targetDoubtKinds.add(d.kind);
|
|
247
|
+
targetDoubtKeys.add(doubtKey(d));
|
|
248
|
+
requiredDoubts.push(d);
|
|
249
|
+
}
|
|
250
|
+
for (const p of trust.paths) {
|
|
251
|
+
targetDoubtKinds.add(p.doubt.kind);
|
|
252
|
+
targetDoubtKeys.add(doubtKey(p.doubt));
|
|
253
|
+
requiredDoubts.push(p.doubt);
|
|
254
|
+
}
|
|
255
|
+
if (targetErrorMsgs.length > 0) targetDoubtKinds.add("error");
|
|
256
|
+
const allTaint = buildAllTaint(
|
|
257
|
+
facts,
|
|
258
|
+
trust,
|
|
259
|
+
targetDoubtKinds,
|
|
260
|
+
targetDoubtKeys,
|
|
261
|
+
);
|
|
262
|
+
const allEvents = [];
|
|
263
|
+
collectEvents(script.events, allEvents);
|
|
264
|
+
const sorrySteps = new Set();
|
|
265
|
+
const errorSteps = new Set();
|
|
266
|
+
const stepOwnDoubtKeys = new Map();
|
|
267
|
+
const recordStepOwnKey = (sid, key) => {
|
|
268
|
+
const prev = stepOwnDoubtKeys.get(sid);
|
|
269
|
+
if (prev) prev.add(key);
|
|
270
|
+
else stepOwnDoubtKeys.set(sid, new Set([key]));
|
|
271
|
+
};
|
|
272
|
+
const targetDecl = facts.decls.find((d) => d.name === facts.target);
|
|
273
|
+
if (targetDecl) {
|
|
274
|
+
for (const s of targetDecl.sorries) {
|
|
275
|
+
if (!s.at) continue;
|
|
276
|
+
const sid = innermostStepAt(script.steps, s.at);
|
|
277
|
+
if (sid === undefined) continue;
|
|
278
|
+
if (s.synthetic) errorSteps.add(sid);
|
|
279
|
+
else sorrySteps.add(sid);
|
|
280
|
+
recordStepOwnKey(
|
|
281
|
+
sid,
|
|
282
|
+
doubtKey({
|
|
283
|
+
kind: s.synthetic ? "error" : "sorry",
|
|
284
|
+
in: s.in ?? targetDecl.userName,
|
|
285
|
+
at: s.at,
|
|
286
|
+
}),
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for (const d of targetOwn) {
|
|
291
|
+
if ((d.kind === "sorry" || d.kind === "error") && d.at) {
|
|
292
|
+
const sid = innermostStepAt(script.steps, d.at);
|
|
293
|
+
if (sid !== undefined) recordStepOwnKey(sid, doubtKey(d));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
for (const msg of targetErrorMsgs) {
|
|
297
|
+
const sid = innermostStepAt(script.steps, msg.at);
|
|
298
|
+
if (sid !== undefined) errorSteps.add(sid);
|
|
299
|
+
}
|
|
300
|
+
const directCoveredKeys = new Set();
|
|
301
|
+
const visit = (block) => {
|
|
302
|
+
const marks = new Set(block.marks);
|
|
303
|
+
const restsOnKinds = new Set(block.restsOnKinds);
|
|
304
|
+
let errorLabel = block.errorLabel;
|
|
305
|
+
const visitedInto = block.into.map(visit);
|
|
306
|
+
const childHasError = visitedInto.some((c) => c.marks.has("error"));
|
|
307
|
+
for (const sid of block.steps) {
|
|
308
|
+
if (sorrySteps.has(sid)) marks.add("sorry");
|
|
309
|
+
if (errorSteps.has(sid) && !childHasError) {
|
|
310
|
+
marks.add("error");
|
|
311
|
+
if (errorLabel === undefined) {
|
|
312
|
+
const step = stepById.get(sid);
|
|
313
|
+
if (step) errorLabel = step.text;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const ownKeys = stepOwnDoubtKeys.get(sid);
|
|
317
|
+
if (ownKeys) for (const k of ownKeys) directCoveredKeys.add(k);
|
|
318
|
+
}
|
|
319
|
+
const lastGoal = goalById.get(block.last);
|
|
320
|
+
if (block.into.length === 0 && lastGoal) {
|
|
321
|
+
const closedByStep = tree.closes.has(block.last);
|
|
322
|
+
if (!closedByStep) {
|
|
323
|
+
const matchedError = findMatchingErrorStep({
|
|
324
|
+
goalId: lastGoal.id,
|
|
325
|
+
allEvents,
|
|
326
|
+
stepById,
|
|
327
|
+
facts,
|
|
328
|
+
});
|
|
329
|
+
if (matchedError !== undefined) {
|
|
330
|
+
marks.add("error");
|
|
331
|
+
errorLabel ??= matchedError;
|
|
332
|
+
} else if (lastGoal.closedBy === "error") {
|
|
333
|
+
marks.add("error");
|
|
334
|
+
errorLabel ??= findFailingStep({
|
|
335
|
+
goalId: lastGoal.id,
|
|
336
|
+
allEvents,
|
|
337
|
+
stepById,
|
|
338
|
+
facts,
|
|
339
|
+
});
|
|
340
|
+
} else if (lastGoal.final === "open") {
|
|
341
|
+
marks.add("open");
|
|
342
|
+
} else if (lastGoal.closedBy === "sorry") {
|
|
343
|
+
marks.add("sorry");
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
if (lastGoal.closedBy === "sorry") marks.add("sorry");
|
|
347
|
+
else if (lastGoal.closedBy === "error") marks.add("error");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const hasOwnSorryOrError = marks.has("sorry") || marks.has("error");
|
|
351
|
+
for (const sid of block.steps) {
|
|
352
|
+
const step = stepById.get(sid);
|
|
353
|
+
if (!step) continue;
|
|
354
|
+
for (const name of step.names) {
|
|
355
|
+
if (name === "sorryAx" && hasOwnSorryOrError) continue;
|
|
356
|
+
const entry = allTaint.get(name);
|
|
357
|
+
if (entry && entry.kinds.size > 0) {
|
|
358
|
+
marks.add("restsOn");
|
|
359
|
+
for (const k of entry.kinds) restsOnKinds.add(k);
|
|
360
|
+
for (const key of entry.keys) directCoveredKeys.add(key);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
...block,
|
|
366
|
+
errorLabel,
|
|
367
|
+
marks,
|
|
368
|
+
restsOnKinds,
|
|
369
|
+
into: visitedInto,
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
const directMarked = roots.map(({ root, block }) => ({
|
|
373
|
+
root,
|
|
374
|
+
block: visit(block),
|
|
375
|
+
}));
|
|
376
|
+
const targetHasDoubt = trust.paths.length > 0 || targetDoubts.length > 0;
|
|
377
|
+
const targetHasError = targetErrorMsgs.length > 0;
|
|
378
|
+
const unattributedErrors = targetErrorMsgs.filter(
|
|
379
|
+
(m) => innermostStepAt(script.steps, m.at) === undefined,
|
|
380
|
+
);
|
|
381
|
+
const anyDirectMark = directMarked.some((r) => hasSubtreeMark(r.block));
|
|
382
|
+
const missingDoubt = requiredDoubts.some(
|
|
383
|
+
(d) => !directCoveredKeys.has(doubtKey(d)),
|
|
384
|
+
);
|
|
385
|
+
const unattributedDoubt =
|
|
386
|
+
unattributedErrors.length > 0 ||
|
|
387
|
+
((targetHasDoubt || targetHasError) && !anyDirectMark) ||
|
|
388
|
+
((targetHasDoubt || targetHasError) && script.partial === true) ||
|
|
389
|
+
missingDoubt;
|
|
390
|
+
if ((targetHasDoubt || targetHasError) && !anyDirectMark) {
|
|
391
|
+
const firstError =
|
|
392
|
+
unattributedErrors[0]?.text.split(/\r?\n/)[0]?.trim() ??
|
|
393
|
+
targetErrorMsgs[0]?.text.split(/\r?\n/)[0]?.trim();
|
|
394
|
+
const outRoots = directMarked.map(({ root, block }) => {
|
|
395
|
+
const marks = new Set(block.marks);
|
|
396
|
+
const restsOnKinds = new Set(block.restsOnKinds);
|
|
397
|
+
let errorLabel = block.errorLabel;
|
|
398
|
+
if (targetHasError || targetOwn.some((d) => d.kind === "error")) {
|
|
399
|
+
marks.add("error");
|
|
400
|
+
errorLabel ??= firstError;
|
|
401
|
+
} else if (targetOwn.some((d) => d.kind === "sorry")) {
|
|
402
|
+
marks.add("sorry");
|
|
403
|
+
} else {
|
|
404
|
+
marks.add("restsOn");
|
|
405
|
+
for (const d of targetDoubts) restsOnKinds.add(d.kind);
|
|
406
|
+
if (restsOnKinds.size === 0) {
|
|
407
|
+
for (const p of trust.paths) restsOnKinds.add(p.doubt.kind);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
root,
|
|
412
|
+
block: {
|
|
413
|
+
...block,
|
|
414
|
+
marks,
|
|
415
|
+
restsOnKinds,
|
|
416
|
+
errorLabel,
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
return {
|
|
421
|
+
roots: outRoots,
|
|
422
|
+
unattributedDoubt,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
roots: directMarked,
|
|
427
|
+
unattributedDoubt,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
export function markBlocks(input) {
|
|
431
|
+
return analyzeProofMarks(input).roots;
|
|
432
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { edgeKey } from "../ir.mjs";
|
|
2
|
+
function reachByKind(graph, kind) {
|
|
3
|
+
const memo = new Map();
|
|
4
|
+
const visit = (name) => {
|
|
5
|
+
const cached = memo.get(name);
|
|
6
|
+
if (cached) return cached;
|
|
7
|
+
const out = new Set();
|
|
8
|
+
const lemma = graph.lemmas.get(name);
|
|
9
|
+
if (lemma) {
|
|
10
|
+
for (const edge of lemma.to) {
|
|
11
|
+
if (edge.through !== kind) continue;
|
|
12
|
+
out.add(edge.name);
|
|
13
|
+
for (const sub of visit(edge.name)) out.add(sub);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
memo.set(name, out);
|
|
17
|
+
return out;
|
|
18
|
+
};
|
|
19
|
+
for (const name of graph.lemmas.keys()) visit(name);
|
|
20
|
+
return memo;
|
|
21
|
+
}
|
|
22
|
+
export function reduceLemmas(input) {
|
|
23
|
+
const { graph, trust } = input;
|
|
24
|
+
const protectedEdges = new Set();
|
|
25
|
+
for (const entry of trust.paths) {
|
|
26
|
+
for (let i = 0; i + 1 < entry.path.length; i++) {
|
|
27
|
+
protectedEdges.add(
|
|
28
|
+
edgeKey({
|
|
29
|
+
from: entry.path[i],
|
|
30
|
+
to: entry.path[i + 1],
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const reachProof = reachByKind(graph, "proof");
|
|
36
|
+
const reachDef = reachByKind(graph, "definition");
|
|
37
|
+
const lemmas = new Map();
|
|
38
|
+
let reducedEdges = graph.reducedEdges;
|
|
39
|
+
for (const [name, lemma] of graph.lemmas) {
|
|
40
|
+
const kept = [];
|
|
41
|
+
for (const edge of lemma.to) {
|
|
42
|
+
if (
|
|
43
|
+
protectedEdges.has(
|
|
44
|
+
edgeKey({
|
|
45
|
+
from: name,
|
|
46
|
+
to: edge.name,
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
) {
|
|
50
|
+
kept.push(edge);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const reach = edge.through === "proof" ? reachProof : reachDef;
|
|
54
|
+
const redundant = lemma.to.some(
|
|
55
|
+
(other) =>
|
|
56
|
+
other.through === edge.through &&
|
|
57
|
+
other.name !== edge.name &&
|
|
58
|
+
(reach.get(other.name)?.has(edge.name) ?? false),
|
|
59
|
+
);
|
|
60
|
+
if (redundant) reducedEdges++;
|
|
61
|
+
else kept.push(edge);
|
|
62
|
+
}
|
|
63
|
+
lemmas.set(name, {
|
|
64
|
+
...lemma,
|
|
65
|
+
to: kept,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
target: graph.target,
|
|
70
|
+
lemmas,
|
|
71
|
+
reducedEdges,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { byText, doubtKey, isNativeAxiom, isStandardAxiom } from "../ir.mjs";
|
|
2
|
+
function dedupeDoubts(items) {
|
|
3
|
+
const seen = new Map();
|
|
4
|
+
for (const item of items) {
|
|
5
|
+
const key = doubtKey(item);
|
|
6
|
+
if (!seen.has(key)) seen.set(key, item);
|
|
7
|
+
}
|
|
8
|
+
return [...seen.entries()].sort(([a], [b]) => byText(a, b)).map(([, d]) => d);
|
|
9
|
+
}
|
|
10
|
+
function ownDoubtsOf(lemma) {
|
|
11
|
+
const out = [];
|
|
12
|
+
for (const s of lemma.sorries) {
|
|
13
|
+
out.push({
|
|
14
|
+
kind: s.synthetic ? "error" : "sorry",
|
|
15
|
+
in: s.in,
|
|
16
|
+
at: s.at,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
for (const ax of lemma.axioms) {
|
|
20
|
+
if (ax === "sorryAx") {
|
|
21
|
+
if (lemma.sorries.length === 0)
|
|
22
|
+
out.push({
|
|
23
|
+
kind: "sorry",
|
|
24
|
+
in: lemma.decl.userName,
|
|
25
|
+
at: undefined,
|
|
26
|
+
});
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (isStandardAxiom(ax)) continue;
|
|
30
|
+
if (isNativeAxiom(ax))
|
|
31
|
+
out.push({
|
|
32
|
+
kind: "native",
|
|
33
|
+
name: ax,
|
|
34
|
+
});
|
|
35
|
+
else
|
|
36
|
+
out.push({
|
|
37
|
+
kind: "axiom",
|
|
38
|
+
name: ax,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return dedupeDoubts(out);
|
|
42
|
+
}
|
|
43
|
+
export function analyzeTrust(graph) {
|
|
44
|
+
const own = new Map();
|
|
45
|
+
for (const [name, lemma] of graph.lemmas) own.set(name, ownDoubtsOf(lemma));
|
|
46
|
+
const below = new Map();
|
|
47
|
+
const resolveBelow = (name) => {
|
|
48
|
+
const cached = below.get(name);
|
|
49
|
+
if (cached) return cached;
|
|
50
|
+
const acc = [...(own.get(name) ?? [])];
|
|
51
|
+
const lemma = graph.lemmas.get(name);
|
|
52
|
+
if (lemma) {
|
|
53
|
+
for (const edge of lemma.to) {
|
|
54
|
+
for (const d of resolveBelow(edge.name)) acc.push(d);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const result = dedupeDoubts(acc);
|
|
58
|
+
below.set(name, result);
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
for (const name of graph.lemmas.keys()) resolveBelow(name);
|
|
62
|
+
const parent = new Map([[graph.target, undefined]]);
|
|
63
|
+
const order = [graph.target];
|
|
64
|
+
let idx = 0;
|
|
65
|
+
while (idx < order.length) {
|
|
66
|
+
const cur = order[idx++];
|
|
67
|
+
const lemma = graph.lemmas.get(cur);
|
|
68
|
+
if (!lemma) continue;
|
|
69
|
+
const nextNames = lemma.to.map((e) => e.name).sort(byText);
|
|
70
|
+
for (const next of nextNames) {
|
|
71
|
+
if (parent.has(next)) continue;
|
|
72
|
+
parent.set(next, cur);
|
|
73
|
+
order.push(next);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const pathTo = (node) => {
|
|
77
|
+
const rev = [];
|
|
78
|
+
let cur = node;
|
|
79
|
+
while (cur !== undefined) {
|
|
80
|
+
rev.push(cur);
|
|
81
|
+
cur = parent.get(cur);
|
|
82
|
+
}
|
|
83
|
+
return rev.reverse();
|
|
84
|
+
};
|
|
85
|
+
const seenPath = new Set();
|
|
86
|
+
const paths = [];
|
|
87
|
+
for (const node of order) {
|
|
88
|
+
const doubts = own.get(node) ?? [];
|
|
89
|
+
if (doubts.length === 0) continue;
|
|
90
|
+
const path = pathTo(node);
|
|
91
|
+
for (const doubt of doubts) {
|
|
92
|
+
const key = doubtKey(doubt);
|
|
93
|
+
if (seenPath.has(key)) continue;
|
|
94
|
+
seenPath.add(key);
|
|
95
|
+
paths.push({
|
|
96
|
+
doubt,
|
|
97
|
+
path,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
paths.sort(
|
|
102
|
+
(a, b) =>
|
|
103
|
+
a.path.length - b.path.length ||
|
|
104
|
+
byText(doubtKey(a.doubt), doubtKey(b.doubt)),
|
|
105
|
+
);
|
|
106
|
+
return {
|
|
107
|
+
own,
|
|
108
|
+
below,
|
|
109
|
+
paths,
|
|
110
|
+
};
|
|
111
|
+
}
|