Skip to content

Conversation

@jhl-aa
Copy link
Collaborator

@jhl-aa jhl-aa commented Dec 23, 2024

No description provided.

Copy link

@benbrandt benbrandt left a comment

Choose a reason for hiding this comment

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

Since we're bringing in breaking changes, I think we should fix a few more things before merging.

From the user side we are just making it possible to configure more things, but I don't want to change it again after.

I think we have an issue where registry is used in two levels, which hints at a naming problem in our domain.

And more importantly, we need to define what a NamespaceIdentifier is and make sure it is serialized as such from env variables and strings.

I would suggest:

  • letters
  • numbers
  • -

You should be able to check the characters (maybe only allow alphanumeric and - or _ ?) and also use the heck crate if you need to convert. (Though with the previous rules maybe it is as simple as replacing _ with -)

# Each of the value can alternatively be provided as environment variables, which have higher precedence:
# NAMESPACES__PLAYGROUND__CONFIG_URL
# NAMESPACES__PLAYGROUND__CONFIG_ACCESS_TOKEN
# NAMESPACES__PLAYGROUND__REGISTRY__REGISTRY

Choose a reason for hiding this comment

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

I still feel this is telling us we have a bad name here... Shouldn't have registry twice

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changing the field to name

config_url: String,
config_access_token_env_var: Option<String>,
config_access_token: Option<String>,
registry: Registry,

Choose a reason for hiding this comment

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

Ok this is the issue for me. This causes the double registry in the variable which is a signal to me we got the naming wrong.

This isn't always a registry.... I wonder if this is something like source or ... I don't know. But we need another name because then this type has a name that is the same

@benbrandt
Copy link

On second thought... The normalization would also apply at the url level, so it's possible we can sort this out afterwards... But might still be good to sort out before releasing as a separate breaking release.

Copy link

@benbrandt benbrandt left a comment

Choose a reason for hiding this comment

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

We're getting there! Nice work. Still some small things

[namespaces.pharia-kernel-team.registry]
type = "oci"
registry = "registry.gitlab.aleph-alpha.de"
name = "registry.gitlab.aleph-alpha.de"

Choose a reason for hiding this comment

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

I think we're getting closer here. But I still feel like registry is the right name at this level. According to the spec https://github.com/opencontainers/distribution-spec/blob/main/spec.md this is indeed the name of this URL.

I feel like our domain model is slightly off for this enum. The enum is called Registry, but then the variants are a file based or an OCI based one. Which is why i wonder if we need a different name at the top level.

You could argue however, that while this is our concept internally, from a user perspective they only ever deal with OCI registries and therefore registry is the right term at the outer level, which is fair.
In that case I feel this should be domain or host or something.

Sorry to be pedantic about this, but obviously I care we get the right names here :)

Choose a reason for hiding this comment

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

Basically I'm sure you guys discussed so:

If you feel the correct name of this domain object is indeed Registry, I am ok with this, but then I wonder if there is a more specific, intuitive name for name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Absolutely, in fact we spent most of the time pondering about this, and we are still not satisfied with the results.

I think it is a symptom of internal (enum) representation leaking into user interface.

pub enum NamespaceConfig {
    TeamOwned {
        config_url: String,
        config_access_token: Option<String>,
        registry: Registry,
    },
    Watch { directory: PathBuf },
    InPlace {
        skills: Vec<SkillDescription>,
        registry: Registry,
    },
}

If we look at the current definition, NamespaceConfig consists of two things:

  1. Skill config
  2. Skill registry (or source)

For TeamOwned, the skill config is already prefixed with config and registry would be prefixed with registry, at least this is consistent.
For Watch, the directory acts as both the skill config and the skill registry.
For InPlace, the skills is the skill config, while the registry is equivalent to TeamOwned.

Thinking top-down, maybe we can streamline the interface:

# TeamOwned + OciRegistry
[namespaces.oci-team]
config_url = ""
config_access_token = ""
registry = ""
repository = ""
registry_user = ""
registry_password = ""

# TeamOwned + FileRegistry
[namespaces.file-team]
config_url = ""
config_access_token = ""
path = ""

# Watch
[namespaces.dev]
directory = ""

# InPlace + OciRegistry
[namespaces.oci-default]
skills = []
registry = ""
repository = ""
registry_user = ""
registry_password = ""

# InPlace + FileRegistry
[namespaces.file-default]
skills = []
path = ""

What do you think?
This would mean flattening the registry, untagging the Registry enum, and adding prefix to user/password.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm also considering refactoring config_url and config_access_token as skill_config (which can be via file or http) and skill_config_access_token.

pub fn from_toml(config: &str) -> anyhow::Result<Self> {
Ok(toml::from_str(config)?)
fn environment() -> Environment {
// A namespace can contain the characters `[a-z0-9-]` e.g. `pharia-kernel-team`.

Choose a reason for hiding this comment

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

This is a great doc comment ☺️ just move up one line

/// implies that the skills in team owned namespaces are configured by a team rather than the
/// operators of Pharia Kernel, which in turn means we only refer the teams documentation here.
TeamOwned {
#[serde(alias = "config-url")]

Choose a reason for hiding this comment

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

I think we can remove these aliases once we sort out if we need kebab for all environment variables

src/shell.rs Outdated
/// The qualified name of the skill to invoke. The qualified name consists of a namespace and
/// a skill name (e.g. "acme/summarize").
/// If the namespace is omitted, the default 'pharia-kernel-team' namespace is used.
/// If the namespace is omitted, the default `pharia-kernel-team` namespace is used.

Choose a reason for hiding this comment

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

Oh we should remove this line. No longer true. It is required

moldhouse and others added 24 commits January 2, 2025 16:32
Previously, the namespace config access token, as well as the user and
the password for the skill registry are provided as the associated
environment variable keys only.

As we have now adopted config-rs, the actual values can be provided
directly, or more commonly via the associated environment variables.
@jhl-aa jhl-aa merged commit e0933df into main Jan 2, 2025
3 checks passed
@jhl-aa jhl-aa deleted the config-rs branch January 2, 2025 15:57
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.

4 participants