Skip to content

feat(cli): add soul did show and soul did verify commands#276

Open
sshekhar563 wants to merge 4 commits into
qbtrix:devfrom
sshekhar563:feat/did-cli
Open

feat(cli): add soul did show and soul did verify commands#276
sshekhar563 wants to merge 4 commits into
qbtrix:devfrom
sshekhar563:feat/did-cli

Conversation

@sshekhar563

Copy link
Copy Markdown
Collaborator

What

Phase 1 of the DID CLI feature — adds soul did command group for inspecting
and verifying a soul's decentralized identity.

Commands

soul did show <source>

Displays the soul's identity info:

  • Name, DID (did:soul:...), archetype, born date
  • Ed25519 public key (truncated)
  • Private key status (present/absent)
  • Trust chain entry count and key rotation status

soul did verify <source>

Verifies the soul's DID integrity:

  • DID format validation (did:soul: prefix)
  • Public key presence check
  • Trust chain signature verification via Soul.verify_chain()
  • --verbose flag shows individual chain entries

Tests

15 tests added — all passing:

  • TestDidShow (7 tests): name, DID, algorithm, public key, private key status
  • TestDidVerify (5 tests): valid soul, no-keys, verbose, error handling
  • TestDidGroup (3 tests): help text for all commands

Files Changed

  • [NEW] src/soul_protocol/cli/did.py — DID CLI module
  • [MODIFY] src/soul_protocol/cli/main.py — Register did command group
  • [NEW] tests/test_did_cli.py — 15 test cases

@prakashUXtech prakashUXtech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Path and Text imports, and import sys placed after console = Console() trips E402. Moving the sys import to the top clears it.
  • Docs: docs/cli-reference.md and CHANGELOG.md should pick up the new commands in this PR.
  • soul verify already verifies chains with exit codes and --json, and soul audit already renders the chain timeline. The real new value here is the DID and key display. Worth considering whether did verify should delegate the chain check to that shared path (you'd get exit codes and --json for 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.
@sshekhar563 sshekhar563 requested a review from prakashUXtech July 4, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants