feat(cli): add soul did show and soul did verify commands#276
feat(cli): add soul did show and soul did verify commands#276sshekhar563 wants to merge 4 commits into
soul did show and soul did verify commands#276Conversation
prakashUXtech
left a comment
There was a problem hiding this comment.
Nice work getting soul did off the ground. The Rich output panels read well, and the small conventions are all in place: lazy Soul import inside the command, the file-header comment, click.Path(exists=True) matching the other commands.
There are a couple of correctness issues in did verify that I hit by running the branch, so I'd like those sorted before it goes in.
1. did verify exits 0 even when verification fails. Pointed at a soul with a tampered trust chain, it prints the red "Verification failed" panel but still returns exit code 0. The existing soul verify returns 1 in the same case. Anything scripting soul did verify x.soul && ... would treat a forged soul as valid, so this needs sys.exit(1) on any failed check.
2. did verify --verbose crashes on a soul that has chain entries. The verbose table reads entry.ts, but the field on TrustEntry is timestamp, so it raises AttributeError on the first non-empty chain.
3. The test fixture's trust chain is empty, which is why 1 and 2 slipped past 15 green tests. The fixture builds the soul with birth() + remember(), and remember() doesn't append trust-chain entries. So every test runs the empty-chain path and verify_chain() never actually executes. Using observe() in the fixture gives you a real chain to verify against, plus a tampered-chain case to assert the non-zero exit.
Smaller things:
- ruff fails on the branch: unused
PathandTextimports, andimport sysplaced afterconsole = Console()trips E402. Moving thesysimport to the top clears it. - Docs:
docs/cli-reference.mdandCHANGELOG.mdshould pick up the new commands in this PR. soul verifyalready verifies chains with exit codes and--json, andsoul auditalready renders the chain timeline. The real new value here is the DID and key display. Worth considering whetherdid verifyshould delegate the chain check to that shared path (you'd get exit codes and--jsonfor free), or a note in the PR on why you'd rather keep it separate.
One heads-up that isn't on you: none of the ruff issues showed up as a check because CI doesn't currently run lint or tests on PRs targeting dev. That's a repo gap, and I'm fixing it in a separate PR.
Phase 1 of the DID CLI feature. Adds two new subcommands: - soul did show: displays DID, public key, algorithm, trust chain length - soul did verify: verifies DID format, public key, and trust chain integrity - 15 tests added (all passing) - Windows-safe Unicode symbols for cross-platform support
- did verify exits 1 on failed checks (was always 0) - Fix verbose crash: use entry.timestamp not entry.ts - Fix ruff: remove unused Path/Text imports, move sys to top - Add real trust chain tests using observe() with Interaction - Add tampered chain test asserting non-zero exit code - 18 tests all passing
- Fix P1: missing public key now fails verify (all_ok includes pub_valid) - Add soul did show and soul did verify to docs/cli-reference.md
- Soul.awaken() regenerates keys in memory, so checking the runtime keystore falsely reported keys as present even if they were stripped from the archive. - Added _source_has_public_key() helper to inspect zip archive / folder contents directly.
What
Phase 1 of the DID CLI feature — adds
soul didcommand group for inspectingand verifying a soul's decentralized identity.
Commands
soul did show <source>Displays the soul's identity info:
did:soul:...), archetype, born datesoul did verify <source>Verifies the soul's DID integrity:
did:soul:prefix)Soul.verify_chain()--verboseflag shows individual chain entriesTests
15 tests added — all passing:
TestDidShow(7 tests): name, DID, algorithm, public key, private key statusTestDidVerify(5 tests): valid soul, no-keys, verbose, error handlingTestDidGroup(3 tests): help text for all commandsFiles Changed
src/soul_protocol/cli/did.py— DID CLI modulesrc/soul_protocol/cli/main.py— Registerdidcommand grouptests/test_did_cli.py— 15 test cases