Skip to content

Claude/add claude documentation k8vv j#88

Merged
wrhalpin merged 2 commits into
mainfrom
claude/add-claude-documentation-k8vvJ
Apr 8, 2026
Merged

Claude/add claude documentation k8vv j#88
wrhalpin merged 2 commits into
mainfrom
claude/add-claude-documentation-k8vvJ

Conversation

@wrhalpin
Copy link
Copy Markdown
Owner

@wrhalpin wrhalpin commented Apr 8, 2026

No description provided.

claude added 2 commits April 8, 2026 20:28
- gnat/review/: ReviewItem dataclass, ReviewQueueStore (SQLAlchemy),
  ReviewService (submit/approve/reject/modify/promote/bulk ops/stats)
- gnat/serve/routers/review.py: 8 REST endpoints; registered in app.py
- gnat/tui/screens/review.py: ReviewScreen (F6) with stats bar,
  DataTable, detail pane, approve/reject actions
- gnat/tui/app.py: 6th tab (Review F6), db_url param propagated
- gnat/cli/main.py: gnat review list/approve/reject/stats subcommands
- tests/unit/review/: 40 tests covering full service/store/model layer
- tests/unit/test_tui.py: F6 binding, 6-tab assertion, ReviewScreen import
- CHANGELOG.md: document review queue + STIX object validation additions

https://claude.ai/code/session_01BDoue9HxB83ijLzFARAugq
Full ConnectorMixin implementation for Discord REST API v10:
- authenticate() sets Bot token auth header
- health_check() via /gateway/bot
- get_object/list_objects/upsert_object/delete_object for messages,
  channels, threads, and guild members
- STIX translation: messages→note, channels→observed-data, users→identity
  with x_discord extension on all objects
- Domain helpers: post_message, list_messages, start_thread,
  list_archived_threads, get_user, list_members
- Registered as "discord" in CLIENT_REGISTRY
- 52 unit tests covering all public methods and STIX translation
- config/config.ini.example: [discord] section added

https://claude.ai/code/session_01BDoue9HxB83ijLzFARAugq
Copilot AI review requested due to automatic review settings April 8, 2026 20:37
@wrhalpin wrhalpin merged commit 508b960 into main Apr 8, 2026
7 of 24 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces two major feature areas to GNAT: (1) a Discord Bot connector integrated into the connector registry/config, and (2) an AI-extracted intel review queue with persistence, CLI, REST API, and a new TUI “Review” tab (F6).

Changes:

  • Add a full Discord REST API v10 connector (DiscordClient) and register it in CLIENT_REGISTRY, with config example + unit tests.
  • Add a new gnat.review package (models/store/service), plus FastAPI router and CLI subcommands to manage the review workflow and promotion.
  • Extend the Textual TUI to include a new “Review” tab/screen and update related unit tests and changelog.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 26 comments.

Show a summary per file
File Description
tests/unit/test_tui.py Updates TUI tests for the new Review tab/F6 binding and adds a 6-tab assertion.
tests/unit/review/test_review.py Adds unit tests for the new review queue model/store/service.
tests/unit/review/__init__.py Adds package marker for review unit tests.
tests/unit/connectors/test_connectors.py Adds a Discord connector test suite (CRUD, helpers, STIX translation, registry).
gnat/tui/screens/review.py Implements the new Textual “Review” screen (queue browsing + approve/reject UX).
gnat/tui/app.py Adds the Review tab pane and F6 binding to the TUI app.
gnat/serve/routers/review.py Adds a FastAPI router exposing the review queue endpoints.
gnat/serve/app.py Registers the new review router with the FastAPI app.
gnat/review/store.py Adds SQLAlchemy-backed persistence for the review queue.
gnat/review/service.py Adds review workflow business logic (submit/approve/reject/modify/promote/bulk/stats).
gnat/review/models.py Adds ReviewItem and ReviewStatus model definitions + serialization helpers.
gnat/review/__init__.py Exposes the review package public API.
gnat/connectors/discord/connector.py Replaces placeholder with a full Discord REST connector implementation.
gnat/connectors/discord/__init__.py Exposes DiscordClient from the discord connector package.
gnat/clients/__init__.py Registers discord in CLIENT_REGISTRY.
gnat/cli/main.py Adds gnat review CLI subcommands (list/approve/reject/stats) and TUI screen choice.
config/config.ini.example Adds example [discord] configuration section.
CHANGELOG.md Documents the Discord connector and review queue additions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/test_tui.py
from gnat.tui.screens.review import ReviewScreen
from gnat.tui.screens.scheduler import SchedulerScreen

assert all([QueryScreen, LibraryScreen, SchedulerScreen, ReportsScreen, InvestigationsScreen])
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

ReviewScreen is imported here but not referenced in the assertion, which will trigger Ruff F401 (unused import) for this test function. Either include ReviewScreen in the assert all([...]) list or remove the import.

Suggested change
assert all([QueryScreen, LibraryScreen, SchedulerScreen, ReportsScreen, InvestigationsScreen])
assert all(
[
QueryScreen,
LibraryScreen,
SchedulerScreen,
ReportsScreen,
ReviewScreen,
InvestigationsScreen,
]
)

Copilot uses AI. Check for mistakes.
from __future__ import annotations

import pytest
from datetime import datetime, timezone
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

datetime/timezone are imported but unused in this test module, which will fail Ruff F401. Please remove the unused import(s) or use them in the tests.

Suggested change
from datetime import datetime, timezone

Copilot uses AI. Check for mistakes.

from __future__ import annotations

import json
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

json is imported but never used in this module; Ruff will flag this as F401. Remove the unused import (or use it).

Suggested change
import json

Copilot uses AI. Check for mistakes.
Comment on lines +277 to +278
if item.reviewer_notes:
self.query_one("#detail-notes-input", Input).value = item.reviewer_notes
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

When switching between items, reviewer notes are only set if item.reviewer_notes is truthy; selecting an item with no notes will leave the previous item's notes in the input. Set the notes input value unconditionally (e.g., to item.reviewer_notes or "") to avoid stale UI state.

Suggested change
if item.reviewer_notes:
self.query_one("#detail-notes-input", Input).value = item.reviewer_notes
self.query_one("#detail-notes-input", Input).value = item.reviewer_notes or ""

Copilot uses AI. Check for mistakes.
Comment on lines +367 to +371
if thread_id:
body["thread_id"] = thread_id
if embeds:
body["embeds"] = embeds
return self.post(f"{_API_BASE}/channels/{channel_id}/messages", json_body=body)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

BaseClient.post() accepts json= (see gnat/clients/base.py), not json_body=. Passing json_body will raise TypeError at runtime. Update these calls to use json=body (and adjust tests accordingly).

Copilot uses AI. Check for mistakes.
Comment thread gnat/review/store.py
Comment on lines +1 to +5
"""
gnat.review.store
==================
SQLAlchemy-backed persistence for the AI-extracted intel review queue.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

This new module is missing the project-standard SPDX/copyright header (compare e.g. gnat/serve/routers/reports.py:1-2). Please add the SPDX-License-Identifier and copyright lines at the top for consistency/licensing hygiene.

Copilot uses AI. Check for mistakes.
Comment thread CHANGELOG.md
Comment on lines +95 to +99
### Added — Discord Bot Connector

**`gnat/connectors/discord/connector.py`** — full `ConnectorMixin` implementation
- `DiscordClient(BaseClient, ConnectorMixin)` targeting Discord REST API v10
- `authenticate()`: sets `Authorization: Bot <token>` + `Content-Type: application/json`; normalises bare token (adds `Bot ` prefix)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The PR title suggests Claude documentation work, but this changelog entry documents substantial new functionality (Discord connector + review queue). Consider updating the PR title/description to accurately reflect the scope to avoid confusion during release/review.

Copilot uses AI. Check for mistakes.
Comment thread gnat/review/store.py

import json
import logging
from datetime import datetime, timezone
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

datetime/timezone are imported but unused in this module, which will fail Ruff F401. Please remove the unused import(s).

Suggested change
from datetime import datetime, timezone

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +170
if stix_type in ("note", "indicator"):
parts = object_id.split(":", 1)
if len(parts) != 2:
raise GNATClientError(
f"object_id must be '<channel_id>:<message_id>' for stix_type '{stix_type}'"
)
channel_id, message_id = parts
msg = self.get_message(channel_id, message_id)
return self.to_stix(msg)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

get_object("indicator", ...) currently returns self.to_stix(msg), which produces a STIX note (not an indicator). This breaks the expectation that get_object returns an object of the requested STIX type, and makes the indicator branch indistinguishable from note. Consider either (a) returning an actual STIX Indicator here (if IOC extraction is available), or (b) removing indicator support and requiring callers to fetch note then extract IOCs separately.

Copilot uses AI. Check for mistakes.
Comment thread gnat/review/__init__.py
Comment on lines +1 to +5
"""
gnat.review
============
AI-extracted intel review and promotion queue.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

This new module is missing the project-standard SPDX/copyright header (compare e.g. gnat/tui/screens/query.py:1-2). Please add the SPDX-License-Identifier and copyright lines at the top for consistency/licensing hygiene.

Copilot uses AI. Check for mistakes.
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.

3 participants