claude-mpm 5.4.36__py3-none-any.whl → 5.4.62__py3-none-any.whl
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.
Potentially problematic release.
This version of claude-mpm might be problematic. Click here for more details.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/CLAUDE_MPM_TEACHER_OUTPUT_STYLE.md +5 -0
- claude_mpm/agents/PM_INSTRUCTIONS.md +489 -177
- claude_mpm/agents/base_agent.json +1 -1
- claude_mpm/agents/frontmatter_validator.py +2 -2
- claude_mpm/cli/commands/configure_agent_display.py +12 -0
- claude_mpm/cli/commands/mpm_init/core.py +72 -0
- claude_mpm/cli/commands/profile.py +276 -0
- claude_mpm/cli/commands/skills.py +14 -18
- claude_mpm/cli/executor.py +10 -0
- claude_mpm/cli/parsers/base_parser.py +7 -0
- claude_mpm/cli/parsers/profile_parser.py +147 -0
- claude_mpm/cli/parsers/skills_parser.py +0 -6
- claude_mpm/cli/startup.py +433 -147
- claude_mpm/commands/mpm-config.md +13 -250
- claude_mpm/commands/mpm-doctor.md +9 -22
- claude_mpm/commands/mpm-help.md +5 -206
- claude_mpm/commands/mpm-init.md +81 -507
- claude_mpm/commands/mpm-monitor.md +15 -402
- claude_mpm/commands/mpm-organize.md +61 -441
- claude_mpm/commands/mpm-postmortem.md +6 -108
- claude_mpm/commands/mpm-session-resume.md +12 -363
- claude_mpm/commands/mpm-status.md +5 -69
- claude_mpm/commands/mpm-ticket-view.md +52 -495
- claude_mpm/commands/mpm-version.md +5 -107
- claude_mpm/core/optimized_startup.py +61 -0
- claude_mpm/core/shared/config_loader.py +3 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/0.DWzvg0-y.css +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/2.ThTw9_ym.css +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/{CWc5urbQ.js → 4TdZjIqw.js} +1 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/5shd3_w0.js +24 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/B0uc0UOD.js +36 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/B7RN905-.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/B7xVLGWV.js +2 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BIF9m_hv.js +61 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BKjSRqUr.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BPYeabCQ.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BQaXIfA_.js +331 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/{uj46x2Wr.js → BSNlmTZj.js} +1 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Be7GpZd6.js +7 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Bh0LDWpI.js +145 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BofRWZRR.js +10 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BovzEFCE.js +30 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/C30mlcqg.js +165 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/C4B-KCzX.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/C4JcI4KD.js +122 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CBBdVcY8.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CDuw-vjf.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/C_Usid8X.js +15 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Cfqx1Qun.js +10 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CiIAseT4.js +128 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CmKTTxBW.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CnA0NrzZ.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Cs_tUR18.js +24 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Cu_Erd72.js +261 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CyWMqx4W.js +43 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CzZX-COe.js +220 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CzeYkLYB.js +65 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/D3k0OPJN.js +4 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/D9lljYKQ.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DGkLK5U1.js +267 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DI7hHRFL.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DLVjFsZ3.js +139 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DUrLdbGD.js +89 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DVp1hx9R.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DY1XQ8fi.js +2 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DZX00Y4g.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Da0KfYnO.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DaimHw_p.js +68 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Dfy6j1xT.js +323 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Dhb8PKl3.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Dle-35c7.js +64 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DmxopI1J.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DwBR2MJi.js +60 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/GYwsonyD.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/Gi6I4Gst.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/{DjhvlsAc.js → NqQ1dWOy.js} +1 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/RJiighC3.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/{N4qtv3Hx.js → Vzk33B_K.js} +1 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/ZGh7QtNv.js +7 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/bT1r9zLR.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/bTOqqlTd.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/eNVUfhuA.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/iEWssX7S.js +162 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/sQeU3Y1z.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/uuIeMWc-.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/app.D6-I5TpK.js +2 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/start.NWzMBYRp.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/{0.CAGBuiOw.js → 0.m1gL8KXf.js} +1 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/1.CgNOuw-d.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/2.C0GcWctS.js +1 -0
- claude_mpm/dashboard/static/svelte-build/_app/version.json +1 -1
- claude_mpm/dashboard/static/svelte-build/index.html +10 -10
- claude_mpm/dashboard-svelte/node_modules/katex/src/fonts/generate_fonts.py +58 -0
- claude_mpm/dashboard-svelte/node_modules/katex/src/metrics/extract_tfms.py +114 -0
- claude_mpm/dashboard-svelte/node_modules/katex/src/metrics/extract_ttfs.py +122 -0
- claude_mpm/dashboard-svelte/node_modules/katex/src/metrics/format_json.py +28 -0
- claude_mpm/dashboard-svelte/node_modules/katex/src/metrics/parse_tfm.py +211 -0
- claude_mpm/hooks/kuzu_memory_hook.py +5 -5
- claude_mpm/init.py +276 -0
- claude_mpm/services/agents/agent_builder.py +3 -3
- claude_mpm/services/agents/deployment/agent_deployment.py +22 -0
- claude_mpm/services/agents/deployment/agent_discovery_service.py +3 -1
- claude_mpm/services/agents/deployment/agent_format_converter.py +25 -13
- claude_mpm/services/agents/deployment/agent_template_builder.py +37 -17
- claude_mpm/services/agents/deployment/async_agent_deployment.py +31 -27
- claude_mpm/services/agents/deployment/local_template_deployment.py +3 -1
- claude_mpm/services/agents/deployment/multi_source_deployment_service.py +149 -4
- claude_mpm/services/agents/deployment/remote_agent_discovery_service.py +47 -26
- claude_mpm/services/agents/git_source_manager.py +21 -2
- claude_mpm/services/agents/sources/git_source_sync_service.py +116 -5
- claude_mpm/services/monitor/management/lifecycle.py +7 -1
- claude_mpm/services/pm_skills_deployer.py +711 -0
- claude_mpm/services/profile_manager.py +337 -0
- claude_mpm/services/skills/git_skill_source_manager.py +148 -11
- claude_mpm/services/skills/selective_skill_deployer.py +97 -48
- claude_mpm/services/skills_deployer.py +161 -65
- claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +79 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +178 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/agent-prompts.md +577 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/coordination-patterns.md +467 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/examples.md +537 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/troubleshooting.md +730 -0
- claude_mpm/skills/bundled/collaboration/git-worktrees.md +317 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +112 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/references/code-reviewer-template.md +146 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/references/review-examples.md +412 -0
- claude_mpm/skills/bundled/collaboration/stacked-prs.md +251 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +81 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/references/best-practices.md +362 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/references/plan-structure-templates.md +312 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +152 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/advanced-techniques.md +668 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/examples.md +587 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/integration.md +438 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/tracing-techniques.md +391 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +131 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +325 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/integration-and-workflows.md +490 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/red-flags-and-failures.md +425 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +499 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/INTEGRATION.md +611 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/README.md +596 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/SKILL.md +260 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/examples/nextjs-env-structure.md +315 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/frameworks.md +436 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/security.md +433 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/synchronization.md +452 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/troubleshooting.md +404 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/validation.md +420 -0
- claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +86 -0
- claude_mpm/skills/bundled/main/internal-comms/SKILL.md +43 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
- claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +160 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/design_principles.md +412 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/workflow.md +1237 -0
- claude_mpm/skills/bundled/main/skill-creator/SKILL.md +189 -0
- claude_mpm/skills/bundled/main/skill-creator/references/best-practices.md +500 -0
- claude_mpm/skills/bundled/main/skill-creator/references/creation-workflow.md +464 -0
- claude_mpm/skills/bundled/main/skill-creator/references/examples.md +619 -0
- claude_mpm/skills/bundled/main/skill-creator/references/progressive-disclosure.md +437 -0
- claude_mpm/skills/bundled/main/skill-creator/references/skill-structure.md +231 -0
- claude_mpm/skills/bundled/php/espocrm-development/SKILL.md +170 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/architecture.md +602 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/common-tasks.md +821 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/development-workflow.md +742 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/frontend-customization.md +726 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/hooks-and-services.md +764 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/testing-debugging.md +831 -0
- claude_mpm/skills/bundled/pm/pm-delegation-patterns/SKILL.md +167 -0
- claude_mpm/skills/bundled/pm/pm-git-file-tracking/SKILL.md +113 -0
- claude_mpm/skills/bundled/pm/pm-pr-workflow/SKILL.md +124 -0
- claude_mpm/skills/bundled/pm/pm-ticketing-integration/SKILL.md +154 -0
- claude_mpm/skills/bundled/pm/pm-verification-protocols/SKILL.md +198 -0
- claude_mpm/skills/bundled/react/flexlayout-react.md +742 -0
- claude_mpm/skills/bundled/rust/desktop-applications/SKILL.md +226 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/architecture-patterns.md +901 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/native-gui-frameworks.md +901 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/platform-integration.md +775 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/state-management.md +937 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/tauri-framework.md +770 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/testing-deployment.md +961 -0
- claude_mpm/skills/bundled/security-scanning.md +112 -0
- claude_mpm/skills/bundled/tauri/tauri-async-patterns.md +495 -0
- claude_mpm/skills/bundled/tauri/tauri-build-deploy.md +599 -0
- claude_mpm/skills/bundled/tauri/tauri-command-patterns.md +535 -0
- claude_mpm/skills/bundled/tauri/tauri-error-handling.md +613 -0
- claude_mpm/skills/bundled/tauri/tauri-event-system.md +648 -0
- claude_mpm/skills/bundled/tauri/tauri-file-system.md +673 -0
- claude_mpm/skills/bundled/tauri/tauri-frontend-integration.md +767 -0
- claude_mpm/skills/bundled/tauri/tauri-performance.md +669 -0
- claude_mpm/skills/bundled/tauri/tauri-state-management.md +573 -0
- claude_mpm/skills/bundled/tauri/tauri-testing.md +384 -0
- claude_mpm/skills/bundled/tauri/tauri-window-management.md +628 -0
- claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +119 -0
- claude_mpm/skills/bundled/testing/condition-based-waiting/references/patterns-and-implementation.md +253 -0
- claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/SKILL.md +458 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/examples/example-inspection-report.md +411 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/references/assertion-quality.md +317 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/references/inspection-checklist.md +270 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/references/red-flags.md +436 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +140 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md +572 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/core-anti-patterns.md +411 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/detection-guide.md +569 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/tdd-connection.md +695 -0
- claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +184 -0
- claude_mpm/skills/bundled/testing/webapp-testing/decision-tree.md +459 -0
- claude_mpm/skills/bundled/testing/webapp-testing/playwright-patterns.md +479 -0
- claude_mpm/skills/bundled/testing/webapp-testing/reconnaissance-pattern.md +687 -0
- claude_mpm/skills/bundled/testing/webapp-testing/server-management.md +758 -0
- claude_mpm/skills/bundled/testing/webapp-testing/troubleshooting.md +868 -0
- claude_mpm/skills/skill_manager.py +98 -3
- claude_mpm/templates/.pre-commit-config.yaml +112 -0
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/METADATA +3 -2
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/RECORD +244 -68
- claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/0.B_FtCwCQ.css +0 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/2.Cl_eSA4x.css +0 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BgChzWQ1.js +0 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CIXEwuWe.js +0 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DMkZpdF2.js +0 -2
- claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/app.DTL5mJO-.js +0 -2
- claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/start.DzuEhzqh.js +0 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/1.DFLC8jdE.js +0 -1
- claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/2.DPvEihJJ.js +0 -10
- claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager.cpython-311.pyc +0 -0
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/WHEEL +0 -0
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/entry_points.txt +0 -0
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/licenses/LICENSE-FAQ.md +0 -0
- {claude_mpm-5.4.36.dist-info → claude_mpm-5.4.62.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
# Real-World Tracing Examples
|
|
2
|
+
|
|
3
|
+
Detailed examples showing complete root cause tracing processes with full trace chains and solutions.
|
|
4
|
+
|
|
5
|
+
## Example 1: Git Init in Wrong Directory
|
|
6
|
+
|
|
7
|
+
### The Symptom
|
|
8
|
+
|
|
9
|
+
**Observed behavior:**
|
|
10
|
+
```bash
|
|
11
|
+
$ npm test
|
|
12
|
+
...
|
|
13
|
+
Error: fatal: .git directory created in /Users/jesse/project/packages/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Tests were creating a `.git` directory in the source code folder instead of a temporary directory.
|
|
17
|
+
|
|
18
|
+
### Initial Investigation
|
|
19
|
+
|
|
20
|
+
**First thought:** "Just validate the directory parameter in git init"
|
|
21
|
+
|
|
22
|
+
**WRONG:** This would be a symptom fix. We need to find WHY the directory is wrong.
|
|
23
|
+
|
|
24
|
+
### The Trace
|
|
25
|
+
|
|
26
|
+
#### Step 1: Find Immediate Cause
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// worktree-manager.ts:45
|
|
30
|
+
async function createSessionWorktree(projectDir: string, sessionId: string) {
|
|
31
|
+
// This line creates .git in wrong place
|
|
32
|
+
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Discovery:** `projectDir` is an empty string `''`
|
|
37
|
+
**Why is this wrong:** Empty string as `cwd` resolves to `process.cwd()` (current directory)
|
|
38
|
+
|
|
39
|
+
#### Step 2: Where Does Empty String Come From?
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// session.ts:34
|
|
43
|
+
static async create(name: string, projectDir: string) {
|
|
44
|
+
const session = new Session(name);
|
|
45
|
+
await session.initializeWorkspace(projectDir); // ← calls worktree manager
|
|
46
|
+
return session;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Discovery:** Session.create() receives `projectDir = ''`
|
|
51
|
+
**Question:** Where does Session.create() get this value?
|
|
52
|
+
|
|
53
|
+
#### Step 3: Trace to Caller
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// project.ts:67
|
|
57
|
+
static async create(name: string, directory: string) {
|
|
58
|
+
await Session.create(name, directory); // ← passes directory through
|
|
59
|
+
// ...
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Discovery:** Project.create() also receives `directory = ''`
|
|
64
|
+
**Question:** What calls Project.create() with empty string?
|
|
65
|
+
|
|
66
|
+
#### Step 4: Check Test Code
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// project.test.ts:12
|
|
70
|
+
const context = setupCoreTest();
|
|
71
|
+
const PROJECT_DIR = context.tempDir; // ← Accessed at module load time!
|
|
72
|
+
|
|
73
|
+
describe('Project', () => {
|
|
74
|
+
it('should create project', async () => {
|
|
75
|
+
await Project.create('test-project', PROJECT_DIR);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Discovery:** `PROJECT_DIR` is set to `context.tempDir` at module load time
|
|
81
|
+
**Question:** What is `context.tempDir` at module load time?
|
|
82
|
+
|
|
83
|
+
#### Step 5: Root Cause Found
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// test-setup.ts
|
|
87
|
+
export function setupCoreTest() {
|
|
88
|
+
let _tempDir = ''; // ← Initial value is empty string
|
|
89
|
+
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
_tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-'));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
afterEach(() => {
|
|
95
|
+
if (_tempDir) fs.rmSync(_tempDir, { recursive: true });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
tempDir: _tempDir // ← Returns empty string at module load time
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**ROOT CAUSE:** The test accesses `context.tempDir` at module load time (when defining `PROJECT_DIR`), but `_tempDir` is only set during `beforeEach`. At module load time, it's still `''`.
|
|
105
|
+
|
|
106
|
+
### The Solution
|
|
107
|
+
|
|
108
|
+
#### Fix at Source
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
export function setupCoreTest() {
|
|
112
|
+
let _tempDir: string | null = null; // ← null instead of empty string
|
|
113
|
+
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
_tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-'));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
afterEach(() => {
|
|
119
|
+
if (_tempDir) fs.rmSync(_tempDir, { recursive: true });
|
|
120
|
+
_tempDir = null;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
get tempDir(): string {
|
|
125
|
+
if (!_tempDir) {
|
|
126
|
+
throw new Error('tempDir accessed before beforeEach ran');
|
|
127
|
+
}
|
|
128
|
+
return _tempDir;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Why this works:**
|
|
135
|
+
- Accessing `context.tempDir` at module load time now throws immediately
|
|
136
|
+
- Forces tests to access it only within test cases
|
|
137
|
+
- Clear error message guides developers to fix
|
|
138
|
+
|
|
139
|
+
#### Add Defense-in-Depth
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
// Layer 1: Project.create() validates directory
|
|
143
|
+
static async create(name: string, directory: string) {
|
|
144
|
+
if (!directory || directory.trim() === '') {
|
|
145
|
+
throw new Error('Project directory cannot be empty');
|
|
146
|
+
}
|
|
147
|
+
// ...
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Layer 2: WorkspaceManager validates not empty
|
|
151
|
+
async function initializeWorkspace(projectDir: string) {
|
|
152
|
+
if (!projectDir) {
|
|
153
|
+
throw new Error('projectDir cannot be empty');
|
|
154
|
+
}
|
|
155
|
+
// ...
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Layer 3: NODE_ENV guard refuses git init outside tmpdir
|
|
159
|
+
async function createSessionWorktree(projectDir: string, sessionId: string) {
|
|
160
|
+
if (process.env.NODE_ENV === 'test' && !projectDir.includes('tmp')) {
|
|
161
|
+
throw new Error(`Test safety: refusing git init outside tmpdir: ${projectDir}`);
|
|
162
|
+
}
|
|
163
|
+
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Layer 4: Stack trace logging before git init
|
|
167
|
+
async function createSessionWorktree(projectDir: string, sessionId: string) {
|
|
168
|
+
if (!projectDir || projectDir === process.cwd()) {
|
|
169
|
+
console.error('DEBUG git init:', {
|
|
170
|
+
projectDir,
|
|
171
|
+
cwd: process.cwd(),
|
|
172
|
+
stack: new Error().stack
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
await execFileAsync('git', ['init'], { cwd: projectDir });
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Results
|
|
180
|
+
|
|
181
|
+
- 1847 tests passed
|
|
182
|
+
- Zero `.git` pollution
|
|
183
|
+
- Clear error message for similar issues
|
|
184
|
+
- Multiple layers prevent similar bugs
|
|
185
|
+
|
|
186
|
+
### Time Saved
|
|
187
|
+
|
|
188
|
+
**With root cause tracing:** 45 minutes
|
|
189
|
+
**Without (symptom fixes):** 3+ hours of whack-a-mole
|
|
190
|
+
|
|
191
|
+
## Example 2: Database Connection URL Wrong
|
|
192
|
+
|
|
193
|
+
### The Symptom
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
Error: Connection failed: database "undefined" does not exist
|
|
197
|
+
at Database.connect (database.ts:34)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Application crashes on startup because database name is undefined.
|
|
201
|
+
|
|
202
|
+
### The Trace
|
|
203
|
+
|
|
204
|
+
#### Step 1: Find Immediate Cause
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// database.ts:34
|
|
208
|
+
async function connect(url: string) {
|
|
209
|
+
this.connection = await pg.connect(url); // ← Crashes here
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Discovery:** `url = "postgresql://localhost/undefined"`
|
|
214
|
+
**Why is this wrong:** Database name is literally the string "undefined"
|
|
215
|
+
|
|
216
|
+
#### Step 2: Where Does URL Come From?
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// database.ts:12
|
|
220
|
+
constructor(config: DatabaseConfig) {
|
|
221
|
+
this.url = `postgresql://${config.host}/${config.database}`; // ← constructs URL
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Discovery:** `config.database = undefined`
|
|
226
|
+
**Question:** Where does config come from?
|
|
227
|
+
|
|
228
|
+
#### Step 3: Trace to Configuration Loading
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// app.ts:23
|
|
232
|
+
const dbConfig: DatabaseConfig = {
|
|
233
|
+
host: process.env.DATABASE_HOST || 'localhost',
|
|
234
|
+
database: process.env.DATABASE_NAME, // ← No default value!
|
|
235
|
+
port: parseInt(process.env.DATABASE_PORT || '5432')
|
|
236
|
+
};
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Discovery:** `DATABASE_NAME` environment variable is not set
|
|
240
|
+
**Question:** Why isn't it set?
|
|
241
|
+
|
|
242
|
+
#### Step 4: Check Environment Setup
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
// .env file
|
|
246
|
+
DATABASE_HOST=localhost
|
|
247
|
+
DATABASE_PORT=5432
|
|
248
|
+
# DATABASE_NAME missing!
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**ROOT CAUSE:** Environment variable not defined, and code doesn't validate required variables.
|
|
252
|
+
|
|
253
|
+
### The Solution
|
|
254
|
+
|
|
255
|
+
#### Fix at Source
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
// config.ts - Load and validate environment
|
|
259
|
+
export function loadDatabaseConfig(): DatabaseConfig {
|
|
260
|
+
const requiredEnvVars = ['DATABASE_NAME', 'DATABASE_HOST'];
|
|
261
|
+
const missing = requiredEnvVars.filter(v => !process.env[v]);
|
|
262
|
+
|
|
263
|
+
if (missing.length > 0) {
|
|
264
|
+
throw new Error(`Required environment variables missing: ${missing.join(', ')}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
host: process.env.DATABASE_HOST!,
|
|
269
|
+
database: process.env.DATABASE_NAME!,
|
|
270
|
+
port: parseInt(process.env.DATABASE_PORT || '5432')
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Add Defense-in-Depth
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Layer 1: Type-safe config with validation
|
|
279
|
+
interface DatabaseConfig {
|
|
280
|
+
host: string;
|
|
281
|
+
database: string;
|
|
282
|
+
port: number;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Layer 2: Constructor validates config
|
|
286
|
+
constructor(config: DatabaseConfig) {
|
|
287
|
+
if (!config.database || config.database === 'undefined') {
|
|
288
|
+
throw new Error('Database name cannot be empty or undefined');
|
|
289
|
+
}
|
|
290
|
+
this.url = `postgresql://${config.host}/${config.database}`;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Layer 3: Validate URL before connect
|
|
294
|
+
async function connect(url: string) {
|
|
295
|
+
if (url.includes('/undefined')) {
|
|
296
|
+
throw new Error(`Invalid database URL: ${url}`);
|
|
297
|
+
}
|
|
298
|
+
this.connection = await pg.connect(url);
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Results
|
|
303
|
+
|
|
304
|
+
- Application fails fast at startup with clear error
|
|
305
|
+
- Developers immediately know which env var is missing
|
|
306
|
+
- Prevents confusing "database undefined does not exist" error
|
|
307
|
+
|
|
308
|
+
## Example 3: User ID = 0 in Database Query
|
|
309
|
+
|
|
310
|
+
### The Symptom
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
Error: Cannot query user: id cannot be 0
|
|
314
|
+
at UserRepository.findById (user-repository.ts:45)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Database query fails because user ID is 0 (invalid).
|
|
318
|
+
|
|
319
|
+
### The Trace
|
|
320
|
+
|
|
321
|
+
#### Step 1: Find Immediate Cause
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
// user-repository.ts:45
|
|
325
|
+
async findById(id: number): Promise<User> {
|
|
326
|
+
if (id === 0) {
|
|
327
|
+
throw new Error('Cannot query user: id cannot be 0');
|
|
328
|
+
}
|
|
329
|
+
return await this.db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Discovery:** `id = 0` being passed to query
|
|
334
|
+
**Question:** Where does this come from?
|
|
335
|
+
|
|
336
|
+
#### Step 2: Trace to Caller
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
// auth-middleware.ts:67
|
|
340
|
+
async authenticate(req: Request): Promise<User> {
|
|
341
|
+
const userId = this.extractUserId(req);
|
|
342
|
+
return await this.userRepo.findById(userId); // ← userId is 0
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Discovery:** `extractUserId()` returns 0
|
|
347
|
+
**Question:** Why does it return 0?
|
|
348
|
+
|
|
349
|
+
#### Step 3: Check ID Extraction
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
// auth-middleware.ts:34
|
|
353
|
+
private extractUserId(req: Request): number {
|
|
354
|
+
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
355
|
+
if (!token) return 0; // ← Default to 0 if no token!
|
|
356
|
+
|
|
357
|
+
const decoded = jwt.verify(token, SECRET);
|
|
358
|
+
return decoded.userId;
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Discovery:** Returns 0 when no authorization header
|
|
363
|
+
**Question:** Why is there no authorization header?
|
|
364
|
+
|
|
365
|
+
#### Step 4: Check Request Handling
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
// router.ts:23
|
|
369
|
+
app.get('/api/user/profile', async (req, res) => {
|
|
370
|
+
const user = await authMiddleware.authenticate(req); // ← Called on public route!
|
|
371
|
+
res.json(user);
|
|
372
|
+
});
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
**ROOT CAUSE:** Authentication middleware called on public route that doesn't require authentication. When no token present, it defaults to userId=0.
|
|
376
|
+
|
|
377
|
+
### The Solution
|
|
378
|
+
|
|
379
|
+
#### Fix at Source
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
// router.ts - Separate public and protected routes
|
|
383
|
+
app.get('/api/public/profile', async (req, res) => {
|
|
384
|
+
// Public route - no authentication
|
|
385
|
+
res.json({ message: 'Public profile' });
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
app.get('/api/user/profile',
|
|
389
|
+
requireAuth(), // ← Middleware throws if no auth
|
|
390
|
+
async (req, res) => {
|
|
391
|
+
const user = await authMiddleware.authenticate(req);
|
|
392
|
+
res.json(user);
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### Add Defense-in-Depth
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
// Layer 1: Don't default to 0, throw instead
|
|
401
|
+
private extractUserId(req: Request): number {
|
|
402
|
+
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
403
|
+
if (!token) {
|
|
404
|
+
throw new UnauthorizedError('No authorization token provided');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const decoded = jwt.verify(token, SECRET);
|
|
408
|
+
return decoded.userId;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Layer 2: Validate userId before query
|
|
412
|
+
async findById(id: number): Promise<User> {
|
|
413
|
+
if (!id || id <= 0) {
|
|
414
|
+
throw new Error(`Invalid user ID: ${id}`);
|
|
415
|
+
}
|
|
416
|
+
return await this.db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Layer 3: Type system (use branded types)
|
|
420
|
+
type UserId = number & { readonly __brand: 'UserId' };
|
|
421
|
+
|
|
422
|
+
function validateUserId(id: number): UserId {
|
|
423
|
+
if (!id || id <= 0) throw new Error('Invalid user ID');
|
|
424
|
+
return id as UserId;
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Results
|
|
429
|
+
|
|
430
|
+
- Authentication errors are clear and immediate
|
|
431
|
+
- Protected routes always require authentication
|
|
432
|
+
- No magic "0" default that causes confusing errors
|
|
433
|
+
|
|
434
|
+
## Example 4: React Component Renders Wrong Data
|
|
435
|
+
|
|
436
|
+
### The Symptom
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
Component shows data from previous user after logout/login
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
User logs out, logs in as different user, but sees previous user's data briefly.
|
|
443
|
+
|
|
444
|
+
### The Trace
|
|
445
|
+
|
|
446
|
+
#### Step 1: Observe Behavior
|
|
447
|
+
|
|
448
|
+
- User A logs in → sees correct data
|
|
449
|
+
- User A logs out → data clears
|
|
450
|
+
- User B logs in → sees User A's data for ~100ms
|
|
451
|
+
- After 100ms → sees correct User B data
|
|
452
|
+
|
|
453
|
+
**Discovery:** Stale data being shown before new data loads
|
|
454
|
+
|
|
455
|
+
#### Step 2: Check Component Data Source
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
// UserDashboard.tsx
|
|
459
|
+
function UserDashboard() {
|
|
460
|
+
const user = useSelector(state => state.auth.user);
|
|
461
|
+
const data = useSelector(state => state.userData.data);
|
|
462
|
+
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
dispatch(fetchUserData(user.id)); // ← Fetches new data
|
|
465
|
+
}, [user.id]);
|
|
466
|
+
|
|
467
|
+
return <div>{data.name}</div>; // ← Shows stale data during fetch
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Discovery:** Redux store still has old user's data when new user logs in
|
|
472
|
+
**Question:** Why isn't the old data cleared?
|
|
473
|
+
|
|
474
|
+
#### Step 3: Check Login/Logout Actions
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
// auth.actions.ts
|
|
478
|
+
export function logout() {
|
|
479
|
+
return { type: 'LOGOUT' }; // ← Only clears auth state
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// auth.reducer.ts
|
|
483
|
+
case 'LOGOUT':
|
|
484
|
+
return { user: null }; // ← Only clears user
|
|
485
|
+
|
|
486
|
+
// userData.reducer.ts (SEPARATE REDUCER)
|
|
487
|
+
case 'FETCH_USER_DATA':
|
|
488
|
+
return { ...state, data: action.payload }; // ← Never cleared!
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**ROOT CAUSE:** Logout action only clears auth state, not user data. User data reducer never listens to LOGOUT action.
|
|
492
|
+
|
|
493
|
+
### The Solution
|
|
494
|
+
|
|
495
|
+
#### Fix at Source
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
// userData.reducer.ts
|
|
499
|
+
import { LOGOUT } from './auth.actions';
|
|
500
|
+
|
|
501
|
+
case LOGOUT:
|
|
502
|
+
return initialState; // ← Clear data on logout
|
|
503
|
+
|
|
504
|
+
case 'FETCH_USER_DATA':
|
|
505
|
+
return { ...state, data: action.payload };
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### Add Defense-in-Depth
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
// Layer 1: Clear all data on logout
|
|
512
|
+
export function logout() {
|
|
513
|
+
return (dispatch) => {
|
|
514
|
+
dispatch({ type: 'LOGOUT' });
|
|
515
|
+
dispatch({ type: 'CLEAR_USER_DATA' });
|
|
516
|
+
dispatch({ type: 'CLEAR_PREFERENCES' });
|
|
517
|
+
dispatch({ type: 'CLEAR_CACHE' });
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Layer 2: Check user ID matches before showing data
|
|
522
|
+
function UserDashboard() {
|
|
523
|
+
const user = useSelector(state => state.auth.user);
|
|
524
|
+
const userData = useSelector(state => state.userData.data);
|
|
525
|
+
|
|
526
|
+
// Don't show data if user IDs don't match
|
|
527
|
+
const dataIsValid = userData && userData.userId === user?.id;
|
|
528
|
+
|
|
529
|
+
return <div>{dataIsValid ? userData.name : 'Loading...'}</div>;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// Layer 3: Reset all reducers on logout
|
|
533
|
+
const appReducer = combineReducers({
|
|
534
|
+
auth: authReducer,
|
|
535
|
+
userData: userDataReducer,
|
|
536
|
+
// ...
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
const rootReducer = (state, action) => {
|
|
540
|
+
if (action.type === 'LOGOUT') {
|
|
541
|
+
state = undefined; // ← Reset entire store
|
|
542
|
+
}
|
|
543
|
+
return appReducer(state, action);
|
|
544
|
+
};
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### Results
|
|
548
|
+
|
|
549
|
+
- No stale data shown after logout
|
|
550
|
+
- Clean state for each user session
|
|
551
|
+
- Prevents data leakage between users
|
|
552
|
+
|
|
553
|
+
## Common Patterns Across Examples
|
|
554
|
+
|
|
555
|
+
### Pattern: Unvalidated Input at Boundaries
|
|
556
|
+
|
|
557
|
+
**Examples:**
|
|
558
|
+
- Git init: Empty string not caught at entry point
|
|
559
|
+
- Database: Missing env var not validated at startup
|
|
560
|
+
- User ID: Missing token defaulted to 0
|
|
561
|
+
|
|
562
|
+
**Solution:** Validate at system boundaries (entry points, config loading)
|
|
563
|
+
|
|
564
|
+
### Pattern: State Not Cleared on Transitions
|
|
565
|
+
|
|
566
|
+
**Examples:**
|
|
567
|
+
- Test setup: tempDir accessed before initialization
|
|
568
|
+
- React: User data not cleared on logout
|
|
569
|
+
|
|
570
|
+
**Solution:** Explicit state transitions with cleanup
|
|
571
|
+
|
|
572
|
+
### Pattern: Magic Default Values
|
|
573
|
+
|
|
574
|
+
**Examples:**
|
|
575
|
+
- Empty string defaulting to process.cwd()
|
|
576
|
+
- 0 as default user ID
|
|
577
|
+
- undefined becoming string "undefined"
|
|
578
|
+
|
|
579
|
+
**Solution:** No magic defaults - fail fast with errors
|
|
580
|
+
|
|
581
|
+
## Takeaways
|
|
582
|
+
|
|
583
|
+
1. **Never stop at symptoms** - Always trace to root cause
|
|
584
|
+
2. **Fix at source** - Don't add bandaids at error point
|
|
585
|
+
3. **Add defense** - Multiple layers catch similar issues
|
|
586
|
+
4. **Document trace** - Write down call chain as you go
|
|
587
|
+
5. **Verify fix** - Ensure fix addresses root cause, not just symptom
|