Skip to content

feat(governance): add custom properties tools - #2992

Open
SamMorrowDrums wants to merge 6 commits into
sammorrowdrums-governance-rulesetsfrom
sammorrowdrums-add-rulesets-custom-properties
Open

feat(governance): add custom properties tools#2992
SamMorrowDrums wants to merge 6 commits into
sammorrowdrums-governance-rulesetsfrom
sammorrowdrums-add-rulesets-custom-properties

Conversation

@SamMorrowDrums

@SamMorrowDrums SamMorrowDrums commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Governance toolset — Custom Properties (PR 2 of 2)

Adds the second half of the non-default governance toolset: GitHub custom properties at the repository, organization, and enterprise levels.

Supersedes the very stale #821 (re: #820), replayed onto the current codebase (modelcontextprotocol/go-sdk, go-github v89) and consolidated to fit today's tool surface.

Stacked on #2991 — review that one first. This PR is based on the sammorrowdrums-governance-rulesets branch, so its diff shows only the custom-properties changes. It will retarget to main automatically once #2991 merges.

Tools (2)

Rather than porting #821's six single-level tools verbatim, this consolidates them into two level-parameterized tools, mirroring the ruleset tools in #2991:

Tool level values Read-only
custom_properties_read repository / organization / enterprise
custom_properties_write repository / organization / enterprise

Values vs. definitions

The level argument dispatches to the correct GitHub API, and the semantics differ by level (documented in the tool + field descriptions):

  • repository reads/writes property values (property_name + value) — this is the inventory-ID / cost-centre source-of-truth use case customers asked for.
  • organization / enterprise read/write property definitions / schema (value_type, required, allowed_values, default_value, description, values_editable_by).

Scope challenge

Both tools reuse the shared governanceReadScopeAccess / governanceWriteScopeAccess helpers introduced in #2991 (renamed from the ruleset-specific names). They use a DynamicChallenge keyed on level, so a repository-level call needs only repo scope and org/enterprise calls up-scope from there — one consistent, exhaustive policy across both rulesets and custom properties.

Size

+812 / −20 across 9 files (363 lines of tool logic, 262 of tests, plus toolsnaps + regenerated README).

Verified: script/lint (0 issues), script/test (race), script/generate-docs all green.

Co-authored with @patrick-knight, original author of #821.

Closes #820

Copilot AI 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.

Pull request overview

Adds six custom-property tools to the governance toolset for repository values and organization/enterprise definitions.

Changes:

  • Adds read and write handlers with level-specific scopes.
  • Adds unit tests and tool-schema snapshots.
  • Updates generated governance documentation.
Show a summary per file
File Description
README.md Documents the new tools.
pkg/github/tools.go Registers tools and updates metadata.
pkg/github/custom_properties.go Implements custom-property tools and schemas.
pkg/github/custom_properties_test.go Tests handlers and schemas.
pkg/github/__toolsnaps__/get_repository_custom_properties.snap Snapshots repository read schema.
pkg/github/__toolsnaps__/get_organization_custom_properties.snap Snapshots organization read schema.
pkg/github/__toolsnaps__/get_enterprise_custom_properties.snap Snapshots enterprise read schema.
pkg/github/__toolsnaps__/create_or_update_repository_custom_properties.snap Snapshots repository write schema.
pkg/github/__toolsnaps__/create_or_update_organization_custom_properties.snap Snapshots organization write schema.
pkg/github/__toolsnaps__/create_or_update_enterprise_custom_properties.snap Snapshots enterprise write schema.
docs/remote-server.md Updates remote governance documentation.

Review details

  • Files reviewed: 11/11 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread pkg/github/custom_properties.go Outdated
Comment thread pkg/github/custom_properties.go
@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-governance-rulesets branch from 53de049 to f340ea4 Compare August 25, 2026 14:44
@SamMorrowDrums

Copy link
Copy Markdown
Collaborator Author

👋 Heads up: #2991 (this PR's base) was rebased onto current main and redesigned around #3128's per-call OAuth scope checks — it now consolidates the 5 level-specific ruleset tools down to 2 (repository_ruleset_read, create_repository_ruleset), each taking a level argument (repository/organization/enterprise) and using scopes.DynamicChallenge to return the exact scope for that call instead of splitting tools by level.

This PR's custom-properties functionality is not superseded by that change — it's a separate API surface and remains a valid follow-on layer. Two things to do before it can merge cleanly though:

  1. Rebase this branch onto the updated sammorrowdrums-governance-rulesets (its history was rewritten, so this PR currently shows as conflicting).
  2. Consider applying the same per-level consolidation pattern here for consistency — e.g. a single get_custom_properties / create_or_update_custom_properties pair with a level argument and a DynamicChallenge-based scope check, rather than the current 6 single-scope tools split by level. Not required, but would match the direction the toolset is heading in.

Leaving this open since the functionality itself is still needed.

@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-governance-rulesets branch from 8e78920 to fe0ece5 Compare August 27, 2026 14:08
@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-add-rulesets-custom-properties branch 2 times, most recently from 484991c to 718451c Compare September 1, 2026 11:02
@SamMorrowDrums
SamMorrowDrums requested a balanced review from Copilot September 1, 2026 12:41

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Unknown property fields can be silently discarded, causing unintended governance definitions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity pkg/​github/​custom_properties.go — Unknown item keys are currently allowed by the schema and then silently discarded by…
Issues resolved since last review (2)
Severity Finding
Medium severity pkg/​github/​custom_properties.go — The description limits default_value to a string or string array, but the schema has no type… View resolved comment
High severity pkg/​github/​custom_properties.govalue is optional in this schema, but go-github's CustomPropertyValue.Value is serialized… View resolved comment

Comment thread pkg/github/custom_properties.go
@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-add-rulesets-custom-properties branch from b11fcb2 to 528fcc7 Compare September 2, 2026 10:13
@SamMorrowDrums
SamMorrowDrums requested a balanced review from Copilot September 2, 2026 10:16

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

Level-incompatible property fields are accepted and then silently discarded.

Review tier: Balanced
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity pkg/​github/​custom_properties.go — Unknown item keys are currently allowed by the schema and then silently discarded by… View resolved comment
Suppressed comments (1)

pkg/github/custom_properties.go:283

  • The combined item schema accepts fields from both payload shapes at every level, but parseCustomProperties later unmarshals into a level-specific go-github struct, so encoding/json silently drops fields from the other shape. For example, an organization item containing property_name, value_type, and value succeeds while value never reaches GitHub; repository items similarly discard definition fields. Reject fields that are invalid for the selected level (or use level-specific oneOf schemas) so accepted input is not silently ignored.
// customPropertyItemSchema combines repository values with organization and enterprise definitions.
func customPropertyItemSchema() *jsonschema.Schema {
	return &jsonschema.Schema{
		Type:                 "object",
		AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},

@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-add-rulesets-custom-properties branch from 528fcc7 to bfc8eb5 Compare September 2, 2026 10:33
@SamMorrowDrums
SamMorrowDrums requested a balanced review from Copilot September 2, 2026 10:36

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The implementation, validation, scope dispatch, tests, snapshots, and generated documentation are consistent and complete.

Review tier: Balanced
Findings: None

@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-add-rulesets-custom-properties branch from bfc8eb5 to 8716efe Compare September 2, 2026 11:56
@SamMorrowDrums
SamMorrowDrums requested a balanced review from Copilot September 2, 2026 11:59

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The write contract does not disclose replacement semantics that can silently reset governance settings.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity pkg/​github/​custom_properties.go — For organization and enterprise definitions, this bulk PATCH replaces an existing definition:…

Comment thread pkg/github/custom_properties.go
@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-governance-rulesets branch from 3bea8e2 to b89714a Compare September 2, 2026 13:17
SamMorrowDrums and others added 5 commits September 2, 2026 15:19
…challenge

Add custom properties support to the non-default governance toolset,
completing the second half of the rulesets + custom properties work
requested in #820.

Rather than porting the original six single-level tools verbatim, this
consolidates them into two level-parameterized tools:

- custom_properties_read  (level: repository | organization | enterprise)
- custom_properties_write (level: repository | organization | enterprise)

The `level` argument dispatches to the correct GitHub API. Repository level
reads and writes property VALUES (property_name + value), while organization
and enterprise levels read and write property DEFINITIONS/schema (value_type,
required, allowed_values, default_value, description, values_editable_by).
This distinction is documented in the tool and field descriptions.

Both tools reuse the shared governanceReadScopeAccess/governanceWriteScopeAccess
helpers (renamed from the ruleset-specific names) so rulesets and custom
properties present one consistent, exhaustive scope-challenge policy that
up-scopes based on the requested level.

Co-authored-by: Patrick Knight <patrick-knight@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e886867-a922-419a-b02c-ac643716aea8
Co-authored-by: Patrick Knight <patrick-knight@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e886867-a922-419a-b02c-ac643716aea8
Co-authored-by: Patrick Knight <patrick-knight@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e886867-a922-419a-b02c-ac643716aea8
Co-authored-by: Patrick Knight <patrick-knight@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e886867-a922-419a-b02c-ac643716aea8
Co-authored-by: Patrick Knight <patrick-knight@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e886867-a922-419a-b02c-ac643716aea8
@SamMorrowDrums
SamMorrowDrums force-pushed the sammorrowdrums-add-rulesets-custom-properties branch from 8716efe to 7c7720e Compare September 2, 2026 13:21
@SamMorrowDrums
SamMorrowDrums requested a balanced review from Copilot September 2, 2026 13:23

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

The write API does not disclose destructive replacement semantics for omitted definition fields.

Review tier: Balanced
Findings: 1 Medium severity

Pre-existing issues (1)
Severity Finding
Medium severity pkg/​github/​custom_properties.go — For organization and enterprise definitions, this bulk PATCH replaces an existing definition:… View comment
Suppressed comments (1)

pkg/github/custom_properties.go:179

  • For organization and enterprise updates, GitHub replaces an existing definition and resets every omitted optional field to its default. Describing these fields only as optional makes a partial-looking update capable of silently clearing required, default_value, description, and allowed_values, and resetting values_editable_by. Please either document that each item must contain the complete desired definition or merge omitted fields with the current definition before PATCHing.
						Description: "The custom properties to create or update. At the repository level each item assigns a value ('property_name' and 'value'); at the organization and enterprise levels each item defines the schema ('property_name' and 'value_type', plus optional definition fields).",

Co-authored-by: Patrick Knight <patrick-knight@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1e886867-a922-419a-b02c-ac643716aea8

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The implementation, scope dispatch, validation, tests, snapshots, and generated documentation are consistent and complete.

Review tier: Balanced
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity pkg/​github/​custom_properties.go — For organization and enterprise definitions, this bulk PATCH replaces an existing definition:… View resolved comment

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